netfilter: updates for net
Subsystems (4)
Florian Westphal
maintainercover netfilter: updates for net
Hi,
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 a6099f263e1f408bcc7913c9df24b0677164fc5d:
net: ethernet: ti: am65-cpsw-nuss: Fix null pointer dereference for ndev (2025-09-02 14:51:45 +0200)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-25-09-02
for you to fetch changes up to 745d9ca5317a03b55016cdd810e4d2aac57f45df:
netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX (2025-09-02 20:52:28 +0200)
----------------------------------------------------------------
netfilter pull request nf-25-09-02
----------------------------------------------------------------
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 | 3 +- 5 files changed, 39 insertions(+), 15 deletions(-)
Florian Westphal
maintainerPATCH 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 (;;). Switch to stdatomic to prevent this.
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.
--- 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 | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
tools/testing/selftests/net/netfilter/conntrack_clash.sh +1 -1
@@ -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
@@ -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 +2 -1
@@ -14,6 +14,7 @@* ed07d9a021df ("netfilter: nf_conntrack: resolve clash for matching conntracks") * 6a757c07e51f ("netfilter: conntrack: allow insertion of clashing entries") */ +#include <stdatomic.h> #include <stdio.h> #include <string.h> #include <stdlib.h>
@@ -29,7 +30,7 @@ struct thread_args {int sockfd; }; -static int wait =1 ; +static atomic_int wait =ATOMIC_VAR_INIT (1 );static void *thread_main (void *varg) {
Signature · 1 line
2.49.1
Jakub Kicinski
maintainerRe: [PATCH net 1/2] selftests: netfilter: fix udpclash tool hang
Quoted 3 lines · On Tue, 2 Sep 2025 20:58:54 +0200 Florian Westphal wrote:
Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Switch to stdatomic to prevent this.
gcc version 15.1.1 (F42) w/ whatever flags kselftests use appear to be unaware of this macro:
udpclash.c:33:26: error: implicit declaration of function ‘ATOMIC_VAR_INIT’; did you mean ‘ATOMIC_FLAG_INIT’? [-Wimplicit-function-declaration]
33 | static atomic_int wait = ATOMIC_VAR_INIT(1);
| ^~~~~~~~~~~~~~~
| ATOMIC_FLAG_INITudpclash.c:33:26: error: initializer element is not constant
Could you perhaps use volatile instead?
Quoted 13 lines
tools/testing/selftests/net/netfilter/udpclash.c +2
-1+#include <stdatomic.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -29,7 +30,7 @@ struct thread_args {int sockfd; }; -static int wait =1 ; +static atomic_int wait =ATOMIC_VAR_INIT (1 );static void *thread_main (void *varg) {
Florian Westphal
maintainerRe: [PATCH net 1/2] selftests: netfilter: fix udpclash tool hang
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 2 Sep 2025 20:58:54 +0200 Florian Westphal wrote:
Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Switch to stdatomic to prevent this.
gcc version 15.1.1 (F42) w/ whatever flags kselftests use appear to be unaware of this macro:
Quoted 6 lines
udpclash.c:33:26: error: implicit declaration of function ‘ATOMIC_VAR_INIT’; did you mean ‘ATOMIC_FLAG_INIT’? [-Wimplicit-function-declaration]
33 | static atomic_int wait = ATOMIC_VAR_INIT(1); | ^~~~~~~~~~~~~~~ | ATOMIC_FLAG_INITudpclash.c:33:26: error: initializer element is not constant Could you perhaps use volatile instead?
That works too. I'll send a new PR tomorrow, its late here.
Jakub Kicinski
maintainerRe: [PATCH net 1/2] selftests: netfilter: fix udpclash tool hang
Quoted 9 lines · On Thu, 4 Sep 2025 00:52:20 +0200 Florian Westphal wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 2 Sep 2025 20:58:54 +0200 Florian Westphal wrote:
Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Switch to stdatomic to prevent this.
gcc version 15.1.1 (F42) w/ whatever flags kselftests use appear to be unaware of this macro:
Quoted 8 lines
Quoted 6 lines
udpclash.c:33:26: error: implicit declaration of function ‘ATOMIC_VAR_INIT’; did you mean ‘ATOMIC_FLAG_INIT’? [-Wimplicit-function-declaration]
33 | static atomic_int wait = ATOMIC_VAR_INIT(1); | ^~~~~~~~~~~~~~~ | ATOMIC_FLAG_INITudpclash.c:33:26: error: initializer element is not constant Could you perhaps use volatile instead?
That works too. I'll send a new PR tomorrow, its late here.
👍️ FWIW I'll be sending the PR tomorrow so plenty time..
Florian Westphal
maintainerPATCH 2/2 netfilter: nf_tables: Introduce NFTA_DEVICE_PREFIX
In reply to Florian WestphalFrom: 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.
--- 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
@@ -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