Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1238452pxb; Fri, 21 Jan 2022 13:05:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJy682ydj6KkzxquaStQebrwVYLfPdS0biKdJi1CJvc0SZLe3lqW+n48TVB/3ZM1LYTKF6pg X-Received: by 2002:a17:902:aa03:b0:14a:c57b:b570 with SMTP id be3-20020a170902aa0300b0014ac57bb570mr5442288plb.8.1642799113582; Fri, 21 Jan 2022 13:05:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799113; cv=none; d=google.com; s=arc-20160816; b=AjOUJLmvEXJFYM2TPimUr0HJxbHWzx5XtrHEOBR3pjswMvNzBuPsL6miWnF4qBc0gD wSmWN//oGOVr8bGVw7z3GD52zdDYvDmrJOlOybRv0FAmmmF6mfsDJSl5qnxLgMo0PEaz RPbFafOK0szR6tpyk+8CKkzGkxPHVqMG0Zt10ld3r8o3RtaeCvN+bP0R/2RcZShjx7oP 8d/xHXraVl1JhQOJl1HOZWwVSLofmJyCV2bv/OuXEiV36cLWJLFte+Eoc5sCXLOJJSoK pfateUgBY6t2rXdtqnQXFkY121dFlao3GMVtmb03gJWKoObyOF/6ijWsb6bD8tOe0oJZ 7jow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5O9D7ASqdDFucJQiKUFfcDp4wBTBWg4Hgx0/kZPiSxU=; b=l7mvlIJVNyNsx3IsnBAPRhbqs8J/aDELX4a49Si6D6V8plWYZrJAHlhfpT/vAbzSrg B9EnsSi47iiNGvtXYikjzJRHD3dP1dq/1N902/+dg+dZctP7gVf+lqOAceXtBhGt/MU7 K7vcR0VQpGPW/VJoM0a/amfXd14TgKWo6ZOBuQZUu6DYZLzW1VgncynPx2FP0q/TvTJh x3M59pMNYZKIkY5tgFh82gSa37Gcw9CdeLULKSFkaZySP1OJMsuElc+rWf+QazhGoJZS zSEZsi762lXJ+RrGuwtYa+Q0BOzXGo6C0ASB2b0Mmsr3LgfjRIi1i1XUWNxnWK8LQM/G +PtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ejvL66Bn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si6707171plr.18.2022.01.21.13.05.01; Fri, 21 Jan 2022 13:05:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ejvL66Bn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358431AbiATESA (ORCPT + 99 others); Wed, 19 Jan 2022 23:18:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235622AbiATER6 (ORCPT ); Wed, 19 Jan 2022 23:17:58 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE4D4C061574; Wed, 19 Jan 2022 20:17:57 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id v11-20020a17090a520b00b001b512482f36so1822149pjh.3; Wed, 19 Jan 2022 20:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5O9D7ASqdDFucJQiKUFfcDp4wBTBWg4Hgx0/kZPiSxU=; b=ejvL66BnCYzDxKqG+DD3FBrnNi3QE4YCQFR1pXSIb0BJSeJ8fKlwkKhNg9XNmfCjvF hd4vupjOjc4JmZnUUoGVbWYKz5jIunu41HFFQ0binTBWqMGQl5D3Rl5yzgMbp4rsxf4B jPT7KdJ+ispFIHWS19l6NI78PIoPQGpRaMczWKeJGZj8e0Z7Pn7T4GSUvxd3svEO+OZk 6by35hcA1y2ACeA+ma6Weo5clinm5oAuX9cJRJ5pt6MXx9iOuTI1YAldaWf6el2SnF0x J9I/D8/YoCLj5qg539NCA3DJLZGh5Hl13+HCWguO60kwIWKVKVDtjRDd1xpuH+2cL0v3 xzXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5O9D7ASqdDFucJQiKUFfcDp4wBTBWg4Hgx0/kZPiSxU=; b=ijAi+MKNfZl6kGX2H0iNbrGPYVIEUJC94QYjpMEFOyYMUxJzp+2diW38/YAkksbARB 38AjV3oJd14iSv+144JfA/gI5IjulYcq51nzGA9AydC3/VKImubUnugX1gZ1ZbU8LXBW r4dLsPjWn7Zwqlf8uH37VoWxOhuzzMwI+tqVbY+Ui5JiAeZKsOSUzfQOpW4Esdg/Ifo/ 93ROwMhnLMUj5gkeO1Q/6blOL6cgkUQrmrahMnCOX4IcuR+BXc8pGsT9fTTkzm+f2qHf cH2zgFxpOiBWKrzGduhGkf4HePOq1gwnyJQJCvQ/F6tttmmz739mAO58oxfAUKedlFs0 rmYQ== X-Gm-Message-State: AOAM530kzOt3YlZUM629zIXUgU4oslCx/IbZrMY+yq+ZNVV4gQFbqDTg xH84bYc4yvzzUTDUm6zWi74= X-Received: by 2002:a17:90a:2e09:: with SMTP id q9mr8409597pjd.2.1642652277409; Wed, 19 Jan 2022 20:17:57 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:400::5:9dc9]) by smtp.gmail.com with ESMTPSA id m21sm1111708pfk.185.2022.01.19.20.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 20:17:56 -0800 (PST) Date: Wed, 19 Jan 2022 20:17:54 -0800 From: Alexei Starovoitov To: Menglong Dong Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Network Development , bpf , LKML , Mengen Sun , flyingpeng@tencent.com, mungerjiang@tencent.com, Menglong Dong Subject: Re: [PATCH bpf-next] bpf: Add document for 'dst_port' of 'struct bpf_sock' Message-ID: <20220120041754.scj3hsrxmwckl7pd@ast-mbp.dhcp.thefacebook.com> References: <20220113070245.791577-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 11:02:27AM +0800, Menglong Dong wrote: > Hello! > > On Thu, Jan 20, 2022 at 6:03 AM Alexei Starovoitov > wrote: > > > [...] > > > > Looks like > > __sk_buff->remote_port > > bpf_sock_ops->remote_port > > sk_msg_md->remote_port > > are doing the right thing, > > but bpf_sock->dst_port is not correct? > > > > I think it's better to fix it, > > but probably need to consolidate it with > > convert_ctx_accesses() that deals with narrow access. > > I suspect reading u8 from three flavors of 'remote_port' > > won't be correct. > > What's the meaning of 'narrow access'? Do you mean to > make 'remote_port' u16? Or 'remote_port' should be made > accessible with u8? In fact, '*((u16 *)&skops->remote_port + 1)' > won't work, as it only is accessible with u32. u8 access to remote_port won't pass the verifier, but u8 access to dst_port will. Though it will return incorrect data. See how convert_ctx_accesses() handles narrow loads. I think we need to generalize it for different endian fields.