summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPeilin Ye <peilin.ye@bytedance.com>2022-04-21 15:07:57 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-12 12:14:55 +0200
commit1bdd46a8dce18ecdeead95af4f379dc9efa256b7 (patch)
treee54ad87fdecd0532eeaeed86bc7b3d09ea714b40 /net
parentbc03249a5d2dab1e9def59c9f0be7053998e71d7 (diff)
downloadlinux-1bdd46a8dce18ecdeead95af4f379dc9efa256b7.tar.gz
linux-1bdd46a8dce18ecdeead95af4f379dc9efa256b7.tar.bz2
linux-1bdd46a8dce18ecdeead95af4f379dc9efa256b7.zip
ip_gre: Make o_seqno start from 0 in native mode
[ Upstream commit ff827beb706ed719c766acf36449801ded0c17fc ] For GRE and GRETAP 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 gre_fb_xmit(), where tunnel->o_seqno is passed to gre_build_header() before getting incremented. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_gre.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index fe1801d9f059..eec225c637f0 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -339,14 +339,12 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
__be16 proto)
{
struct ip_tunnel *tunnel = netdev_priv(dev);
-
- if (tunnel->parms.o_flags & TUNNEL_SEQ)
- tunnel->o_seqno++;
+ __be16 flags = tunnel->parms.o_flags;
/* Push GRE header. */
gre_build_header(skb, tunnel->tun_hlen,
- tunnel->parms.o_flags, proto, tunnel->parms.o_key,
- htonl(tunnel->o_seqno));
+ flags, proto, tunnel->parms.o_key,
+ (flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
ip_tunnel_xmit(skb, dev, tnl_params, tnl_params->protocol);
}