fix(xdp): walk IPv6 extension headers and apply the blacklist to every protocol

IPv6 packets with any extension header, and IPv4 ICMP/GRE/ESP, returned XDP_PASS
before the whitelist/blacklist were read. pkt_test gains phases for both (they fail
on the previous filter). Explicit TCP header bounds checks keep the 5.15 verifier happy.
This commit is contained in:
Loki 2026-11-21 20:05:09 +01:00
parent fb951ac225
commit b670a69866
Signed by: boba
GPG key ID: 6CDE87BC9A778D97
7 changed files with 177 additions and 19 deletions

View file

@ -12,6 +12,13 @@
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define IPPROTO_FRAGMENT 44
#define IPPROTO_HOPOPTS 0
#define IPPROTO_ROUTING 43
#define IPPROTO_AH 51
#define IPPROTO_DSTOPTS 60
/* Extension headers walked before giving up; a longer chain is treated as
* "L4 not found" (source blacklist only), never as a free pass. */
#define RAMPART_V6_MAX_EXT 4
#define IP_OFFSET 0x1FFF
#define IP_MF 0x2000
@ -26,6 +33,15 @@ struct rampart_vlan_hdr {
__u16 encap_proto; // EtherType of the next header
};
/**
* First two bytes shared by every IPv6 extension header that carries a length
* (hop-by-hop, routing, destination options, AH).
*/
struct rampart_ipv6_ext {
__u8 nexthdr;
__u8 hdrlen; // 8-byte units minus 1 (AH: 4-byte units minus 2)
};
/**
* Protocol-agnostic TCP connection states.
*