Re: [PATCH net-next v2 1/2] Add a helper function to get socket cookie in eBPF

2017-02-06 Thread Daniel Borkmann
On 02/06/2017 03:17 AM, Chenbo Feng wrote: From: Chenbo Feng Retrieve the socket cookie generated by sock_gen_cookie() from a sk_buff with a known socket. Generates a new cookie if one was not yet set.If the socket pointer inside sk_buff is NULL, 0 is returned. The helper function coud be usefu

Re: [PATCH net-next v2 1/2] Add a helper function to get socket cookie in eBPF

2017-02-05 Thread Eric Dumazet
On Mon, 2017-02-06 at 12:01 +0900, Lorenzo Colitti wrote: > On Mon, Feb 6, 2017 at 11:17 AM, Chenbo Feng > wrote: > > +BPF_CALL_1(bpf_get_socket_cookie, struct sk_buff *, skb) > > +{ > > + return skb->sk ? sock_gen_cookie(skb->sk) : 0; > > +} > > + > > Does this code need to increment the s

Re: [PATCH net-next v2 1/2] Add a helper function to get socket cookie in eBPF

2017-02-05 Thread Lorenzo Colitti
On Mon, Feb 6, 2017 at 11:17 AM, Chenbo Feng wrote: > +BPF_CALL_1(bpf_get_socket_cookie, struct sk_buff *, skb) > +{ > + return skb->sk ? sock_gen_cookie(skb->sk) : 0; > +} > + Does this code need to increment the socket refcount, or call ACCESS_ONCE to get skb->sk? The socket filter codepa

Re: [PATCH net-next v2 1/2] Add a helper function to get socket cookie in eBPF

2017-02-05 Thread Eric Dumazet
On Sun, 2017-02-05 at 18:17 -0800, Chenbo Feng wrote: > From: Chenbo Feng > > Retrieve the socket cookie generated by sock_gen_cookie() from a sk_buff > with a known socket. Generates a new cookie if one was not yet set.If > the socket pointer inside sk_buff is NULL, 0 is returned. The helper > f

[PATCH net-next v2 1/2] Add a helper function to get socket cookie in eBPF

2017-02-05 Thread Chenbo Feng
From: Chenbo Feng Retrieve the socket cookie generated by sock_gen_cookie() from a sk_buff with a known socket. Generates a new cookie if one was not yet set.If the socket pointer inside sk_buff is NULL, 0 is returned. The helper function coud be useful in monitoring per socket networking traffic