Re: [RFC PATCH 14/17] libbpf: Add support for querying dequeue programs

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

 



On Wed, Jul 13, 2022 at 4:15 AM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote:
>
> Add support to libbpf for reading the dequeue program ID from netlink when
> querying for installed XDP programs. No additional support is needed to
> install dequeue programs, as they are just using a new mode flag for the
> regular XDP program installation mechanism.
>
> Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
> ---
>  tools/lib/bpf/libbpf.h  | 1 +
>  tools/lib/bpf/netlink.c | 8 ++++++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index e4d5353f757b..b15ff90279cb 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -906,6 +906,7 @@ struct bpf_xdp_query_opts {
>         __u32 drv_prog_id;      /* output */
>         __u32 hw_prog_id;       /* output */
>         __u32 skb_prog_id;      /* output */
> +       __u32 dequeue_prog_id;  /* output */

can't do that, you have to put it after attach_mode to preserve
backwards/forward compat

>         __u8 attach_mode;       /* output */
>         size_t :0;
>  };
> diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
> index 6c013168032d..64a9aceb9c9c 100644
> --- a/tools/lib/bpf/netlink.c
> +++ b/tools/lib/bpf/netlink.c
> @@ -32,6 +32,7 @@ struct xdp_link_info {
>         __u32 drv_prog_id;
>         __u32 hw_prog_id;
>         __u32 skb_prog_id;
> +       __u32 dequeue_prog_id;
>         __u8 attach_mode;
>  };
>
> @@ -354,6 +355,10 @@ static int get_xdp_info(void *cookie, void *msg, struct nlattr **tb)
>                 xdp_id->info.hw_prog_id = libbpf_nla_getattr_u32(
>                         xdp_tb[IFLA_XDP_HW_PROG_ID]);
>
> +       if (xdp_tb[IFLA_XDP_DEQUEUE_PROG_ID])
> +               xdp_id->info.dequeue_prog_id = libbpf_nla_getattr_u32(
> +                       xdp_tb[IFLA_XDP_DEQUEUE_PROG_ID]);
> +
>         return 0;
>  }
>
> @@ -391,6 +396,7 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
>         OPTS_SET(opts, drv_prog_id, xdp_id.info.drv_prog_id);
>         OPTS_SET(opts, hw_prog_id, xdp_id.info.hw_prog_id);
>         OPTS_SET(opts, skb_prog_id, xdp_id.info.skb_prog_id);
> +       OPTS_SET(opts, dequeue_prog_id, xdp_id.info.dequeue_prog_id);
>         OPTS_SET(opts, attach_mode, xdp_id.info.attach_mode);
>
>         return 0;
> @@ -415,6 +421,8 @@ int bpf_xdp_query_id(int ifindex, int flags, __u32 *prog_id)
>                 *prog_id = opts.hw_prog_id;
>         else if (flags & XDP_FLAGS_SKB_MODE)
>                 *prog_id = opts.skb_prog_id;
> +       else if (flags & XDP_FLAGS_DEQUEUE_MODE)
> +               *prog_id = opts.dequeue_prog_id;
>         else
>                 *prog_id = 0;
>
> --
> 2.37.0
>




[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