selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic
Subsystems (3)
PATCH v3 1/1 selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic
From: Qingshuang Fu <[email protected]>
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 checking ping's output for "0 packets transmitted" or "message too long" instead of relying on exit code.
--- tools/testing/selftests/net/broadcast_pmtu.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
tools/testing/selftests/net/broadcast_pmtu.sh +11 -4
@@ -40,8 +40,15 @@ 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
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerQuoted 11 lines · On Fri, 27 Mar 2026 09:27:05 +0800 [email protected] wrote:
The
broadcast_pmtu.shtest 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 checking ping's output for "0 packets transmitted" or "message too long" instead of relying on exit code.
Still failing, are you testing this locally before you repost it? Does it pass for you?
Please do not post another version until someone asks for it.