diff options
author | Andrii Nakryiko | 2022-02-02 14:59:16 -0800 |
---|---|---|
committer | Daniel Borkmann | 2022-02-03 16:32:25 +0100 |
commit | 1e4edb6d8c4f045823291862e7e28591cb6f2067 (patch) | |
tree | 3c8240d57d32432db4e88d68f76d9258d98c7c15 /samples/bpf/xdp1_user.c | |
parent | e4e284a8c0d9823c07ee674445de05928be67231 (diff) |
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/xdp1_user.c')
-rw-r--r-- | samples/bpf/xdp1_user.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c index 3ec8ad9c1750..631f0cabe139 100644 --- a/samples/bpf/xdp1_user.c +++ b/samples/bpf/xdp1_user.c @@ -79,13 +79,11 @@ static void usage(const char *prog) int main(int argc, char **argv) { - struct bpf_prog_load_attr prog_load_attr = { - .prog_type = BPF_PROG_TYPE_XDP, - }; struct bpf_prog_info info = {}; __u32 info_len = sizeof(info); const char *optstr = "FSN"; int prog_fd, map_fd, opt; + struct bpf_program *prog; struct bpf_object *obj; struct bpf_map *map; char filename[256]; @@ -123,11 +121,19 @@ int main(int argc, char **argv) } snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); - prog_load_attr.file = filename; + obj = bpf_object__open_file(filename, NULL); + if (libbpf_get_error(obj)) + return 1; + + prog = bpf_object__next_program(obj, NULL); + bpf_program__set_type(prog, BPF_PROG_TYPE_XDP); - if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd)) + err = bpf_object__load(obj); + if (err) return 1; + prog_fd = bpf_program__fd(prog); + map = bpf_object__next_map(obj, NULL); if (!map) { printf("finding a map in obj file failed\n"); |