OSDN Git Service

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)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 12 Apr 2023 23:40:39 +0000 (16:40 -0700)
commitac931d4cdec3df8b6eac3bc40a6871123021f078
tree065022679356dc2df5bbd75aa98d888dbd444c00
parented17aa92dc56b6d8883e4b7a8f1c6fbf5ed6cd29
ipip,ip_tunnel,sit: Add FOU support for externally controlled ipip devices

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>
include/net/ip_tunnels.h
net/ipv4/ip_tunnel.c
net/ipv4/ipip.c
net/ipv6/sit.c