From: Alexei Starovoitov Subject: Re: [PATCH net-next v4 1/3] Add a helper function to get socket cookie in eBPF Date: Mon, 20 Mar 2017 08:53:44 -0700 Message-ID: <20170320155343.GC80094@ast-mbp.thefacebook.com> References: <1489968524-2495-1-git-send-email-chenbofeng.kernel@gmail.com> <1489968524-2495-2-git-send-email-chenbofeng.kernel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Lorenzo Colitti , Willem de Bruijn , Chenbo Feng To: Chenbo Feng Return-path: Received: from mail-pf0-f194.google.com ([209.85.192.194]:36425 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754985AbdCTQAq (ORCPT ); Mon, 20 Mar 2017 12:00:46 -0400 Received: by mail-pf0-f194.google.com with SMTP id r137so14114604pfr.3 for ; Mon, 20 Mar 2017 09:00:45 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1489968524-2495-2-git-send-email-chenbofeng.kernel@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, Mar 19, 2017 at 05:08:42PM -0700, 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 useful in monitoring per socket networking traffic > statistics and provide a unique socket identifier per namespace. > > Signed-off-by: Chenbo Feng Acked-by: Alexei Starovoitov > @@ -2633,6 +2646,8 @@ sk_filter_func_proto(enum bpf_func_id func_id) > switch (func_id) { > case BPF_FUNC_skb_load_bytes: > return &bpf_skb_load_bytes_proto; > + case BPF_FUNC_get_socket_cookie: > + return &bpf_get_socket_cookie_proto; > default: > return bpf_base_func_proto(func_id); > } > @@ -2692,6 +2707,8 @@ tc_cls_act_func_proto(enum bpf_func_id func_id) > return &bpf_get_smp_processor_id_proto; > case BPF_FUNC_skb_under_cgroup: > return &bpf_skb_under_cgroup_proto; > + case BPF_FUNC_get_socket_cookie: > + return &bpf_get_socket_cookie_proto; > default: > return bpf_base_func_proto(func_id); Not related to this patch, but we probably need a separate cleanup to enable these two new helpers on lwt and cg_skb. All of them should probably be calling sk_filter_func_proto() instead of bpf_base_func_proto().