Skip to content

Commit f477b0f

Browse files
bastien-curutchetAlexei Starovoitov
authored andcommitted
selftests/bpf: test_xsk: Release resources when swap fails
testapp_validate_traffic() doesn't release the sockets and the umem created by the threads if the test isn't currently in its last step. Thus, if the swap_xsk_resources() fails before the last step, the created resources aren't cleaned up. Clean the sockets and the umem in case of swap_xsk_resources() failure. Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent e3dfa0f commit f477b0f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/testing/selftests/bpf/test_xsk.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,8 +1866,13 @@ int testapp_xdp_prog_cleanup(struct test_spec *test)
18661866
if (testapp_validate_traffic(test))
18671867
return TEST_FAILURE;
18681868

1869-
if (swap_xsk_resources(test))
1869+
if (swap_xsk_resources(test)) {
1870+
clean_sockets(test, test->ifobj_rx);
1871+
clean_sockets(test, test->ifobj_tx);
1872+
clean_umem(test, test->ifobj_rx, test->ifobj_tx);
18701873
return TEST_FAILURE;
1874+
}
1875+
18711876
return testapp_validate_traffic(test);
18721877
}
18731878

0 commit comments

Comments
 (0)