From: Daniel Borkmann Subject: Re: [PATCH bpf-next] bpf: allow BPF read access to qdisc pkt_len Date: Sat, 1 Dec 2018 01:41:00 +0100 Message-ID: References: <20181130200831.165645-1-willemdebruijn.kernel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Network Development , Alexei Starovoitov , Petar Penkov , Vlad Dumitrescu , Petar Penkov , Willem de Bruijn To: Willem de Bruijn , liu.song.a23@gmail.com Return-path: Received: from www62.your-server.de ([213.133.104.62]:44010 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbeLALwM (ORCPT ); Sat, 1 Dec 2018 06:52:12 -0500 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 12/01/2018 12:42 AM, Willem de Bruijn wrote: > On Fri, Nov 30, 2018 at 5:48 PM Song Liu wrote: >> >> On Fri, Nov 30, 2018 at 12:09 PM Willem de Bruijn >> wrote: >>> >>> From: Petar Penkov >>> >>> The pkt_len field in qdisc_skb_cb stores the skb length as it will >>> appear on the wire after segmentation. For byte accounting, this value >>> is more accurate than skb->len. It is computed on entry to the TC >>> layer, so only valid there. >>> >>> Allow read access to this field from BPF tc classifier and action >>> programs. The implementation is analogous to tc_classid, aside from >>> restricting to read access. >>> >>> Signed-off-by: Petar Penkov >>> Signed-off-by: Vlad Dumitrescu >>> Signed-off-by: Willem de Bruijn >>> --- >>> include/uapi/linux/bpf.h | 1 + >>> net/core/filter.c | 16 +++++++++++ >>> tools/include/uapi/linux/bpf.h | 1 + >>> tools/testing/selftests/bpf/test_verifier.c | 32 +++++++++++++++++++++ >>> 4 files changed, 50 insertions(+) >> >> Please split this into 3 patches: >> 1 for include/uapi/linux/bpf.h and filter.c >> 1 for tools/include/uapi/linux/bpf.h >> 1 for tools/testing/selftests/bpf/test_verifier.c >> >> Other than this >> Acked-by: Song Liu > > Thanks for the fast review. > > I'm happy to resend in three parts, of course, but am curious: what is > the rationale for splitting this up? > > This patch follows the process for commit f11216b24219 ("bpf: add > skb->tstamp r/w access from tc clsact and cg skb progs"), which went > in as a single patch just last week. Yeah, I think it's fine as is, one small thing I'm wondering though is given that we now would have both 'skb->len' and 'skb->pkt_len', would it be more intuitive for a BPF program developer to distinguish the two by having the latter named e.g. 'skb->wire_len' so it's slightly more obvious that it's including header size at post-segmentation? If not probably some comment in the uapi header similar as in qdisc_pkt_len_init() might be helpful in any case. Thanks, Daniel