selftests/bpf: Fix attach tests retcode checks
authorArtem Savkov <asavkov@redhat.com>
Thu, 21 Apr 2022 13:01:04 +0000 (15:01 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Apr 2022 14:34:55 +0000 (16:34 +0200)
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: b858ba8c52b6 ("selftests/bpf: Use libbpf 1.0 API mode instead of RLIMIT_MEMLOCK")
Signed-off-by: Artem Savkov <asavkov@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Yafang Shao <laoar.shao@gmail.com>
Link: https://lore.kernel.org/bpf/20220421130104.1582053-1-asavkov@redhat.com
tools/testing/selftests/bpf/test_sock.c
tools/testing/selftests/bpf/test_sysctl.c

index 6c4494076bbf5b5b5c75f1171be9e483ea98c614..810c3740b2ccbbcaec133848f1dc902d6bfce2e0 100644 (file)
@@ -492,7 +492,7 @@ static int run_test_case(int cgfd, const struct sock_test *test)
                        goto err;
        }
 
-       if (attach_sock_prog(cgfd, progfd, test->attach_type) == -1) {
+       if (attach_sock_prog(cgfd, progfd, test->attach_type) < 0) {
                if (test->result == ATTACH_REJECT)
                        goto out;
                else
index 5bae25ca19fbef1e3ec3416ff9846cc3dd3f107f..57620e7c904863081593481e589f8fb97d2d1942 100644 (file)
@@ -1560,7 +1560,7 @@ static int run_test_case(int cgfd, struct sysctl_test *test)
                        goto err;
        }
 
-       if (bpf_prog_attach(progfd, cgfd, atype, BPF_F_ALLOW_OVERRIDE) == -1) {
+       if (bpf_prog_attach(progfd, cgfd, atype, BPF_F_ALLOW_OVERRIDE) < 0) {
                if (test->result == ATTACH_REJECT)
                        goto out;
                else