All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin@isovalent.com>
To: "Daniel Müller" <deso@posteo.net>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpftool: Add feature list (prog/map/link/attach types, helpers)
Date: Wed, 29 Jun 2022 21:35:41 +0100	[thread overview]
Message-ID: <CACdoK4Ktf4HWtrDK9_k0yMXEg3G90qYiG9+65NbbSn3aSVaBTQ@mail.gmail.com> (raw)
In-Reply-To: <20220629173251.zk33plyiqsrkfpzg@muellerd-fedora-MJ0AC3F3>

On Wed, 29 Jun 2022 at 18:33, Daniel Müller <deso@posteo.net> wrote:
>
> On Wed, Jun 29, 2022 at 03:40:18PM +0100, Quentin Monnet wrote:
> > Add a "bpftool feature list" subcommand to list BPF "features".
> > Contrarily to "bpftool feature probe", this is not about the features
> > available on the system. Instead, it lists all features known to bpftool
> > from compilation time; in other words, all program, map, attach, link
> > types known to the libbpf version in use, and all helpers found in the
> > UAPI BPF header.
> >
> > The first use case for this feature is bash completion: running the
> > command provides a list of types that can be used to produce the list of
> > candidate map types, for example.
> >
> > Now that bpftool uses "standard" names provided by libbpf for the
> > program, map, link, and attach types, having the ability to list these
> > types and helpers could also be useful in scripts to loop over existing
> > items.
> >
> > Sample output:
> >
> >     # bpftool feature list prog_types | grep -vw unspec | head -n 6
> >     socket_filter
> >     kprobe
> >     sched_cls
> >     sched_act
> >     tracepoint
> >     xdp
> >
> >     # bpftool -p feature list map_types | jq '.[1]'
> >     "hash"
> >
> >     # bpftool feature list attach_types | grep '^cgroup_'
> >     cgroup_inet_ingress
> >     cgroup_inet_egress
> >     [...]
> >     cgroup_inet_sock_release
> >
> >     # bpftool feature list helpers | grep -vw bpf_unspec | wc -l
> >     207
> >
> > The "unspec" types and helpers are not filtered out by bpftool, so as to
> > remain closer to the enums, and to preserve the indices in the JSON
> > arrays (e.g. "hash" at index 1 == BPF_MAP_TYPE_HASH in map types list).
> >
> > Signed-off-by: Quentin Monnet <quentin@isovalent.com>
> > ---
> >  .../bpftool/Documentation/bpftool-feature.rst | 12 ++++
> >  tools/bpf/bpftool/bash-completion/bpftool     |  7 ++-
> >  tools/bpf/bpftool/feature.c                   | 55 +++++++++++++++++++
> >  3 files changed, 73 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/bpf/bpftool/Documentation/bpftool-feature.rst b/tools/bpf/bpftool/Documentation/bpftool-feature.rst
> > index 4ce9a77bc1e0..4bf1724d0e8c 100644
> > --- a/tools/bpf/bpftool/Documentation/bpftool-feature.rst
> > +++ b/tools/bpf/bpftool/Documentation/bpftool-feature.rst
> > @@ -24,9 +24,11 @@ FEATURE COMMANDS
> >  ================
> >
> >  |    **bpftool** **feature probe** [*COMPONENT*] [**full**] [**unprivileged**] [**macros** [**prefix** *PREFIX*]]
> > +|    **bpftool** **feature list** *GROUP*
> >  |    **bpftool** **feature help**
> >  |
> >  |    *COMPONENT* := { **kernel** | **dev** *NAME* }
> > +|    *GROUP* := { **prog_types** | **map_types** | **attach_types** | **helpers** }
>
> Is **link_types** missing from this enumeration?

Yes of course, thanks for catching this. And for the review! v2 is on its way.
Quentin

  reply	other threads:[~2022-06-29 20:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-29 14:40 [PATCH bpf-next 0/2] bpftool: Add command to list BPF types, helpers Quentin Monnet
2022-06-29 14:40 ` [PATCH bpf-next 1/2] bpftool: Add feature list (prog/map/link/attach types, helpers) Quentin Monnet
2022-06-29 17:32   ` Daniel Müller
2022-06-29 20:35     ` Quentin Monnet [this message]
2022-06-29 14:40 ` [PATCH bpf-next 2/2] bpftool: Use feature list in bash completion Quentin Monnet
2022-06-29 16:56   ` Daniel Müller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACdoK4Ktf4HWtrDK9_k0yMXEg3G90qYiG9+65NbbSn3aSVaBTQ@mail.gmail.com \
    --to=quentin@isovalent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=deso@posteo.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.