Re: [PATCH bpf-next v2 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu

Andrii Nakryiko <[email protected]>
Newsgroups org.kernel.vger.xdp-newbies,org.kernel.vger.bpf,org.kernel.vger.netdev
Message-ID <CAEf4Bzbw5TOkbQMOv99ONc374yp9xVXAKnGZAnwCw=TUro0wsA@mail.gmail.com>
On Sat, Oct 10, 2020 at 11:17 AM Daniel T. Lee <[email protected]> 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 <[email protected]>
>
> ---
> 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 <[email protected]>

>         free(cpu);
>         return err;
> --
> 2.25.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.