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

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

Use the new type-safe wrappers around bpf_obj_get_info_by_fd().
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-5-iii@linux.ibm.com
parent 38f0408e
...@@ -38,7 +38,7 @@ static void check_map_id(int inner_map_fd, int map_in_map_fd, uint32_t key) ...@@ -38,7 +38,7 @@ static void check_map_id(int inner_map_fd, int map_in_map_fd, uint32_t key)
uint32_t info_len = sizeof(info); uint32_t info_len = sizeof(info);
int ret, id; int ret, id;
ret = bpf_obj_get_info_by_fd(inner_map_fd, &info, &info_len); ret = bpf_map_get_info_by_fd(inner_map_fd, &info, &info_len);
assert(!ret); assert(!ret);
ret = bpf_map_lookup_elem(map_in_map_fd, &key, &id); ret = bpf_map_lookup_elem(map_in_map_fd, &key, &id);
......
...@@ -153,7 +153,7 @@ int main(int argc, char **argv) ...@@ -153,7 +153,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
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) { if (err) {
printf("can't get prog info - %s\n", strerror(errno)); printf("can't get prog info - %s\n", strerror(errno));
return err; return err;
......
...@@ -184,7 +184,7 @@ int main(int argc, char **argv) ...@@ -184,7 +184,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
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) { if (err) {
printf("can't get prog info - %s\n", strerror(errno)); printf("can't get prog info - %s\n", strerror(errno));
return 1; return 1;
......
...@@ -76,9 +76,9 @@ static int do_detach(int ifindex, const char *ifname, const char *app_name) ...@@ -76,9 +76,9 @@ static int do_detach(int ifindex, const char *ifname, const char *app_name)
return prog_fd; return prog_fd;
} }
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) { if (err) {
printf("ERROR: bpf_obj_get_info_by_fd failed (%s)\n", printf("ERROR: bpf_prog_get_info_by_fd failed (%s)\n",
strerror(errno)); strerror(errno));
goto close_out; goto close_out;
} }
......
...@@ -494,9 +494,9 @@ int main(int argc, char **argv) ...@@ -494,9 +494,9 @@ int main(int argc, char **argv)
goto end_cpu; goto end_cpu;
} }
ret = bpf_obj_get_info_by_fd(bpf_map__fd(skel->maps.cpu_map), &info, &infosz); ret = bpf_map_get_info_by_fd(bpf_map__fd(skel->maps.cpu_map), &info, &infosz);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Failed bpf_obj_get_info_by_fd for cpumap: %s\n", fprintf(stderr, "Failed bpf_map_get_info_by_fd for cpumap: %s\n",
strerror(errno)); strerror(errno));
goto end_cpu; goto end_cpu;
} }
......
...@@ -602,7 +602,7 @@ int main(int argc, char **argv) ...@@ -602,7 +602,7 @@ int main(int argc, char **argv)
return EXIT_FAIL_XDP; return EXIT_FAIL_XDP;
} }
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) { if (err) {
printf("can't get prog info - %s\n", strerror(errno)); printf("can't get prog info - %s\n", strerror(errno));
return err; return err;
......
...@@ -35,7 +35,7 @@ static int do_attach(int idx, int fd, const char *name) ...@@ -35,7 +35,7 @@ static int do_attach(int idx, int fd, const char *name)
return err; return err;
} }
err = bpf_obj_get_info_by_fd(fd, &info, &info_len); err = bpf_prog_get_info_by_fd(fd, &info, &info_len);
if (err) { if (err) {
printf("can't get prog info - %s\n", strerror(errno)); printf("can't get prog info - %s\n", strerror(errno));
return err; return err;
......
...@@ -295,7 +295,7 @@ int main(int argc, char **argv) ...@@ -295,7 +295,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
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) { if (err) {
printf("can't get prog info - %s\n", strerror(errno)); printf("can't get prog info - %s\n", strerror(errno));
return err; return err;
......
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