All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: Quentin Monnet <quentin.monnet@netronome.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<kernel-team@fb.com>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<jakub.kicinski@netronome.com>, <kafai@fb.com>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH v2 net-next 4/4] bpftool: implement cgroup bpf operations
Date: Fri, 8 Dec 2017 14:12:59 +0000	[thread overview]
Message-ID: <20171208141251.GA9458@castle> (raw)
In-Reply-To: <d3cc2f85-f3ee-7771-c5b2-13ca6e80a910@netronome.com>

On Fri, Dec 08, 2017 at 10:34:16AM +0000, Quentin Monnet wrote:
> 2017-12-07 18:39 UTC+0000 ~ Roman Gushchin <guro@fb.com>
> > This patch adds basic cgroup bpf operations to bpftool:
> > cgroup list, attach and detach commands.
> > 
> > Usage is described in the corresponding man pages,
> > and examples are provided.
[...]
> > +MAP COMMANDS
> > +=============
> > +
> > +|	**bpftool** **cgroup list** *CGROUP*
> > +|	**bpftool** **cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
> > +|	**bpftool** **cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
> > +|	**bpftool** **cgroup help**
> > +|
> > +|	*PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
> 
> Could you please give the different possible values for ATTACH_TYPE and
> ATTACH_FLAGS, and provide some documentation for the flags?

I intentionally didn't include the list of possible values, as it depends
on the exact kernel version, and other bpftool docs are carefully avoiding
specifying such things.

It would be nice to have a way to ask the kernel about provided bpf program types,
attach types, etc; but I'm not sure that hardcoding it in bpftool docs is
a good idea.

> 
> > +
> > +DESCRIPTION
> > +===========
> > +	**bpftool cgroup list** *CGROUP*
> > +		  List all programs attached to the cgroup *CGROUP*.
> > +
> > +		  Output will start with program ID followed by attach type,
> > +		  attach flags and program name.
> > +
> > +	**bpftool cgroup attach** *CGROUP* *ATTACH_TYPE* *PROG* [*ATTACH_FLAGS*]
> > +		  Attach program *PROG* to the cgroup *CGROUP* with attach type
> > +		  *ATTACH_TYPE* and optional *ATTACH_FLAGS*.
[...]
> > +
> > +	attach_type = parse_attach_type(argv[1]);
> > +	if (attach_type == __MAX_BPF_ATTACH_TYPE) {
> > +		p_err("invalid attach type");
> > +		goto exit_cgroup;
> > +	}
> > +
> > +	argc -= 2;
> > +	argv = &argv[2];
> > +	prog_fd = prog_parse_fd(&argc, &argv);
> > +	if (prog_fd < 0)
> > +		goto exit_cgroup;
> > +
> > +	if (bpf_prog_detach2(prog_fd, cgroup_fd, attach_type)) {
> > +		p_err("failed to attach program");
> 
> Failed to *detach* instead of “attach”.

Fixed.

> 
> > +		goto exit_prog;
> > +	}
> > +
> > +	if (json_output)
> > +		jsonw_null(json_wtr);
> > +
> > +	ret = 0;
> > +
> > +exit_prog:
> > +	close(prog_fd);
> > +exit_cgroup:
> > +	close(cgroup_fd);
> > +exit:
> > +	return ret;
> > +}
> 
> […]
> 
> Very nice work on this v2, thanks a lot!
> Quentin

Thank you for reviewing!

  parent reply	other threads:[~2017-12-08 14:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 18:39 [PATCH v2 net-next 0/4] bpftool: cgroup bpf operations Roman Gushchin
2017-12-07 18:39 ` [PATCH v2 net-next 1/4] libbpf: add ability to guess program type based on section name Roman Gushchin
2017-12-08 10:33   ` Quentin Monnet
2017-12-07 18:39 ` [PATCH v2 net-next 2/4] libbpf: prefer global symbols as bpf program name source Roman Gushchin
2017-12-07 18:39 ` [PATCH v2 net-next 3/4] bpftool: implement prog load command Roman Gushchin
2017-12-07 21:55   ` Jakub Kicinski
2017-12-08 10:33   ` Quentin Monnet
2017-12-07 18:39 ` [PATCH v2 net-next 4/4] bpftool: implement cgroup bpf operations Roman Gushchin
2017-12-07 19:22   ` David Ahern
2017-12-07 22:23   ` Jakub Kicinski
2017-12-07 23:00     ` Philippe Ombredanne
2017-12-08 14:17     ` Roman Gushchin
2017-12-08 10:34   ` Quentin Monnet
2017-12-08 13:56     ` Philippe Ombredanne
2017-12-08 14:53       ` Roman Gushchin
2017-12-08 14:12     ` Roman Gushchin [this message]
2017-12-08 15:39       ` Quentin Monnet
2017-12-08 16:52         ` David Ahern
2017-12-08 23:30           ` Jakub Kicinski
2017-12-09 19:19         ` Roman Gushchin

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=20171208141251.GA9458@castle \
    --to=guro@fb.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=kafai@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin.monnet@netronome.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.