Re: [PATCH net-next 2/5] selftests/xsk: roll back partial socket setup on configure failures

[email protected]
Newsgroups org.kernel.vger.netdev,org.kernel.vger.bpf
Message-ID <432070173bb986e48f8bdc1373590b8ace7ab192e8505d9f1343df78ab34d2e9@mail.kernel.org>
> commit 4ffc9af96ac7d98a2901bb6fe522a2076e0c73b4
> Author: Tushar Vyavahare <[email protected]>
>
>     selftests/xsk: roll back partial socket setup on configure failures
>
>     When xsk_socket__create() fails after all retries, or when busy-poll
>     setup fails after the socket is created, already-configured sockets for
>     the same ifobject are leaked.

Could you clarify which failure path causes the leak described here?

When xsk_configure() fails, the worker thread sets test->fail:

worker_testapp_validate_rx() at line 1719-1722:
    if (err) {
        test->fail = true;
        pthread_exit(NULL);
    }

worker_testapp_validate_tx() at line 1676-1686:
    if (thread_common_ops(...)) {
        test->fail = true;
        pthread_exit(NULL);
    }

Then __testapp_validate_traffic() tears down both ifobjects after joining
the threads:

test_xsk.c:__testapp_validate_traffic() {
    if (test->total_steps == test->current_step || test->fail) {
        xsk_delete_all_ifobj_sockets(test, ifobj2);
        xsk_delete_all_ifobj_sockets(test, ifobj1);
    }
}

Since xsk_delete_all_ifobj_sockets() walks slots 0..nb_sockets-1 (the same
range xsk_configure() iterates), the already-configured sockets should be
deleted there.

If there's a failure path that escapes this teardown, naming it in the
commit message would help clarify why the rollback is needed.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31554903166
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.