From: Thomas Graf <tgraf@suug.ch>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, daniel@zonque.org, ast@fb.com,
daniel@iogearbox.net
Subject: Re: [PATCH net-next 2/3] bpf: Add new cgroups prog type to enable sock modifications
Date: Wed, 26 Oct 2016 20:57:28 +0200 [thread overview]
Message-ID: <20161026185728.GB21683@pox.localdomain> (raw)
In-Reply-To: <993982d6-7192-cde5-6fcb-a2fa04f93389@cumulusnetworks.com>
On 10/26/16 at 10:08am, David Ahern wrote:
> On 10/26/16 2:41 AM, Thomas Graf wrote:
> > On 10/25/16 at 03:30pm, David Ahern wrote:
> >> @@ -171,6 +177,9 @@ int __cgroup_bpf_run_filter(struct sock *sk,
> >> case BPF_CGROUP_INET_EGRESS:
> >> ret = __cgroup_bpf_run_filter_skb(skb, prog);
> >> break;
> >> + case BPF_CGROUP_INET_SOCK_CREATE:
> >> + ret = __cgroup_bpf_run_filter_sk_create(sk, prog);
> >> + break;
> >> /* make gcc happy else complains about missing enum value */
> >> default:
> >> return 0;
> >
> > Thinking further ahead of your simple example. Instead of adding yet
> > another prog type for the same hook, we can make this compatible with
> > BPF_CGROUP_INET_EGRESS instead which would then provide a ctx which
> > contains both, the sk and skb.
> >
> > The ctx concept is very flexible. We can keep the existing dummy skb
> > representation and add sk_ fields which are only valid for BPF at
> > socket layer, e.g skb->sk_bound_dev_if would translate to
> > sk->bound_dev_if.
> >
>
> It's an odd user semantic to me to put sock elements into the shadow sk_buff and to reuse BPF_CGROUP_INET_EGRESS.
>
> I can drop the _CREATE and just make it BPF_CGROUP_INET_SOCK so it works for any sock modification someone wants to add -- e.g., the port binding use case.
Your specific sk_alloc hook won't have an skb but the majority of
socket BPF programs will want to see both skb and sk. It is not
ideal to introduce a new bpf_prog_type for every minimal difference
in capability if the majority of capabilities and restrictions are
shared. Instead, the subtype approach was implemented by the Landlock
series looks much cleaner to me.
I think we should think about how to do this properly for all BPF
programs which operate in socket cgroup context.
next prev parent reply other threads:[~2016-10-26 19:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 22:30 [PATCH net-next 0/3] Add bpf support to set sk_bound_dev_if David Ahern
2016-10-25 22:30 ` [PATCH net-next 1/3] bpf: Refactor cgroups code in prep for new type David Ahern
2016-10-25 23:01 ` Daniel Borkmann
2016-10-25 23:04 ` David Ahern
2016-10-25 22:30 ` [PATCH net-next 2/3] bpf: Add new cgroups prog type to enable sock modifications David Ahern
2016-10-25 23:28 ` Daniel Borkmann
2016-10-26 1:55 ` Alexei Starovoitov
2016-10-26 2:38 ` David Ahern
2016-10-26 2:05 ` David Ahern
2016-10-26 8:33 ` Daniel Borkmann
2016-10-26 15:44 ` David Ahern
[not found] ` <CAF2d9jhE0OHgWrDfHwYzRk2tDbnmK_=ZdgFd2-ccpbTjdQzqmQ@mail.gmail.com>
2016-10-26 20:42 ` David Ahern
2016-10-25 23:39 ` Eric Dumazet
2016-10-26 2:21 ` David Ahern
2016-10-26 2:48 ` Eric Dumazet
2016-10-26 3:09 ` David Ahern
2016-10-26 8:41 ` Thomas Graf
2016-10-26 16:08 ` David Ahern
2016-10-26 18:57 ` Thomas Graf [this message]
2016-10-25 22:30 ` [PATCH net-next 3/3] samples: bpf: add userspace example for modifying sk_bound_dev_if David Ahern
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=20161026185728.GB21683@pox.localdomain \
--to=tgraf@suug.ch \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=daniel@zonque.org \
--cc=dsa@cumulusnetworks.com \
--cc=netdev@vger.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