diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-12-01 15:28:23 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-12-02 15:23:40 -0800 |
commit | c58f9815ba9735752d3735efb915e8878604684b (patch) | |
tree | 4af974bfbf16a9cf5739729d06f4621f5eccb927 /samples/bpf/sockex2_user.c | |
parent | 527024f7aeb683ce7ef49b07ef7ce9ecf015288d (diff) |
samples/bpf: Get rid of deprecated libbpf API uses
Replace deprecated APIs with new ones. Also mute source code using
deprecated AF_XDP (xsk.h). Figuring out what to do with all the AF_XDP
stuff is a separate problem that should be solved with its own set of
changes.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211201232824.3166325-9-andrii@kernel.org
Diffstat (limited to 'samples/bpf/sockex2_user.c')
-rw-r--r-- | samples/bpf/sockex2_user.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/samples/bpf/sockex2_user.c b/samples/bpf/sockex2_user.c index bafa567b840c..6a3fd369d3fc 100644 --- a/samples/bpf/sockex2_user.c +++ b/samples/bpf/sockex2_user.c @@ -16,18 +16,26 @@ struct pair { int main(int ac, char **argv) { + struct bpf_program *prog; struct bpf_object *obj; int map_fd, prog_fd; char filename[256]; - int i, sock; + int i, sock, err; FILE *f; snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); + 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_SOCKET_FILTER); - if (bpf_prog_load(filename, BPF_PROG_TYPE_SOCKET_FILTER, - &obj, &prog_fd)) + err = bpf_object__load(obj); + if (err) return 1; + prog_fd = bpf_program__fd(prog); map_fd = bpf_object__find_map_fd_by_name(obj, "hash_map"); sock = open_raw_sock("lo"); |