selftests/bpf: Destroy XDP link correctly
authorAndrii Nakryiko <andrii@kernel.org>
Sun, 7 Nov 2021 16:55:20 +0000 (08:55 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:23 +0000 (11:04 +0100)
[ Upstream commit f91231eeeed752119f49eb6620cae44ec745a007 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/prog_tests/migrate_reuseport.c

index 59adb4715394fa99391e1868dc9014b76e9da612..3c85247f96f95845b6709456b93c5e4be3057d7c 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;