Skip to content

Commit 920fd5e

Browse files
sm00thborkmann
authored andcommitted
selftests/bpf: Fix attach tests retcode checks
Switching to libbpf 1.0 API broke test_sock and test_sysctl as they check for return of bpf_prog_attach to be exactly -1. Switch the check to '< 0' instead. Fixes: b858ba8 ("selftests/bpf: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK") Signed-off-by: Artem Savkov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Yafang Shao <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9d87e41 commit 920fd5e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/testing/selftests/bpf/test_sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static int run_test_case(int cgfd, const struct sock_test *test)
492492
goto err;
493493
}
494494

495-
if (attach_sock_prog(cgfd, progfd, test->attach_type) == -1) {
495+
if (attach_sock_prog(cgfd, progfd, test->attach_type) < 0) {
496496
if (test->result == ATTACH_REJECT)
497497
goto out;
498498
else

tools/testing/selftests/bpf/test_sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test)
15601560
goto err;
15611561
}
15621562

1563-
if (bpf_prog_attach(progfd, cgfd, atype, BPF_F_ALLOW_OVERRIDE) == -1) {
1563+
if (bpf_prog_attach(progfd, cgfd, atype, BPF_F_ALLOW_OVERRIDE) < 0) {
15641564
if (test->result == ATTACH_REJECT)
15651565
goto out;
15661566
else

0 commit comments

Comments
 (0)