When RX socket setup fails during the first traffic step, the RX worker reports test->fail only after waiting at the setup barrier. As a result, the main thread may begin TX setup before it detects the failure. In shared-UMEM tests, TX setup relies on the RX-side socket and UMEM state being initialized successfully. Proceeding with TX setup after an RX configuration failure can therefore access uninitialized state. Set test->fail before the RX worker reaches the barrier and verify it before starting the TX thread. The existing teardown path after thread join already handles cleanup of the RX socket slots and UMEM. Co-developed-by: Magnus Karlsson Signed-off-by: Magnus Karlsson Signed-off-by: Tushar Vyavahare --- tools/testing/selftests/bpf/prog_tests/test_xsk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c index bba5e8d4222d..814b8325493f 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c +++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c @@ -1699,12 +1699,15 @@ void *worker_testapp_validate_rx(void *arg) strerror(-err)); } + /* Publish setup failure before releasing the main thread from the barrier. */ + if (err) + test->fail = true; + if (test->use_barrier) pthread_barrier_wait(&barr); /* We leave only now in case of error to avoid getting stuck in the barrier */ if (err) { - test->fail = true; pthread_exit(NULL); } @@ -1907,7 +1910,7 @@ static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *i } } - if (ifobj2) { + if (ifobj2 && !test->fail) { /*Spawn TX thread */ pthread_create(&t1, NULL, ifobj2->func_ptr, test); pthread_join(t1, NULL); -- 2.43.0