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 9990FC169C4 for ; Fri, 8 Feb 2019 08:56:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FF2221920 for ; Fri, 8 Feb 2019 08:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727422AbfBHI4V (ORCPT ); Fri, 8 Feb 2019 03:56:21 -0500 Received: from www62.your-server.de ([213.133.104.62]:44706 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbfBHI4U (ORCPT ); Fri, 8 Feb 2019 03:56:20 -0500 Received: from [78.46.172.3] (helo=sslproxy06.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 1gs1xL-0003fh-1U; Fri, 08 Feb 2019 09:56:19 +0100 Received: from [2a02:1203:ecb1:b710:c81f:d2d6:50a9:c2d] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gs1xK-00080Y-RR; Fri, 08 Feb 2019 09:56:18 +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> <58d44fb9-a10b-d6dd-6313-60f7802e4519@iogearbox.net> <20190208055601.wwqqi2bpwtfft4nz@kafai-mbp.dhcp.thefacebook.com> From: Daniel Borkmann Message-ID: Date: Fri, 8 Feb 2019 09:56:18 +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: <20190208055601.wwqqi2bpwtfft4nz@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/08/2019 06:56 AM, Martin Lau wrote: > On Thu, Feb 07, 2019 at 11:21:41PM +0100, Daniel Borkmann wrote: >> 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? > I will add sk_to_full_sk() to bpf_sk_fullsock() and bpf_tcp_sock(). Ok, sounds good, thanks!