Skip to contentSkip to conversation

selftests: netfilter: tone-down conntrack clash test

PATCH Superseded Florian Westphal 2 participants 4 messages Jul 17, 2025 – Jul 21, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 selftests: netfilter: tone-down conntrack clash test

Stop this test from failing.

This is a stop-gap measure to not keep failing on NIPA CI.

The test is supposed to observe that clash_resolution stat counter incremented (code path was covered). This path is only exercised when multiple packets race: depending on kernel config, number of CPUs, scheduling policy etc. this might not trigger at all.

Therefore, if the test program did not observe the expected number of replies, make a note of it but do not flip script retval to 1.

With this change the test should either SKIP or pass. Hard error can be restored later once its clear whats going on.

Fixes 78a588363587 ("selftests: netfilter: add conntrack clash resolution test case")
---
 .../net/netfilter/conntrack_clash.sh          | 40 ++++++++++---------
 .../selftests/net/netfilter/udpclash.c        | 11 +++--
 2 files changed, 27 insertions(+), 24 deletions(-)
tools/testing/selftests/net/netfilter/conntrack_clash.sh +22 -18
index 3712c1b9b38b..1c54505e0d03 100755
@@ -93,19 +93,20 @@ ping_test()
 run_one_clash_test()
 {
 	local ns="$1"
-	local daddr="$2"
-	local dport="$3"
+	local ctns="$2"
+	local daddr="$3"
+	local dport="$4"
 	local entries
 	local cre
 
-	if ! ip netns exec "$ns" ./udpclash $daddr $dport;then
-		echo "FAIL: did not receive expected number of replies for $daddr:$dport"
-		ret=1
-		return 1
+	if ! ip netns exec "$ns" timeout 10s ./udpclash $daddr $dport;then
+		echo "NOTICE: udpclash did not receive any packets, cpus $(nprocs)"
+		ip netns exec "$ns" ss -niupa
+		# don't fail: check if clash resolution triggered.
 	fi
 
-	entries=$(conntrack -S | wc -l)
-	cre=$(conntrack -S | grep -v "clash_resolve=0" | wc -l)
+	entries=$(ip netns exec "$ctns" conntrack -S | wc -l)
+	cre=$(ip netns exec "$ctns" conntrack -S | grep "clash_resolve=0" | wc -l)
 
 	if [ "$cre" -ne "$entries" ] ;then
 		clash_resolution_active=1
@@ -117,8 +118,8 @@ run_one_clash_test()
 		return 0
 	fi
 
-	# not a failure: clash resolution logic did not trigger, but all replies
-	# were received.  With right timing, xmit completed sequentially and
+	# not a failure: clash resolution logic did not trigger.
+	# With right timing, xmit completed sequentially and
 	# no parallel insertion occurs.
 	return $ksft_skip
 }
@@ -126,20 +127,23 @@ run_one_clash_test()
 run_clash_test()
 {
 	local ns="$1"
-	local daddr="$2"
-	local dport="$3"
+	local ctns="$2"
+	local daddr="$3"
+	local dport="$4"
+	local harderr=0
 
 	for i in $(seq 1 10);do
-		run_one_clash_test "$ns" "$daddr" "$dport"
+		run_one_clash_test "$ns" "$ctns" "$daddr" "$dport"
 		local rv=$?
 		if [ $rv -eq 0 ];then
 			echo "PASS: clash resolution test for $daddr:$dport on attempt $i"
 			return 0
 		elif [ $rv -eq 1 ];then
-			echo "FAIL: clash resolution test for $daddr:$dport on attempt $i"
-			return 1
+			harderr=1
 		fi
 	done
+
+	[ $harderr -eq 1 ] && echo "FAIL: no packets received for $daddr:$dport with $(nproc) cpus"
 }
 
 ip link add veth0 netns "$nsclient1" type veth peer name veth0 netns "$nsrouter"
@@ -161,15 +165,15 @@ spawn_servers "$nsclient2"
 
 # exercise clash resolution with nat:
 # nsrouter is supposed to dnat to 10.0.2.1:900{0,1,2,3}.
-run_clash_test "$nsclient1" 10.0.1.99 "$dport"
+run_clash_test "$nsclient1" "$nsrouter" 10.0.1.99 "$dport"
 
 # exercise clash resolution without nat.
 load_simple_ruleset "$nsclient2"
-run_clash_test "$nsclient2" 127.0.0.1 9001
+run_clash_test "$nsclient2" "$nsclient2" 127.0.0.1 9001
 
 if [ $clash_resolution_active -eq 0 ];then
 	[ "$ret" -eq 0 ] && ret=$ksft_skip
-	echo "SKIP: Clash resolution did not trigger"
+	echo "SKIP: Clash resolution did not trigger with $(nproc) cpus."
 fi
 
 exit $ret
tools/testing/selftests/net/netfilter/udpclash.c +5 -6
index 85c7b906ad08..506caf110605 100644
@@ -87,10 +87,8 @@ static int run_test(int fd, const struct sockaddr_in *si_remote)
 		ret = recvfrom(fd, repl, sizeof(repl), MSG_NOSIGNAL,
 			       (struct sockaddr *) &si_repl, &si_repl_len);
 		if (ret < 0) {
-			if (timeout++ > 5000) {
-				fputs("timed out while waiting for reply from thread\n", stderr);
+			if (timeout++ > 10000)
 				break;
-			}
 
 			/* give reply time to pass though the stack */
 			usleep(1000);
@@ -114,11 +112,12 @@ static int run_test(int fd, const struct sockaddr_in *si_remote)
 		repl_count++;
 	}
 
-	printf("got %d of %d replies\n", repl_count, THREAD_COUNT);
-
 	free(tid);
 
-	return repl_count == THREAD_COUNT ? 0 : 1;
+	if (repl_count != THREAD_COUNT)
+		printf("got %d of %d replies\n", repl_count, THREAD_COUNT);
+
+	return repl_count > 0 ? 0 : 1;
 }
 
 int main(int argc, char *argv[])
Signature · 1 line
2.49.1
maintainer
#1 lore raw
Quoted 9 lines · On Thu, 17 Jul 2025 17:09:37 +0200 Florian Westphal wrote:

Stop this test from failing.

This is a stop-gap measure to not keep failing on NIPA CI.

The test is supposed to observe that clash_resolution stat counter incremented (code path was covered). This path is only exercised when multiple packets race: depending on kernel config, number of CPUs, scheduling policy etc. this might not trigger at all.

Quoted 5 lines

Therefore, if the test program did not observe the expected number of replies, make a note of it but do not flip script retval to 1.

With this change the test should either SKIP or pass. Hard error can be restored later once its clear whats going on.

Hm, someone set this patch to Deferred and Archived in patchwork, which is rather unusual. If someone did that on purpose please reply otherwise we'll apply the patch.

author maintainer
#2 lore raw
Quoted 1 line · Jakub Kicinski

Hm, someone set this patch to Deferred and Archived in patchwork,

I did. I will send a v2 next week.

Quoted 1 line

otherwise we'll apply the patch.

I got the impression that there is no urgency anymore since the failing test no longer reports to patchwork, so I'd prefer to take more time to try and understand whats going on.

maintainer
#3 lore raw
Quoted 4 lines · On Sat, 19 Jul 2025 09:06:31 +0200 Florian Westphal wrote:
Quoted 1 line · Jakub Kicinski

Hm, someone set this patch to Deferred and Archived in patchwork,

I did.

Please use pw-bot commands in the future, this way everyone knows what's going on.

Quoting documentation:

Updating patch status
~~~~~~~~~~~~~~~~~~~~~

Contributors and reviewers do not have the permissions to update patch state directly in patchwork. Patchwork doesn't expose much information about the history of the state of patches, therefore having multiple people update the state leads to confusion.

Instead of delegating patchwork permissions netdev uses a simple mail bot which looks for special commands/lines within the emails sent to the mailing list. For example to mark a series as Changes Requested one needs to send the following line anywhere in the email thread::

pw-bot: changes-requested

As a result the bot will set the entire series to Changes Requested. This may be useful when author discovers a bug in their own series and wants to prevent it from getting applied.

The use of the bot is entirely optional, if in doubt ignore its existence completely. Maintainers will classify and update the state of the patches themselves. No email should ever be sent to the list with the main purpose of communicating with the bot, the bot commands should be seen as metadata.

The use of the bot is restricted to authors of the patches (the ``From:`` header on patch submission and command must match!), maintainers of the modified code according to the MAINTAINERS file (again, ``From:`` must match the MAINTAINERS entry) and a handful of senior reviewers.

Bot records its activity here:

https://netdev.bots.linux.dev/pw-bot.html

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#updating-patch-status