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=-6.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 BD0F6C433E2 for ; Fri, 11 Sep 2020 14:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88E19222D5 for ; Fri, 11 Sep 2020 14:44:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RTpDK0Th" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725899AbgIKOn1 (ORCPT ); Fri, 11 Sep 2020 10:43:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21666 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726192AbgIKNDR (ORCPT ); Fri, 11 Sep 2020 09:03:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599829368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Oqtp+pU6EVX5K85gU9EYn6QWRvb00undsqSAgRZGvwg=; b=RTpDK0Th+/1iYevBS8TVp63NXYXnNBcc2fmuX1p9OcZ424O+72UegBbxIlHM3r8idOo/qk JmlUX0c6DJ/gtWwxEhf2QLzQRi7aKmNA+Nwf0PS/2M58Wt0dzUNK5itVIqwXjBcdsIvjS+ EzBDM5hWP/qxgxRJMutSQDnjXrh2ttk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-kt3iaoLZOAWSvM6rs-mcOA-1; Fri, 11 Sep 2020 09:02:47 -0400 X-MC-Unique: kt3iaoLZOAWSvM6rs-mcOA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CC75802B46; Fri, 11 Sep 2020 13:02:45 +0000 (UTC) Received: from krava (unknown [10.40.192.120]) by smtp.corp.redhat.com (Postfix) with SMTP id 39C7B75129; Fri, 11 Sep 2020 13:02:34 +0000 (UTC) Date: Fri, 11 Sep 2020 15:02:32 +0200 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Networking , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Jesper Dangaard Brouer , Eelco Chaudron , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Adding test for arg dereference in extension trace Message-ID: <20200911130232.GB1714160@krava> References: <20200909151115.1559418-1-jolsa@kernel.org> <20200909151115.1559418-2-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Sep 10, 2020 at 03:34:26PM -0700, Andrii Nakryiko wrote: SNIP > > + > > +void test_trace_ext(void) > > +{ > > + struct test_trace_ext_tracing *skel_trace = NULL; > > + struct test_trace_ext_tracing__bss *bss_trace; > > + const char *file = "./test_pkt_md_access.o"; > > + struct test_trace_ext *skel_ext = NULL; > > + struct test_trace_ext__bss *bss_ext; > > + int err, prog_fd, ext_fd; > > + struct bpf_object *obj; > > + char buf[100]; > > + __u32 retval; > > + __u64 len; > > + > > + err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd); > > + if (CHECK_FAIL(err)) > > + return; > > We should avoid using bpf_prog_load() for new code. Can you please > just skeleton instead? Or at least bpf_object__open_file()? ok > > > + > > + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, > > + .attach_prog_fd = prog_fd, > > + ); > > DECLARE_LIBBPF_OPTS does declare a variable, so should be together > with all the other variables above, otherwise some overly strict C89 > mode compiler will start complaining. You can assign > `opts.attach_prog_fd = prog_fd;` outside of declaration. But I also > don't think you need this one. Having .attach_prog_fd in open_opts is > not great, because it's a per-program setting specified at bpf_object > level. Would bpf_program__set_attach_target() work here? right, I'll try it, it should be enough SNIP > > + > > +cleanup: > > + test_trace_ext__destroy(skel_ext); > > + bpf_object__close(obj); > > +} > > diff --git a/tools/testing/selftests/bpf/progs/test_trace_ext.c b/tools/testing/selftests/bpf/progs/test_trace_ext.c > > new file mode 100644 > > index 000000000000..a6318f6b52ee > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/test_trace_ext.c > > @@ -0,0 +1,18 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +// Copyright (c) 2019 Facebook > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +volatile __u64 ext_called = 0; > > nit: no need for volatile, global variables are not going anywhere; > same below in two places ok, thanks jirka