Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-05 Thread Lorenzo Colitti
On Fri, Feb 3, 2017 at 10:51 AM, Eric Dumazet wrote: > if (sk) { > sk = sk_to_full_sk(sk); > if (sk_fullsock(sk)) > return sk->sk_uid; > } Sure, though sk_to_full_sk is in inet_sock.h so I have to move some core around. Options I see: 1. Move sk_to_full_sk from inet_sock.h to soc

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-03 Thread Daniel Borkmann
On 02/03/2017 02:51 AM, Eric Dumazet wrote: On Fri, 2017-02-03 at 10:18 +0900, Lorenzo Colitti wrote: On Fri, Feb 3, 2017 at 9:31 AM, Eric Dumazet wrote: It should be safe to call sock_net_uid on any type of socket (including NULL). sk_uid was added to struct sock in 86741ec25462 ("net: core:

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Eric Dumazet
On Fri, 2017-02-03 at 10:18 +0900, Lorenzo Colitti wrote: > On Fri, Feb 3, 2017 at 9:31 AM, Eric Dumazet wrote: > >> It should be safe to call sock_net_uid on any type of socket > >> (including NULL). sk_uid was added to struct sock in 86741ec25462 > >> ("net: core: Add a UID field to struct sock.

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Lorenzo Colitti
On Fri, Feb 3, 2017 at 9:31 AM, Eric Dumazet wrote: >> It should be safe to call sock_net_uid on any type of socket >> (including NULL). sk_uid was added to struct sock in 86741ec25462 >> ("net: core: Add a UID field to struct sock.") > > But a request socket or a timewait socket do not have this

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Eric Dumazet
On Fri, 2017-02-03 at 09:00 +0900, Lorenzo Colitti wrote: > On Fri, Feb 3, 2017 at 6:32 AM, Daniel Borkmann wrote: > >> + sk = skb->sk; > >> + kuid = sock_net_uid(dev_net(skb->dev), sk); > > > > > > Don't you need to test for fullsock? Do you mean something like below? > > It should b

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Daniel Borkmann
On 02/03/2017 01:00 AM, Lorenzo Colitti wrote: On Fri, Feb 3, 2017 at 6:32 AM, Daniel Borkmann wrote: + sk = skb->sk; + kuid = sock_net_uid(dev_net(skb->dev), sk); Don't you need to test for fullsock? Do you mean something like below? It should be safe to call sock_net_uid on an

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Lorenzo Colitti
On Fri, Feb 3, 2017 at 6:32 AM, Daniel Borkmann wrote: >> + sk = skb->sk; >> + kuid = sock_net_uid(dev_net(skb->dev), sk); > > > Don't you need to test for fullsock? Do you mean something like below? It should be safe to call sock_net_uid on any type of socket (including NULL). sk_uid

Re: [PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Daniel Borkmann
On 02/02/2017 09:59 PM, Chenbo Feng wrote: From: Chenbo Feng Returns the owner uid of the socket inside a sk_buff. This is useful to perform per-UID accounting of network traffic or per-UID packet filtering. Signed-off-by: Chenbo Feng --- include/linux/bpf.h | 1 + include/uapi/linux

[PATCH net-next 2/2] Add a eBPF helper function to retrieve socket uid

2017-02-02 Thread Chenbo Feng
From: Chenbo Feng Returns the owner uid of the socket inside a sk_buff. This is useful to perform per-UID accounting of network traffic or per-UID packet filtering. Signed-off-by: Chenbo Feng --- include/linux/bpf.h | 1 + include/uapi/linux/bpf.h | 9 - net/core/filter.c