Commit c5a237a4 authored by Ilya Leoshkevich's avatar Ilya Leoshkevich Committed by Andrii Nakryiko

selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()

Use the new type-safe wrappers around bpf_obj_get_info_by_fd().
Fix a prog/map mixup in prog_holds_map().
Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230214231221.249277-6-iii@linux.ibm.com
parent c0ca277b
...@@ -18,7 +18,7 @@ static __u32 get_map_id_from_fd(int map_fd) ...@@ -18,7 +18,7 @@ static __u32 get_map_id_from_fd(int map_fd)
uint32_t info_len = sizeof(map_info); uint32_t info_len = sizeof(map_info);
int ret; int ret;
ret = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len); ret = bpf_map_get_info_by_fd(map_fd, &map_info, &info_len);
CHECK(ret < 0, "Finding map info failed", "error:%s\n", CHECK(ret < 0, "Finding map info failed", "error:%s\n",
strerror(errno)); strerror(errno));
......
...@@ -195,8 +195,8 @@ static void check_bpf_link_info(const struct bpf_program *prog) ...@@ -195,8 +195,8 @@ static void check_bpf_link_info(const struct bpf_program *prog)
return; return;
info_len = sizeof(info); info_len = sizeof(info);
err = bpf_obj_get_info_by_fd(bpf_link__fd(link), &info, &info_len); err = bpf_link_get_info_by_fd(bpf_link__fd(link), &info, &info_len);
ASSERT_OK(err, "bpf_obj_get_info_by_fd"); ASSERT_OK(err, "bpf_link_get_info_by_fd");
ASSERT_EQ(info.iter.task.tid, getpid(), "check_task_tid"); ASSERT_EQ(info.iter.task.tid, getpid(), "check_task_tid");
bpf_link__destroy(link); bpf_link__destroy(link);
...@@ -684,13 +684,13 @@ static void test_overflow(bool test_e2big_overflow, bool ret1) ...@@ -684,13 +684,13 @@ static void test_overflow(bool test_e2big_overflow, bool ret1)
/* setup filtering map_id in bpf program */ /* setup filtering map_id in bpf program */
map_info_len = sizeof(map_info); map_info_len = sizeof(map_info);
err = bpf_obj_get_info_by_fd(map1_fd, &map_info, &map_info_len); err = bpf_map_get_info_by_fd(map1_fd, &map_info, &map_info_len);
if (CHECK(err, "get_map_info", "get map info failed: %s\n", if (CHECK(err, "get_map_info", "get map info failed: %s\n",
strerror(errno))) strerror(errno)))
goto free_map2; goto free_map2;
skel->bss->map1_id = map_info.id; skel->bss->map1_id = map_info.id;
err = bpf_obj_get_info_by_fd(map2_fd, &map_info, &map_info_len); err = bpf_map_get_info_by_fd(map2_fd, &map_info, &map_info_len);
if (CHECK(err, "get_map_info", "get map info failed: %s\n", if (CHECK(err, "get_map_info", "get map info failed: %s\n",
strerror(errno))) strerror(errno)))
goto free_map2; goto free_map2;
......
...@@ -44,7 +44,7 @@ void serial_test_bpf_obj_id(void) ...@@ -44,7 +44,7 @@ void serial_test_bpf_obj_id(void)
CHECK(err >= 0 || errno != ENOENT, CHECK(err >= 0 || errno != ENOENT,
"get-fd-by-notexist-link-id", "err %d errno %d\n", err, errno); "get-fd-by-notexist-link-id", "err %d errno %d\n", err, errno);
/* Check bpf_obj_get_info_by_fd() */ /* Check bpf_map_get_info_by_fd() */
bzero(zeros, sizeof(zeros)); bzero(zeros, sizeof(zeros));
for (i = 0; i < nr_iters; i++) { for (i = 0; i < nr_iters; i++) {
now = time(NULL); now = time(NULL);
...@@ -79,7 +79,7 @@ void serial_test_bpf_obj_id(void) ...@@ -79,7 +79,7 @@ void serial_test_bpf_obj_id(void)
/* Check getting map info */ /* Check getting map info */
info_len = sizeof(struct bpf_map_info) * 2; info_len = sizeof(struct bpf_map_info) * 2;
bzero(&map_infos[i], info_len); bzero(&map_infos[i], info_len);
err = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i], err = bpf_map_get_info_by_fd(map_fds[i], &map_infos[i],
&info_len); &info_len);
if (CHECK(err || if (CHECK(err ||
map_infos[i].type != BPF_MAP_TYPE_ARRAY || map_infos[i].type != BPF_MAP_TYPE_ARRAY ||
...@@ -118,7 +118,7 @@ void serial_test_bpf_obj_id(void) ...@@ -118,7 +118,7 @@ void serial_test_bpf_obj_id(void)
err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts); err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts);
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
goto done; goto done;
err = bpf_obj_get_info_by_fd(prog_fds[i], &prog_infos[i], err = bpf_prog_get_info_by_fd(prog_fds[i], &prog_infos[i],
&info_len); &info_len);
load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec) load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec)
+ (prog_infos[i].load_time / nsec_per_sec); + (prog_infos[i].load_time / nsec_per_sec);
...@@ -161,7 +161,7 @@ void serial_test_bpf_obj_id(void) ...@@ -161,7 +161,7 @@ void serial_test_bpf_obj_id(void)
bzero(&link_infos[i], info_len); bzero(&link_infos[i], info_len);
link_infos[i].raw_tracepoint.tp_name = ptr_to_u64(&tp_name); link_infos[i].raw_tracepoint.tp_name = ptr_to_u64(&tp_name);
link_infos[i].raw_tracepoint.tp_name_len = sizeof(tp_name); link_infos[i].raw_tracepoint.tp_name_len = sizeof(tp_name);
err = bpf_obj_get_info_by_fd(bpf_link__fd(links[i]), err = bpf_link_get_info_by_fd(bpf_link__fd(links[i]),
&link_infos[i], &info_len); &link_infos[i], &info_len);
if (CHECK(err || if (CHECK(err ||
link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT || link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT ||
...@@ -217,7 +217,7 @@ void serial_test_bpf_obj_id(void) ...@@ -217,7 +217,7 @@ void serial_test_bpf_obj_id(void)
* prog_info.map_ids = NULL * prog_info.map_ids = NULL
*/ */
prog_info.nr_map_ids = 1; prog_info.nr_map_ids = 1;
err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &info_len);
if (CHECK(!err || errno != EFAULT, if (CHECK(!err || errno != EFAULT,
"get-prog-fd-bad-nr-map-ids", "err %d errno %d(%d)", "get-prog-fd-bad-nr-map-ids", "err %d errno %d(%d)",
err, errno, EFAULT)) err, errno, EFAULT))
...@@ -228,7 +228,7 @@ void serial_test_bpf_obj_id(void) ...@@ -228,7 +228,7 @@ void serial_test_bpf_obj_id(void)
saved_map_id = *(int *)((long)prog_infos[i].map_ids); saved_map_id = *(int *)((long)prog_infos[i].map_ids);
prog_info.map_ids = prog_infos[i].map_ids; prog_info.map_ids = prog_infos[i].map_ids;
prog_info.nr_map_ids = 2; prog_info.nr_map_ids = 2;
err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &info_len);
prog_infos[i].jited_prog_insns = 0; prog_infos[i].jited_prog_insns = 0;
prog_infos[i].xlated_prog_insns = 0; prog_infos[i].xlated_prog_insns = 0;
CHECK(err || info_len != sizeof(struct bpf_prog_info) || CHECK(err || info_len != sizeof(struct bpf_prog_info) ||
...@@ -277,7 +277,7 @@ void serial_test_bpf_obj_id(void) ...@@ -277,7 +277,7 @@ void serial_test_bpf_obj_id(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
goto done; goto done;
err = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len); err = bpf_map_get_info_by_fd(map_fd, &map_info, &info_len);
CHECK(err || info_len != sizeof(struct bpf_map_info) || CHECK(err || info_len != sizeof(struct bpf_map_info) ||
memcmp(&map_info, &map_infos[i], info_len) || memcmp(&map_info, &map_infos[i], info_len) ||
array_value != array_magic_value, array_value != array_magic_value,
...@@ -322,7 +322,7 @@ void serial_test_bpf_obj_id(void) ...@@ -322,7 +322,7 @@ void serial_test_bpf_obj_id(void)
nr_id_found++; nr_id_found++;
err = bpf_obj_get_info_by_fd(link_fd, &link_info, &info_len); err = bpf_link_get_info_by_fd(link_fd, &link_info, &info_len);
cmp_res = memcmp(&link_info, &link_infos[i], cmp_res = memcmp(&link_info, &link_infos[i],
offsetof(struct bpf_link_info, raw_tracepoint)); offsetof(struct bpf_link_info, raw_tracepoint));
CHECK(err || info_len != sizeof(link_info) || cmp_res, CHECK(err || info_len != sizeof(link_info) || cmp_res,
......
...@@ -4422,7 +4422,7 @@ static int test_big_btf_info(unsigned int test_num) ...@@ -4422,7 +4422,7 @@ static int test_big_btf_info(unsigned int test_num)
info->btf = ptr_to_u64(user_btf); info->btf = ptr_to_u64(user_btf);
info->btf_size = raw_btf_size; info->btf_size = raw_btf_size;
err = bpf_obj_get_info_by_fd(btf_fd, info, &info_len); err = bpf_btf_get_info_by_fd(btf_fd, info, &info_len);
if (CHECK(!err, "!err")) { if (CHECK(!err, "!err")) {
err = -1; err = -1;
goto done; goto done;
...@@ -4435,7 +4435,7 @@ static int test_big_btf_info(unsigned int test_num) ...@@ -4435,7 +4435,7 @@ static int test_big_btf_info(unsigned int test_num)
* to userspace. * to userspace.
*/ */
info_garbage.garbage = 0; info_garbage.garbage = 0;
err = bpf_obj_get_info_by_fd(btf_fd, info, &info_len); err = bpf_btf_get_info_by_fd(btf_fd, info, &info_len);
if (CHECK(err || info_len != sizeof(*info), if (CHECK(err || info_len != sizeof(*info),
"err:%d errno:%d info_len:%u sizeof(*info):%zu", "err:%d errno:%d info_len:%u sizeof(*info):%zu",
err, errno, info_len, sizeof(*info))) { err, errno, info_len, sizeof(*info))) {
...@@ -4499,7 +4499,7 @@ static int test_btf_id(unsigned int test_num) ...@@ -4499,7 +4499,7 @@ static int test_btf_id(unsigned int test_num)
/* Test BPF_OBJ_GET_INFO_BY_ID on btf_id */ /* Test BPF_OBJ_GET_INFO_BY_ID on btf_id */
info_len = sizeof(info[0]); info_len = sizeof(info[0]);
err = bpf_obj_get_info_by_fd(btf_fd[0], &info[0], &info_len); err = bpf_btf_get_info_by_fd(btf_fd[0], &info[0], &info_len);
if (CHECK(err, "errno:%d", errno)) { if (CHECK(err, "errno:%d", errno)) {
err = -1; err = -1;
goto done; goto done;
...@@ -4512,7 +4512,7 @@ static int test_btf_id(unsigned int test_num) ...@@ -4512,7 +4512,7 @@ static int test_btf_id(unsigned int test_num)
} }
ret = 0; ret = 0;
err = bpf_obj_get_info_by_fd(btf_fd[1], &info[1], &info_len); err = bpf_btf_get_info_by_fd(btf_fd[1], &info[1], &info_len);
if (CHECK(err || info[0].id != info[1].id || if (CHECK(err || info[0].id != info[1].id ||
info[0].btf_size != info[1].btf_size || info[0].btf_size != info[1].btf_size ||
(ret = memcmp(user_btf[0], user_btf[1], info[0].btf_size)), (ret = memcmp(user_btf[0], user_btf[1], info[0].btf_size)),
...@@ -4535,7 +4535,7 @@ static int test_btf_id(unsigned int test_num) ...@@ -4535,7 +4535,7 @@ static int test_btf_id(unsigned int test_num)
} }
info_len = sizeof(map_info); info_len = sizeof(map_info);
err = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len); err = bpf_map_get_info_by_fd(map_fd, &map_info, &info_len);
if (CHECK(err || map_info.btf_id != info[0].id || if (CHECK(err || map_info.btf_id != info[0].id ||
map_info.btf_key_type_id != 1 || map_info.btf_value_type_id != 2, map_info.btf_key_type_id != 1 || map_info.btf_value_type_id != 2,
"err:%d errno:%d info.id:%u btf_id:%u btf_key_type_id:%u btf_value_type_id:%u", "err:%d errno:%d info.id:%u btf_id:%u btf_key_type_id:%u btf_value_type_id:%u",
...@@ -4638,7 +4638,7 @@ static void do_test_get_info(unsigned int test_num) ...@@ -4638,7 +4638,7 @@ static void do_test_get_info(unsigned int test_num)
info.btf_size = user_btf_size; info.btf_size = user_btf_size;
ret = 0; ret = 0;
err = bpf_obj_get_info_by_fd(btf_fd, &info, &info_len); err = bpf_btf_get_info_by_fd(btf_fd, &info, &info_len);
if (CHECK(err || !info.id || info_len != sizeof(info) || if (CHECK(err || !info.id || info_len != sizeof(info) ||
info.btf_size != raw_btf_size || info.btf_size != raw_btf_size ||
(ret = memcmp(raw_btf, user_btf, expected_nbytes)), (ret = memcmp(raw_btf, user_btf, expected_nbytes)),
...@@ -4755,7 +4755,7 @@ static void do_test_file(unsigned int test_num) ...@@ -4755,7 +4755,7 @@ static void do_test_file(unsigned int test_num)
/* get necessary program info */ /* get necessary program info */
info_len = sizeof(struct bpf_prog_info); info_len = sizeof(struct bpf_prog_info);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err < 0, "invalid get info (1st) errno:%d", errno)) { if (CHECK(err < 0, "invalid get info (1st) errno:%d", errno)) {
fprintf(stderr, "%s\n", btf_log_buf); fprintf(stderr, "%s\n", btf_log_buf);
...@@ -4787,7 +4787,7 @@ static void do_test_file(unsigned int test_num) ...@@ -4787,7 +4787,7 @@ static void do_test_file(unsigned int test_num)
info.func_info_rec_size = rec_size; info.func_info_rec_size = rec_size;
info.func_info = ptr_to_u64(func_info); info.func_info = ptr_to_u64(func_info);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err < 0, "invalid get info (2nd) errno:%d", errno)) { if (CHECK(err < 0, "invalid get info (2nd) errno:%d", errno)) {
fprintf(stderr, "%s\n", btf_log_buf); fprintf(stderr, "%s\n", btf_log_buf);
...@@ -6405,7 +6405,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test, ...@@ -6405,7 +6405,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
/* get necessary lens */ /* get necessary lens */
info_len = sizeof(struct bpf_prog_info); info_len = sizeof(struct bpf_prog_info);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err < 0, "invalid get info (1st) errno:%d", errno)) { if (CHECK(err < 0, "invalid get info (1st) errno:%d", errno)) {
fprintf(stderr, "%s\n", btf_log_buf); fprintf(stderr, "%s\n", btf_log_buf);
return -1; return -1;
...@@ -6435,7 +6435,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test, ...@@ -6435,7 +6435,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
info.nr_func_info = nr_func_info; info.nr_func_info = nr_func_info;
info.func_info_rec_size = rec_size; info.func_info_rec_size = rec_size;
info.func_info = ptr_to_u64(func_info); info.func_info = ptr_to_u64(func_info);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err < 0, "invalid get info (2nd) errno:%d", errno)) { if (CHECK(err < 0, "invalid get info (2nd) errno:%d", errno)) {
fprintf(stderr, "%s\n", btf_log_buf); fprintf(stderr, "%s\n", btf_log_buf);
err = -1; err = -1;
...@@ -6499,7 +6499,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test, ...@@ -6499,7 +6499,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
nr_jited_func_lens = nr_jited_ksyms; nr_jited_func_lens = nr_jited_ksyms;
info_len = sizeof(struct bpf_prog_info); info_len = sizeof(struct bpf_prog_info);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err < 0, "err:%d errno:%d", err, errno)) { if (CHECK(err < 0, "err:%d errno:%d", err, errno)) {
err = -1; err = -1;
goto done; goto done;
...@@ -6573,7 +6573,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test, ...@@ -6573,7 +6573,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
info.jited_func_lens = ptr_to_u64(jited_func_lens); info.jited_func_lens = ptr_to_u64(jited_func_lens);
} }
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
/* /*
* Only recheck the info.*line_info* fields. * Only recheck the info.*line_info* fields.
......
...@@ -14,7 +14,7 @@ static __u32 bpf_map_id(struct bpf_map *map) ...@@ -14,7 +14,7 @@ static __u32 bpf_map_id(struct bpf_map *map)
int err; int err;
memset(&info, 0, info_len); memset(&info, 0, info_len);
err = bpf_obj_get_info_by_fd(bpf_map__fd(map), &info, &info_len); err = bpf_map_get_info_by_fd(bpf_map__fd(map), &info, &info_len);
if (err) if (err)
return 0; return 0;
return info.id; return info.id;
......
...@@ -59,7 +59,7 @@ static void test_check_mtu_xdp_attach(void) ...@@ -59,7 +59,7 @@ static void test_check_mtu_xdp_attach(void)
memset(&link_info, 0, sizeof(link_info)); memset(&link_info, 0, sizeof(link_info));
fd = bpf_link__fd(link); fd = bpf_link__fd(link);
err = bpf_obj_get_info_by_fd(fd, &link_info, &link_info_len); err = bpf_link_get_info_by_fd(fd, &link_info, &link_info_len);
if (CHECK(err, "link_info", "failed: %d\n", err)) if (CHECK(err, "link_info", "failed: %d\n", err))
goto out; goto out;
......
...@@ -28,7 +28,7 @@ void test_enable_stats(void) ...@@ -28,7 +28,7 @@ void test_enable_stats(void)
prog_fd = bpf_program__fd(skel->progs.test_enable_stats); prog_fd = bpf_program__fd(skel->progs.test_enable_stats);
memset(&info, 0, info_len); memset(&info, 0, info_len);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err, "get_prog_info", if (CHECK(err, "get_prog_info",
"failed to get bpf_prog_info for fd %d\n", prog_fd)) "failed to get bpf_prog_info for fd %d\n", prog_fd))
goto cleanup; goto cleanup;
......
...@@ -79,7 +79,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file, ...@@ -79,7 +79,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
return; return;
info_len = sizeof(prog_info); info_len = sizeof(prog_info);
err = bpf_obj_get_info_by_fd(tgt_fd, &prog_info, &info_len); err = bpf_prog_get_info_by_fd(tgt_fd, &prog_info, &info_len);
if (!ASSERT_OK(err, "tgt_fd_get_info")) if (!ASSERT_OK(err, "tgt_fd_get_info"))
goto close_prog; goto close_prog;
...@@ -136,7 +136,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file, ...@@ -136,7 +136,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
info_len = sizeof(link_info); info_len = sizeof(link_info);
memset(&link_info, 0, sizeof(link_info)); memset(&link_info, 0, sizeof(link_info));
err = bpf_obj_get_info_by_fd(bpf_link__fd(link[i]), err = bpf_link_get_info_by_fd(bpf_link__fd(link[i]),
&link_info, &info_len); &link_info, &info_len);
ASSERT_OK(err, "link_fd_get_info"); ASSERT_OK(err, "link_fd_get_info");
ASSERT_EQ(link_info.tracing.attach_type, ASSERT_EQ(link_info.tracing.attach_type,
...@@ -417,7 +417,7 @@ static int find_prog_btf_id(const char *name, __u32 attach_prog_fd) ...@@ -417,7 +417,7 @@ static int find_prog_btf_id(const char *name, __u32 attach_prog_fd)
struct btf *btf; struct btf *btf;
int ret; int ret;
ret = bpf_obj_get_info_by_fd(attach_prog_fd, &info, &info_len); ret = bpf_prog_get_info_by_fd(attach_prog_fd, &info, &info_len);
if (ret) if (ret)
return ret; return ret;
...@@ -483,12 +483,12 @@ static void test_fentry_to_cgroup_bpf(void) ...@@ -483,12 +483,12 @@ static void test_fentry_to_cgroup_bpf(void)
if (!ASSERT_GE(fentry_fd, 0, "load_fentry")) if (!ASSERT_GE(fentry_fd, 0, "load_fentry"))
goto cleanup; goto cleanup;
/* Make sure bpf_obj_get_info_by_fd works correctly when attaching /* Make sure bpf_prog_get_info_by_fd works correctly when attaching
* to another BPF program. * to another BPF program.
*/ */
ASSERT_OK(bpf_obj_get_info_by_fd(fentry_fd, &info, &info_len), ASSERT_OK(bpf_prog_get_info_by_fd(fentry_fd, &info, &info_len),
"bpf_obj_get_info_by_fd"); "bpf_prog_get_info_by_fd");
ASSERT_EQ(info.btf_id, 0, "info.btf_id"); ASSERT_EQ(info.btf_id, 0, "info.btf_id");
ASSERT_EQ(info.attach_btf_id, btf_id, "info.attach_btf_id"); ASSERT_EQ(info.attach_btf_id, btf_id, "info.attach_btf_id");
......
...@@ -60,9 +60,9 @@ static __u32 query_prog_id(int prog) ...@@ -60,9 +60,9 @@ static __u32 query_prog_id(int prog)
__u32 info_len = sizeof(info); __u32 info_len = sizeof(info);
int err; int err;
err = bpf_obj_get_info_by_fd(prog, &info, &info_len); err = bpf_prog_get_info_by_fd(prog, &info, &info_len);
if (CHECK_FAIL(err || info_len != sizeof(info))) { if (CHECK_FAIL(err || info_len != sizeof(info))) {
perror("bpf_obj_get_info_by_fd"); perror("bpf_prog_get_info_by_fd");
return 0; return 0;
} }
...@@ -497,7 +497,7 @@ static void test_link_get_info(int netns, int prog1, int prog2) ...@@ -497,7 +497,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
} }
info_len = sizeof(info); info_len = sizeof(info);
err = bpf_obj_get_info_by_fd(link, &info, &info_len); err = bpf_link_get_info_by_fd(link, &info, &info_len);
if (CHECK_FAIL(err)) { if (CHECK_FAIL(err)) {
perror("bpf_obj_get_info"); perror("bpf_obj_get_info");
goto out_unlink; goto out_unlink;
...@@ -521,7 +521,7 @@ static void test_link_get_info(int netns, int prog1, int prog2) ...@@ -521,7 +521,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
link_id = info.id; link_id = info.id;
info_len = sizeof(info); info_len = sizeof(info);
err = bpf_obj_get_info_by_fd(link, &info, &info_len); err = bpf_link_get_info_by_fd(link, &info, &info_len);
if (CHECK_FAIL(err)) { if (CHECK_FAIL(err)) {
perror("bpf_obj_get_info"); perror("bpf_obj_get_info");
goto out_unlink; goto out_unlink;
...@@ -546,7 +546,7 @@ static void test_link_get_info(int netns, int prog1, int prog2) ...@@ -546,7 +546,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
netns = -1; netns = -1;
info_len = sizeof(info); info_len = sizeof(info);
err = bpf_obj_get_info_by_fd(link, &info, &info_len); err = bpf_link_get_info_by_fd(link, &info, &info_len);
if (CHECK_FAIL(err)) { if (CHECK_FAIL(err)) {
perror("bpf_obj_get_info"); perror("bpf_obj_get_info");
goto out_unlink; goto out_unlink;
......
...@@ -29,9 +29,9 @@ void test_libbpf_get_fd_by_id_opts(void) ...@@ -29,9 +29,9 @@ void test_libbpf_get_fd_by_id_opts(void)
if (!ASSERT_OK(ret, "test_libbpf_get_fd_by_id_opts__attach")) if (!ASSERT_OK(ret, "test_libbpf_get_fd_by_id_opts__attach"))
goto close_prog; goto close_prog;
ret = bpf_obj_get_info_by_fd(bpf_map__fd(skel->maps.data_input), ret = bpf_map_get_info_by_fd(bpf_map__fd(skel->maps.data_input),
&info_m, &len); &info_m, &len);
if (!ASSERT_OK(ret, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(ret, "bpf_map_get_info_by_fd"))
goto close_prog; goto close_prog;
fd = bpf_map_get_fd_by_id(info_m.id); fd = bpf_map_get_fd_by_id(info_m.id);
......
...@@ -47,7 +47,8 @@ static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func) ...@@ -47,7 +47,8 @@ static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func)
fd = bpf_prog_get_fd_by_id(p.prog_ids[i]); fd = bpf_prog_get_fd_by_id(p.prog_ids[i]);
ASSERT_GE(fd, 0, "prog_get_fd_by_id"); ASSERT_GE(fd, 0, "prog_get_fd_by_id");
ASSERT_OK(bpf_obj_get_info_by_fd(fd, &info, &info_len), "prog_info_by_fd"); ASSERT_OK(bpf_prog_get_info_by_fd(fd, &info, &info_len),
"prog_info_by_fd");
close(fd); close(fd);
if (info.attach_btf_id == if (info.attach_btf_id ==
......
...@@ -16,7 +16,7 @@ static int duration; ...@@ -16,7 +16,7 @@ static int duration;
static int prog_holds_map(int prog_fd, int map_fd) static int prog_holds_map(int prog_fd, int map_fd)
{ {
struct bpf_prog_info prog_info = {}; struct bpf_prog_info prog_info = {};
struct bpf_prog_info map_info = {}; struct bpf_map_info map_info = {};
__u32 prog_info_len; __u32 prog_info_len;
__u32 map_info_len; __u32 map_info_len;
__u32 *map_ids; __u32 *map_ids;
...@@ -25,12 +25,12 @@ static int prog_holds_map(int prog_fd, int map_fd) ...@@ -25,12 +25,12 @@ static int prog_holds_map(int prog_fd, int map_fd)
int i; int i;
map_info_len = sizeof(map_info); map_info_len = sizeof(map_info);
ret = bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_len); ret = bpf_map_get_info_by_fd(map_fd, &map_info, &map_info_len);
if (ret) if (ret)
return -errno; return -errno;
prog_info_len = sizeof(prog_info); prog_info_len = sizeof(prog_info);
ret = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &prog_info_len); ret = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &prog_info_len);
if (ret) if (ret)
return -errno; return -errno;
...@@ -44,7 +44,7 @@ static int prog_holds_map(int prog_fd, int map_fd) ...@@ -44,7 +44,7 @@ static int prog_holds_map(int prog_fd, int map_fd)
prog_info.map_ids = ptr_to_u64(map_ids); prog_info.map_ids = ptr_to_u64(map_ids);
prog_info_len = sizeof(prog_info); prog_info_len = sizeof(prog_info);
ret = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &prog_info_len); ret = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &prog_info_len);
if (ret) { if (ret) {
ret = -errno; ret = -errno;
goto free_map_ids; goto free_map_ids;
......
...@@ -64,7 +64,7 @@ void test_mmap(void) ...@@ -64,7 +64,7 @@ void test_mmap(void)
/* get map's ID */ /* get map's ID */
memset(&map_info, 0, map_info_sz); memset(&map_info, 0, map_info_sz);
err = bpf_obj_get_info_by_fd(data_map_fd, &map_info, &map_info_sz); err = bpf_map_get_info_by_fd(data_map_fd, &map_info, &map_info_sz);
if (CHECK(err, "map_get_info", "failed %d\n", errno)) if (CHECK(err, "map_get_info", "failed %d\n", errno))
goto cleanup; goto cleanup;
data_map_id = map_info.id; data_map_id = map_info.id;
......
...@@ -54,7 +54,7 @@ void serial_test_perf_link(void) ...@@ -54,7 +54,7 @@ void serial_test_perf_link(void)
goto cleanup; goto cleanup;
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
err = bpf_obj_get_info_by_fd(link_fd, &info, &info_len); err = bpf_link_get_info_by_fd(link_fd, &info, &info_len);
if (!ASSERT_OK(err, "link_get_info")) if (!ASSERT_OK(err, "link_get_info"))
goto cleanup; goto cleanup;
......
...@@ -18,7 +18,7 @@ __u32 get_map_id(struct bpf_object *obj, const char *name) ...@@ -18,7 +18,7 @@ __u32 get_map_id(struct bpf_object *obj, const char *name)
if (CHECK(!map, "find map", "NULL map")) if (CHECK(!map, "find map", "NULL map"))
return 0; return 0;
err = bpf_obj_get_info_by_fd(bpf_map__fd(map), err = bpf_map_get_info_by_fd(bpf_map__fd(map),
&map_info, &map_info_len); &map_info, &map_info_len);
CHECK(err, "get map info", "err %d errno %d", err, errno); CHECK(err, "get map info", "err %d errno %d", err, errno);
return map_info.id; return map_info.id;
......
...@@ -12,7 +12,7 @@ static void check_run_cnt(int prog_fd, __u64 run_cnt) ...@@ -12,7 +12,7 @@ static void check_run_cnt(int prog_fd, __u64 run_cnt)
__u32 info_len = sizeof(info); __u32 info_len = sizeof(info);
int err; int err;
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (CHECK(err, "get_prog_info", "failed to get bpf_prog_info for fd %d\n", prog_fd)) if (CHECK(err, "get_prog_info", "failed to get bpf_prog_info for fd %d\n", prog_fd))
return; return;
......
...@@ -31,7 +31,7 @@ void test_recursion(void) ...@@ -31,7 +31,7 @@ void test_recursion(void)
bpf_map_delete_elem(bpf_map__fd(skel->maps.hash2), &key); bpf_map_delete_elem(bpf_map__fd(skel->maps.hash2), &key);
ASSERT_EQ(skel->bss->pass2, 2, "pass2 == 2"); ASSERT_EQ(skel->bss->pass2, 2, "pass2 == 2");
err = bpf_obj_get_info_by_fd(bpf_program__fd(skel->progs.on_delete), err = bpf_prog_get_info_by_fd(bpf_program__fd(skel->progs.on_delete),
&prog_info, &prog_info_len); &prog_info, &prog_info_len);
if (!ASSERT_OK(err, "get_prog_info")) if (!ASSERT_OK(err, "get_prog_info"))
goto out; goto out;
......
...@@ -299,9 +299,9 @@ static __u32 query_prog_id(int prog_fd) ...@@ -299,9 +299,9 @@ static __u32 query_prog_id(int prog_fd)
__u32 info_len = sizeof(info); __u32 info_len = sizeof(info);
int err; int err;
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd") || if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd") ||
!ASSERT_EQ(info_len, sizeof(info), "bpf_obj_get_info_by_fd")) !ASSERT_EQ(info_len, sizeof(info), "bpf_prog_get_info_by_fd"))
return 0; return 0;
return info.id; return info.id;
......
...@@ -119,19 +119,19 @@ static void test_recursion(void) ...@@ -119,19 +119,19 @@ static void test_recursion(void)
prog_fd = bpf_program__fd(skel->progs.on_lookup); prog_fd = bpf_program__fd(skel->progs.on_lookup);
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
ASSERT_OK(err, "get prog info"); ASSERT_OK(err, "get prog info");
ASSERT_GT(info.recursion_misses, 0, "on_lookup prog recursion"); ASSERT_GT(info.recursion_misses, 0, "on_lookup prog recursion");
prog_fd = bpf_program__fd(skel->progs.on_update); prog_fd = bpf_program__fd(skel->progs.on_update);
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
ASSERT_OK(err, "get prog info"); ASSERT_OK(err, "get prog info");
ASSERT_EQ(info.recursion_misses, 0, "on_update prog recursion"); ASSERT_EQ(info.recursion_misses, 0, "on_update prog recursion");
prog_fd = bpf_program__fd(skel->progs.on_enter); prog_fd = bpf_program__fd(skel->progs.on_enter);
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
ASSERT_OK(err, "get prog info"); ASSERT_OK(err, "get prog info");
ASSERT_EQ(info.recursion_misses, 0, "on_enter prog recursion"); ASSERT_EQ(info.recursion_misses, 0, "on_enter prog recursion");
...@@ -221,7 +221,7 @@ static void test_nodeadlock(void) ...@@ -221,7 +221,7 @@ static void test_nodeadlock(void)
info_len = sizeof(info); info_len = sizeof(info);
prog_fd = bpf_program__fd(skel->progs.socket_post_create); prog_fd = bpf_program__fd(skel->progs.socket_post_create);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
ASSERT_OK(err, "get prog info"); ASSERT_OK(err, "get prog info");
ASSERT_EQ(info.recursion_misses, 0, "prog recursion"); ASSERT_EQ(info.recursion_misses, 0, "prog recursion");
......
...@@ -29,8 +29,8 @@ static int test_tc_bpf_basic(const struct bpf_tc_hook *hook, int fd) ...@@ -29,8 +29,8 @@ static int test_tc_bpf_basic(const struct bpf_tc_hook *hook, int fd)
__u32 info_len = sizeof(info); __u32 info_len = sizeof(info);
int ret; int ret;
ret = bpf_obj_get_info_by_fd(fd, &info, &info_len); ret = bpf_prog_get_info_by_fd(fd, &info, &info_len);
if (!ASSERT_OK(ret, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(ret, "bpf_prog_get_info_by_fd"))
return ret; return ret;
ret = bpf_tc_attach(hook, &opts); ret = bpf_tc_attach(hook, &opts);
......
...@@ -45,8 +45,9 @@ void serial_test_tp_attach_query(void) ...@@ -45,8 +45,9 @@ void serial_test_tp_attach_query(void)
prog_info.xlated_prog_len = 0; prog_info.xlated_prog_len = 0;
prog_info.nr_map_ids = 0; prog_info.nr_map_ids = 0;
info_len = sizeof(prog_info); info_len = sizeof(prog_info);
err = bpf_obj_get_info_by_fd(prog_fd[i], &prog_info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd[i], &prog_info,
if (CHECK(err, "bpf_obj_get_info_by_fd", "err %d errno %d\n", &info_len);
if (CHECK(err, "bpf_prog_get_info_by_fd", "err %d errno %d\n",
err, errno)) err, errno))
goto cleanup1; goto cleanup1;
saved_prog_ids[i] = prog_info.id; saved_prog_ids[i] = prog_info.id;
......
...@@ -179,7 +179,7 @@ static void test_unpriv_bpf_disabled_negative(struct test_unpriv_bpf_disabled *s ...@@ -179,7 +179,7 @@ static void test_unpriv_bpf_disabled_negative(struct test_unpriv_bpf_disabled *s
ASSERT_EQ(bpf_prog_get_next_id(prog_id, &next), -EPERM, "prog_get_next_id_fails"); ASSERT_EQ(bpf_prog_get_next_id(prog_id, &next), -EPERM, "prog_get_next_id_fails");
ASSERT_EQ(bpf_prog_get_next_id(0, &next), -EPERM, "prog_get_next_id_fails"); ASSERT_EQ(bpf_prog_get_next_id(0, &next), -EPERM, "prog_get_next_id_fails");
if (ASSERT_OK(bpf_obj_get_info_by_fd(map_fds[0], &map_info, &map_info_len), if (ASSERT_OK(bpf_map_get_info_by_fd(map_fds[0], &map_info, &map_info_len),
"obj_get_info_by_fd")) { "obj_get_info_by_fd")) {
ASSERT_EQ(bpf_map_get_fd_by_id(map_info.id), -EPERM, "map_get_fd_by_id_fails"); ASSERT_EQ(bpf_map_get_fd_by_id(map_info.id), -EPERM, "map_get_fd_by_id_fails");
ASSERT_EQ(bpf_map_get_next_id(map_info.id, &next), -EPERM, ASSERT_EQ(bpf_map_get_next_id(map_info.id, &next), -EPERM,
...@@ -187,7 +187,7 @@ static void test_unpriv_bpf_disabled_negative(struct test_unpriv_bpf_disabled *s ...@@ -187,7 +187,7 @@ static void test_unpriv_bpf_disabled_negative(struct test_unpriv_bpf_disabled *s
} }
ASSERT_EQ(bpf_map_get_next_id(0, &next), -EPERM, "map_get_next_id_fails"); ASSERT_EQ(bpf_map_get_next_id(0, &next), -EPERM, "map_get_next_id_fails");
if (ASSERT_OK(bpf_obj_get_info_by_fd(bpf_link__fd(skel->links.sys_nanosleep_enter), if (ASSERT_OK(bpf_link_get_info_by_fd(bpf_link__fd(skel->links.sys_nanosleep_enter),
&link_info, &link_info_len), &link_info, &link_info_len),
"obj_get_info_by_fd")) { "obj_get_info_by_fd")) {
ASSERT_EQ(bpf_link_get_fd_by_id(link_info.id), -EPERM, "link_get_fd_by_id_fails"); ASSERT_EQ(bpf_link_get_fd_by_id(link_info.id), -EPERM, "link_get_fd_by_id_fails");
...@@ -269,7 +269,7 @@ void test_unpriv_bpf_disabled(void) ...@@ -269,7 +269,7 @@ void test_unpriv_bpf_disabled(void)
} }
prog_fd = bpf_program__fd(skel->progs.sys_nanosleep_enter); prog_fd = bpf_program__fd(skel->progs.sys_nanosleep_enter);
ASSERT_OK(bpf_obj_get_info_by_fd(prog_fd, &prog_info, &prog_info_len), ASSERT_OK(bpf_prog_get_info_by_fd(prog_fd, &prog_info, &prog_info_len),
"obj_get_info_by_fd"); "obj_get_info_by_fd");
prog_id = prog_info.id; prog_id = prog_info.id;
ASSERT_GT(prog_id, 0, "valid_prog_id"); ASSERT_GT(prog_id, 0, "valid_prog_id");
......
...@@ -16,8 +16,9 @@ void test_verif_stats(void) ...@@ -16,8 +16,9 @@ void test_verif_stats(void)
if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load")) if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
goto cleanup; goto cleanup;
err = bpf_obj_get_info_by_fd(skel->progs.sys_enter.prog_fd, &info, &len); err = bpf_prog_get_info_by_fd(skel->progs.sys_enter.prog_fd,
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd")) &info, &len);
if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto cleanup; goto cleanup;
if (!ASSERT_GT(info.verified_insns, 0, "verified_insns")) if (!ASSERT_GT(info.verified_insns, 0, "verified_insns"))
......
...@@ -18,7 +18,7 @@ void serial_test_xdp_attach(void) ...@@ -18,7 +18,7 @@ void serial_test_xdp_attach(void)
err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj1, &fd1); err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj1, &fd1);
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
err = bpf_obj_get_info_by_fd(fd1, &info, &len); err = bpf_prog_get_info_by_fd(fd1, &info, &len);
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
goto out_1; goto out_1;
id1 = info.id; id1 = info.id;
...@@ -28,7 +28,7 @@ void serial_test_xdp_attach(void) ...@@ -28,7 +28,7 @@ void serial_test_xdp_attach(void)
goto out_1; goto out_1;
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
err = bpf_obj_get_info_by_fd(fd2, &info, &len); err = bpf_prog_get_info_by_fd(fd2, &info, &len);
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
goto out_2; goto out_2;
id2 = info.id; id2 = info.id;
......
...@@ -33,8 +33,8 @@ static void test_xdp_with_cpumap_helpers(void) ...@@ -33,8 +33,8 @@ static void test_xdp_with_cpumap_helpers(void)
prog_fd = bpf_program__fd(skel->progs.xdp_dummy_cm); prog_fd = bpf_program__fd(skel->progs.xdp_dummy_cm);
map_fd = bpf_map__fd(skel->maps.cpu_map); map_fd = bpf_map__fd(skel->maps.cpu_map);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto out_close; goto out_close;
val.bpf_prog.fd = prog_fd; val.bpf_prog.fd = prog_fd;
...@@ -85,8 +85,8 @@ static void test_xdp_with_cpumap_frags_helpers(void) ...@@ -85,8 +85,8 @@ static void test_xdp_with_cpumap_frags_helpers(void)
frags_prog_fd = bpf_program__fd(skel->progs.xdp_dummy_cm_frags); frags_prog_fd = bpf_program__fd(skel->progs.xdp_dummy_cm_frags);
map_fd = bpf_map__fd(skel->maps.cpu_map); map_fd = bpf_map__fd(skel->maps.cpu_map);
err = bpf_obj_get_info_by_fd(frags_prog_fd, &info, &len); err = bpf_prog_get_info_by_fd(frags_prog_fd, &info, &len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto out_close; goto out_close;
val.bpf_prog.fd = frags_prog_fd; val.bpf_prog.fd = frags_prog_fd;
......
...@@ -35,8 +35,8 @@ static void test_xdp_with_devmap_helpers(void) ...@@ -35,8 +35,8 @@ static void test_xdp_with_devmap_helpers(void)
dm_fd = bpf_program__fd(skel->progs.xdp_dummy_dm); dm_fd = bpf_program__fd(skel->progs.xdp_dummy_dm);
map_fd = bpf_map__fd(skel->maps.dm_ports); map_fd = bpf_map__fd(skel->maps.dm_ports);
err = bpf_obj_get_info_by_fd(dm_fd, &info, &len); err = bpf_prog_get_info_by_fd(dm_fd, &info, &len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto out_close; goto out_close;
val.bpf_prog.fd = dm_fd; val.bpf_prog.fd = dm_fd;
...@@ -98,8 +98,8 @@ static void test_xdp_with_devmap_frags_helpers(void) ...@@ -98,8 +98,8 @@ static void test_xdp_with_devmap_frags_helpers(void)
dm_fd_frags = bpf_program__fd(skel->progs.xdp_dummy_dm_frags); dm_fd_frags = bpf_program__fd(skel->progs.xdp_dummy_dm_frags);
map_fd = bpf_map__fd(skel->maps.dm_ports); map_fd = bpf_map__fd(skel->maps.dm_ports);
err = bpf_obj_get_info_by_fd(dm_fd_frags, &info, &len); err = bpf_prog_get_info_by_fd(dm_fd_frags, &info, &len);
if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd")) if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto out_close; goto out_close;
val.bpf_prog.fd = dm_fd_frags; val.bpf_prog.fd = dm_fd_frags;
......
...@@ -34,7 +34,7 @@ void serial_test_xdp_info(void) ...@@ -34,7 +34,7 @@ void serial_test_xdp_info(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
err = bpf_obj_get_info_by_fd(prog_fd, &info, &len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &len);
if (CHECK(err, "get_prog_info", "errno=%d\n", errno)) if (CHECK(err, "get_prog_info", "errno=%d\n", errno))
goto out_close; goto out_close;
......
...@@ -29,13 +29,13 @@ void serial_test_xdp_link(void) ...@@ -29,13 +29,13 @@ void serial_test_xdp_link(void)
prog_fd2 = bpf_program__fd(skel2->progs.xdp_handler); prog_fd2 = bpf_program__fd(skel2->progs.xdp_handler);
memset(&prog_info, 0, sizeof(prog_info)); memset(&prog_info, 0, sizeof(prog_info));
err = bpf_obj_get_info_by_fd(prog_fd1, &prog_info, &prog_info_len); err = bpf_prog_get_info_by_fd(prog_fd1, &prog_info, &prog_info_len);
if (!ASSERT_OK(err, "fd_info1")) if (!ASSERT_OK(err, "fd_info1"))
goto cleanup; goto cleanup;
id1 = prog_info.id; id1 = prog_info.id;
memset(&prog_info, 0, sizeof(prog_info)); memset(&prog_info, 0, sizeof(prog_info));
err = bpf_obj_get_info_by_fd(prog_fd2, &prog_info, &prog_info_len); err = bpf_prog_get_info_by_fd(prog_fd2, &prog_info, &prog_info_len);
if (!ASSERT_OK(err, "fd_info2")) if (!ASSERT_OK(err, "fd_info2"))
goto cleanup; goto cleanup;
id2 = prog_info.id; id2 = prog_info.id;
...@@ -119,7 +119,8 @@ void serial_test_xdp_link(void) ...@@ -119,7 +119,8 @@ void serial_test_xdp_link(void)
goto cleanup; goto cleanup;
memset(&link_info, 0, sizeof(link_info)); memset(&link_info, 0, sizeof(link_info));
err = bpf_obj_get_info_by_fd(bpf_link__fd(link), &link_info, &link_info_len); err = bpf_link_get_info_by_fd(bpf_link__fd(link),
&link_info, &link_info_len);
if (!ASSERT_OK(err, "link_info")) if (!ASSERT_OK(err, "link_info"))
goto cleanup; goto cleanup;
...@@ -137,7 +138,8 @@ void serial_test_xdp_link(void) ...@@ -137,7 +138,8 @@ void serial_test_xdp_link(void)
goto cleanup; goto cleanup;
memset(&link_info, 0, sizeof(link_info)); memset(&link_info, 0, sizeof(link_info));
err = bpf_obj_get_info_by_fd(bpf_link__fd(link), &link_info, &link_info_len); err = bpf_link_get_info_by_fd(bpf_link__fd(link),
&link_info, &link_info_len);
ASSERT_OK(err, "link_info"); ASSERT_OK(err, "link_info");
ASSERT_EQ(link_info.prog_id, id1, "link_prog_id"); ASSERT_EQ(link_info.prog_id, id1, "link_prog_id");
......
...@@ -1275,7 +1275,7 @@ static void test_map_in_map(void) ...@@ -1275,7 +1275,7 @@ static void test_map_in_map(void)
goto out_map_in_map; goto out_map_in_map;
} }
err = bpf_obj_get_info_by_fd(fd, &info, &len); err = bpf_map_get_info_by_fd(fd, &info, &len);
if (err) { if (err) {
printf("Failed to get map info by fd %d: %d", fd, printf("Failed to get map info by fd %d: %d", fd,
errno); errno);
......
...@@ -93,7 +93,7 @@ int get_map_fd_by_prog_id(int prog_id) ...@@ -93,7 +93,7 @@ int get_map_fd_by_prog_id(int prog_id)
info.nr_map_ids = 1; info.nr_map_ids = 1;
info.map_ids = (__u64) (unsigned long) map_ids; info.map_ids = (__u64) (unsigned long) map_ids;
if (bpf_obj_get_info_by_fd(prog_fd, &info, &info_len)) { if (bpf_prog_get_info_by_fd(prog_fd, &info, &info_len)) {
log_err("Failed to get info by prog fd %d", prog_fd); log_err("Failed to get info by prog fd %d", prog_fd);
goto err; goto err;
} }
......
...@@ -96,7 +96,7 @@ static int get_map_fd_by_prog_id(int prog_id, bool *xdp) ...@@ -96,7 +96,7 @@ static int get_map_fd_by_prog_id(int prog_id, bool *xdp)
info.nr_map_ids = 1; info.nr_map_ids = 1;
info.map_ids = (__u64)(unsigned long)map_ids; info.map_ids = (__u64)(unsigned long)map_ids;
if (bpf_obj_get_info_by_fd(prog_fd, &info, &info_len)) { if (bpf_prog_get_info_by_fd(prog_fd, &info, &info_len)) {
log_err("Failed to get info by prog fd %d", prog_fd); log_err("Failed to get info by prog fd %d", prog_fd);
goto err; goto err;
} }
......
...@@ -1239,8 +1239,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt) ...@@ -1239,8 +1239,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
__u32 xlated_prog_len; __u32 xlated_prog_len;
__u32 buf_element_size = sizeof(struct bpf_insn); __u32 buf_element_size = sizeof(struct bpf_insn);
if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) { if (bpf_prog_get_info_by_fd(fd_prog, &info, &info_len)) {
perror("bpf_obj_get_info_by_fd failed"); perror("bpf_prog_get_info_by_fd failed");
return -1; return -1;
} }
...@@ -1261,8 +1261,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt) ...@@ -1261,8 +1261,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
bzero(&info, sizeof(info)); bzero(&info, sizeof(info));
info.xlated_prog_len = xlated_prog_len; info.xlated_prog_len = xlated_prog_len;
info.xlated_prog_insns = (__u64)(unsigned long)*buf; info.xlated_prog_insns = (__u64)(unsigned long)*buf;
if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) { if (bpf_prog_get_info_by_fd(fd_prog, &info, &info_len)) {
perror("second bpf_obj_get_info_by_fd failed"); perror("second bpf_prog_get_info_by_fd failed");
goto out_free_buf; goto out_free_buf;
} }
......
...@@ -164,7 +164,7 @@ __u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info) ...@@ -164,7 +164,7 @@ __u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info)
int err; int err;
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
err = bpf_obj_get_info_by_fd(bpf_link__fd(link), info, &info_len); err = bpf_link_get_info_by_fd(bpf_link__fd(link), info, &info_len);
if (err) { if (err) {
printf("failed to get link info: %d\n", -errno); printf("failed to get link info: %d\n", -errno);
return 0; return 0;
......
...@@ -217,9 +217,10 @@ static int syncookie_attach(const char *argv0, unsigned int ifindex, bool tc) ...@@ -217,9 +217,10 @@ static int syncookie_attach(const char *argv0, unsigned int ifindex, bool tc)
prog_fd = bpf_program__fd(prog); prog_fd = bpf_program__fd(prog);
err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
if (err < 0) { if (err < 0) {
fprintf(stderr, "Error: bpf_obj_get_info_by_fd: %s\n", strerror(-err)); fprintf(stderr, "Error: bpf_prog_get_info_by_fd: %s\n",
strerror(-err));
goto out; goto out;
} }
attached_tc = tc; attached_tc = tc;
...@@ -292,9 +293,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports ...@@ -292,9 +293,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports
}; };
info_len = sizeof(prog_info); info_len = sizeof(prog_info);
err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); err = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &info_len);
if (err != 0) { if (err != 0) {
fprintf(stderr, "Error: bpf_obj_get_info_by_fd: %s\n", strerror(-err)); fprintf(stderr, "Error: bpf_prog_get_info_by_fd: %s\n",
strerror(-err));
goto out; goto out;
} }
...@@ -317,9 +319,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports ...@@ -317,9 +319,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports
map_fd = err; map_fd = err;
info_len = sizeof(map_info); info_len = sizeof(map_info);
err = bpf_obj_get_info_by_fd(map_fd, &map_info, &info_len); err = bpf_map_get_info_by_fd(map_fd, &map_info, &info_len);
if (err != 0) { if (err != 0) {
fprintf(stderr, "Error: bpf_obj_get_info_by_fd: %s\n", strerror(-err)); fprintf(stderr, "Error: bpf_map_get_info_by_fd: %s\n",
strerror(-err));
close(map_fd); close(map_fd);
goto err_close_map_fds; goto err_close_map_fds;
} }
......
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