Skip to content

Commit fde98ae

Browse files
peilin-yedavem330
authored andcommitted
ip6_gre: Make o_seqno start from 0 in native mode
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: c12b395 ("gre: Support GRE over IPv6") 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>
1 parent ff827be commit fde98ae

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

net/ipv6/ip6_gre.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
724724
{
725725
struct ip6_tnl *tunnel = netdev_priv(dev);
726726
__be16 protocol;
727+
__be16 flags;
727728

728729
if (dev->type == ARPHRD_ETHER)
729730
IPCB(skb)->flags = 0;
@@ -739,7 +740,6 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
739740
if (tunnel->parms.collect_md) {
740741
struct ip_tunnel_info *tun_info;
741742
const struct ip_tunnel_key *key;
742-
__be16 flags;
743743
int tun_hlen;
744744

745745
tun_info = skb_tunnel_info_txcheck(skb);
@@ -770,15 +770,14 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
770770
: 0);
771771

772772
} else {
773-
if (tunnel->parms.o_flags & TUNNEL_SEQ)
774-
tunnel->o_seqno++;
775-
776773
if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
777774
return -ENOMEM;
778775

779-
gre_build_header(skb, tunnel->tun_hlen, tunnel->parms.o_flags,
776+
flags = tunnel->parms.o_flags;
777+
778+
gre_build_header(skb, tunnel->tun_hlen, flags,
780779
protocol, tunnel->parms.o_key,
781-
htonl(tunnel->o_seqno));
780+
(flags & TUNNEL_SEQ) ? htonl(tunnel->o_seqno++) : 0);
782781
}
783782

784783
return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,

0 commit comments

Comments
 (0)