tools/testing/selftests/net/broadcast_pmtu.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
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 | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/broadcast_pmtu.sh b/tools/testing/selftests/net/broadcast_pmtu.sh
index 726eb5d25839..c2d66c6284eb 100755
--- a/tools/testing/selftests/net/broadcast_pmtu.sh
+++ b/tools/testing/selftests/net/broadcast_pmtu.sh
@@ -40,8 +40,14 @@ cleanup() {
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 $?
+ echo "Testing for broadcast route MTU"
+ 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}
base-commit: bbeb83d3182abe0d245318e274e8531e5dd7a948
--
2.25.1
On Thu, 26 Mar 2026 17:42:19 +0800 fffsqian@163.com wrote: > 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. Still failing, does it pass for you? Also please read this - https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
© 2016 - 2026 Red Hat, Inc.