net/sched: act_nat: fix inner IP header checksum in ICMP error packets
Subsystems (5)
PATCH v2 1/2 net/sched: act_nat: fix inner IP header checksum in ICMP error packets
Update the inner IP header checksum when rewriting addresses inside ICMP error payloads, matching netfilter's nf_nat_ipv4_manip_pkt() behavior.
--- net/sched/act_nat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/sched/act_nat.c +3 -1
@@ -242,7 +242,9 @@ TC_INDIRECT_SCOPE int tcf_nat_act(struct sk_buff *skb, new_addr &= mask; new_addr |= addr & ~mask; -/* XXX Fix up the inner checksums. */ +/* Update inner IP header checksum after address rewrite */ +csum_replace4 (&iph->check, addr, new_addr); +if (egress) iph->daddr = new_addr;else
Signature · 1 line
2.53.0
PATCH v2 2/2 selftests: net: add act_nat ICMP inner checksum test
Verify that act_nat correctly updates the inner IP header checksum when rewriting addresses inside ICMP error payloads.
The test sets up two namespaces with act_nat on a veth pair, triggers an ICMP destination unreachable, and validates the inner IP header checksum in the received ICMP error.
--- tools/testing/selftests/net/Makefile | 1 + .../selftests/net/act_nat_icmp_csum.sh | 72 +++++++++ .../selftests/net/act_nat_icmp_csum_verify.py | 144 ++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100755 tools/testing/selftests/net/act_nat_icmp_csum.sh create mode 100755 tools/testing/selftests/net/act_nat_icmp_csum_verify.py
tools/testing/selftests/net/Makefile +1 -0
@@ -7,6 +7,7 @@ CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES) CFLAGS += -I../ TEST_PROGS := \ + act_nat_icmp_csum.sh \ altnames.sh \ amt.sh \ arp_ndisc_evict_nocarrier.sh \
tools/testing/selftests/net/act_nat_icmp_csum.sh new file +72 -0
72 lines not on this page · raw message
tools/testing/selftests/net/act_nat_icmp_csum_verify.py new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerRe: [PATCH v2 2/2] selftests: net: add act_nat ICMP inner checksum test
Quoted 10 lines · On Sat, 4 Apr 2026 13:03:10 +0100 David Carlier wrote:
Verify that
act_natcorrectly updates the inner IP header checksum when rewriting addresses inside ICMP error payloads.The test sets up two namespaces with
act_naton a veth pair, triggers an ICMP destination unreachable, and validates the inner IP header checksum in the received ICMP error.Signed-off-by David Carlier <[email protected]>--- tools/testing/selftests/net/Makefile | 1 +
you need to add the CONFIG* dependencies to the relevant config file.