From: Yonghong Song <yonghong.song@linux.dev>
To: Jiayuan Chen <jiayuan.chen@linux.dev>, bpf@vger.kernel.org
Cc: Jiayuan Chen <jiayuan.chen@shopee.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v1] selftests/bpf: Improve connect_force_port test reliability
Date: Sun, 15 Mar 2026 09:44:46 -0700 [thread overview]
Message-ID: <6555dc32-b651-4c45-adaf-e3aecb013904@linux.dev> (raw)
In-Reply-To: <20260312062042.387367-1-jiayuan.chen@linux.dev>
On 3/11/26 11:20 PM, Jiayuan Chen wrote:
> From: Jiayuan Chen <jiayuan.chen@shopee.com>
>
> No functional changes.
This is not true as you mentioned below.
>
> The connect_force_port test can fail intermittently because the
> hardcoded server ports (60123/60124) may already be in use by other
> tests or processes in CI environments [1].
>
> Fix this by using dynamically assigned ports (port 0) for start_server
> and propagating the actual port to the BPF programs at runtime via
> skel->bss->port. Convert the test from the legacy bpf_object__open_file
> loading model to the skeleton (skel) pattern, which provides direct
> access to BPF global variables without introducing maps or other
> mechanisms.
I suggest you have two patches:
. patch 1: fix port issue
. patch 2: improve code from bpf_object__*() to skel based.
patch 2 is optional.
>
> Test:
>
> ./test_progs -a connect_force_port -v
>
> test_v4:PASS:skel4_open_and_load 0 nsec
> attach_progs:PASS:attach connect 0 nsec
> attach_progs:PASS:attach getpeername 0 nsec
> attach_progs:PASS:attach getsockname 0 nsec
> run_tests:PASS:start_server tcp 0 nsec
> run_tests:PASS:get_socket_local_port 0 nsec
> run_tests:PASS:connect_to_fd 0 nsec
> run_tests:PASS:verify_ports 0 nsec
> run_tests:PASS:start_server udp 0 nsec
> run_tests:PASS:get_socket_local_port 0 nsec
> run_tests:PASS:connect_to_fd 0 nsec
> run_tests:PASS:verify_ports 0 nsec
> test_v6:PASS:skel6_open_and_load 0 nsec
> attach_progs:PASS:attach connect 0 nsec
> attach_progs:PASS:attach getpeername 0 nsec
> attach_progs:PASS:attach getsockname 0 nsec
> run_tests:PASS:start_server tcp 0 nsec
> run_tests:PASS:get_socket_local_port 0 nsec
> run_tests:PASS:connect_to_fd 0 nsec
> run_tests:PASS:verify_ports 0 nsec
> run_tests:PASS:start_server udp 0 nsec
> run_tests:PASS:get_socket_local_port 0 nsec
> run_tests:PASS:connect_to_fd 0 nsec
> run_tests:PASS:verify_ports 0 nsec
> #80 connect_force_port:OK
> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
>
> [1] https://github.com/kernel-patches/bpf/actions/runs/22697676317/job/65808536038
>
> Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
> ---
> .../bpf/prog_tests/connect_force_port.c | 190 +++++++++---------
> .../selftests/bpf/progs/connect_force_port4.c | 10 +-
> .../selftests/bpf/progs/connect_force_port6.c | 10 +-
> 3 files changed, 108 insertions(+), 102 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/connect_force_port.c b/tools/testing/selftests/bpf/prog_tests/connect_force_port.c
> index 24d553109f8dd..3e62f9b9f1d94 100644
> --- a/tools/testing/selftests/bpf/prog_tests/connect_force_port.c
> +++ b/tools/testing/selftests/bpf/prog_tests/connect_force_port.c
> @@ -3,6 +3,8 @@
> #include <test_progs.h>
> #include "cgroup_helpers.h"
> #include "network_helpers.h"
> +#include "connect_force_port4.skel.h"
> +#include "connect_force_port6.skel.h"
>
> static int verify_ports(int family, int fd,
> __u16 expected_local, __u16 expected_peer)
> @@ -46,122 +48,122 @@ static int verify_ports(int family, int fd,
> return 0;
> }
>
>
[...]
prev parent reply other threads:[~2026-03-15 16:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 6:20 [PATCH bpf-next v1] selftests/bpf: Improve connect_force_port test reliability Jiayuan Chen
2026-03-15 16:44 ` Yonghong Song [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=6555dc32-b651-4c45-adaf-e3aecb013904@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=jiayuan.chen@linux.dev \
--cc=jiayuan.chen@shopee.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
/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