From 6c3b1506dd2136a2a8064bc2a05133a8735aa443 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 19 Mar 2024 17:48:37 +0800 Subject: [PATCH] bpf fix fix2 Signed-off-by: Geliang Tang --- .../selftests/bpf/benchs/bench_trigger.c | 8 +++---- .../testing/selftests/bpf/prog_tests/mptcp.c | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/testing/selftests/bpf/benchs/bench_trigger.c index ace0d1011a8e5..81a6b3d8a6fcd 100644 --- a/tools/testing/selftests/bpf/benchs/bench_trigger.c +++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c @@ -88,19 +88,19 @@ static void trigger_kprobe_setup(void) static void trigger_kretprobe_setup(void) { setup_ctx(); - attach_bpf(ctx.skel->progs.bench_trigger_kretprobe); + //attach_bpf(ctx.skel->progs.bench_trigger_kretprobe); } static void trigger_kprobe_multi_setup(void) { setup_ctx(); - attach_bpf(ctx.skel->progs.bench_trigger_kprobe_multi); + //attach_bpf(ctx.skel->progs.bench_trigger_kprobe_multi); } static void trigger_kretprobe_multi_setup(void) { setup_ctx(); - attach_bpf(ctx.skel->progs.bench_trigger_kretprobe_multi); + //attach_bpf(ctx.skel->progs.bench_trigger_kretprobe_multi); } static void trigger_fentry_setup(void) @@ -112,7 +112,7 @@ static void trigger_fentry_setup(void) static void trigger_fexit_setup(void) { setup_ctx(); - attach_bpf(ctx.skel->progs.bench_trigger_fexit); + //attach_bpf(ctx.skel->progs.bench_trigger_fexit); } static void trigger_fentry_sleep_setup(void) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index b982ad7fc21c2..6c71974c25a62 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -347,7 +347,7 @@ static int getsetsockopt(int map_fd) } send_byte(client_fd); - SYS(out, "ip netns exec %s ss -Menita", NS_TEST); + //SYS(out, "ip netns exec %s ss -Menita", NS_TEST); close(client_fd); close_server: @@ -398,7 +398,7 @@ void test_sockopt_mptcp(void) } static const unsigned int total_bytes = 10 * 1024 * 1024; -static int stop, duration; +static int stop; static void *server(void *arg) { @@ -431,8 +431,9 @@ static void *server(void *arg) bytes += nr_sent; } - CHECK(bytes != total_bytes, "send", "%zd != %u nr_sent:%zd errno:%d\n", - bytes, total_bytes, nr_sent, errno); + if (bytes != total_bytes) + printf("FAIL:send %zd != %u nr_sent:%zd errno:%d\n", + bytes, total_bytes, nr_sent, errno); done: if (fd >= 0) @@ -455,11 +456,12 @@ static void send_data(int lfd, int fd, char *msg) int err; WRITE_ONCE(stop, 0); + if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) return; err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd); - if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno)) + if (!ASSERT_OK(err, "pthread_create")) return; /* recv total_bytes */ @@ -478,16 +480,17 @@ static void send_data(int lfd, int fd, char *msg) delta_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000; - CHECK(bytes != total_bytes, "recv", "%zd != %u nr_recv:%zd errno:%d\n", - bytes, total_bytes, nr_recv, errno); + if (bytes != total_bytes) + printf("FAIL:recv %zd != %u nr_recv:%zd errno:%d\n", + bytes, total_bytes, nr_recv, errno); printf("%s: %u ms\n", msg, delta_ms); WRITE_ONCE(stop, 1); pthread_join(srv_thread, &thread_ret); - CHECK(IS_ERR(thread_ret), "pthread_join", "thread_ret:%ld", - PTR_ERR(thread_ret)); + if (IS_ERR(thread_ret)) + printf("FAIL:pthread_join thread_ret:%ld\n", thread_ret); } #define ADDR_1 "10.0.1.1"