All of lore.kernel.org
 help / color / mirror / Atom feed
* [nf PATCH 0/2] Review port shadow selftest
@ 2021-11-03 18:53 Phil Sutter
  2021-11-03 18:53 ` [PATCH 1/2] selftests: nft_nat: Improve port shadow test stability Phil Sutter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Phil Sutter @ 2021-11-03 18:53 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Trying the test on a local VM I noticed spurious errors from nc,
complaining about an address being already in use. Patch 1 fixes this.
Validating the notrack workaround led to the minor simplifications in
patch 2.

Phil Sutter (2):
  selftests: nft_nat: Improve port shadow test stability
  selftests: nft_nat: Simplify port shadow notrack test

 tools/testing/selftests/netfilter/nft_nat.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] selftests: nft_nat: Improve port shadow test stability
  2021-11-03 18:53 [nf PATCH 0/2] Review port shadow selftest Phil Sutter
@ 2021-11-03 18:53 ` Phil Sutter
  2021-11-03 18:53 ` [PATCH 2/2] selftests: nft_nat: Simplify port shadow notrack test Phil Sutter
  2021-11-08 10:27 ` [nf PATCH 0/2] Review port shadow selftest Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2021-11-03 18:53 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Setup phase in test_port_shadow() relied upon a race-condition:
Listening nc on port 1405 was started in background before attempting to
create the fake conntrack entry using the same source port. If listening
nc won, fake conntrack entry could not be created causing wrong
behaviour. Reorder nc calls to fix this and introduce a short delay
before testing the setup to wait for listening nc process startup.

Fixes: 465f15a6d1a8f ("selftests: nft_nat: add udp hole punch test case")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tools/testing/selftests/netfilter/nft_nat.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
index da1c1e4b6c86b..905c033db74dc 100755
--- a/tools/testing/selftests/netfilter/nft_nat.sh
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -759,14 +759,16 @@ test_port_shadow()
 	local result=""
 	local logmsg=""
 
+	# make shadow entry, from client (ns2), going to (ns1), port 41404, sport 1405.
+	echo "fake-entry" | ip netns exec "$ns2" nc -w 1 -p 1405 -u "$daddrc" 41404 > /dev/null
+
 	echo ROUTER | ip netns exec "$ns0" nc -w 5 -u -l -p 1405 >/dev/null 2>&1 &
 	nc_r=$!
 
 	echo CLIENT | ip netns exec "$ns2" nc -w 5 -u -l -p 1405 >/dev/null 2>&1 &
 	nc_c=$!
 
-	# make shadow entry, from client (ns2), going to (ns1), port 41404, sport 1405.
-	echo "fake-entry" | ip netns exec "$ns2" nc -w 1 -p 1405 -u "$daddrc" 41404 > /dev/null
+	sleep 0.3
 
 	# ns1 tries to connect to ns0:1405.  With default settings this should connect
 	# to client, it matches the conntrack entry created above.
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] selftests: nft_nat: Simplify port shadow notrack test
  2021-11-03 18:53 [nf PATCH 0/2] Review port shadow selftest Phil Sutter
  2021-11-03 18:53 ` [PATCH 1/2] selftests: nft_nat: Improve port shadow test stability Phil Sutter
@ 2021-11-03 18:53 ` Phil Sutter
  2021-11-08 10:27 ` [nf PATCH 0/2] Review port shadow selftest Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Phil Sutter @ 2021-11-03 18:53 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

The second rule in prerouting chain was probably a leftover: The router
listens on veth0, so not tracking connections via that interface is
sufficient. Likewise, the rule in output chain can be limited to that
interface as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tools/testing/selftests/netfilter/nft_nat.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
index 905c033db74dc..c62e4e26252c1 100755
--- a/tools/testing/selftests/netfilter/nft_nat.sh
+++ b/tools/testing/selftests/netfilter/nft_nat.sh
@@ -818,11 +818,10 @@ table $family raw {
 	chain prerouting {
 		type filter hook prerouting priority -300; policy accept;
 		meta iif veth0 udp dport 1405 notrack
-		udp dport 1405 notrack
 	}
 	chain output {
 		type filter hook output priority -300; policy accept;
-		udp sport 1405 notrack
+		meta oif veth0 udp sport 1405 notrack
 	}
 }
 EOF
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [nf PATCH 0/2] Review port shadow selftest
  2021-11-03 18:53 [nf PATCH 0/2] Review port shadow selftest Phil Sutter
  2021-11-03 18:53 ` [PATCH 1/2] selftests: nft_nat: Improve port shadow test stability Phil Sutter
  2021-11-03 18:53 ` [PATCH 2/2] selftests: nft_nat: Simplify port shadow notrack test Phil Sutter
@ 2021-11-08 10:27 ` Pablo Neira Ayuso
  2 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2021-11-08 10:27 UTC (permalink / raw)
  To: Phil Sutter; +Cc: Florian Westphal, netfilter-devel

On Wed, Nov 03, 2021 at 07:53:41PM +0100, Phil Sutter wrote:
> Trying the test on a local VM I noticed spurious errors from nc,
> complaining about an address being already in use. Patch 1 fixes this.
> Validating the notrack workaround led to the minor simplifications in
> patch 2.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-08 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 18:53 [nf PATCH 0/2] Review port shadow selftest Phil Sutter
2021-11-03 18:53 ` [PATCH 1/2] selftests: nft_nat: Improve port shadow test stability Phil Sutter
2021-11-03 18:53 ` [PATCH 2/2] selftests: nft_nat: Simplify port shadow notrack test Phil Sutter
2021-11-08 10:27 ` [nf PATCH 0/2] Review port shadow selftest Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.