Re: [PATCH v5 bpf-next 7/7] selftests/bpf: Test bpf_sock_destroy

Aditi Ghag
2023-04-03T15:56:32Z

> On Mar 31, 2023, at 3:32 PM, Martin KaFai Lau <martin.lau@linux.dev> wrote:
>
> On 3/30/23 11:46 AM, Stanislav Fomichev wrote:
>>> +void test_sock_destroy(void)
>>> +{
>>> + struct sock_destroy_prog *skel;
>>> + int cgroup_fd = 0;
>>> +
>>> + skel = sock_destroy_prog__open_and_load();
>>> + if (!ASSERT_OK_PTR(skel, "skel_open"))
>>> + return;
>>> +
>>> + cgroup_fd = test__join_cgroup("/sock_destroy");
>
> Please run this test in its own netns also to avoid affecting other tests as much as possible.

Is it okay if I defer this nit to a follow-up patch? It's not conflicting with other tests at the moment.

>
>>> + if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup"))
>>> + goto close_cgroup_fd;
>>> +
>>> + skel->links.sock_connect = bpf_program__attach_cgroup(
>>> + skel->progs.sock_connect, cgroup_fd);
>>> + if (!ASSERT_OK_PTR(skel->links.sock_connect, "prog_attach"))
>>> + goto close_cgroup_fd;
>>> +
>>> + if (test__start_subtest("tcp_client"))
>>> + test_tcp_client(skel);
>>> + if (test__start_subtest("tcp_server"))
>>> + test_tcp_server(skel);
>>> + if (test__start_subtest("udp_client"))
>>> + test_udp_client(skel);
>>> + if (test__start_subtest("udp_server"))
>>> + test_udp_server(skel);
>>> +
>>> +
>>> +close_cgroup_fd:
>>> + close(cgroup_fd);
>>> + sock_destroy_prog__destroy(skel);
>>> +}
>