diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2022-02-02 14:59:16 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-02-03 16:32:25 +0100 |
commit | 1e4edb6d8c4f045823291862e7e28591cb6f2067 (patch) | |
tree | 3c8240d57d32432db4e88d68f76d9258d98c7c15 /samples/bpf/xdp_fwd_user.c | |
parent | e4e284a8c0d9823c07ee674445de05928be67231 (diff) | |
download | lwn-1e4edb6d8c4f045823291862e7e28591cb6f2067.tar.gz lwn-1e4edb6d8c4f045823291862e7e28591cb6f2067.zip |
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_fwd_user.c')
-rw-r--r-- | samples/bpf/xdp_fwd_user.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/samples/bpf/xdp_fwd_user.c b/samples/bpf/xdp_fwd_user.c index 79ccd9891924..1828487bae9a 100644 --- a/samples/bpf/xdp_fwd_user.c +++ b/samples/bpf/xdp_fwd_user.c @@ -75,14 +75,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, - }; const char *prog_name = "xdp_fwd"; struct bpf_program *prog = NULL; struct bpf_program *pos; const char *sec_name; - int prog_fd, map_fd = -1; + int prog_fd = -1, map_fd = -1; char filename[PATH_MAX]; struct bpf_object *obj; int opt, i, idx, err; @@ -119,7 +116,6 @@ int main(int argc, char **argv) if (attach) { snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); - prog_load_attr.file = filename; if (access(filename, O_RDONLY) < 0) { printf("error accessing file %s: %s\n", @@ -127,7 +123,14 @@ int main(int argc, char **argv) return 1; } - err = bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd); + 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); + + err = bpf_object__load(obj); if (err) { printf("Does kernel support devmap lookup?\n"); /* If not, the error message will be: |