From: David Ahern <dsahern@kernel.org>
To: "Ricardo B. Marlière (SUSE)" <ricardo@marliere.net>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] selftests/net: Fix icmp.sh race between ping and tcpdump startup
Date: Wed, 2 Sep 2026 14:29:57 -0600 [thread overview]
Message-ID: <fc45c17c-84f7-45c7-a411-ba9070d1dcd7@kernel.org> (raw)
In-Reply-To: <20260901-selftests-net-icmp_race-v1-1-0b2a27e91a0c@marliere.net>
On 9/1/26 8:09 AM, Ricardo B. Marlière (SUSE) wrote:
> @@ -53,11 +54,21 @@ ip -netns $NS2 route add $RT2 via inet6 $H1_IP6
> # Make sure ns2 will respond with ICMP unreachable
> ip netns exec $NS2 sysctl -qw net.ipv4.icmp_ratelimit=0 net.ipv4.ip_forward=1
>
> -# Run the test - a ping runs in the background, and we capture ICMP responses
> -# with tcpdump; -c 1 means it should exit on the first ping, but add a timeout
> -# in case something goes wrong
> +# Run the test - start tcpdump and wait for it to be capturing before
> +# sending any traffic. -c 1 means it should exit on the first ping, but add
> +# a timeout in case something goes wrong
> +ip netns exec $NS1 timeout 10 tcpdump -tpni veth0 -c 1 \
> + 'icmp and icmp[icmptype] != icmp-echo' > $TMPFILE 2>$TCPDUMP_ERR &
Why keep the 'timeout 10'?
> +TCPDUMP_PID=$!
You have the pid. You can always kill it after the ping command if it
does not terminate on its own after the 1 packet is received.
> +if ! slowwait 3 grep -qs "listening" "$TCPDUMP_ERR"; then
> + echo "FAIL - tcpdump did not start listening"
> + cat "$TCPDUMP_ERR"
> + exit 1
> +fi
> +
> ip netns exec $NS1 ping -w 3 -i 0.5 $PINGADDR >/dev/null &
> -ip netns exec $NS1 timeout 10 tcpdump -tpni veth0 -c 1 'icmp and icmp[icmptype] != icmp-echo' > $TMPFILE 2>/dev/null
> +
> +wait $TCPDUMP_PID
>
prev parent reply other threads:[~2026-09-02 20:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 14:09 [PATCH net] selftests/net: Fix icmp.sh race between ping and tcpdump startup Ricardo B. Marlière (SUSE)
2026-09-02 20:29 ` David Ahern [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc45c17c-84f7-45c7-a411-ba9070d1dcd7@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ricardo@marliere.net \
--cc=shuah@kernel.org \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox