mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 12:35:52 +02:00
Merge branch 'optimize-bpf-selftest-to-increase-ci-success-rate'
Jiayuan Chen says: ==================== Optimize bpf selftest to increase CI success rate 1. Optimized some static bound port selftests to avoid port occupation when running test_progs -j. 2. Optimized the retry logic for test_maps. Some Failed CI: https://github.com/kernel-patches/bpf/actions/runs/13275542359/job/37064974076 https://github.com/kernel-patches/bpf/actions/runs/13549227497/job/37868926343 https://github.com/kernel-patches/bpf/actions/runs/13548089029/job/37865812030 https://github.com/kernel-patches/bpf/actions/runs/13553536268/job/37883329296 (Perhaps it's due to the large number of pull requests requiring CI runs?) ==================== Link: https://patch.msgid.link/20250227142646.59711-1-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
7c2f207a52
|
|
@ -72,11 +72,14 @@ static void test_bpf_nf_ct(int mode)
|
|||
if (!ASSERT_OK(system(cmd), cmd))
|
||||
goto end;
|
||||
|
||||
srv_port = (mode == TEST_XDP) ? 5005 : 5006;
|
||||
srv_fd = start_server(AF_INET, SOCK_STREAM, "127.0.0.1", srv_port, TIMEOUT_MS);
|
||||
srv_fd = start_server(AF_INET, SOCK_STREAM, "127.0.0.1", 0, TIMEOUT_MS);
|
||||
if (!ASSERT_GE(srv_fd, 0, "start_server"))
|
||||
goto end;
|
||||
|
||||
srv_port = get_socket_local_port(srv_fd);
|
||||
if (!ASSERT_GE(srv_port, 0, "get_sock_local_port"))
|
||||
goto end;
|
||||
|
||||
client_fd = connect_to_server(srv_fd);
|
||||
if (!ASSERT_GE(client_fd, 0, "connect_to_server"))
|
||||
goto end;
|
||||
|
|
@ -91,7 +94,7 @@ static void test_bpf_nf_ct(int mode)
|
|||
skel->bss->saddr = peer_addr.sin_addr.s_addr;
|
||||
skel->bss->sport = peer_addr.sin_port;
|
||||
skel->bss->daddr = peer_addr.sin_addr.s_addr;
|
||||
skel->bss->dport = htons(srv_port);
|
||||
skel->bss->dport = srv_port;
|
||||
|
||||
if (mode == TEST_XDP)
|
||||
prog_fd = bpf_program__fd(skel->progs.nf_xdp_ct_test);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,18 @@
|
|||
static int run_test(int cgroup_fd, int server_fd, bool classid)
|
||||
{
|
||||
struct connect4_dropper *skel;
|
||||
int fd, err = 0;
|
||||
int fd, err = 0, port;
|
||||
|
||||
skel = connect4_dropper__open_and_load();
|
||||
if (!ASSERT_OK_PTR(skel, "skel_open"))
|
||||
return -1;
|
||||
|
||||
port = get_socket_local_port(server_fd);
|
||||
if (!ASSERT_GE(port, 0, "get_socket_local_port"))
|
||||
return -1;
|
||||
|
||||
skel->bss->port = ntohs(port);
|
||||
|
||||
skel->links.connect_v4_dropper =
|
||||
bpf_program__attach_cgroup(skel->progs.connect_v4_dropper,
|
||||
cgroup_fd);
|
||||
|
|
@ -48,10 +54,9 @@ void test_cgroup_v1v2(void)
|
|||
{
|
||||
struct network_helper_opts opts = {};
|
||||
int server_fd, client_fd, cgroup_fd;
|
||||
static const int port = 60120;
|
||||
|
||||
/* Step 1: Check base connectivity works without any BPF. */
|
||||
server_fd = start_server(AF_INET, SOCK_STREAM, NULL, port, 0);
|
||||
server_fd = start_server(AF_INET, SOCK_STREAM, NULL, 0, 0);
|
||||
if (!ASSERT_GE(server_fd, 0, "server_fd"))
|
||||
return;
|
||||
client_fd = connect_to_fd_opts(server_fd, &opts);
|
||||
|
|
@ -66,7 +71,7 @@ void test_cgroup_v1v2(void)
|
|||
cgroup_fd = test__join_cgroup("/connect_dropper");
|
||||
if (!ASSERT_GE(cgroup_fd, 0, "cgroup_fd"))
|
||||
return;
|
||||
server_fd = start_server(AF_INET, SOCK_STREAM, NULL, port, 0);
|
||||
server_fd = start_server(AF_INET, SOCK_STREAM, NULL, 0, 0);
|
||||
if (!ASSERT_GE(server_fd, 0, "server_fd")) {
|
||||
close(cgroup_fd);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@
|
|||
#define VERDICT_REJECT 0
|
||||
#define VERDICT_PROCEED 1
|
||||
|
||||
int port;
|
||||
|
||||
SEC("cgroup/connect4")
|
||||
int connect_v4_dropper(struct bpf_sock_addr *ctx)
|
||||
{
|
||||
if (ctx->type != SOCK_STREAM)
|
||||
return VERDICT_PROCEED;
|
||||
if (ctx->user_port == bpf_htons(60120))
|
||||
if (ctx->user_port == bpf_htons(port))
|
||||
return VERDICT_REJECT;
|
||||
return VERDICT_PROCEED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1396,9 +1396,10 @@ static void test_map_stress(void)
|
|||
#define MAX_DELAY_US 50000
|
||||
#define MIN_DELAY_RANGE_US 5000
|
||||
|
||||
static bool retry_for_again_or_busy(int err)
|
||||
static bool can_retry(int err)
|
||||
{
|
||||
return (err == EAGAIN || err == EBUSY);
|
||||
return (err == EAGAIN || err == EBUSY ||
|
||||
(err == ENOMEM && map_opts.map_flags == BPF_F_NO_PREALLOC));
|
||||
}
|
||||
|
||||
int map_update_retriable(int map_fd, const void *key, const void *value, int flags, int attempts,
|
||||
|
|
@ -1451,12 +1452,12 @@ static void test_update_delete(unsigned int fn, void *data)
|
|||
|
||||
if (do_update) {
|
||||
err = map_update_retriable(fd, &key, &value, BPF_NOEXIST, MAP_RETRIES,
|
||||
retry_for_again_or_busy);
|
||||
can_retry);
|
||||
if (err)
|
||||
printf("error %d %d\n", err, errno);
|
||||
assert(err == 0);
|
||||
err = map_update_retriable(fd, &key, &value, BPF_EXIST, MAP_RETRIES,
|
||||
retry_for_again_or_busy);
|
||||
can_retry);
|
||||
if (err)
|
||||
printf("error %d %d\n", err, errno);
|
||||
assert(err == 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user