]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipip,ip_tunnel,sit: Add FOU support for externally controlled ipip devices
authorChristian Ehrig <cehrig@cloudflare.com>
Fri, 7 Apr 2023 13:38:53 +0000 (15:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2025 12:30:00 +0000 (13:30 +0100)
commit19bbca7bc55bf28f4eb61d791f435006d1f2cc9d
treed080895cc609b5514a05bddfb9b7cf5c047122c0
parentde3f999bf8aee16e9da1c1224191abdc69e97c9d
ipip,ip_tunnel,sit: Add FOU support for externally controlled ipip devices

[ Upstream commit ac931d4cdec3df8b6eac3bc40a6871123021f078 ]

Today ipip devices in collect-metadata mode don't allow for sending FOU
or GUE encapsulated packets. This patch lifts the restriction by adding
a struct ip_tunnel_encap to the tunnel metadata.

On the egress path, the members of this struct can be set by the
bpf_skb_set_fou_encap kfunc via a BPF tc-hook. Instead of dropping packets
wishing to use additional UDP encapsulation, ip_md_tunnel_xmit now
evaluates the contents of this struct and adds the corresponding FOU or
GUE header. Furthermore, it is making sure that additional header bytes
are taken into account for PMTU discovery.

On the ingress path, an ipip device in collect-metadata mode will fill this
struct and a BPF tc-hook can obtain the information via a call to the
bpf_skb_get_fou_encap kfunc.

The minor change to ip_tunnel_encap, which now takes a pointer to
struct ip_tunnel_encap instead of struct ip_tunnel, allows us to control
FOU encap type and parameters on a per packet-level.

Signed-off-by: Christian Ehrig <cehrig@cloudflare.com>
Link: https://lore.kernel.org/r/cfea47de655d0f870248abf725932f851b53960a.1680874078.git.cehrig@cloudflare.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: b5a7b661a073 ("net: Fix netns for ip_tunnel_init_flow()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/ip_tunnels.h
net/ipv4/ip_tunnel.c
net/ipv4/ipip.c
net/ipv6/sit.c