selftests/bpf: Use explicit bpf_test_load_program() helper calls
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 3 Nov 2021 22:08:45 +0000 (15:08 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 7 Nov 2021 16:34:24 +0000 (08:34 -0800)
Remove the second part of prog loading testing helper re-definition:

  -Dbpf_load_program=bpf_test_load_program

This completes the clean up of deprecated libbpf program loading APIs.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20211103220845.2676888-13-andrii@kernel.org
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/prog_tests/cgroup_attach_autodetach.c
tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c
tools/testing/selftests/bpf/prog_tests/cgroup_attach_override.c
tools/testing/selftests/bpf/prog_tests/flow_dissector_load_bytes.c
tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c
tools/testing/selftests/bpf/prog_tests/signal_pending.c
tools/testing/selftests/bpf/test_cgroup_storage.c
tools/testing/selftests/bpf/test_tag.c

index 2016c58..e19cc64 100644 (file)
@@ -23,8 +23,7 @@ BPF_GCC               ?= $(shell command -v bpf-gcc;)
 SAN_CFLAGS     ?=
 CFLAGS += -g -O0 -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS)             \
          -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)          \
-         -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT)                      \
-         -Dbpf_load_program=bpf_test_load_program
+         -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT)
 LDLIBS += -lcap -lelf -lz -lrt -lpthread
 
 # Silence some warnings when compiled with clang
index 5de485c..858916d 100644 (file)
@@ -16,7 +16,7 @@ static int prog_load(void)
        };
        size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
 
-       return bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB,
+       return bpf_test_load_program(BPF_PROG_TYPE_CGROUP_SKB,
                               prog, insns_cnt, "GPL", 0,
                               bpf_log_buf, BPF_LOG_BUF_SIZE);
 }
index 731bea8..de9c3e1 100644 (file)
@@ -66,7 +66,7 @@ static int prog_load_cnt(int verdict, int val)
        size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
        int ret;
 
-       ret = bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB,
+       ret = bpf_test_load_program(BPF_PROG_TYPE_CGROUP_SKB,
                               prog, insns_cnt, "GPL", 0,
                               bpf_log_buf, BPF_LOG_BUF_SIZE);
 
index 10d3c33..356547e 100644 (file)
@@ -18,7 +18,7 @@ static int prog_load(int verdict)
        };
        size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
 
-       return bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB,
+       return bpf_test_load_program(BPF_PROG_TYPE_CGROUP_SKB,
                               prog, insns_cnt, "GPL", 0,
                               bpf_log_buf, BPF_LOG_BUF_SIZE);
 }
index 6093728..93ac3f2 100644 (file)
@@ -30,7 +30,7 @@ void serial_test_flow_dissector_load_bytes(void)
 
        /* make sure bpf_skb_load_bytes is not allowed from skb-less context
         */
-       fd = bpf_load_program(BPF_PROG_TYPE_FLOW_DISSECTOR, prog,
+       fd = bpf_test_load_program(BPF_PROG_TYPE_FLOW_DISSECTOR, prog,
                              ARRAY_SIZE(prog), "GPL", 0, NULL, 0);
        CHECK(fd < 0,
              "flow_dissector-bpf_skb_load_bytes-load",
index f0c6c22..7c79462 100644 (file)
@@ -47,9 +47,9 @@ static int load_prog(enum bpf_prog_type type)
        };
        int fd;
 
-       fd = bpf_load_program(type, prog, ARRAY_SIZE(prog), "GPL", 0, NULL, 0);
+       fd = bpf_test_load_program(type, prog, ARRAY_SIZE(prog), "GPL", 0, NULL, 0);
        if (CHECK_FAIL(fd < 0))
-               perror("bpf_load_program");
+               perror("bpf_test_load_program");
 
        return fd;
 }
index fdfdcff..aecfe66 100644 (file)
@@ -22,7 +22,7 @@ static void test_signal_pending_by_type(enum bpf_prog_type prog_type)
                prog[i] = BPF_ALU64_IMM(BPF_MOV, BPF_REG_0, 0);
        prog[ARRAY_SIZE(prog) - 1] = BPF_EXIT_INSN();
 
-       prog_fd = bpf_load_program(prog_type, prog, ARRAY_SIZE(prog),
+       prog_fd = bpf_test_load_program(prog_type, prog, ARRAY_SIZE(prog),
                                   "GPL", 0, NULL, 0);
        CHECK(prog_fd < 0, "test-run", "errno %d\n", errno);
 
index 0cda61d..a63787e 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "bpf_rlimit.h"
 #include "cgroup_helpers.h"
+#include "testing_helpers.h"
 
 char bpf_log_buf[BPF_LOG_BUF_SIZE];
 
@@ -66,7 +67,7 @@ int main(int argc, char **argv)
 
        prog[0].imm = percpu_map_fd;
        prog[7].imm = map_fd;
-       prog_fd = bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB,
+       prog_fd = bpf_test_load_program(BPF_PROG_TYPE_CGROUP_SKB,
                                   prog, insns_cnt, "GPL", 0,
                                   bpf_log_buf, BPF_LOG_BUF_SIZE);
        if (prog_fd < 0) {
index 6272c78..5c7bea5 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "../../../include/linux/filter.h"
 #include "bpf_rlimit.h"
+#include "testing_helpers.h"
 
 static struct bpf_insn prog[BPF_MAXINSNS];
 
@@ -57,7 +58,7 @@ static int bpf_try_load_prog(int insns, int fd_map,
        int fd_prog;
 
        bpf_filler(insns, fd_map);
-       fd_prog = bpf_load_program(BPF_PROG_TYPE_SCHED_CLS, prog, insns, "", 0,
+       fd_prog = bpf_test_load_program(BPF_PROG_TYPE_SCHED_CLS, prog, insns, "", 0,
                                   NULL, 0);
        assert(fd_prog > 0);
        if (fd_map > 0)