On Sat, Oct 10, 2020 at 11:17 AM Daniel T. Lee <danieltimlee@xxxxxxxxx> wrote: > > 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@xxxxxxxxx> > > --- > Changes in v2: > - program section match with bpf_program__is_<type> instead of strncmp > - refactor pointer array initialization > - error code cleanup > > samples/bpf/Makefile | 2 +- > samples/bpf/xdp_redirect_cpu_user.c | 153 +++++++++++++--------------- > 2 files changed, 73 insertions(+), 82 deletions(-) > [...] > @@ -986,6 +975,8 @@ int main(int argc, char **argv) > > stats_poll(interval, use_separators, prog_name, mprog_name, > &value, stress_mode); > + > + err = EXIT_OK; > out: This one doesn't call bpf_object__close() as well, but let's land your refactoring and we can do further improvements in the follow ups. Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > free(cpu); > return err; > -- > 2.25.1 >