summaryrefslogtreecommitdiff
path: root/samples/bpf/xdp_rxq_info_user.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2022-02-03 01:59:16 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2022-02-03 18:32:25 +0300
commit1e4edb6d8c4f045823291862e7e28591cb6f2067 (patch)
tree3c8240d57d32432db4e88d68f76d9258d98c7c15 /samples/bpf/xdp_rxq_info_user.c
parente4e284a8c0d9823c07ee674445de05928be67231 (diff)
downloadlinux-1e4edb6d8c4f045823291862e7e28591cb6f2067.tar.xz
samples/bpf: Get rid of bpf_prog_load_xattr() use
Remove all the remaining uses of deprecated bpf_prog_load_xattr() API. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20220202225916.3313522-7-andrii@kernel.org
Diffstat (limited to 'samples/bpf/xdp_rxq_info_user.c')
-rw-r--r--samples/bpf/xdp_rxq_info_user.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
index fb2532d13aac..f2d90cba5164 100644
--- a/samples/bpf/xdp_rxq_info_user.c
+++ b/samples/bpf/xdp_rxq_info_user.c
@@ -450,14 +450,12 @@ static void stats_poll(int interval, int action, __u32 cfg_opt)
int main(int argc, char **argv)
{
__u32 cfg_options= NO_TOUCH ; /* Default: Don't touch packet memory */
- struct bpf_prog_load_attr prog_load_attr = {
- .prog_type = BPF_PROG_TYPE_XDP,
- };
struct bpf_prog_info info = {};
__u32 info_len = sizeof(info);
int prog_fd, map_fd, opt, err;
bool use_separators = true;
struct config cfg = { 0 };
+ struct bpf_program *prog;
struct bpf_object *obj;
struct bpf_map *map;
char filename[256];
@@ -471,11 +469,19 @@ int main(int argc, char **argv)
char *action_str = NULL;
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
- prog_load_attr.file = filename;
- if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
+ obj = bpf_object__open_file(filename, NULL);
+ if (libbpf_get_error(obj))
return EXIT_FAIL;
+ prog = bpf_object__next_program(obj, NULL);
+ bpf_program__set_type(prog, BPF_PROG_TYPE_XDP);
+
+ err = bpf_object__load(obj);
+ if (err)
+ return EXIT_FAIL;
+ prog_fd = bpf_program__fd(prog);
+
map = bpf_object__find_map_by_name(obj, "config_map");
stats_global_map = bpf_object__find_map_by_name(obj, "stats_global_map");
rx_queue_index_map = bpf_object__find_map_by_name(obj, "rx_queue_index_map");