public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic
@ 2026-03-19  8:37 傅清爽
  0 siblings, 0 replies; 3+ messages in thread
From: 傅清爽 @ 2026-03-19  8:37 UTC (permalink / raw)
  To: netdev
  Cc: davem, edumazet, kuba, pabeni, horms, shuah, linux-kselftest,
	linux-kernel

[-- Attachment #1: Type: text/html, Size: 2612 bytes --]

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

* [PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic
@ 2026-03-26  4:06 fffsqian
  2026-03-26  8:31 ` Paolo Abeni
  0 siblings, 1 reply; 3+ messages in thread
From: fffsqian @ 2026-03-26  4:06 UTC (permalink / raw)
  To: davem, edumazet
  Cc: kuba, pabeni, horms, shuah, netdev, linux-kselftest, linux-kernel,
	Qingshuang Fu

From: Qingshuang Fu <fuqingshuang@kylinos.cn>

The broadcast_pmtu.sh test verifies that broadcast route MTU is respected,
but it uses an incorrect criteria for test success: it relies solely on
the ping command's exit code, which leads to false failures.

When the kernel correctly blocks oversized broadcast packets due to the
configured MTU limit (1500), ping fails to transmit any packets and returns
exit code 1. The original script interprets this as a test failure, even
though the kernel is properly enforcing the MTU (the core goal of the test).

Fix this by:
1. Checking ping's output for clear signs of MTU enforcement (instead of exit code)
   - Match "0 packets transmitted" (no packets sent due to MTU limit)
   - Match "message too long" (kernel rejects oversized packets)
2. Use an exit code variable to avoid early exit breaking the script flow
3. Maintain full compatibility with the original setup/cleanup logic

After this fix, the script returns 0 (success) when the kernel enforces the
broadcast route MTU (packets blocked), and 1 (failure) only when the kernel
fails to enforce the MTU (packets are transmitted but no response is received).

Signed-off-by: Qingshuang Fu <fuqingshuang@kylinos.cn>
---
 tools/testing/selftests/net/broadcast_pmtu.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/broadcast_pmtu.sh b/tools/testing/selftests/net/broadcast_pmtu.sh
index 726eb5d25839..a8d2a205c51d 100755
--- a/tools/testing/selftests/net/broadcast_pmtu.sh
+++ b/tools/testing/selftests/net/broadcast_pmtu.sh
@@ -41,7 +41,13 @@ trap cleanup EXIT
 
 setup &&
 	echo "Testing for broadcast route MTU" &&
-	ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" > /dev/null 2>&1
-
-exit $?
+	ping_output=$(ip net exec "${CLIENT_NS}" ping -f -M want -c 1 -s 8000 -w 1 -b \
+		"${CLIENT_BROADCAST_ADDRESS}" 2>&1) &&
+	if echo "${ping_output}" | grep -q -E "0 packets transmitted|message too long"; then
+		exit_code=0
+	else
+		exit_code=1
+	fi
+
+exit ${exit_code}
 
-- 
2.25.1


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

* Re: [PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic
  2026-03-26  4:06 [PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic fffsqian
@ 2026-03-26  8:31 ` Paolo Abeni
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Abeni @ 2026-03-26  8:31 UTC (permalink / raw)
  To: fffsqian, davem, edumazet
  Cc: kuba, horms, shuah, netdev, linux-kselftest, linux-kernel,
	Qingshuang Fu

On 3/26/26 5:06 AM, fffsqian@163.com wrote:
> From: Qingshuang Fu <fuqingshuang@kylinos.cn>
> 
> The broadcast_pmtu.sh test verifies that broadcast route MTU is respected,
> but it uses an incorrect criteria for test success: it relies solely on
> the ping command's exit code, which leads to false failures.
> 
> When the kernel correctly blocks oversized broadcast packets due to the
> configured MTU limit (1500), ping fails to transmit any packets and returns
> exit code 1. The original script interprets this as a test failure, even
> though the kernel is properly enforcing the MTU (the core goal of the test).
> 
> Fix this by:
> 1. Checking ping's output for clear signs of MTU enforcement (instead of exit code)
>    - Match "0 packets transmitted" (no packets sent due to MTU limit)
>    - Match "message too long" (kernel rejects oversized packets)
> 2. Use an exit code variable to avoid early exit breaking the script flow
> 3. Maintain full compatibility with the original setup/cleanup logic
> 
> After this fix, the script returns 0 (success) when the kernel enforces the
> broadcast route MTU (packets blocked), and 1 (failure) only when the kernel
> fails to enforce the MTU (packets are transmitted but no response is received).
> 
> Signed-off-by: Qingshuang Fu <fuqingshuang@kylinos.cn>
> ---
>  tools/testing/selftests/net/broadcast_pmtu.sh | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/broadcast_pmtu.sh b/tools/testing/selftests/net/broadcast_pmtu.sh
> index 726eb5d25839..a8d2a205c51d 100755
> --- a/tools/testing/selftests/net/broadcast_pmtu.sh
> +++ b/tools/testing/selftests/net/broadcast_pmtu.sh
> @@ -41,7 +41,13 @@ trap cleanup EXIT
>  
>  setup &&
>  	echo "Testing for broadcast route MTU" &&
> -	ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" > /dev/null 2>&1
> -
> -exit $?
> +	ping_output=$(ip net exec "${CLIENT_NS}" ping -f -M want -c 1 -s 8000 -w 1 -b \
> +		"${CLIENT_BROADCAST_ADDRESS}" 2>&1) &&
> +	if echo "${ping_output}" | grep -q -E "0 packets transmitted|message too long"; then
> +		exit_code=0
> +	else
> +		exit_code=1
> +	fi
> +
> +exit ${exit_code}

Apparently now the CI test is consistently failing:

# selftests: net: broadcast_pmtu.sh
# 0.03 [+0.03] Testing for broadcast route MTU
not ok 1 selftests: net: broadcast_pmtu.sh # exit=1

/P


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

end of thread, other threads:[~2026-03-26  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26  4:06 [PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic fffsqian
2026-03-26  8:31 ` Paolo Abeni
  -- strict thread matches above, loose matches on Subject: below --
2026-03-19  8:37 傅清爽

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