Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup ebpf egress programs

2016-09-26 Thread Daniel Borkmann
On 09/23/2016 03:17 PM, Pablo Neira Ayuso wrote: On Thu, Sep 22, 2016 at 05:12:57PM +0200, Daniel Borkmann wrote: On 09/22/2016 02:05 PM, Pablo Neira Ayuso wrote: [...] Have a look at net/ipv4/netfilter/nft_chain_route_ipv4.c for instance. In your case, you have to add a new chain type:

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup ebpf egress programs

2016-09-23 Thread Pablo Neira Ayuso
On Thu, Sep 22, 2016 at 05:12:57PM +0200, Daniel Borkmann wrote: > On 09/22/2016 02:05 PM, Pablo Neira Ayuso wrote: [...] > >Have a look at net/ipv4/netfilter/nft_chain_route_ipv4.c for instance. > >In your case, you have to add a new chain type: > > > >static const struct nf_chain_type

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-22 Thread Daniel Mack
On 09/22/2016 05:12 PM, Daniel Borkmann wrote: > On 09/22/2016 02:05 PM, Pablo Neira Ayuso wrote: >> Benefits are, rewording previous email: >> >> * You get access to all of the existing netfilter hooks in one go >>to run bpf programs. No need for specific redundant hooks. This >>provides

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-22 Thread Daniel Borkmann
On 09/22/2016 02:05 PM, Pablo Neira Ayuso wrote: On Thu, Sep 22, 2016 at 11:54:11AM +0200, Thomas Graf wrote: On 09/22/16 at 11:21am, Pablo Neira Ayuso wrote: I have a hard time to buy this new specific hook, I think we should shift focus of this debate, this is my proposal to untangle this:

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-22 Thread Pablo Neira Ayuso
On Thu, Sep 22, 2016 at 11:54:11AM +0200, Thomas Graf wrote: > On 09/22/16 at 11:21am, Pablo Neira Ayuso wrote: > > I have a hard time to buy this new specific hook, I think we should > > shift focus of this debate, this is my proposal to untangle this: > > > > You add a net/netfilter/nft_bpf.c

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-22 Thread Thomas Graf
On 09/22/16 at 11:21am, Pablo Neira Ayuso wrote: > I have a hard time to buy this new specific hook, I think we should > shift focus of this debate, this is my proposal to untangle this: > > You add a net/netfilter/nft_bpf.c expression that allows you to run > bpf programs from nf_tables. This

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-22 Thread Pablo Neira Ayuso
On Wed, Sep 21, 2016 at 08:48:27PM +0200, Thomas Graf wrote: > On 09/21/16 at 05:45pm, Pablo Neira Ayuso wrote: > > On Tue, Sep 20, 2016 at 06:43:35PM +0200, Daniel Mack wrote: > > > The point is that from an application's perspective, restricting the > > > ability to bind a port and dropping

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-21 Thread Thomas Graf
On 09/21/16 at 05:45pm, Pablo Neira Ayuso wrote: > On Tue, Sep 20, 2016 at 06:43:35PM +0200, Daniel Mack wrote: > > The point is that from an application's perspective, restricting the > > ability to bind a port and dropping packets that are being sent is a > > very different thing. Applications

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-21 Thread Pablo Neira Ayuso
Hi Daniel, On Tue, Sep 20, 2016 at 06:43:35PM +0200, Daniel Mack wrote: > Hi Pablo, > > On 09/20/2016 04:29 PM, Pablo Neira Ayuso wrote: > > On Mon, Sep 19, 2016 at 10:56:14PM +0200, Daniel Mack wrote: > > [...] > >> Why would we artificially limit the use-cases of this implementation if > >>

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-20 Thread Thomas Graf
On 09/20/16 at 04:29pm, Pablo Neira Ayuso wrote: > On Mon, Sep 19, 2016 at 10:56:14PM +0200, Daniel Mack wrote: > [...] > > Why would we artificially limit the use-cases of this implementation if > > the way it stands, both filtering and introspection are possible? > > Why should we place

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-20 Thread Daniel Mack
Hi Pablo, On 09/20/2016 04:29 PM, Pablo Neira Ayuso wrote: > On Mon, Sep 19, 2016 at 10:56:14PM +0200, Daniel Mack wrote: > [...] >> Why would we artificially limit the use-cases of this implementation if >> the way it stands, both filtering and introspection are possible? > > Why should we

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-20 Thread Pablo Neira Ayuso
On Mon, Sep 19, 2016 at 10:56:14PM +0200, Daniel Mack wrote: [...] > Why would we artificially limit the use-cases of this implementation if > the way it stands, both filtering and introspection are possible? Why should we place infrastructure in the kernel to filter packets so late, and why at

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread kbuild test robot
Hi Daniel, [auto build test ERROR on next-20160919] [cannot apply to linus/master linux/master net/master v4.8-rc7 v4.8-rc6 v4.8-rc5 v4.8-rc7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base= (or

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Thomas Graf
On 09/19/16 at 01:13pm, Alexei Starovoitov wrote: > as far as bpf debuggability/visibility there are various efforts on the way: > for kernel side: > - ksym for jit-ed programs > - hash sum for prog code > - compact type information for maps and various pretty printers > - data flow analysis of

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Daniel Mack
On 09/19/2016 10:35 PM, Pablo Neira Ayuso wrote: > On Mon, Sep 19, 2016 at 09:30:02PM +0200, Daniel Mack wrote: >> On 09/19/2016 09:19 PM, Pablo Neira Ayuso wrote: >>> Actually, did you look at Google's approach to this problem? They >>> want to control this at socket level, so you restrict what

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Pablo Neira Ayuso
On Mon, Sep 19, 2016 at 01:13:27PM -0700, Alexei Starovoitov wrote: > On Mon, Sep 19, 2016 at 09:19:10PM +0200, Pablo Neira Ayuso wrote: [...] > > 2) This will turn the stack into a nightmare to debug I predict. If > >any process with CAP_NET_ADMIN can potentially attach bpf blobs > >via

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Pablo Neira Ayuso
On Mon, Sep 19, 2016 at 09:30:02PM +0200, Daniel Mack wrote: > On 09/19/2016 09:19 PM, Pablo Neira Ayuso wrote: > > On Mon, Sep 19, 2016 at 06:44:00PM +0200, Daniel Mack wrote: > >> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c > >> index 6001e78..5dc90aa 100644 > >> ---

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Alexei Starovoitov
On Mon, Sep 19, 2016 at 09:19:10PM +0200, Pablo Neira Ayuso wrote: > On Mon, Sep 19, 2016 at 06:44:00PM +0200, Daniel Mack wrote: > > diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c > > index 6001e78..5dc90aa 100644 > > --- a/net/ipv6/ip6_output.c > > +++ b/net/ipv6/ip6_output.c > > @@

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Daniel Mack
On 09/19/2016 09:19 PM, Pablo Neira Ayuso wrote: > On Mon, Sep 19, 2016 at 06:44:00PM +0200, Daniel Mack wrote: >> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c >> index 6001e78..5dc90aa 100644 >> --- a/net/ipv6/ip6_output.c >> +++ b/net/ipv6/ip6_output.c >> @@ -39,6 +39,7 @@ >>

Re: [PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Pablo Neira Ayuso
On Mon, Sep 19, 2016 at 06:44:00PM +0200, Daniel Mack wrote: > diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c > index 6001e78..5dc90aa 100644 > --- a/net/ipv6/ip6_output.c > +++ b/net/ipv6/ip6_output.c > @@ -39,6 +39,7 @@ > #include > #include > > +#include > #include >

[PATCH v6 5/6] net: ipv4, ipv6: run cgroup eBPF egress programs

2016-09-19 Thread Daniel Mack
If the cgroup associated with the receiving socket has an eBPF programs installed, run them from ip_output(), ip6_output() and ip_mc_output(). eBPF programs used in this context are expected to either return 1 to let the packet pass, or != 1 to drop them. The programs have access to the skb