Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-18 Thread Daniel Mack
On 08/17/2016 08:10 PM, Alexei Starovoitov wrote: > On Wed, Aug 17, 2016 at 09:16:02AM -0700, Eric Dumazet wrote: >> On Wed, 2016-08-17 at 16:00 +0200, Daniel Mack wrote: >> >>> + progp = is_ingress ? &cgrp->bpf_ingress : &cgrp->bpf_egress; >>> + >>> + rcu_read_lock(); >>> +

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Alexei Starovoitov
On Wed, Aug 17, 2016 at 09:16:02AM -0700, Eric Dumazet wrote: > On Wed, 2016-08-17 at 16:00 +0200, Daniel Mack wrote: > > > + progp = is_ingress ? &cgrp->bpf_ingress : &cgrp->bpf_egress; > > + > > + rcu_read_lock(); > > + old_prog = rcu_dereference(*progp); > > +

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Alexei Starovoitov
On Wed, Aug 17, 2016 at 05:51:44PM +0200, Daniel Mack wrote: > On 08/17/2016 05:06 PM, Tejun Heo wrote: > > What I'd suggest is keeping two sets of pointers, one set for the > > programs explicitly attached to the cgroup and the other for programs > > which are to be executed for the cgroup. The t

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Eric Dumazet
On Wed, 2016-08-17 at 16:00 +0200, Daniel Mack wrote: > + progp = is_ingress ? &cgrp->bpf_ingress : &cgrp->bpf_egress; > + > + rcu_read_lock(); > + old_prog = rcu_dereference(*progp); > + rcu_assign_pointer(*progp, prog); > + > + if (old_

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Daniel Mack
On 08/17/2016 05:06 PM, Tejun Heo wrote: > What I'd suggest is keeping two sets of pointers, one set for the > programs explicitly attached to the cgroup and the other for programs > which are to be executed for the cgroup. The two pointers in the > latter set will point to the closest non-null pr

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Tejun Heo
Hello, again. Just one addition. On Wed, Aug 17, 2016 at 04:35:24PM +0200, Daniel Mack wrote: > created. To bring this more in line with how cgroups usually work, I > guess we should add code to copy over the bpf programs from the ancestor > once a new cgroup is instantiated. Please don't copy t

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Tejun Heo
Hello, On Wed, Aug 17, 2016 at 04:35:24PM +0200, Daniel Mack wrote: > > Wouldn't it make sense to update the descendants to point to the > > programs directly so that there's no need to traverse the tree on each > > packet? It's more state to maintain but I think it would make total > > sense giv

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Daniel Mack
Hi Tejun, On 08/17/2016 04:20 PM, Tejun Heo wrote: > On Wed, Aug 17, 2016 at 04:00:46PM +0200, Daniel Mack wrote: >> The current implementation walks the tree from the passed cgroup up >> to the root. If there is any program of the given type installed in >> any of the ancestors, the installation

Re: [RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Tejun Heo
Hello, Daniel. On Wed, Aug 17, 2016 at 04:00:46PM +0200, Daniel Mack wrote: > The current implementation walks the tree from the passed cgroup up > to the root. If there is any program of the given type installed in > any of the ancestors, the installation is rejected. This is because > programs s

[RFC PATCH 3/5] bpf: add BPF_PROG_ATTACH and BPF_PROG_DETACH commands

2016-08-17 Thread Daniel Mack
Extend the bpf(2) syscall by two new commands, BPF_PROG_ATTACH and BPF_PROG_DETACH which allow attaching eBPF programs to a target. On the API level, the target could be anything that has an fd in userspace, hence the name of the field in union bpf_attr is called 'target_fd'. When called with BPF