DORMANTno replies

[PATCH] selftests: net: broadcast_pmtu: Fix false failure from incorrect ping exit code logic

From: 傅清爽 <hidden>
Date: 2026-03-19 08:37:54
Also in: linux-kselftest, lkml

<div style="font-family:Microsoft YaHei;font-size:14px;color:#000000;" class="l_node_has_color"><p>From 7ef7e584027dfab2b984f0a8b9d75682ba250322 Mon Sep 17 00:00:00 2001<br>From: Qingshuang Fu &lt;fuqingshuang@kylinos.cn&gt;<br>Date: Thu, 19 Mar 2026 16:13:29 +0800<br>Subject: [PATCH] selftests: net: broadcast_pmtu: Fix false failure from<br>incorrect ping exit code logic</p>
<p>The broadcast_pmtu.sh test verifies that broadcast route MTU is respected,<br>but it uses an incorrect criteria for test success: it relies solely on<br>the ping command's exit code, which leads to false failures.</p>
<p>When the kernel correctly blocks oversized broadcast packets due to the<br>configured MTU limit (1500), ping fails to transmit any packets and returns<br>exit code 1. The original script interprets this as a test failure, even<br>though the kernel is properly enforcing the MTU (the core goal of the test).</p>
<p>Fix this by:<br>1. Checking ping's output for clear signs of MTU enforcement (instead of exit code)<br>- Match "0 packets transmitted" (no packets sent due to MTU limit)<br>- Match "message too long" (kernel rejects oversized packets)<br>2. Use an exit code variable to avoid early exit breaking the script flow<br>3. Maintain full compatibility with the original setup/cleanup logic</p>
<p>After this fix, the script returns 0 (success) when the kernel enforces the<br>broadcast route MTU (packets blocked), and 1 (failure) only when the kernel<br>fails to enforce the MTU (packets are transmitted but no response is received).</p>
<p>Signed-off-by: Qingshuang Fu &lt;fuqingshuang@kylinos.cn&gt;<br>---<br>tools/testing/selftests/net/broadcast_pmtu.sh | 12 +++++++++---<br>1 file changed, 9 insertions(+), 3 deletions(-)</p>
<p>diff --git a/tools/testing/selftests/net/broadcast_pmtu.sh b/tools/testing/selftests/net/broadcast_pmtu.sh<br>index 726eb5d25839..a8d2a205c51d 100755<br>--- a/tools/testing/selftests/net/broadcast_pmtu.sh<br>+++ b/tools/testing/selftests/net/broadcast_pmtu.sh<br>@@ -41,7 +41,13 @@ trap cleanup EXIT<br><br>setup &amp;&amp;<br>echo "Testing for broadcast route MTU" &amp;&amp;<br>- ip net exec "${CLIENT_NS}" ping -f -M want -q -c 1 -s 8000 -w 1 -b "${CLIENT_BROADCAST_ADDRESS}" &gt; /dev/null 2&gt;&amp;1<br>-<br>-exit $?<br>+ ping_output=$(ip net exec "${CLIENT_NS}" ping -f -M want -c 1 -s 8000 -w 1 -b \<br>+ "${CLIENT_BROADCAST_ADDRESS}" 2&gt;&amp;1) &amp;&amp;<br>+ if echo "${ping_output}" | grep -q -E "0 packets transmitted|message too long"; then<br>+ exit_code=0<br>+ else<br>+ exit_code=1<br>+ fi<br>+<br>+exit ${exit_code}<br><br>-- <br>2.25.1</p></div>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help