aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/netfilter
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-12-17 11:29:57 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2021-12-23 01:07:44 +0100
commit878aed8db324bec64f3c3f956e64d5ae7375a5de (patch)
tree98e79ee96f3c1a14640d950a633c45cfce6d191f /tools/testing/selftests/netfilter
parentnetfilter: conntrack: tag conntracks picked up in local out hook (diff)
downloadlinux-dev-878aed8db324bec64f3c3f956e64d5ae7375a5de.tar.xz
linux-dev-878aed8db324bec64f3c3f956e64d5ae7375a5de.zip
netfilter: nat: force port remap to prevent shadowing well-known ports
If destination port is above 32k and source port below 16k assume this might cause 'port shadowing' where a 'new' inbound connection matches an existing one, e.g. inbound X:41234 -> Y:53 matches existing conntrack entry Z:53 -> X:4123, where Z got natted to X. In this case, new packet is natted to Z:53 which is likely unwanted. We avoid the rewrite for connections that originate from local host: port-shadowing is only possible with forwarded connections. Also adjust test case. v3: no need to call tuple_force_port_remap if already in random mode (Phil) Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Phil Sutter <phil@nwl.cc> Acked-by: Eric Garver <eric@garver.life> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tools/testing/selftests/netfilter')
-rwxr-xr-xtools/testing/selftests/netfilter/nft_nat.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
index d88867d2fed7..349a319a9e51 100755
--- a/tools/testing/selftests/netfilter/nft_nat.sh
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -880,8 +880,9 @@ EOF
return $ksft_skip
fi
- # test default behaviour. Packet from ns1 to ns0 is redirected to ns2.
- test_port_shadow "default" "CLIENT"
+ # test default behaviour. Packet from ns1 to ns0 is not redirected
+ # due to automatic port translation.
+ test_port_shadow "default" "ROUTER"
# test packet filter based mitigation: prevent forwarding of
# packets claiming to come from the service port.