Commit 6f2b219b authored by Hengqi Chen's avatar Hengqi Chen Committed by Andrii Nakryiko

selftests/bpf: Switch to new bpf_object__next_{map,program} APIs

Replace deprecated bpf_{map,program}__next APIs with newly added
bpf_object__next_{map,program} APIs, so that no compilation warnings
emit.
Signed-off-by: default avatarHengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20211003165844.4054931-3-hengqi.chen@gmail.com
parent 2088a3a7
...@@ -128,7 +128,7 @@ int main(int argc, char **argv) ...@@ -128,7 +128,7 @@ int main(int argc, char **argv)
if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd)) if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
return 1; return 1;
map = bpf_map__next(NULL, obj); map = bpf_object__next_map(obj, NULL);
if (!map) { if (!map) {
printf("finding a map in obj file failed\n"); printf("finding a map in obj file failed\n");
return 1; return 1;
......
...@@ -154,7 +154,7 @@ int main(int argc, char **argv) ...@@ -154,7 +154,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
map = bpf_map__next(NULL, obj); map = bpf_object__next_map(obj, NULL);
if (!map) { if (!map) {
printf("finding a map in obj file failed\n"); printf("finding a map in obj file failed\n");
return 1; return 1;
......
...@@ -57,7 +57,7 @@ static int do_pin(int argc, char **argv) ...@@ -57,7 +57,7 @@ static int do_pin(int argc, char **argv)
goto close_obj; goto close_obj;
} }
prog = bpf_program__next(NULL, obj); prog = bpf_object__next_program(obj, NULL);
if (!prog) { if (!prog) {
p_err("can't find bpf program in objfile %s", objfile); p_err("can't find bpf program in objfile %s", objfile);
goto close_obj; goto close_obj;
......
...@@ -1601,7 +1601,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) ...@@ -1601,7 +1601,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
goto err_close_obj; goto err_close_obj;
if (first_prog_only) { if (first_prog_only) {
prog = bpf_program__next(NULL, obj); prog = bpf_object__next_program(obj, NULL);
if (!prog) { if (!prog) {
p_err("object file doesn't contain any bpf program"); p_err("object file doesn't contain any bpf program");
goto err_close_obj; goto err_close_obj;
......
...@@ -4511,7 +4511,7 @@ static void do_test_file(unsigned int test_num) ...@@ -4511,7 +4511,7 @@ static void do_test_file(unsigned int test_num)
if (CHECK(err, "obj: %d", err)) if (CHECK(err, "obj: %d", err))
return; return;
prog = bpf_program__next(NULL, obj); prog = bpf_object__next_program(obj, NULL);
if (CHECK(!prog, "Cannot find bpf_prog")) { if (CHECK(!prog, "Cannot find bpf_prog")) {
err = -1; err = -1;
goto done; goto done;
......
...@@ -285,7 +285,7 @@ static void test_fmod_ret_freplace(void) ...@@ -285,7 +285,7 @@ static void test_fmod_ret_freplace(void)
if (!ASSERT_OK_PTR(freplace_obj, "freplace_obj_open")) if (!ASSERT_OK_PTR(freplace_obj, "freplace_obj_open"))
goto out; goto out;
prog = bpf_program__next(NULL, freplace_obj); prog = bpf_object__next_program(freplace_obj, NULL);
err = bpf_program__set_attach_target(prog, pkt_fd, NULL); err = bpf_program__set_attach_target(prog, pkt_fd, NULL);
ASSERT_OK(err, "freplace__set_attach_target"); ASSERT_OK(err, "freplace__set_attach_target");
...@@ -302,7 +302,7 @@ static void test_fmod_ret_freplace(void) ...@@ -302,7 +302,7 @@ static void test_fmod_ret_freplace(void)
goto out; goto out;
attach_prog_fd = bpf_program__fd(prog); attach_prog_fd = bpf_program__fd(prog);
prog = bpf_program__next(NULL, fmod_obj); prog = bpf_object__next_program(fmod_obj, NULL);
err = bpf_program__set_attach_target(prog, attach_prog_fd, NULL); err = bpf_program__set_attach_target(prog, attach_prog_fd, NULL);
ASSERT_OK(err, "fmod_ret_set_attach_target"); ASSERT_OK(err, "fmod_ret_set_attach_target");
...@@ -352,7 +352,7 @@ static void test_obj_load_failure_common(const char *obj_file, ...@@ -352,7 +352,7 @@ static void test_obj_load_failure_common(const char *obj_file,
if (!ASSERT_OK_PTR(obj, "obj_open")) if (!ASSERT_OK_PTR(obj, "obj_open"))
goto close_prog; goto close_prog;
prog = bpf_program__next(NULL, obj); prog = bpf_object__next_program(obj, NULL);
err = bpf_program__set_attach_target(prog, pkt_fd, NULL); err = bpf_program__set_attach_target(prog, pkt_fd, NULL);
ASSERT_OK(err, "set_attach_target"); ASSERT_OK(err, "set_attach_target");
......
...@@ -114,7 +114,7 @@ static int prepare_bpf_obj(void) ...@@ -114,7 +114,7 @@ static int prepare_bpf_obj(void)
err = bpf_object__load(obj); err = bpf_object__load(obj);
RET_ERR(err, "load bpf_object", "err:%d\n", err); RET_ERR(err, "load bpf_object", "err:%d\n", err);
prog = bpf_program__next(NULL, obj); prog = bpf_object__next_program(obj, NULL);
RET_ERR(!prog, "get first bpf_program", "!prog\n"); RET_ERR(!prog, "get first bpf_program", "!prog\n");
select_by_skb_data_prog = bpf_program__fd(prog); select_by_skb_data_prog = bpf_program__fd(prog);
RET_ERR(select_by_skb_data_prog < 0, "get prog fd", RET_ERR(select_by_skb_data_prog < 0, "get prog fd",
......
...@@ -109,7 +109,7 @@ static int run_test(int cgroup_fd, int server_fd) ...@@ -109,7 +109,7 @@ static int run_test(int cgroup_fd, int server_fd)
return -1; return -1;
} }
map = bpf_map__next(NULL, obj); map = bpf_object__next_map(obj, NULL);
map_fd = bpf_map__fd(map); map_fd = bpf_map__fd(map);
err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0); err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0);
......
...@@ -187,7 +187,7 @@ int main(int argc, char **argv) ...@@ -187,7 +187,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
map = bpf_map__next(NULL, obj); map = bpf_object__next_map(obj, NULL);
if (map) if (map)
map_fd = bpf_map__fd(map); map_fd = bpf_map__fd(map);
if (!map || map_fd < 0) { if (!map || map_fd < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment