From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4905AC282C2 for ; Thu, 7 Feb 2019 22:21:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18F3E21907 for ; Thu, 7 Feb 2019 22:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727074AbfBGWVo (ORCPT ); Thu, 7 Feb 2019 17:21:44 -0500 Received: from www62.your-server.de ([213.133.104.62]:50170 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbfBGWVo (ORCPT ); Thu, 7 Feb 2019 17:21:44 -0500 Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1grs3C-0005Ie-OW; Thu, 07 Feb 2019 23:21:42 +0100 Received: from [178.197.249.40] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1grs3C-0008Xe-Hh; Thu, 07 Feb 2019 23:21:42 +0100 Subject: Re: [PATCH bpf-next 1/6] bpf: Add a bpf_sock pointer to __sk_buff and a bpf_sk_fullsock helper To: Martin Lau Cc: "netdev@vger.kernel.org" , Alexei Starovoitov , Kernel Team , Lawrence Brakmo References: <20190201070356.4148189-1-kafai@fb.com> <20190201070356.4148323-1-kafai@fb.com> <51fe0012-e294-078a-4fc4-6151f8b55195@iogearbox.net> <20190205005029.yxowrbz4aiht7jhm@kafai-mbp> <20190207072716.qat44fx2t6wqvu4l@kafai-mbp.dhcp.thefacebook.com> From: Daniel Borkmann Message-ID: <58d44fb9-a10b-d6dd-6313-60f7802e4519@iogearbox.net> Date: Thu, 7 Feb 2019 23:21:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190207072716.qat44fx2t6wqvu4l@kafai-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.2/25353/Thu Feb 7 12:01:32 2019) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/07/2019 08:27 AM, Martin Lau wrote: [...] > Following up the discussion in the iovisor conf call. > > One of discussion was about: > other than tw, can __sk_buff->sk always return a > fullsock (PTR_TO_SOCKET_OR_NULL). In request_sock case, > it is doable because it can trace back to the listener sock. > > However, that will go back to the sock_common accessing question. > In particular, how to access the sock_common's fields of the > request_sock itself? Those fields in the request_sock are different > from its listener sock. e.g. the skc_daddr and skc_dport. > > Also, if the sock_common fields of tw is needed, it will become weird > because likely a new "struct bpf_tw_sock" is needed which is OK > but all sock_common fields need to be copied from bpf_sock > to bpf_tw_sock. > > I think reading a sk from a ctx should return the > most basic type PTR_TO_SOCK_COMMON_OR_NULL (unless the running > ctx can guarantee that it always has a fullsock). > Currently, it is __sk_buff->sk. Later, sock_ops->sk...etc. > One single 'struct bpf_sock' and limit fullsock field access > at verification time. The bpf_prog then moves down the chain > based on what it needs. It could be fullsock, tcp_sock...etc. > > I think that will be the most flexible way to write bpf_prog > while also avoid having duplicate fields in different > bpf struct in uapi. Ok, thanks for following up and sorry for late reply, lets go with sock_common then. What's the plan to moving forward with accessing full sk in case of req sk? Separate helper or backed into the newly added bpf_sk_fullsock() one? Presumably latter? Thanks, Daniel