Netdev List
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, daniel@iogearbox.net, ast@kernel.org,
	tj@kernel.org, davem@davemloft.net, luto@amacapital.net
Subject: Re: [PATCH v2 net-next 1/8] bpf: Add support for recursively running cgroup sock filters
Date: Tue, 29 Aug 2017 19:58:51 -0700	[thread overview]
Message-ID: <20170830025850.wlp2hp7d4kreodif@ast-mbp> (raw)
In-Reply-To: <ab9b2874-fadc-5ab6-7710-2ccb1d65bb2c@gmail.com>

On Tue, Aug 29, 2017 at 07:03:43PM -0600, David Ahern wrote:
> On 8/28/17 10:11 PM, Alexei Starovoitov wrote:
> > 
> > Agree on the above, but you're mixing semantics of the new recurse
> > flag and implementation of it. Ex: we don't have to copy this flag
> > from prog->attr into cgroup. So this reset or non-reset discussion
> > only makes sense in the context of your current implementation.
> > We can implement the logic differently. Like don't copy that flag
> > at all and at attach time walk parent->parent->parent and see
> > what programs are attached. All of them should have prog->attr & recurse_bit set
> > In such implementation detach from 'b' is a nop from reset/non-reset
> > point of view. When socket creation in 'c' is invoked the program
> > 'c' is called first then the code keeps walking parents until root
> > invoking 'a' along the way.
> 
> So you are suggesting there is no recursive flag per cgroup? How do you
> know you need to walk cgroups? How do you know when to stop running
> programs?

you're talking about implementation, right?
My 'proposed' implemenation of walking from cgroup all the way to the root
is just an example. It's not efficient. More below...

> > I'm not saying it will be an efficient implementation. The point
> > is to discuss UAPI independent of implementation.
> > 
> >> ###
> >>
> >> Also, let's agree on this intention. Based on the new ground rule, I
> >> want to point out this example:
> >>
> >> If 'a' gets a program installed with no recurse flag set, ONLY processes
> >> in 'a' have the 'a' program run. Processes in groups 'b', 'c' and 'd'
> >> all stop at cgroup 'b' program.
> > 
> > I'm proposing that such situation should not be allowed to happen.
> > In a->b->c->d cgroup scenario if override+recurse prog attached to 'b'
> > then only the same override+recurse can be attached to c, d, a.
> > So at detach time there can be gaps (like only 'b' and 'd' have
> > override+recurse progs), but walking up until root from any point
> > will guarantee that only override+recurse programs are seen.
> > 
> 
> That seems very limiting to me. Seems like you are suggesting the entire
> cgroup tree is recursive or non-recursive, but never a mix.

Entire cgroup subtree. Yes. It's the simplest uapi I could think of.
Easy to understand and argue about and I think it's solving your use case.
It's also easily extendable. New combination and features won't break
the users. It feels you're in rush to get this stuff for this merge
window, therefore I want to agree on something that is simple,
non-controversial and extensible.
If you're not in rush (I'm not), we can come up with more flexible uapi.
For example: another way of thinking about your 'recursive' requirement
is to think that all 'program to be run' should be present as a link list
in a given cgroup. So no walking a chain of parents.
Instead of 'recursive' let's call this new flag 'multiprog'.
Now in a->b->c->d scenario. We can install 'multiprog' prog in 'b'.
The kernel will automatically propage it (like it does right now
with css_for_each_descendant_pre() loop) to 'c' and to 'd'.
Now we allow users to attach another 'multiprog' program to 'c'.
The kernel will maintain a link list of programs in every cgroup,
so there will be a link list of two programs in 'c' and 'd'
and invocation of the programs will be faster than walking
cgroup->parent->parent and checking some flags at every step,
since there will be less pointer dereferences and no flags to check.
Just invoke all programs in the current cgroup. Kernel took care
of ordering at the time of attach/detach.
I believe Andy proposed something like this back in Jan/Feb.

  reply	other threads:[~2017-08-30  2:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 19:05 [PATCH v2 net-next 0/8] bpf: Add option to set mark and priority in cgroup sock programs David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 1/8] bpf: Add support for recursively running cgroup sock filters David Ahern
2017-08-26  2:00   ` Daniel Borkmann
2017-08-27 14:22     ` David Ahern
2017-08-26  2:49   ` Alexei Starovoitov
2017-08-27 14:49     ` David Ahern
2017-08-28 23:56       ` Alexei Starovoitov
2017-08-29  0:43         ` David Ahern
2017-08-29  1:12           ` Alexei Starovoitov
2017-08-29  2:22             ` David Ahern
2017-08-29  4:11               ` Alexei Starovoitov
2017-08-30  1:03                 ` David Ahern
2017-08-30  2:58                   ` Alexei Starovoitov [this message]
2017-08-30  3:38                     ` David Ahern
2017-08-30  4:11                       ` Alexei Starovoitov
2017-08-31 14:22       ` Tejun Heo
2017-08-31 20:53         ` David Ahern
2017-09-01  3:27         ` Alexei Starovoitov
2017-09-01 14:11           ` Tejun Heo
2017-08-25 19:05 ` [PATCH v2 net-next 2/8] bpf: Add mark and priority to sock options that can be set David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 3/8] bpf: Allow cgroup sock filters to use get_current_uid_gid helper David Ahern
2017-08-26  2:30   ` Alexei Starovoitov
2017-08-25 19:05 ` [PATCH v2 net-next 4/8] samples/bpf: Update sock test to allow setting mark and priority David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 5/8] samples/bpf: Add detach option to test_cgrp2_sock David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 6/8] samples/bpf: Add option to dump socket settings David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 7/8] samples/bpf: Add test case for nested socket options David Ahern
2017-08-25 19:05 ` [PATCH v2 net-next 8/8] samples/bpf: Update cgroup socket examples to use uid gid helper David Ahern
2017-08-29 21:53 ` [PATCH v2 net-next 0/8] bpf: Add option to set mark and priority in cgroup sock programs David Miller

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=20170830025850.wlp2hp7d4kreodif@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=luto@amacapital.net \
    --cc=netdev@vger.kernel.org \
    --cc=tj@kernel.org \
    /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