Skip to content

ip_gre, ip6_gre: o_seqno fixes

Peilin Ye bpf lkml netdev 1 version Applied

Status from this message: This series was applied to netdev/net.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesApplied 3/3

Patches in v1 All 3 applied

#Subject and filesSizeRepliesApplied
1/3ip_gre: Make o_seqno start from 0 in native modenet/ipv4/ip_gre.c+3 -51 replyApplied
2/3ip6_gre: Make o_seqno start from 0 in native modenet/ipv6/ip6_gre.c+5 -61 replyApplied
3/3ip_gre, ip6_gre: Fix race condition on o_seqno in collect_md modeinclude/net/ip6_tunnel.h include/net/ip_tunnels.h net/ipv4/ip_gre.c +1 more+9 -81 replyApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchWilliam Tu
1/3A-b
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net 0/3] ip_gre, ip6_gre: o_seqno fixes

From: Peilin Ye <[email protected]>

Hi all,

As pointed out [1] by Jakub Kicinski, currently using TUNNEL_SEQ in collect_md mode is racy for [IP6]GRE[TAP] devices, since they (typically, e.g. if created using "ip") use lockless TX.

Patch [3/3] fixes it by making o_seqno atomic_t.

As mentioned by Eric Dumazet in commit b790e01aee74 ("ip_gre: lockless xmit"), making o_seqno atomic_t increases "chance for packets being out of order at receiver" when using lockless TX.

Another way to fix it would be: users must specify "external" and "oseq" at the same time if they want the kernel to allow using TUNNEL_SEQ (e.g. via eBPF) in collect_md mode, but that would break userspace.

I found another issue while reading the code: patches [1,2/3] make o_seqno start from 0 in native mode, as described in RFC 2890 [2] section 2.2.:
"The first datagram is sent with a sequence number of 0."

Now we could make [IP6]GRE[TAP] (and probably [IP6]ERSPAN ?) devices completely NETIF_F_LLTX, but that's out of scope of this fix and will be sent as separate [net-next] patches.

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://datatracker.ietf.org/doc/html/rfc2890#section-2.2

Thanks,
Peilin Ye (3):
ip_gre: Make o_seqno start from 0 in native mode
ip6_gre: Make o_seqno start from 0 in native mode ip_gre, ip6_gre: Fix race condition on o_seqno in collect_md mode

 include/net/ip6_tunnel.h |  2 +-
 include/net/ip_tunnels.h |  2 +-
 net/ipv4/ip_gre.c        | 12 +++++-------
 net/ipv6/ip6_gre.c       | 16 ++++++++--------
 4 files changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.20.1