From: Paolo Abeni <pabeni@redhat.com>
To: Jingjing Xu <xujingjing@cmss.chinamobile.com>, netdev@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org, kuba@kernel.org,
edumazet@kernel.org, horms@kernel.org, shuah@kernel.org,
willemb@google.com
Subject: Re: [PATCH net-next] selftests: net: match the local port in wait_port_listen
Date: Mon, 30 Nov 2026 18:49:06 +0100 [thread overview]
Message-ID: <2fed80ad-9a3c-412f-ac4d-45ec8892133e@redhat.com> (raw)
In-Reply-To: <20261122154923.1272551-1-xujingjing@cmss.chinamobile.com>
On 11/22/26 16:49, Jingjing Xu wrote:
> wait_port_listen() searches anywhere in each /proc/net/{tcp,udp}* row.
> For UDP, a connected client whose remote port matches the requested port
> therefore makes the helper return even if no local receiver is bound.
> Callers waiting for a UDP server can consequently continue too early.
>
> Anchor the pattern to the start of the row and consume the slot and local
> address before matching the port. Consume the remote address before the
> TCP state, and terminate the LISTEN state match at a word boundary.
> Keep accepting locally bound connected UDP sockets.
>
> For example, in an isolated network namespace with loopback up, run this
> from tools/testing/selftests/net, with port 12345 unused locally:
>
> import socket
> from lib.py import wait_port_listen
> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> s.connect(("127.0.0.1", 12345))
> wait_port_listen(12345, proto="udp", deadline=0.1)
>
> The original helper returns; the fixed helper times out as expected.
> AI-assisted review found this issue. Real IPv4/IPv6 socket tests covered
> absent, remote-only, bound and connected UDP ports, and absent, bound,
> established and listening TCP sockets: the original failed two of 16
> cases, and the fixed helper passed all 16. No hardware tests were run.
>
> No kernel instrumentation or fault injection was used.
>
> Fixes: 31611cea8f0f ("selftests: drv-net: add a TCP ping test case (and useful helpers)")
> Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
Can the unmodified self-tests really hit this condition? If so, repost
updating the changelog accordingly. Otherwise do not resubmit.
/P
prev parent reply other threads:[~2026-11-30 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 15:49 [PATCH net-next] selftests: net: match the local port in wait_port_listen Jingjing Xu
2026-11-30 17:49 ` Paolo Abeni [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=2fed80ad-9a3c-412f-ac4d-45ec8892133e@redhat.com \
--to=pabeni@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=willemb@google.com \
--cc=xujingjing@cmss.chinamobile.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