Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380AbbFPRLG (ORCPT ); Tue, 16 Jun 2015 13:11:06 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:33046 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044AbbFPRK7 (ORCPT ); Tue, 16 Jun 2015 13:10:59 -0400 Message-ID: <558058A0.7030201@plumgrid.com> Date: Tue, 16 Jun 2015 10:10:56 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Daniel Borkmann , David Miller CC: luto@amacapital.net, mingo@kernel.org, rostedt@goodmis.org, wangnan0@huawei.com, lizefan@huawei.com, daniel.wagner@bmw-carit.de, linux-api@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 net-next 0/3] bpf: share helpers between tracing and networking References: <1434163154-5218-1-git-send-email-ast@plumgrid.com> <20150615.160130.583783771772303463.davem@davemloft.net> <557F97F3.6060400@plumgrid.com> <557FEA2C.5080408@iogearbox.net> In-Reply-To: <557FEA2C.5080408@iogearbox.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1464 Lines: 26 On 6/16/15 2:19 AM, Daniel Borkmann wrote: > if you really want to, you > could go via skb->sk->sk_socket->file and then retrieve credentials > from there for egress side (you can have a look at xt_owner). You'd > need a different *_proto helper for tc in that case, which would > then map to BPF_FUNC_get_current_uid_gid, etc. But that doesn't work > for ingress however, even if you would have early demux, so you > would need to let the eBPF helper function return an error code in > that case. was looking at cls_flow to do exactly that, but with different helper name. Like bpf_get_socket_uid_gid(). The use case is to collect network statistics per-user and per-process. I think android still using some out of tree hacks for that. Ingress indeed is not solved by this skb->sk->sk_socket approach. I considered kprobe style, but accessing skb->len via probe_read is kernel specific, nonportable and slow-ish. Ideally we would allow a blend of tracing and networking programs, then the best solution would be one or two stable tracepoints in networking stack where skb is visible and receiving/transmitting task is also visible, then skb->len and task->pid together would give nice foundation for accurate stats. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/