* [PATCH nf-next] selftests: netfilter: fix return value in zone subtest
@ 2026-10-06 23:04 Florian Westphal
2026-10-07 11:32 ` Florian Westphal
2026-10-07 12:55 ` Fernando Fernandez Mancera
0 siblings, 2 replies; 3+ messages in thread
From: Florian Westphal @ 2026-10-06 23:04 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
zone subtest prints FAIL, but did not set 'ret=1', so kselftest
framework reports success.
While at it, also fail when "nft -f" returns an error.
Noticed thanks to a (broken) local patch that should have caused this
selftest (resp. the kselftest framework) to report a failure.
Fixes: 33b8aad21ac1 ("selftests: netfilter: add a vrf+conntrack testcase")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
Can also go via nf, I don't mind either way.
.../selftests/net/netfilter/conntrack_vrf.sh | 25 ++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/netfilter/conntrack_vrf.sh b/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
index 207b79932d91..2dbfabaadf4b 100755
--- a/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
+++ b/tools/testing/selftests/net/netfilter/conntrack_vrf.sh
@@ -84,7 +84,7 @@ busywait $BUSYWAIT_TIMEOUT listener_ready "$ns1"
# as decided by the first iteration of the ruleset.
test_ct_zone_in()
{
-ip netns exec "$ns0" nft -f - <<EOF
+if ! ip netns exec "$ns0" nft -f - <<EOF
table testct {
chain rawpre {
type filter hook prerouting priority raw;
@@ -105,6 +105,12 @@ table testct {
}
}
EOF
+ then
+ echo "FAIL: cannot load testct nft ruleset"
+ ret=1
+ return
+ fi
+
ip netns exec "$ns1" ping -W 1 -c 1 -I veth0 "$IP0" > /dev/null
# should be in zone 1, not zone 2
@@ -113,6 +119,7 @@ EOF
echo "PASS: entry found in conntrack zone 1"
else
echo "FAIL: entry not found in conntrack zone 1"
+ ret=1
count=$(ip netns exec "$ns0" conntrack -L -s $IP1 -d $IP0 -p icmp --zone 2 2> /dev/null | wc -l)
if [ "$count" -eq 1 ]; then
echo "FAIL: entry found in zone 2 instead"
@@ -137,7 +144,7 @@ test_masquerade_vrf()
ip netns exec "$ns0" conntrack -F 2>/dev/null
-ip netns exec "$ns0" nft -f - <<EOF
+if ! ip netns exec "$ns0" nft -f - <<EOF
flush ruleset
table ip nat {
chain rawout {
@@ -158,6 +165,12 @@ table ip nat {
}
}
EOF
+ then
+ echo "FAIL: cannot load ip nat nft ruleset"
+ ret=1
+ return
+ fi
+
if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then
echo "FAIL: connect failure with masquerade + sport rewrite on vrf device"
ret=1
@@ -184,7 +197,7 @@ EOF
test_masquerade_veth()
{
ip netns exec "$ns0" conntrack -F 2>/dev/null
-ip netns exec "$ns0" nft -f - <<EOF
+if ! ip netns exec "$ns0" nft -f - <<EOF
flush ruleset
table ip nat {
chain postrouting {
@@ -193,6 +206,12 @@ table ip nat {
}
}
EOF
+ then
+ echo "FAIL: cannot load ip nat postrouting ruleset"
+ ret=1
+ return
+ fi
+
if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then
echo "FAIL: connect failure with masquerade + sport rewrite on veth device"
ret=1
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH nf-next] selftests: netfilter: fix return value in zone subtest
2026-10-06 23:04 [PATCH nf-next] selftests: netfilter: fix return value in zone subtest Florian Westphal
@ 2026-10-07 11:32 ` Florian Westphal
2026-10-07 12:55 ` Fernando Fernandez Mancera
1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2026-10-07 11:32 UTC (permalink / raw)
To: netfilter-devel
Florian Westphal <fw@strlen.de> wrote:
> zone subtest prints FAIL, but did not set 'ret=1', so kselftest
> framework reports success.
>
> While at it, also fail when "nft -f" returns an error.
>
> Noticed thanks to a (broken) local patch that should have caused this
> selftest (resp. the kselftest framework) to report a failure.
https://sashiko.dev/#/patchset/20261006230459.2139-1-fw%40strlen.de
| Does this early return in test_masquerade_vrf() skip the qdisc cleanup?
Yes, but a great many other places don't clean up either.
Tests are supposed to pass, I don't think there is any point in
making scripts more complicated by cleaning up in FAIL cases too.
I don't plan to address this comment. LMK if you disagree.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nf-next] selftests: netfilter: fix return value in zone subtest
2026-10-06 23:04 [PATCH nf-next] selftests: netfilter: fix return value in zone subtest Florian Westphal
2026-10-07 11:32 ` Florian Westphal
@ 2026-10-07 12:55 ` Fernando Fernandez Mancera
1 sibling, 0 replies; 3+ messages in thread
From: Fernando Fernandez Mancera @ 2026-10-07 12:55 UTC (permalink / raw)
To: Florian Westphal, netfilter-devel
On 10/7/26 1:04 AM, Florian Westphal wrote:
> zone subtest prints FAIL, but did not set 'ret=1', so kselftest
> framework reports success.
>
> While at it, also fail when "nft -f" returns an error.
>
> Noticed thanks to a (broken) local patch that should have caused this
> selftest (resp. the kselftest framework) to report a failure.
>
> Fixes: 33b8aad21ac1 ("selftests: netfilter: add a vrf+conntrack testcase")
> Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Regarding the cleanup commit, we can leave that for the moment we have
free cycles or for a newbie to take it. I think it would be nice to have
but not relevant enough for a re-spin.
Thanks Florian!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-07 12:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-06 23:04 [PATCH nf-next] selftests: netfilter: fix return value in zone subtest Florian Westphal
2026-10-07 11:32 ` Florian Westphal
2026-10-07 12:55 ` Fernando Fernandez Mancera
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.