VXLAN and other UDP tunnels can carry locally generated packets whose
outer UDP header holds a complete checksum in the LCO (Local Checksum
Offload) state: the skb is CHECKSUM_PARTIAL and non-GSO, but csum_start
points at the inner transport header rather than at the outer udphdr.
When NAT rewrites the outer header of such a packet, the incremental
checksum helpers either update a value the NIC later recomputes from a
stale seed, or skip the update entirely, so the peer receives packets
with a bad outer checksum and drops them.
This series fixes both NAT paths such a VXLAN flow can take:
Patch 1 fixes the classic conntrack NAT path (__udp_manip_pkt()).
Patch 2 fixes the flowtable software fastpath, which a flow enters
once its conntrack entry is offloaded, and which would otherwise keep
corrupting the outer checksum of every packet after offload even with
patch 1 applied.
Testing (netns + veth + vxlan + iptables MASQUERADE --random-fully):
without the fix, the first TCP connection through the tunnel always
paid a ~1s SYN retransmit because the SYN-ACK was dropped for a bad
outer UDP checksum; with this series applied the first SYN succeeds
and no bad outer checksum is observed.
---
Changes in v4:
- Patch 2 is new: it extends the same LCO fixup to the flowtable
fastpath (nf_flow_nat_ip_udp(), nf_flow_nat_ipv6_udp() and
nf_flow_nat_port_udp()).
- Patch 1 is unchanged compared to v3.
v3: https://lore.kernel.org/netfilter-devel/2026…@cmss.chinamobile.com/
v2: https://lore.kernel.org/netfilter-devel/2026…@cmss.chinamobile.com/
v1: https://lore.kernel.org/netfilter-devel/2026…@cmss.chinamobile.com/
lvjunyu (2):
netfilter: nf_nat: Fix stale outer UDP checksum on VXLAN encapsulated
packets
netfilter: nf_flow_table: Fix stale outer UDP checksum in the fastpath
net/netfilter/nf_flow_table_core.c | 16 ++++++++++++++
net/netfilter/nf_flow_table_ip.c | 34 ++++++++++++++++++++++++++++++
net/netfilter/nf_nat_proto.c | 30 ++++++++++++++++++++++++++
3 files changed, 80 insertions(+)
--
2.43.0