selftests/bpf: Destroy XDP link correctly
authorAndrii Nakryiko <andrii@kernel.org>
Sun, 7 Nov 2021 16:55:20 +0000 (08:55 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 7 Nov 2021 17:14:15 +0000 (09:14 -0800)
bpf_link__detach() was confused with bpf_link__destroy() and leaves
leaked FD in the process. Fix the problem.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Hengqi Chen <hengqi.chen@gmail.com>
Link: https://lore.kernel.org/bpf/20211107165521.9240-9-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c

index 7589c03fd26be727f07b46c3622c8ab5967d5291..eb2feaac81fe25139ce541b8c13dcc94ad27e2eb 100644 (file)
@@ -204,8 +204,8 @@ static int pass_ack(struct migrate_reuseport_test_case *test_case)
 {
        int err;
 
-       err = bpf_link__detach(test_case->link);
-       if (!ASSERT_OK(err, "bpf_link__detach"))
+       err = bpf_link__destroy(test_case->link);
+       if (!ASSERT_OK(err, "bpf_link__destroy"))
                return -1;
 
        test_case->link = NULL;