Skip to contentSkip to conversation

netfilter: updates for net

PATCH Applied Florian Westphal 2 participants 4 messages Sep 4, 2025

Subsystems (4)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

v2 cover netfilter: updates for net

v2: in patch 1, prefer volatile to stdatomic.h. No other changes.

The following patchset contains Netfilter fixes for *net*:

1) Fix a silly bug in conntrack selftest, busyloop may get optimized to for (;;), reported by Yi Chen.

2) Introduce new NFTA_DEVICE_PREFIX attribute in nftables netlink api, re-using old NFTA_DEVICE_NAME led to confusion with different kernel/userspace versions. This refines the wildcard interface support added in 6.16 release. From Phil Sutter.

Please, pull these changes from:
The following changes since commit 8156210d36a43e76372312c87eb5ea3dbb405a85:

ax25: properly unshare skbs in ax25_kiss_rcv() (2025-09-03 17:06:30 -0700)

are available in the Git repository at:

https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-25-09-04

for you to fetch changes up to 4039ce7ef40474d5ba46f414c50cc7020b9cf8ae:

netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX (2025-09-04 09:19:25 +0200)

----------------------------------------------------------------
netfilter pull request nf-25-09-04

----------------------------------------------------------------
Florian Westphal (1):
selftests: netfilter: fix udpclash tool hang

Phil Sutter (1):
netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX

 include/uapi/linux/netfilter/nf_tables.h           |  2 ++
 net/netfilter/nf_tables_api.c                      | 42 ++++++++++++++++------
 .../selftests/net/netfilter/conntrack_clash.sh     |  2 +-
 .../selftests/net/netfilter/conntrack_resize.sh    |  5 +--
 tools/testing/selftests/net/netfilter/udpclash.c   |  2 +-
 5 files changed, 38 insertions(+), 15 deletions(-)
author maintainer
#1 lore raw

PATCH v2 1/2 selftests: netfilter: fix udpclash tool hang

Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Add volatile qualifier to avoid that.

While at it, also run it under timeout(1) and fix the resize script to not ignore the timeout passed as second parameter to insert_flood.

Fixes 78a588363587 ("selftests: netfilter: add conntrack clash resolution test case")
---
 tools/testing/selftests/net/netfilter/conntrack_clash.sh  | 2 +-
 tools/testing/selftests/net/netfilter/conntrack_resize.sh | 5 +++--
 tools/testing/selftests/net/netfilter/udpclash.c          | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/net/netfilter/conntrack_clash.sh +1 -1
index 606a43a60f73..7fc6c5dbd551 100755
@@ -99,7 +99,7 @@ run_one_clash_test()
 	local entries
 	local cre
 
-	if ! ip netns exec "$ns" ./udpclash $daddr $dport;then
+	if ! ip netns exec "$ns" timeout 30 ./udpclash $daddr $dport;then
 		echo "INFO: did not receive expected number of replies for $daddr:$dport"
 		ip netns exec "$ctns" conntrack -S
 		# don't fail: check if clash resolution triggered after all.
tools/testing/selftests/net/netfilter/conntrack_resize.sh +3 -2
index 788cd56ea4a0..615fe3c6f405 100755
@@ -187,7 +187,7 @@ ct_udpclash()
 	[ -x udpclash ] || return
 
         while [ $now -lt $end ]; do
-		ip netns exec "$ns" ./udpclash 127.0.0.1 $((RANDOM%65536)) > /dev/null 2>&1
+		ip netns exec "$ns" timeout 30 ./udpclash 127.0.0.1 $((RANDOM%65536)) > /dev/null 2>&1
 
 		now=$(date +%s)
 	done
@@ -277,6 +277,7 @@ check_taint()
 insert_flood()
 {
 	local n="$1"
+	local timeout="$2"
 	local r=0
 
 	r=$((RANDOM%$insert_count))
@@ -302,7 +303,7 @@ test_floodresize_all()
 	read tainted_then < /proc/sys/kernel/tainted
 
 	for n in "$nsclient1" "$nsclient2";do
-		insert_flood "$n" &
+		insert_flood "$n" "$timeout" &
 	done
 
 	# resize table constantly while flood/insert/dump/flushs
tools/testing/selftests/net/netfilter/udpclash.c +1 -1
index 85c7b906ad08..79de163d61ab 100644
@@ -29,7 +29,7 @@ struct thread_args {
 	int sockfd;
 };
 
-static int wait = 1;
+static volatile int wait = 1;
 
 static void *thread_main(void *varg)
 {
Signature · 1 line
2.49.1
#2 lore raw

Re: [PATCH v2 net 1/2] selftests: netfilter: fix udpclash tool hang

This series was applied to netdev/net.git (main) by Florian Westphal <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Florian Westphal <[email protected]>:

Quoted 8 lines · On Thu, 4 Sep 2025 09:25:47 +0200 you wrote:

Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Add volatile qualifier to avoid that.

While at it, also run it under timeout(1) and fix the resize script to not ignore the timeout passed as second parameter to insert_flood.

[...]

Here is the summary with links:
- [v2,net,1/2] selftests: netfilter: fix udpclash tool hang

    https://git.kernel.org/netdev/net/c/661a4f307fe0
  - [v2,net,2/2] netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX
    https://git.kernel.org/netdev/net/c/4039ce7ef404

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#3 lore raw

PATCH v2 2/2 netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX

In reply to Florian Westphal

From: Phil Sutter <[email protected]>

This new attribute is supposed to be used instead of NFTA_DEVICE_NAME for simple wildcard interface specs. It holds a NUL-terminated string representing an interface name prefix to match on.

While kernel code to distinguish full names from prefixes in NFTA_DEVICE_NAME is simpler than this solution, reusing the existing attribute with different semantics leads to confusion between different versions of kernel and user space though:

* With old kernels, wildcards submitted by user space are accepted yet silently treated as regular names.
* With old user space, wildcards submitted by kernel may cause crashes since libnftnl expects NUL-termination when there is none.

Using a distinct attribute type sanitizes these situations as the receiving part detects and rejects the unexpected attribute nested in *_HOOK_DEVS attributes.

Fixes 6d07a289504a ("netfilter: nf_tables: Support wildcard netdev hook specs")
---
 include/uapi/linux/netfilter/nf_tables.h |  2 ++
 net/netfilter/nf_tables_api.c            | 42 +++++++++++++++++-------
 2 files changed, 33 insertions(+), 11 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +2 -0
index 2beb30be2c5f..8e0eb832bc01 100644
@@ -1784,10 +1784,12 @@ enum nft_synproxy_attributes {
  * enum nft_device_attributes - nf_tables device netlink attributes
  *
  * @NFTA_DEVICE_NAME: name of this device (NLA_STRING)
+ * @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING)
  */
 enum nft_devices_attributes {
 	NFTA_DEVICE_UNSPEC,
 	NFTA_DEVICE_NAME,
+	NFTA_DEVICE_PREFIX,
 	__NFTA_DEVICE_MAX
 };
 #define NFTA_DEVICE_MAX		(__NFTA_DEVICE_MAX - 1)
net/netfilter/nf_tables_api.c +31 -11

96 lines not on this page · raw message

Signature · 1 line
2.49.1