Re: [PATCH RFC bpf-next 6/7] libbpf: add bpf_link based TC-BPF management API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 28, 2021 at 1:01 PM Kumar Kartikeya Dwivedi
<memxor@xxxxxxxxx> wrote:
>
> This adds userspace TC-BPF management API based on bpf_link.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> ---
>  tools/lib/bpf/bpf.c      |  5 ++++
>  tools/lib/bpf/bpf.h      |  8 +++++-
>  tools/lib/bpf/libbpf.c   | 59 ++++++++++++++++++++++++++++++++++++++--
>  tools/lib/bpf/libbpf.h   | 17 ++++++++++++
>  tools/lib/bpf/libbpf.map |  1 +
>  tools/lib/bpf/netlink.c  |  5 ++--
>  tools/lib/bpf/netlink.h  |  8 ++++++
>  7 files changed, 98 insertions(+), 5 deletions(-)
>  create mode 100644 tools/lib/bpf/netlink.h
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 86dcac44f32f..ab2e2e9ccc5e 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -28,6 +28,7 @@
>  #include <asm/unistd.h>
>  #include <errno.h>
>  #include <linux/bpf.h>
> +#include <arpa/inet.h>
>  #include "bpf.h"
>  #include "libbpf.h"
>  #include "libbpf_internal.h"
> @@ -692,6 +693,10 @@ int bpf_link_create(int prog_fd, int target_fd,
>         attr.link_create.target_fd = target_fd;
>         attr.link_create.attach_type = attach_type;
>         attr.link_create.flags = OPTS_GET(opts, flags, 0);
> +       attr.link_create.tc.parent = OPTS_GET(opts, tc.parent, 0);
> +       attr.link_create.tc.handle = OPTS_GET(opts, tc.handle, 0);
> +       attr.link_create.tc.priority = OPTS_GET(opts, tc.priority, 0);
> +       attr.link_create.tc.gen_flags = OPTS_GET(opts, tc.gen_flags, 0);

you can't do filling out link_create.tc unless you know it's TC
bpf_link that is being created, right? link_create.tc is part of a
union, so you might be overwriting bpf_iter link data, for instance.


>
>         if (iter_info_len) {
>                 attr.link_create.iter_info =

[...]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux