]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Improve connect_force_port test reliability
authorVarun R Mallya <varunrmallya@gmail.com>
Mon, 23 Mar 2026 08:11:31 +0000 (13:41 +0530)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 23 Mar 2026 18:37:34 +0000 (11:37 -0700)
commitbb6da652c585c397fc2c98df9e7534197e1b1cb1
treed2932cf6c3eb682305ff7fffdd881d79b07d3a34
parentbfec8e88ff6022b056615ec71506703e7e54de82
selftests/bpf: Improve connect_force_port test reliability

The connect_force_port test fails intermittently in CI because the
hardcoded server ports (60123/60124) may already be in use by other
tests or processes [1].

Fix this by passing port 0 to start_server(), letting the kernel assign
a free port dynamically. The actual assigned port is then propagated to
the BPF programs by writing it into the .bss map's initial value (via
bpf_map__initial_value()) before loading, so the BPF programs use the
correct backend port at runtime.

[1] https://github.com/kernel-patches/bpf/actions/runs/22697676317/job/65808536038

Suggested-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Varun R Mallya <varunrmallya@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Sun Jian <sun.jian.kdev@gmail.com>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20260323081131.65604-1-varunrmallya@gmail.com
tools/testing/selftests/bpf/prog_tests/connect_force_port.c
tools/testing/selftests/bpf/progs/connect_force_port4.c
tools/testing/selftests/bpf/progs/connect_force_port6.c