netfilter: nft_synproxy: use the family-aware checksum helper
Subsystems (3)
PATCH 1/1 netfilter: nft_synproxy: use the family-aware checksum helper
nft_synproxy_do_eval() verifies the TCP checksum before it switches on skb->protocol. It uses nf_ip_checksum(), which constructs an IPv4 pseudo header and relies on the IPv4 header checksum when folding the whole skb. Neither operation is valid for an IPv6 packet.
A correctly checksummed IPv6 segment can therefore fail verification when it reaches the hook as CHECKSUM_NONE or, at NF_INET_LOCAL_IN, CHECKSUM_COMPLETE. nft_synproxy_do_eval() returns NF_DROP before nft_synproxy_eval_v6() can send a SYN-ACK.
nft_synproxy_validate() deliberately admits NFPROTO_IPV6 and NFPROTO_INET, and the xtables counterpart ip6t_SYNPROXY.c already calls nf_ip6_checksum().
Use nf_checksum() with nft_pf() so the checksum helper dispatches to the packet family's implementation.
---
Notes (testing):
Testing:
- Raspberry Pi 400 with bcmgenet and 6.18.39+rpt-rpi-v8: the base kernel received IPv6 SYNs but sent no reply. IPv4 with the same synproxy rule and IPv6 without synproxy completed normally.
- Two x86_64 QEMU guests with pcnet CHECKSUM_NONE receive packets: the current-mainline base completed the IPv4 handshake but dropped six IPv6 SYNs. With this patch, both families completed SYN, SYN-ACK and ACK. ICMP controls passed and the invalid-drop counters stayed zero.
net/netfilter/nft_synproxy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nft_synproxy.c +2 -1
@@ -118,7 +118,8 @@ static void nft_synproxy_do_eval(const struct nft_synproxy *priv,return ; } -if (nf_ip_checksum (skb,nft_hook (pkt), thoff,IPPROTO_TCP )) { +if (nf_checksum (skb,nft_hook (pkt), thoff,IPPROTO_TCP , +nft_pf (pkt))) { regs->verdict.code =NF_DROP ;return ; }
base-commit: 50d05c7c76c96b90462f24debacca971d2e86713
Signature · 1 line
2.53.0