Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1668124iob; Thu, 5 May 2022 06:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqFhIq8/rBX4WICBmilQMngrVjRbNZ4/5k7lLu1XmBFxVvl+i0zjCvbFO5B79i8IgbOgUz X-Received: by 2002:a17:902:d5ce:b0:158:48db:9719 with SMTP id g14-20020a170902d5ce00b0015848db9719mr27180247plh.7.1651756285119; Thu, 05 May 2022 06:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651756285; cv=none; d=google.com; s=arc-20160816; b=viIouzTf4zLphiUVaG0ltSte91y/vBj94weEqi1HjE0uCwmVhx3kMkpG2etJVvqVzu ViDQe9A2rqNrRePA+fcAQDZimpp8ZqHThkoVB4uijVpXe8i92JK5wTXe1HtHCLHlmG53 Au7n5gkx0wE/dHqPT1CUDn6EVb0M4NC+PBx3kEBipRQ0q8hvw/gQeeGT+FXoVDHHD24t tlAw+g59S5Ap3xifl0EU6AZd3n41LNGNxSQRsONvYeloQjOAdSyqBX5OG02gIT0KHcM7 ryZsdp0foRXsoWQ4ne/+6tyg3/o7orInnqPbtdoHV78GDL2N9kb3H9ibD35Z3Lnnu4a+ DZ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UfaBeMHLZE1JKlzggo7JbDXV2ZZ2lNkpWq9IBxu8fyg=; b=x62RTWiPV8f2QEMPOXS5VQRgyp2YmZ3ALxuRCgR3XDTEpUha4xrXXAm1ahpmRbq69b sq1FfcAhkCS46VJOlt94otrao5WeBjgdAXi7KnU4BcMkhbNzxiVZBcsxTd26KqnPB0y5 E7n8D8MRWkk/EFdPOHpfUZAAosftn4tjlK4cmTEXvdtf17RnMM88CQoETirGmWmlgIOF OhDdEJr9FI/mXvupgTtpXJqPCPi68yIBxRZUwNGdn1LvHXOC7IxkMoJjcffXMdUbJ2KV KyrfuudFJAuSmDj4yKVqaD1RXo2ZMQdJ1i/eu16+PcB2C2hWTTYTzhIMBQzpAO3+sulC bAow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fFyRoTxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x190-20020a6386c7000000b003c5f0bcf33bsi1427085pgd.506.2022.05.05.06.11.08; Thu, 05 May 2022 06:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fFyRoTxA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356671AbiEDRWw (ORCPT + 99 others); Wed, 4 May 2022 13:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356429AbiEDRFM (ORCPT ); Wed, 4 May 2022 13:05:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B018050E20; Wed, 4 May 2022 09:54:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C7F51B827A5; Wed, 4 May 2022 16:54:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DD82C385A5; Wed, 4 May 2022 16:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683246; bh=0gX0SpLF4d8wYM7UAJuh4x9vkfWWnABx2guuzFrTmcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFyRoTxAURIp1IL6z0MuBJDyCxhUzBM7qsWVEK0XG0rp51qeccVIJM+/csWPR6jez /f3eTcv7jE3qclSVp+0vF6efN8wxlFysUSYq47coQs/RuNSvHWmQsuJfSoOEY5No6p DgIeof1xH6IOsSO5iTuUAqCg0RKE+u9osTcy7cqE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peilin Ye , William Tu , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 099/177] ip6_gre: Make o_seqno start from 0 in native mode Date: Wed, 4 May 2022 18:44:52 +0200 Message-Id: <20220504153101.986521745@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye [ Upstream commit fde98ae91f79cab4e020f40c35ed23cbdc59661c ] For IP6GRE and IP6GRETAP devices, currently o_seqno starts from 1 in native mode. According to RFC 2890 2.2., "The first datagram is sent with a sequence number of 0." Fix it. It is worth mentioning that o_seqno already starts from 0 in collect_md mode, see the "if (tunnel->parms.collect_md)" clause in __gre6_xmit(), where tunnel->o_seqno is passed to gre_build_header() before getting incremented. Fixes: c12b395a4664 ("gre: Support GRE over IPv6") Signed-off-by: Peilin Ye Acked-by: William Tu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/ip6_gre.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 869c3337e319..4ccbee5e7526 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -724,6 +724,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb, { struct ip6_tnl *tunnel = netdev_priv(dev); __be16 protocol; + __be16 flags; if (dev->type == ARPHRD_ETHER) IPCB(skb)->flags = 0; @@ -739,7 +740,6 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb, if (tunnel->parms.collect_md) { struct ip_tunnel_info *tun_info; const struct ip_tunnel_key *key; - __be16 flags; int tun_hlen; tun_info = skb_tunnel_info_txcheck(skb); @@ -770,15 +770,14 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb, : 0); } else { - if (tunnel->parms.o_flags & TUNNEL_SEQ) - tunnel->o_seqno++; - if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen)) return -ENOMEM; - gre_build_header(skb, tunnel->tun_hlen, tunnel->parms.o_flags, + flags = tunnel->parms.o_flags; + + gre_build_header(skb, tunnel->tun_hlen, flags, protocol, tunnel->parms.o_key, - htonl(tunnel->o_seqno)); + (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0); } return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu, -- 2.35.1