Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1237700pxb; Fri, 21 Jan 2022 13:04:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUD42/v4q19L08BJu6pOyXVmWC3zbgrBCa/rn5bJRawOvVTGitPrTsCoB2PgnMoI8x8x4X X-Received: by 2002:a17:902:f68a:b0:14a:3fd3:f318 with SMTP id l10-20020a170902f68a00b0014a3fd3f318mr5457007plg.113.1642799061491; Fri, 21 Jan 2022 13:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799061; cv=none; d=google.com; s=arc-20160816; b=T81tp5qLxNFQJiGjbaF+FlDZB7oGj9JPtnd78ev/uNAUmUqZfEoF0x2mcLzxNusy/I eoolne9DCICqRPG9BoFH7tT094kgJoawPMWJWOhDsMRo0z+K7ZuSiUAhFrugKpf5m3QX kNKk5u6rfNTFST+WNZje4EjyN6mK3mLIKivOUchFxReArE0V8NfRpbCXUUkHcDQm3sjr khz5rn9znq92W8PzyDhFF9xtAHqRI8hNwupBWO7dPBkkQ6Va3gkZbJr086O81a+eC1Vv QfXCuyio8kC9Y7fvxUzbOuAXKybybPQd/0yJbBQUgkneUVmqB2gRgaBEj17T9vxERjS6 9GQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6AciR2AKfyPUvmQqqeZADltLycshLQ4pZRWrBxQwNds=; b=i2iuSATeqjEVwguda7GeWKJXXNokaB0HdQrf9PCZN8yJ1H0JLx/mh1XHqp356IMObu 7tPtmH44A4ux5OUkEhfk3eltNi1+aIFDi3SJ2rLQIb4ABXwHVSjJ96yun78SvM9Rm7pk Cj6XL/Fz6zoOtQ+wS32XpxNj6r/05Tn7Z2lliXslBswIbiVEVrmx3VsURgM132EybtCW Gd6DnDZdMhDz1qtFu8MMOBKuiGwYXzynj7+5emeBZRZoHibXj9bngbQvzYFq0MDpFivo Yk6uINlTsxpjFqoIijd1kutsgG5eeOf6MXFHlqJVHKAkRDQ2Q2wdSvoiG/vrj7ktlEKf WDXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=au9z0HdV; 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 w4si8456370pfu.105.2022.01.21.13.04.08; Fri, 21 Jan 2022 13:04:21 -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=au9z0HdV; 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 S1358263AbiATDHS (ORCPT + 99 others); Wed, 19 Jan 2022 22:07:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiATDHR (ORCPT ); Wed, 19 Jan 2022 22:07:17 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A46C061574; Wed, 19 Jan 2022 19:07:15 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id c24so20196161edy.4; Wed, 19 Jan 2022 19:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6AciR2AKfyPUvmQqqeZADltLycshLQ4pZRWrBxQwNds=; b=au9z0HdVBZBLq5GfMsCVAczVs4JxTYHuhw8YWbzU3jXlJyCU6DL0bwgPzEtW8Q8pMO w2QzOztChaWzGqqbCBStS3qGn94DQneWOlOTDG1rf8+JZ9spA8lXCOidJkdOepG+cHEr /J0j1QXW9Ez241MyXdzdKzKCUecaofMtnlFj3posuMFpcDABBbEC2r0wkXW836j8KsDz Jf2plTDfzee+VKHPwUt+gw0i/RuaN+WQqbP+akYY7AYCDR67q51uOuNr7q19WHiQHu3X FzocVx7JtVwd3smRGeMxDwSbO1r79iQuhiJ1Jgw7q1e8Bdig/ilWPj1V22s9btrBfWBd uNhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6AciR2AKfyPUvmQqqeZADltLycshLQ4pZRWrBxQwNds=; b=zc76t+ayH30k4aoEfSxZcgqlEDPE3jSd+MwH+cJ6X+Vr8tGHC1OHqEu+i9r8jLYIiw oJIFtvkpUwCYPgf9Wk5d2/Z8jPoRRq+evz72IhxQcqlSx6bJUoeRlo7UsZ5kh/GnzEuG hvt5OnCaeHcP+9/Aa6eitKWRP/PgfieEoD22Rha3va18vT/r8sEZp4lay2FFleI9+LgM 9HjMkj3XD65xWsrcxyxwnFIKm+v8HwuIKiA2lTibgNr614bRrxFQb4JMy1d/rAeE4m7F v7Ml8T9y/nmD5czybV2ufg55A7Ake/I9SEoZKo/z0D6bB6DJkTquNpQbD4tQ2WBGEOl8 JT7g== X-Gm-Message-State: AOAM533EaQRQL9P2rbjZ/bV5JUUvDVoDPkftGsGwYyTbz15SpfAZK+og kYtJm4tSNNuCafgr27lfSLfyvLO0VnY+1fBM210= X-Received: by 2002:a05:6402:34c9:: with SMTP id w9mr34197425edc.403.1642648009169; Wed, 19 Jan 2022 19:06:49 -0800 (PST) MIME-Version: 1.0 References: <20220113070245.791577-1-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Thu, 20 Jan 2022 11:02:27 +0800 Message-ID: Subject: Re: [PATCH bpf-next] bpf: Add document for 'dst_port' of 'struct bpf_sock' To: Alexei Starovoitov 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I can simply make 'dst_port' endianness right with what 'remote_port' do. Thanks! Menglong Dong > 'dst_port' works with a narrow load, but gets endianness wrong.