Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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

authored by

Artem Savkov and committed by
Daniel Borkmann
920fd5e1 9d87e41a

+2 -2
+1 -1
tools/testing/selftests/bpf/test_sock.c
··· 492 492 goto err; 493 493 } 494 494 495 - if (attach_sock_prog(cgfd, progfd, test->attach_type) == -1) { 495 + if (attach_sock_prog(cgfd, progfd, test->attach_type) < 0) { 496 496 if (test->result == ATTACH_REJECT) 497 497 goto out; 498 498 else
+1 -1
tools/testing/selftests/bpf/test_sysctl.c
··· 1560 1560 goto err; 1561 1561 } 1562 1562 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) { 1564 1564 if (test->result == ATTACH_REJECT) 1565 1565 goto out; 1566 1566 else