Netdev List
 help / color / mirror / Atom feed
* [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh
@ 2026-11-24  7:19 Zhiqi Zhang
  2026-11-24  9:21 ` Florian Westphal
  2026-11-25  7:44 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Zhiqi Zhang @ 2026-11-24  7:19 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Florian Westphal, Phil Sutter
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Shuah Khan, netfilter-devel, coreteam, netdev,
	linux-kselftest, linux-kernel, Zhiqi Zhang

The ping failure path tries to execute the failure message as a command
because the echo command is missing. This reports a confusing "command not
found" error and returns 127 from that command instead of printing the
intended diagnostic.

Add the missing echo so the ping failure is reported consistently with the
other failure paths in the script.

I found this bug manually. OpenAI Codex generated the one-line code
change. I wrote the reproducer/test case, reviewed the generated change,
and tested the patch.

Fixes: d6905f088d2b ("selftests: netfilter: nft_nat_zones.sh: shellcheck cleanups")
Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
---
 tools/testing/selftests/net/netfilter/nft_nat_zones.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
index d935c967dd..f15bfd3373 100755
--- a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
+++ b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
@@ -171,7 +171,7 @@ done
 
 wait || ret=1
 
-[ "$ret" -ne 0 ] && "FAIL: Ping failure from $cl" 1>&2
+[ "$ret" -ne 0 ] && echo "FAIL: Ping failure from $cl" 1>&2
 
 for i in $(seq 1 "$maxclients"); do
    if ! ip netns exec "$gw" nft get element inet raw inicmp "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 }" | grep -q "{ 10.1.0.3 . \"veth$i\" . 10.3.0.99 counter packets 3 bytes 252 }"; then
-- 
2.54.0 (Apple Git-157)


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

* Re: [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh
  2026-11-24  7:19 [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh Zhiqi Zhang
@ 2026-11-24  9:21 ` Florian Westphal
  2026-11-25  7:44 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2026-11-24  9:21 UTC (permalink / raw)
  To: Zhiqi Zhang
  Cc: Pablo Neira Ayuso, Phil Sutter, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan,
	netfilter-devel, coreteam, netdev, linux-kselftest, linux-kernel

@netdev maintainers:

feel free to take this one directly.

Zhiqi Zhang <zhiqizhangg@gmail.com> wrote:
> The ping failure path tries to execute the failure message as a command
> because the echo command is missing. This reports a confusing "command not
> found" error and returns 127 from that command instead of printing the
> intended diagnostic.
> 
> Add the missing echo so the ping failure is reported consistently with the
> other failure paths in the script.
> 
> I found this bug manually. OpenAI Codex generated the one-line code
> change. I wrote the reproducer/test case, reviewed the generated change,
> and tested the patch.
> 
> Fixes: d6905f088d2b ("selftests: netfilter: nft_nat_zones.sh: shellcheck cleanups")
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
> ---
>  tools/testing/selftests/net/netfilter/nft_nat_zones.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> index d935c967dd..f15bfd3373 100755
> --- a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> +++ b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> @@ -171,7 +171,7 @@ done
>  
>  wait || ret=1
>  
> -[ "$ret" -ne 0 ] && "FAIL: Ping failure from $cl" 1>&2
> +[ "$ret" -ne 0 ] && echo "FAIL: Ping failure from $cl" 1>&2

Acked-by: Florian Westphal <fw@strlen.de>

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

* Re: [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh
  2026-11-24  7:19 [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh Zhiqi Zhang
  2026-11-24  9:21 ` Florian Westphal
@ 2026-11-25  7:44 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25  7:44 UTC (permalink / raw)
  To: zhiqizhangg
  Cc: pablo, fw, phil, davem, edumazet, kuba, pabeni, horms, shuah,
	netfilter-devel, coreteam, netdev, linux-kselftest, linux-kernel

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0 (1)

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch fixes a statement that can never run, so it does not
  do what the commit message says.
- [Medium] The diagnostic this patch turns into a real message, `echo
  "FAIL: Ping failure from $cl"` on line 174 of…

Pre-existing issues:
- [Low] On the veth0 icmp counter-mismatch path in
  tools/testing/selftests/net/netfilter/nft_nat_zones.sh, the check on…

--

selftests: netfilter: fix missing echo in nft_nat_zones.sh

The patch adds a missing echo to the ping failure diagnostic in
nft_nat_zones.sh. Without it, the shell tries to run the message string
as a command. The commit message says this makes ping failures get
reported the same way as the script's other failure paths.

> diff --git a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> index d935c967dd13b..f15bfd33739f1 100755
> --- a/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> +++ b/tools/testing/selftests/net/netfilter/nft_nat_zones.sh
> @@ -171,7 +171,7 @@ done
>  
>  wait || ret=1
>  
> -[ "$ret" -ne 0 ] && "FAIL: Ping failure from $cl" 1>&2
> +[ "$ret" -ne 0 ] && echo "FAIL: Ping failure from $cl" 1>&2

[Severity: High]

Can this echo ever run? The script is #!/bin/bash, and the loop above
starts the pings in the background without saving their PIDs:

  ip netns exec "$cl" ping -i 0.5 -q -c 3 10.3.0.99 > /dev/null 2>&1 &

In bash, a bare wait with no arguments returns zero once all background
jobs finish, whatever their exit status. The only trap in the script is
on EXIT, so no trapped signal can make wait fail either. That means
"wait || ret=1" never sets ret.

ret is set to 0 near the top of nft_nat_zones.sh, and nothing else
assigns it before this check. All the other ret=1 assignments come
later. So [ "$ret" -ne 0 ] looks to be always false, both before and
after this patch.

If that's right, the "command not found" and 127 symptom described in
the commit message can't happen on an unmodified run. A failed client
ping would also still go unreported here.

Would it make more sense to replace "wait || ret=1" with a per-PID wait?
For example, save pids[$i]=$! in the ping loop, then call
wait "${pids[$i]}" for each client and set ret and print the failure on
error. nft_flowtable.sh in the same directory uses wait $lpid this way.

Also, before d6905f088d2b the loop checked $? right after "ping ... &".
That is also always 0, so it looks like ping failure detection never
worked at this point. Backporting with the current Fixes: tag would not
bring back any ping failure detection.

[Severity: Medium]

Which client will this message name? cl is the loop variable from the
background ping loop:

  for i in $(seq 1 "$maxclients"); do
    cl=$(eval echo \$cl"$i")
    ip netns exec "$cl" ping ... &
  done

After the loop, cl always holds the namespace for i == maxclients (100,
or 40 with KSFT_MACHINE_SLOW=yes). A failure from client 5, for example,
would be reported as coming from the last client.

The socat failure path later in the script prints $cl inside its loop,
so it names the correct client:

  echo "FAIL: Failure to connect for $cl" 1>&2

The wrong name came in with d6905f088d2b, when the message moved out of
the loop. Since this patch presents the line as the fix for ping failure
reporting, could the respin also report from inside a per-client wait
loop?

[ ... ]

[Severity: Low]

This is a pre-existing issue, and this patch did not introduce it. It is
in the same script, outside the quoted hunk. On the veth0 icmp counter
mismatch path, the check looks up one key and the debug dump looks up a
different one:

  if ! ip netns exec "$gw" nft get element inet raw inicmp "{ 10.3.0.99 . \"veth0\" . 10.3.0.1 }" | grep -q ...
      ...
      ip netns exec "$gw" nft get element inet raw inicmp "{ 10.3.99 . \"veth0\" . 10.3.0.1 }" 1>&2

Should 10.3.99 in the debug dump be 10.3.0.99, to match the key that was
checked?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124071926.8818-1-zhiqizhangg%40gmail.com

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

end of thread, other threads:[~2026-11-25  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  7:19 [PATCH] selftests: netfilter: fix missing echo in nft_nat_zones.sh Zhiqi Zhang
2026-11-24  9:21 ` Florian Westphal
2026-11-25  7:44 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox