bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Paul Chaignon <paul.chaignon@orange.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: Tue, 10 Dec 2019 13:04:13 -0800	[thread overview]
Message-ID: <20191210124101.6d5be2dd@cakuba.netronome.com> (raw)
In-Reply-To: <1e3ede4f901a36af342e71bc4fdd2b27fbf9a418.1575991886.git.paul.chaignon@orange.com>

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?

> +			p_err("can't parse name");
> +			return -1;
> +		}
> +		NEXT_ARGP();
> +
> +		return prog_fd_by_nametag(name, fds, false);
>  	} else if (is_prefix(**argv, "pinned")) {
>  		char *path;
>  
> @@ -191,7 +205,7 @@ prog_parse_fds(int *argc, char ***argv, int *fds)
>  		return 1;
>  	}
>  
> -	p_err("expected 'id', 'tag' or 'pinned', got: '%s'?", **argv);
> +	p_err("expected 'id', 'tag', 'name' or 'pinned', got: '%s'?", **argv);
>  	return -1;
>  }
>  


  parent reply	other threads:[~2019-12-10 21:06 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 [this message]
2019-12-13 12:40     ` Paul Chaignon
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=20191210124101.6d5be2dd@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=paul.chaignon@gmail.com \
    --cc=paul.chaignon@orange.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).