samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu
authorDaniel T. Lee <danieltimlee@gmail.com>
Sat, 10 Oct 2020 18:17:33 +0000 (03:17 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 11 Oct 2020 19:14:36 +0000 (12:14 -0700)
commit151936bf51afcdd6db52b3b73e339d021064b0ea
tree18efa2d681bf805b1a564eda4be8bc070fad4321
parent8ac91df6de164923c1025e340ea81d085fb4ab85
samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

>From commit d7a18ea7e8b6 ("libbpf: Add generic bpf_program__attach()"),
for some BPF programs, it is now possible to attach BPF programs
with __attach() instead of explicitly calling __attach_<type>().

This commit refactors the __attach_tracepoint() with libbpf's generic
__attach() method. In addition, this refactors the logic of setting
the map FD to simplify the code. Also, the missing removal of
bpf_load.o in Makefile has been fixed.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20201010181734.1109-3-danieltimlee@gmail.com
samples/bpf/Makefile
samples/bpf/xdp_redirect_cpu_user.c