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=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 84DF2ECE58F for ; Tue, 15 Oct 2019 23:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CCFD20659 for ; Tue, 15 Oct 2019 23:45:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fomichev-me.20150623.gappssmtp.com header.i=@fomichev-me.20150623.gappssmtp.com header.b="Zg86mDDW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387856AbfJOXpy (ORCPT ); Tue, 15 Oct 2019 19:45:54 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38285 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbfJOXpy (ORCPT ); Tue, 15 Oct 2019 19:45:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id h195so13485260pfe.5 for ; Tue, 15 Oct 2019 16:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zde/2EvOGyJVHgELKq3tUH6iDHa5DC1abeaGck2Hkeg=; b=Zg86mDDWBEjHecKXKUnKcm6jCJvouNz1uVLYrpeKJBIEEpp1EdotbSguvhU8SYOAqz fIxIcRM8cMpjqAYuMfo4EPYNL/y752pVbIbOTXJHaIxd1dF6JN091zp/4mKULxxzW4+Z ZGQ66fkFzQLuo5hYoDYIV2K5vWWWIDodcQTYrv6B4l644zaeO8wn3XF51bMpf2C5GOzj qWZ4Y2uyVLObYYLPjl7Tq7j5kQrrq8LD47xZfSmksNadQb4A2HW/wDY67RgmLFtwD490 NKi91yQfy9l1LZKgzfP6MCs4rvfbNBC6j+bEPQMFnoejhYO3Vq5EtN/oD4oFYMJyazaQ sMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zde/2EvOGyJVHgELKq3tUH6iDHa5DC1abeaGck2Hkeg=; b=f/RMMiCqUNuMX0+4Zb9Bm3f9tCBBPbb1CRKYZy6Muoi87V9D+f+K2ZmxN7YdGoHdhV my++g/HeM4si4VyLi/4JyPhEL3JfaP7HQF3PufGWb/ZlwC05iC14aJNOzvWVEXNh4FG+ eebdlfZuq2B/K63qw+jib4x42bFcjOffZq9YV3/ZQ3ctqAA7pE3Irf1uSUie5e6A2yFY 1negCnRXGa2kSvSgcRgEhSuuXV1pwcTqX5N1uAHsYR2S28HAJakHRQDJOhvSh4DaFhUU 8b4N5X5BdK6ZkWE/CeW+Dp7TK//iqWO28ZUKq4lTO1azxsxlR7J6ZIQa5C6dmQKUHJdH 4FiQ== X-Gm-Message-State: APjAAAX4mldYiVSpRGi0tNvhRVygDzHnHV8/Ukb3PTw3Pp7yrhzTlcCG n50OM4g0grR7f55DIOsZxEX7cA== X-Google-Smtp-Source: APXvYqzen9OMXKNPAMisvZj8Ft/zTLPHT3WPx5UqTdL7nBQZJFMktDJFDKXRWA6oKSP72gjBwrICHQ== X-Received: by 2002:a62:6842:: with SMTP id d63mr40591333pfc.16.1571183153820; Tue, 15 Oct 2019 16:45:53 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id w14sm42330817pge.56.2019.10.15.16.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 16:45:53 -0700 (PDT) Date: Tue, 15 Oct 2019 16:45:52 -0700 From: Stanislav Fomichev To: Alexei Starovoitov Cc: Andrii Nakryiko , Stanislav Fomichev , Networking , bpf , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann Subject: Re: [PATCH bpf-next 1/2] bpf: allow __sk_buff tstamp in BPF_PROG_TEST_RUN Message-ID: <20191015234552.GC1897241@mini-arch> References: <20191015183125.124413-1-sdf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 10/15, Alexei Starovoitov wrote: > On Tue, Oct 15, 2019 at 4:15 PM Andrii Nakryiko > wrote: > > > > On Tue, Oct 15, 2019 at 2:26 PM Stanislav Fomichev wrote: > > > > > > It's useful for implementing EDT related tests (set tstamp, run the > > > test, see how the tstamp is changed or observe some other parameter). > > > > > > Note that bpf_ktime_get_ns() helper is using monotonic clock, so for > > > the BPF programs that compare tstamp against it, tstamp should be > > > derived from clock_gettime(CLOCK_MONOTONIC, ...). > > > > > > Signed-off-by: Stanislav Fomichev > > > --- > > > net/bpf/test_run.c | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c > > > index 1153bbcdff72..0be4497cb832 100644 > > > --- a/net/bpf/test_run.c > > > +++ b/net/bpf/test_run.c > > > @@ -218,10 +218,18 @@ static int convert___skb_to_skb(struct sk_buff *skb, struct __sk_buff *__skb) > > > > > > if (!range_is_zero(__skb, offsetof(struct __sk_buff, cb) + > > > FIELD_SIZEOF(struct __sk_buff, cb), > > > + offsetof(struct __sk_buff, tstamp))) > > > + return -EINVAL; > > > + > > > + /* tstamp is allowed */ > > > + > > > + if (!range_is_zero(__skb, offsetof(struct __sk_buff, tstamp) + > > > + FIELD_SIZEOF(struct __sk_buff, tstamp), > > > > with no context on this particular change whatsoever: isn't this the > > same as offsetofend(struct __sk_buff, tstamp)? Same above for cb. > > > > Overall, this seems like the 4th similar check, would it make sense to > > add a static array of ranges we want to check for zeros and just loop > > over it?.. > > I wouldn't bother, but offsetofend() is a good suggestion that > can be done in a followup. > > Applied both patches. Thanks Thanks. I'll follow up with offsetofend, sounds like a good suggestion that can eliminate a bit of copy paste.