From: Paul Chaignon <paul.chaignon@orange.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: bpf@vger.kernel.org,
Quentin Monnet <quentin.monnet@netronome.com>,
paul.chaignon@gmail.com, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>
Subject: Re: [PATCH bpf-next 2/3] bpftool: match programs by name
Date: Fri, 13 Dec 2019 13:40:38 +0100 [thread overview]
Message-ID: <20191213124038.GB6538@Omicron> (raw)
In-Reply-To: <20191210124101.6d5be2dd@cakuba.netronome.com>
On Tue, Dec 10, 2019 at 01:04:13PM -0800, Jakub Kicinski wrote:
> On Tue, 10 Dec 2019 17:06:42 +0100, Paul Chaignon wrote:
> > When working with frequently modified BPF programs, both the ID and the
> > tag may change. bpftool currently doesn't provide a "stable" way to match
> > such programs.
> >
> > This patch implements lookup by name for programs. The show and dump
> > commands will return all programs with the given name, whereas other
> > commands will error out if several programs have the same name.
> >
> > Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
>
> > @@ -164,7 +165,7 @@ prog_parse_fds(int *argc, char ***argv, int *fds)
> > }
> > return 1;
> > } else if (is_prefix(**argv, "tag")) {
> > - unsigned char tag[BPF_TAG_SIZE];
> > + char tag[BPF_TAG_SIZE];
>
> Perhaps better to change the argument to prog_fd_by_nametag() to void *?
>
> >
> > NEXT_ARGP();
> >
> > @@ -176,7 +177,20 @@ prog_parse_fds(int *argc, char ***argv, int *fds)
> > }
> > NEXT_ARGP();
> >
> > - return prog_fd_by_tag(tag, fds);
> > + return prog_fd_by_nametag(tag, fds, true);
> > + } else if (is_prefix(**argv, "name")) {
> > + char *name;
> > +
> > + NEXT_ARGP();
> > +
> > + name = **argv;
> > + if (strlen(name) > BPF_OBJ_NAME_LEN - 1) {
>
> Is this needed? strncmp will simply never match, is it preferred to
> hard error?
I tried to follow the fail-early pattern of lookups by tag above. I do
like that there's a different error message for a longer than expected
name. Since libbpf silently truncates names, typing a longer name is
not uncommon.
[...]
Paul
next prev parent reply other threads:[~2019-12-13 20:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 16:05 [PATCH bpf-next 0/3] bpftool: match programs and maps by names Paul Chaignon
2019-12-10 16:06 ` [PATCH bpf-next 1/3] bpftool: match several programs with same tag Paul Chaignon
2019-12-10 17:29 ` Quentin Monnet
2019-12-13 18:10 ` Paul Chaignon
2019-12-10 20:36 ` Jakub Kicinski
2019-12-13 12:39 ` Paul Chaignon
2019-12-10 16:06 ` [PATCH bpf-next 2/3] bpftool: match programs by name Paul Chaignon
2019-12-10 17:29 ` Quentin Monnet
2019-12-10 21:04 ` Jakub Kicinski
2019-12-13 12:40 ` Paul Chaignon [this message]
2019-12-13 17:56 ` Jakub Kicinski
2019-12-10 16:06 ` [PATCH bpf-next 3/3] bpftool: match maps " Paul Chaignon
2019-12-10 17:29 ` Quentin Monnet
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=20191213124038.GB6538@Omicron \
--to=paul.chaignon@orange.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=paul.chaignon@gmail.com \
--cc=quentin.monnet@netronome.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).