Re: [PATCH net-next 3/5] bpftool: implement cgattach command

2017-11-30 Thread Jakub Kicinski
On Thu, 30 Nov 2017 13:43:00 +, Roman Gushchin wrote: > + attach_type = parse_attach_type(argv[2]); > + if (attach_type == __MAX_BPF_ATTACH_TYPE) { > + bpf_object__close(obj); > + close(prog_fd); > + close(cgroup_fd); > + p_err("Invalid at

Re: [PATCH net-next 3/5] bpftool: implement cgattach command

2017-11-30 Thread Roman Gushchin
On Thu, Nov 30, 2017 at 09:17:17AM -0700, David Ahern wrote: > On 11/30/17 6:43 AM, Roman Gushchin wrote: > > @@ -75,12 +80,13 @@ static int do_help(int argc, char **argv) > > fprintf(stderr, > > "Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n" > > " %s batch file

Re: [PATCH net-next 3/5] bpftool: implement cgattach command

2017-11-30 Thread David Ahern
On 11/30/17 6:43 AM, Roman Gushchin wrote: > + if (bpf_prog_attach(prog_fd, cgroup_fd, attach_type, 0)) { > + bpf_object__close(obj); > + close(prog_fd); > + close(cgroup_fd); > + p_err("Failed to attach program"); > + return -1; > +

Re: [PATCH net-next 3/5] bpftool: implement cgattach command

2017-11-30 Thread David Ahern
On 11/30/17 6:43 AM, Roman Gushchin wrote: > @@ -75,12 +80,13 @@ static int do_help(int argc, char **argv) > fprintf(stderr, > "Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n" > " %s batch file FILE\n" > + " %s cgattach FILE CGROUP TYPE\n"

[PATCH net-next 3/5] bpftool: implement cgattach command

2017-11-30 Thread Roman Gushchin
This patch add the cgattach command to bpftool. It allows to load a bpf program from a binary file and attach it to a given cgroup. Example: $ bpftool cgattach ./mybpfprog.o /sys/fs/cgroup/user.slice/ ingress Signed-off-by: Roman Gushchin Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Jakub Ki