fix(xdp): ban expiry on CLOCK_MONOTONIC; per-protocol L4 minimum
- userspace wrote epoch ns while the kernel compares ban expiry against bpf_ktime_get_ns(), so gateway/detector bans never expired (v4 and v6). xdp::monotonic_ns() now reads CLOCK_MONOTONIC. - universal_filter.c required sizeof(tcphdr) (20 bytes) of L4 for every protocol, so short UDP datagrams took an early XDP_PASS and bypassed the blacklist (v4 and v6). Minimum now depends on the protocol. - tests/xdp_ban_clock.rs guards the clock choice. - xdp_ipv6_smoke.sh: v6 pass/ban/unban, short datagrams, v4 short datagrams and real 2s ban expiry on a live kernel.
This commit is contained in:
parent
59d5a088b2
commit
295ab81fb4
7 changed files with 173 additions and 78 deletions
|
|
@ -211,7 +211,13 @@ int rampart_universal_filter(struct xdp_md *ctx)
|
|||
ip_hdr_len = ip->ihl * 4;
|
||||
}
|
||||
|
||||
if ((void *)l4 + sizeof(struct tcphdr) > data_end)
|
||||
// Minimum L4 header per protocol: a short UDP datagram used to fall through
|
||||
// to XDP_PASS because the check was sized for TCP, letting it bypass the
|
||||
// blacklist entirely. IPv6 native fragmentation is already filtered above
|
||||
// (nexthdr must be TCP/UDP), so a short UDP header here is a real datagram.
|
||||
__u32 min_l4 = (l4_proto == IPPROTO_TCP) ? sizeof(struct tcphdr)
|
||||
: sizeof(struct udphdr);
|
||||
if ((void *)l4 + min_l4 > data_end)
|
||||
return XDP_PASS;
|
||||
|
||||
// ── Port range check (protected services) ──
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue