From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, daniel@zonque.org, ast@fb.com,
daniel@iogearbox.net, maheshb@google.com, tgraf@suug.ch
Subject: Re: [PATCH net-next v5 2/3] bpf: Add new cgroup attach type to enable sock modifications
Date: Tue, 29 Nov 2016 12:01:43 -0800 [thread overview]
Message-ID: <20161129200141.GB24152@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <1480434813-3141-3-git-send-email-dsa@cumulusnetworks.com>
On Tue, Nov 29, 2016 at 07:53:32AM -0800, David Ahern wrote:
> Add new cgroup based program type, BPF_PROG_TYPE_CGROUP_SOCK. Similar to
> BPF_PROG_TYPE_CGROUP_SKB programs can be attached to a cgroup and run
> any time a process in the cgroup opens an AF_INET or AF_INET6 socket.
> Currently only sk_bound_dev_if is exported to userspace for modification
> by a bpf program.
>
> This allows a cgroup to be configured such that AF_INET{6} sockets opened
> by processes are automatically bound to a specific device. In turn, this
> enables the running of programs that do not support SO_BINDTODEVICE in a
> specific VRF context / L3 domain.
>
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
...
> +struct bpf_sock {
> + __u32 bound_dev_if;
> +};
overall looks great to me.
Could you also expose sk_protcol and sk_type as read only fields?
They have user space visible values already and will make this new
BPF_PROG_TYPE_CGROUP_SOCK program type much more useful beyond vrf
use case. Like we'll be able to write a tiny bpf program to block all
raw sockets or all udp sockets for an application within a given cgroup.
If someone would want to prevent udp traffic from an application,
it can be done here within close to zero overhead for socket() syscall
instead of checking every packet at networking layer.
It can help vrf use case as well, so you can auto-bindtodevice
only udp and tcp sockets instead of all... or do it for ipv4 or ipv6 only.
Plenty of interesting opportunities with just two extra fields
that cost nothing when not in use.
next prev parent reply other threads:[~2016-11-29 20:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 15:53 [PATCH net-next v5 0/3] net: Add bpf support to set sk_bound_dev_if David Ahern
2016-11-29 15:53 ` [PATCH net-next v5 1/3] bpf: Refactor cgroups code in prep for new type David Ahern
2016-11-29 19:41 ` Alexei Starovoitov
2016-11-29 15:53 ` [PATCH net-next v5 2/3] bpf: Add new cgroup attach type to enable sock modifications David Ahern
2016-11-29 20:01 ` Alexei Starovoitov [this message]
2016-11-29 21:01 ` David Ahern
2016-11-30 0:43 ` David Ahern
2016-11-30 0:59 ` Alexei Starovoitov
2016-11-30 1:07 ` David Ahern
2016-11-30 5:41 ` Alexei Starovoitov
2016-11-30 16:24 ` David Ahern
2016-11-29 15:53 ` [PATCH net-next v5 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=20161129200141.GB24152@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=daniel@zonque.org \
--cc=dsa@cumulusnetworks.com \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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