selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 14 Feb 2023 23:12:18 +0000 (00:12 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 16 Feb 2023 23:32:46 +0000 (15:32 -0800)
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: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230214231221.249277-6-iii@linux.ibm.com
34 files changed:
tools/testing/selftests/bpf/map_tests/map_in_map_batch_ops.c
tools/testing/selftests/bpf/prog_tests/bpf_iter.c
tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c
tools/testing/selftests/bpf/prog_tests/btf.c
tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
tools/testing/selftests/bpf/prog_tests/check_mtu.c
tools/testing/selftests/bpf/prog_tests/enable_stats.c
tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
tools/testing/selftests/bpf/prog_tests/flow_dissector_reattach.c
tools/testing/selftests/bpf/prog_tests/libbpf_get_fd_by_id_opts.c
tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c
tools/testing/selftests/bpf/prog_tests/metadata.c
tools/testing/selftests/bpf/prog_tests/mmap.c
tools/testing/selftests/bpf/prog_tests/perf_link.c
tools/testing/selftests/bpf/prog_tests/pinning.c
tools/testing/selftests/bpf/prog_tests/prog_run_opts.c
tools/testing/selftests/bpf/prog_tests/recursion.c
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
tools/testing/selftests/bpf/prog_tests/task_local_storage.c
tools/testing/selftests/bpf/prog_tests/tc_bpf.c
tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
tools/testing/selftests/bpf/prog_tests/verif_stats.c
tools/testing/selftests/bpf/prog_tests/xdp_attach.c
tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c
tools/testing/selftests/bpf/prog_tests/xdp_info.c
tools/testing/selftests/bpf/prog_tests/xdp_link.c
tools/testing/selftests/bpf/test_maps.c
tools/testing/selftests/bpf/test_skb_cgroup_id_user.c
tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c
tools/testing/selftests/bpf/test_verifier.c
tools/testing/selftests/bpf/testing_helpers.c
tools/testing/selftests/bpf/xdp_synproxy.c

index f472d28ad11a8db4c09411feec87097e0e7f0753..16f1671e4bde54f582d7f5c53c33c47559cb5cb1 100644 (file)
@@ -18,7 +18,7 @@ static __u32 get_map_id_from_fd(int map_fd)
        uint32_t info_len = sizeof(map_info);
        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",
              strerror(errno));
 
index 3af6450763e9ac946c8b7f83f5cb509ced004b6e..1f02168103dd776fd5c9e83d4a90f173f0153ae1 100644 (file)
@@ -195,8 +195,8 @@ static void check_bpf_link_info(const struct bpf_program *prog)
                return;
 
        info_len = sizeof(info);
-       err = bpf_obj_get_info_by_fd(bpf_link__fd(link), &info, &info_len);
-       ASSERT_OK(err, "bpf_obj_get_info_by_fd");
+       err = bpf_link_get_info_by_fd(bpf_link__fd(link), &info, &info_len);
+       ASSERT_OK(err, "bpf_link_get_info_by_fd");
        ASSERT_EQ(info.iter.task.tid, getpid(), "check_task_tid");
 
        bpf_link__destroy(link);
@@ -684,13 +684,13 @@ static void test_overflow(bool test_e2big_overflow, bool ret1)
 
        /* setup filtering map_id in bpf program */
        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",
                  strerror(errno)))
                goto free_map2;
        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",
                  strerror(errno)))
                goto free_map2;
index e1c1e521cca2cf85af058d7ecf013f70d4899cd7..675b90b1528084ca10f5cd5b55024f02d5cb7883 100644 (file)
@@ -44,7 +44,7 @@ void serial_test_bpf_obj_id(void)
        CHECK(err >= 0 || errno != ENOENT,
              "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));
        for (i = 0; i < nr_iters; i++) {
                now = time(NULL);
@@ -79,7 +79,7 @@ void serial_test_bpf_obj_id(void)
                /* Check getting map info */
                info_len = sizeof(struct bpf_map_info) * 2;
                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);
                if (CHECK(err ||
                          map_infos[i].type != BPF_MAP_TYPE_ARRAY ||
@@ -118,8 +118,8 @@ void serial_test_bpf_obj_id(void)
                err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts);
                if (CHECK_FAIL(err))
                        goto done;
-               err = bpf_obj_get_info_by_fd(prog_fds[i], &prog_infos[i],
-                                            &info_len);
+               err = bpf_prog_get_info_by_fd(prog_fds[i], &prog_infos[i],
+                                             &info_len);
                load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec)
                        + (prog_infos[i].load_time / nsec_per_sec);
                if (CHECK(err ||
@@ -161,8 +161,8 @@ void serial_test_bpf_obj_id(void)
                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_len = sizeof(tp_name);
-               err = bpf_obj_get_info_by_fd(bpf_link__fd(links[i]),
-                                            &link_infos[i], &info_len);
+               err = bpf_link_get_info_by_fd(bpf_link__fd(links[i]),
+                                             &link_infos[i], &info_len);
                if (CHECK(err ||
                          link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT ||
                          link_infos[i].prog_id != prog_infos[i].id ||
@@ -217,7 +217,7 @@ void serial_test_bpf_obj_id(void)
                 * prog_info.map_ids = NULL
                 */
                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,
                          "get-prog-fd-bad-nr-map-ids", "err %d errno %d(%d)",
                          err, errno, EFAULT))
@@ -228,7 +228,7 @@ void serial_test_bpf_obj_id(void)
                saved_map_id = *(int *)((long)prog_infos[i].map_ids);
                prog_info.map_ids = prog_infos[i].map_ids;
                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].xlated_prog_insns = 0;
                CHECK(err || info_len != sizeof(struct bpf_prog_info) ||
@@ -277,7 +277,7 @@ void serial_test_bpf_obj_id(void)
                if (CHECK_FAIL(err))
                        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) ||
                      memcmp(&map_info, &map_infos[i], info_len) ||
                      array_value != array_magic_value,
@@ -322,7 +322,7 @@ void serial_test_bpf_obj_id(void)
 
                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],
                                offsetof(struct bpf_link_info, raw_tracepoint));
                CHECK(err || info_len != sizeof(link_info) || cmp_res,
index de1b5b9eb93a81695a390ea25453a53e794b8fab..cbb600be943d338a3c36f699d4698ee8f8b30222 100644 (file)
@@ -4422,7 +4422,7 @@ static int test_big_btf_info(unsigned int test_num)
        info->btf = ptr_to_u64(user_btf);
        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")) {
                err = -1;
                goto done;
@@ -4435,7 +4435,7 @@ static int test_big_btf_info(unsigned int test_num)
         * to userspace.
         */
        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),
                  "err:%d errno:%d info_len:%u sizeof(*info):%zu",
                  err, errno, info_len, sizeof(*info))) {
@@ -4499,7 +4499,7 @@ static int test_btf_id(unsigned int test_num)
 
        /* Test BPF_OBJ_GET_INFO_BY_ID on btf_id */
        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)) {
                err = -1;
                goto done;
@@ -4512,7 +4512,7 @@ static int test_btf_id(unsigned int test_num)
        }
 
        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 ||
                  info[0].btf_size != info[1].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)
        }
 
        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 ||
                  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",
@@ -4638,7 +4638,7 @@ static void do_test_get_info(unsigned int test_num)
        info.btf_size = user_btf_size;
 
        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) ||
                  info.btf_size != raw_btf_size ||
                  (ret = memcmp(raw_btf, user_btf, expected_nbytes)),
@@ -4755,7 +4755,7 @@ static void do_test_file(unsigned int test_num)
 
        /* get necessary program 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)) {
                fprintf(stderr, "%s\n", btf_log_buf);
@@ -4787,7 +4787,7 @@ static void do_test_file(unsigned int test_num)
        info.func_info_rec_size = rec_size;
        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)) {
                fprintf(stderr, "%s\n", btf_log_buf);
@@ -6405,7 +6405,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
 
        /* get necessary lens */
        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)) {
                fprintf(stderr, "%s\n", btf_log_buf);
                return -1;
@@ -6435,7 +6435,7 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
        info.nr_func_info = nr_func_info;
        info.func_info_rec_size = rec_size;
        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)) {
                fprintf(stderr, "%s\n", btf_log_buf);
                err = -1;
@@ -6499,7 +6499,7 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
        nr_jited_func_lens = nr_jited_ksyms;
 
        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)) {
                err = -1;
                goto done;
@@ -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);
        }
 
-       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.
index eb90a6b8850d2fb7602ddbe24bdc6d03b51c9391..a8b53b8736f0184d914fa9178a803d082b05126d 100644 (file)
@@ -14,7 +14,7 @@ static __u32 bpf_map_id(struct bpf_map *map)
        int err;
 
        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)
                return 0;
        return info.id;
index 12f4395f18b37a7df4ea02e49c2cb9226225435c..5338d2ea04603ce1b5d2b02a4da7142ce86da1b4 100644 (file)
@@ -59,7 +59,7 @@ static void test_check_mtu_xdp_attach(void)
 
        memset(&link_info, 0, sizeof(link_info));
        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))
                goto out;
 
index 2cb2085917e7dabe4692bd3487fabf8952edef79..75f85d0fe74a4771ee5b95d8c43c3341fbbde3f0 100644 (file)
@@ -28,7 +28,7 @@ void test_enable_stats(void)
 
        prog_fd = bpf_program__fd(skel->progs.test_enable_stats);
        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",
                  "failed to get bpf_prog_info for fd %d\n", prog_fd))
                goto cleanup;
index 20f5fa0fcec99f3b81a90d4f8d59cda838212121..8ec73fdfcdab949cb65141f895fb3aaa13783e45 100644 (file)
@@ -79,7 +79,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
                return;
 
        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"))
                goto close_prog;
 
@@ -136,8 +136,8 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
 
                info_len = sizeof(link_info);
                memset(&link_info, 0, sizeof(link_info));
-               err = bpf_obj_get_info_by_fd(bpf_link__fd(link[i]),
-                                            &link_info, &info_len);
+               err = bpf_link_get_info_by_fd(bpf_link__fd(link[i]),
+                                             &link_info, &info_len);
                ASSERT_OK(err, "link_fd_get_info");
                ASSERT_EQ(link_info.tracing.attach_type,
                          bpf_program__expected_attach_type(prog[i]),
@@ -417,7 +417,7 @@ static int find_prog_btf_id(const char *name, __u32 attach_prog_fd)
        struct btf *btf;
        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)
                return ret;
 
@@ -483,12 +483,12 @@ static void test_fentry_to_cgroup_bpf(void)
        if (!ASSERT_GE(fentry_fd, 0, "load_fentry"))
                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.
         */
 
-       ASSERT_OK(bpf_obj_get_info_by_fd(fentry_fd, &info, &info_len),
-                 "bpf_obj_get_info_by_fd");
+       ASSERT_OK(bpf_prog_get_info_by_fd(fentry_fd, &info, &info_len),
+                 "bpf_prog_get_info_by_fd");
 
        ASSERT_EQ(info.btf_id, 0, "info.btf_id");
        ASSERT_EQ(info.attach_btf_id, btf_id, "info.attach_btf_id");
index 7c79462d27029672c70eb7abfd1a7b0d48c02bf1..9333f7346d15e9d1defa4b7728eb4306c036c035 100644 (file)
@@ -60,9 +60,9 @@ static __u32 query_prog_id(int prog)
        __u32 info_len = sizeof(info);
        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))) {
-               perror("bpf_obj_get_info_by_fd");
+               perror("bpf_prog_get_info_by_fd");
                return 0;
        }
 
@@ -497,7 +497,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
        }
 
        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)) {
                perror("bpf_obj_get_info");
                goto out_unlink;
@@ -521,7 +521,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
 
        link_id = info.id;
        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)) {
                perror("bpf_obj_get_info");
                goto out_unlink;
@@ -546,7 +546,7 @@ static void test_link_get_info(int netns, int prog1, int prog2)
        netns = -1;
 
        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)) {
                perror("bpf_obj_get_info");
                goto out_unlink;
index 25e5dfa9c315ceae80a1348fc8d3ab1dbe60f32a..a3f238f51d05111c9885e787ee11f4f7b8550a7d 100644 (file)
@@ -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"))
                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);
-       if (!ASSERT_OK(ret, "bpf_obj_get_info_by_fd"))
+       if (!ASSERT_OK(ret, "bpf_map_get_info_by_fd"))
                goto close_prog;
 
        fd = bpf_map_get_fd_by_id(info_m.id);
index f117bfef68a142b8fb7be20da3bdf23aa30315cb..130a3b21e467f84b7518d11d7a32e8e4a5236eca 100644 (file)
@@ -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]);
                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);
 
                if (info.attach_btf_id ==
index 2c53eade88e3784605916bad2fce2dcea225ffad..8b67dfc10f5cfe3ccbdaad15ac095b13e485aebb 100644 (file)
@@ -16,7 +16,7 @@ static int duration;
 static int prog_holds_map(int prog_fd, int map_fd)
 {
        struct bpf_prog_info prog_info = {};
-       struct bpf_prog_info map_info = {};
+       struct bpf_map_info map_info = {};
        __u32 prog_info_len;
        __u32 map_info_len;
        __u32 *map_ids;
@@ -25,12 +25,12 @@ static int prog_holds_map(int prog_fd, int map_fd)
        int i;
 
        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)
                return -errno;
 
        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)
                return -errno;
 
@@ -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_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) {
                ret = -errno;
                goto free_map_ids;
index 37b002ca11671e2186c6426460cfd63d32a0d5ab..a271d5a0f7aba2157dcd08a8577c1c7e957b178b 100644 (file)
@@ -64,7 +64,7 @@ void test_mmap(void)
 
        /* get map's ID */
        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))
                goto cleanup;
        data_map_id = map_info.id;
index 224eba6fef2ee1f8cfabecbb2f84590e50d53da3..3a25f1c743a168ba49fbefed42a96681f91e2ce1 100644 (file)
@@ -54,7 +54,7 @@ void serial_test_perf_link(void)
                goto cleanup;
 
        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"))
                goto cleanup;
 
index d95cee5867b7715e41cce5f75cdfed45e942a90c..c799a3c5ad1ff92b7ee8b4be18b4b2bf3c456589 100644 (file)
@@ -18,7 +18,7 @@ __u32 get_map_id(struct bpf_object *obj, const char *name)
        if (CHECK(!map, "find map", "NULL map"))
                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);
        CHECK(err, "get map info", "err %d errno %d", err, errno);
        return map_info.id;
index 1ccd2bdf8fa8676005c1168dc6d74bca426e8b8b..01f1d1b6715a6c4feb56b3b86fba65adb1a2d7f2 100644 (file)
@@ -12,7 +12,7 @@ static void check_run_cnt(int prog_fd, __u64 run_cnt)
        __u32 info_len = sizeof(info);
        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))
                return;
 
index f3af2627b59971e92b082255220f066a0cb36303..23552d3e33651c0e822009e872de071fc5f50e17 100644 (file)
@@ -31,8 +31,8 @@ void test_recursion(void)
        bpf_map_delete_elem(bpf_map__fd(skel->maps.hash2), &key);
        ASSERT_EQ(skel->bss->pass2, 2, "pass2 == 2");
 
-       err = bpf_obj_get_info_by_fd(bpf_program__fd(skel->progs.on_delete),
-                                    &prog_info, &prog_info_len);
+       err = bpf_prog_get_info_by_fd(bpf_program__fd(skel->progs.on_delete),
+                                     &prog_info, &prog_info_len);
        if (!ASSERT_OK(err, "get_prog_info"))
                goto out;
        ASSERT_EQ(prog_info.recursion_misses, 2, "recursion_misses");
index 0aa088900699bda90e7cf75d6a30336987cc430d..0ce25a967481e028180cd1fc33151ff6d9214a9a 100644 (file)
@@ -299,9 +299,9 @@ static __u32 query_prog_id(int prog_fd)
        __u32 info_len = sizeof(info);
        int err;
 
-       err = bpf_obj_get_info_by_fd(prog_fd, &info, &info_len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd") ||
-           !ASSERT_EQ(info_len, sizeof(info), "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd") ||
+           !ASSERT_EQ(info_len, sizeof(info), "bpf_prog_get_info_by_fd"))
                return 0;
 
        return info.id;
index a176bd75a74884c78df98327f574e88b4e6a85d3..ea8537c54413110fa8d69aaaaa360af1286eccb4 100644 (file)
@@ -119,19 +119,19 @@ static void test_recursion(void)
 
        prog_fd = bpf_program__fd(skel->progs.on_lookup);
        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_GT(info.recursion_misses, 0, "on_lookup prog recursion");
 
        prog_fd = bpf_program__fd(skel->progs.on_update);
        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_EQ(info.recursion_misses, 0, "on_update prog recursion");
 
        prog_fd = bpf_program__fd(skel->progs.on_enter);
        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_EQ(info.recursion_misses, 0, "on_enter prog recursion");
 
@@ -221,7 +221,7 @@ static void test_nodeadlock(void)
 
        info_len = sizeof(info);
        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_EQ(info.recursion_misses, 0, "prog recursion");
 
index 4a505a5adf4dd511e0c7063114f3807e6c70e90f..e873766276d10354978639647d2ca47ebe65bb1b 100644 (file)
@@ -29,8 +29,8 @@ static int test_tc_bpf_basic(const struct bpf_tc_hook *hook, int fd)
        __u32 info_len = sizeof(info);
        int ret;
 
-       ret = bpf_obj_get_info_by_fd(fd, &info, &info_len);
-       if (!ASSERT_OK(ret, "bpf_obj_get_info_by_fd"))
+       ret = bpf_prog_get_info_by_fd(fd, &info, &info_len);
+       if (!ASSERT_OK(ret, "bpf_prog_get_info_by_fd"))
                return ret;
 
        ret = bpf_tc_attach(hook, &opts);
index a479080533dbf55610587b7121db47f105085f80..770fcc3bb1baeb03e65c2b782e3a42108f9089c0 100644 (file)
@@ -45,8 +45,9 @@ void serial_test_tp_attach_query(void)
                prog_info.xlated_prog_len = 0;
                prog_info.nr_map_ids = 0;
                info_len = sizeof(prog_info);
-               err = bpf_obj_get_info_by_fd(prog_fd[i], &prog_info, &info_len);
-               if (CHECK(err, "bpf_obj_get_info_by_fd", "err %d errno %d\n",
+               err = bpf_prog_get_info_by_fd(prog_fd[i], &prog_info,
+                                             &info_len);
+               if (CHECK(err, "bpf_prog_get_info_by_fd", "err %d errno %d\n",
                          err, errno))
                        goto cleanup1;
                saved_prog_ids[i] = prog_info.id;
index 1ed3cc2092dbae8cc2d22595e7acf912e85fafbf..8383a99f610fd0ac7ee4f207b59d2bd012e28b83 100644 (file)
@@ -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(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")) {
                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,
@@ -187,8 +187,8 @@ 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");
 
-       if (ASSERT_OK(bpf_obj_get_info_by_fd(bpf_link__fd(skel->links.sys_nanosleep_enter),
-                                            &link_info, &link_info_len),
+       if (ASSERT_OK(bpf_link_get_info_by_fd(bpf_link__fd(skel->links.sys_nanosleep_enter),
+                                             &link_info, &link_info_len),
                      "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_next_id(link_info.id, &next), -EPERM,
@@ -269,7 +269,7 @@ void test_unpriv_bpf_disabled(void)
        }
 
        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");
        prog_id = prog_info.id;
        ASSERT_GT(prog_id, 0, "valid_prog_id");
index a47e7c0e1ffd8a4859ac4c53711608a44e3f5a0b..af4b95f57ac16918976cd44688643a7dca6c158d 100644 (file)
@@ -16,8 +16,9 @@ void test_verif_stats(void)
        if (!ASSERT_OK_PTR(skel, "trace_vprintk__open_and_load"))
                goto cleanup;
 
-       err = bpf_obj_get_info_by_fd(skel->progs.sys_enter.prog_fd, &info, &len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(skel->progs.sys_enter.prog_fd,
+                                     &info, &len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
                goto cleanup;
 
        if (!ASSERT_GT(info.verified_insns, 0, "verified_insns"))
index 062fbc8c8e5e3334513e15a2e4ac9954889e572d..d4cd9f873c14a023ccea308461d3d8eee48d54e4 100644 (file)
@@ -18,7 +18,7 @@ void serial_test_xdp_attach(void)
        err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj1, &fd1);
        if (CHECK_FAIL(err))
                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))
                goto out_1;
        id1 = info.id;
@@ -28,7 +28,7 @@ void serial_test_xdp_attach(void)
                goto out_1;
 
        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))
                goto out_2;
        id2 = info.id;
index f775a1613833cd13a08efc4c49ce612b3372635b..481626a875d1c3db9c7bfe92c3cca6e967a6d45c 100644 (file)
@@ -33,8 +33,8 @@ static void test_xdp_with_cpumap_helpers(void)
 
        prog_fd = bpf_program__fd(skel->progs.xdp_dummy_cm);
        map_fd = bpf_map__fd(skel->maps.cpu_map);
-       err = bpf_obj_get_info_by_fd(prog_fd, &info, &len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(prog_fd, &info, &len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
                goto out_close;
 
        val.bpf_prog.fd = prog_fd;
@@ -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);
        map_fd = bpf_map__fd(skel->maps.cpu_map);
-       err = bpf_obj_get_info_by_fd(frags_prog_fd, &info, &len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(frags_prog_fd, &info, &len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
                goto out_close;
 
        val.bpf_prog.fd = frags_prog_fd;
index ead40016c32457eca95c7dfb75ea19ee0dc0c8ea..ce6812558287a415d2b1ee42058ccb84ff490a1d 100644 (file)
@@ -35,8 +35,8 @@ static void test_xdp_with_devmap_helpers(void)
 
        dm_fd = bpf_program__fd(skel->progs.xdp_dummy_dm);
        map_fd = bpf_map__fd(skel->maps.dm_ports);
-       err = bpf_obj_get_info_by_fd(dm_fd, &info, &len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(dm_fd, &info, &len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
                goto out_close;
 
        val.bpf_prog.fd = dm_fd;
@@ -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);
        map_fd = bpf_map__fd(skel->maps.dm_ports);
-       err = bpf_obj_get_info_by_fd(dm_fd_frags, &info, &len);
-       if (!ASSERT_OK(err, "bpf_obj_get_info_by_fd"))
+       err = bpf_prog_get_info_by_fd(dm_fd_frags, &info, &len);
+       if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
                goto out_close;
 
        val.bpf_prog.fd = dm_fd_frags;
index 286c21ecdc659175ab2689ba0f860906a94fd161..1dbddcab87a8e88a853f44a68611018bbd37af8b 100644 (file)
@@ -34,7 +34,7 @@ void serial_test_xdp_info(void)
        if (CHECK_FAIL(err))
                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))
                goto out_close;
 
index 3e9d5c5521f02549c3596cf8d9ae6bdecafa6d00..e7e9f3c22edf2ec196e6fa8171e748d582639ea9 100644 (file)
@@ -29,13 +29,13 @@ void serial_test_xdp_link(void)
        prog_fd2 = bpf_program__fd(skel2->progs.xdp_handler);
 
        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"))
                goto cleanup;
        id1 = prog_info.id;
 
        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"))
                goto cleanup;
        id2 = prog_info.id;
@@ -119,7 +119,8 @@ void serial_test_xdp_link(void)
                goto cleanup;
 
        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"))
                goto cleanup;
 
@@ -137,7 +138,8 @@ void serial_test_xdp_link(void)
                goto cleanup;
 
        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_EQ(link_info.prog_id, id1, "link_prog_id");
index b73152822aa2822909130cdc6d59ffbb1adc41d6..7fc00e423e4ddaa09f24455ba4195cc85d80b0e1 100644 (file)
@@ -1275,7 +1275,7 @@ static void test_map_in_map(void)
                        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) {
                        printf("Failed to get map info by fd %d: %d", fd,
                               errno);
index 3256de30f5630b523eb7abfcc6eca5b8d043f9bb..ed518d075d1d13327e93a3cac1290dc99d3a95f0 100644 (file)
@@ -93,7 +93,7 @@ int get_map_fd_by_prog_id(int prog_id)
        info.nr_map_ids = 1;
        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);
                goto err;
        }
index 5c8ef062f760696d6062736ba046df4b70e09ddb..32df937470959b5068db10730fc56a8b2079c2e8 100644 (file)
@@ -96,7 +96,7 @@ static int get_map_fd_by_prog_id(int prog_id, bool *xdp)
        info.nr_map_ids = 1;
        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);
                goto err;
        }
index 887c49dc5abd44a8c42fd4db95984141772383fe..8b9949bb833d74a1382e245571287dee4fcc17e3 100644 (file)
@@ -1239,8 +1239,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
        __u32 xlated_prog_len;
        __u32 buf_element_size = sizeof(struct bpf_insn);
 
-       if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) {
-               perror("bpf_obj_get_info_by_fd failed");
+       if (bpf_prog_get_info_by_fd(fd_prog, &info, &info_len)) {
+               perror("bpf_prog_get_info_by_fd failed");
                return -1;
        }
 
@@ -1261,8 +1261,8 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
        bzero(&info, sizeof(info));
        info.xlated_prog_len = xlated_prog_len;
        info.xlated_prog_insns = (__u64)(unsigned long)*buf;
-       if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) {
-               perror("second bpf_obj_get_info_by_fd failed");
+       if (bpf_prog_get_info_by_fd(fd_prog, &info, &info_len)) {
+               perror("second bpf_prog_get_info_by_fd failed");
                goto out_free_buf;
        }
 
index 9695318e8132d79da1541cf9f08ee30ea6081361..6c44153755e6644a98326d06459c16884cffa564 100644 (file)
@@ -164,7 +164,7 @@ __u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info)
        int err;
 
        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) {
                printf("failed to get link info: %d\n", -errno);
                return 0;
index 6dbe0b7451985595a3eda481fc038123cbb2132a..ce68c342b56fb602bba596ac39d46a43e0a10f20 100644 (file)
@@ -217,9 +217,10 @@ static int syncookie_attach(const char *argv0, unsigned int ifindex, bool tc)
 
        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) {
-               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;
        }
        attached_tc = tc;
@@ -292,9 +293,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports
        };
        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) {
-               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;
        }
 
@@ -317,9 +319,10 @@ static int syncookie_open_bpf_maps(__u32 prog_id, int *values_map_fd, int *ports
                map_fd = err;
 
                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) {
-                       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);
                        goto err_close_map_fds;
                }