Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp32330imw; Tue, 12 Jul 2022 14:05:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ulIV6bCI6/zhdywtEFY2xE9evMyVLTBEkbD2MIbL4Z2jxePSQBOv5I8vL945R/JVoHg8ZZ X-Received: by 2002:a17:902:b198:b0:16c:1c13:cd8d with SMTP id s24-20020a170902b19800b0016c1c13cd8dmr25618145plr.92.1657659900482; Tue, 12 Jul 2022 14:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657659900; cv=none; d=google.com; s=arc-20160816; b=df8Zcac18cypTwaNFEeq0r8VO/qvoHM5IIF5vu+8d0RTBJ/jecZH+XbkQqZJUv2s3v nzsLZZTXzu9r3i5jLSAHgswPUlv/Z70dN6cbiE7SoOpbgwrGCBzUgT4wy3wPAih1ail1 q6cPAmv1D54ckIQ4fWBTRtVSTH0+t/YUWxxwa1nLG2BOmuztO7WeRW2wbD/9CRL1j3KK wPW1PhguAn9l3jF7zuQv7073BsWroDIqy60EDHprFhe9RRwCz5F7QIwCSQJzetGwZj2H Z3rL/rW6U/NmO+H4JYoKaUHBrWsthA7XxEJRvRySIteDXR1ln5ttlYsFnmi8t9kOf4sj oxtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=UmaN+lg1gVY00nS/FFRqdUXBbU3SwpvZPAY4iW8kINU=; b=I4em6qvT6pKvytqPFXaG7c34KjUcrdcFEOlDVZ5vDl3Kr0CcGyfbgUbTaoup5B7nJV Du4jxWnlsZ18eWMLzAYRv3SDZWLkpk1PQYZKiQfUg5OsAaSllfG6xvi5vcWcEcMwmUQN dRFAEsL5d7i+yfnkiYhyQrzhMArJtD/9q1EciCGZcgIXqTDgM950hKFdit+GIellBO/K DLpYb0cNqKceLFY8+uEbtWG9FXv41K57NJKF/o4VyYkq8B6QLzbDp0QTBkePh6rHOERs FwrNF15UEdYJlnuuTHPqefNWbjr0If7CFwysll7Qzq6peIe5SozwKcich5d4tMVg3IoZ jNvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JahOGRhQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020a056a000a8100b00528d3de8c76si16031291pfl.63.2022.07.12.14.04.22; Tue, 12 Jul 2022 14:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JahOGRhQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbiGLUrp (ORCPT + 99 others); Tue, 12 Jul 2022 16:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbiGLUro (ORCPT ); Tue, 12 Jul 2022 16:47:44 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C77831222 for ; Tue, 12 Jul 2022 13:47:42 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id i21-20020aa79095000000b00528bd947f66so2680012pfa.18 for ; Tue, 12 Jul 2022 13:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UmaN+lg1gVY00nS/FFRqdUXBbU3SwpvZPAY4iW8kINU=; b=JahOGRhQjUoYH60LNMTwoBdEccmWhGvwskp4rfCVpx6hGwVorvPWF/E7+XyBzuUWYy Aae2gHO54dT9ri42KU80XMdFRDcvraWnpX7VleGfAMo6DcWbXADZyPDdHv6Y7DLDmW+K ti8d8wt6YR8zc9yoDpHpzewPVVOWaZgY7KifsdyYRPSk+9hSAR4mo5Yd0D1GOwjeJ5ka gSDiyoXDx0mNdITZDRaTBwYhL1siKUSvqo7v/hXR+ry1w9u15WpBrpLngGuH7g0sO24q gMXBqqTJYlkB4LR8QlHdRxNk7uGJFWXW+Rj4qbA7Ce+TbJQEizGslfzLpyfS0vtzpcH6 G5+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UmaN+lg1gVY00nS/FFRqdUXBbU3SwpvZPAY4iW8kINU=; b=MVFrgZOzA54avTVN7+/YpMQHVYye2qyJ+Og3p+adKYm6JnVKGov8eZSENUVKb/QI5u 0vwY28eDhT0PnybWciN2YAPeCDY+JIqCI+lhZkW73FHpkPpHxb5CcH7VkTGaSRhT6y90 nMD8E9xDrpfyeVuioOfo/lT5gYIGoQJz4S0S4AI1m90YbfGR2bzbqDRLN7JE/dewK+ik iY/nxZ2aiyxxW6LC+ecM/BP5RxWGyepb0pLiIC8g3gXDFBVg6lkpLvRkSk3anx5AOb2+ eQdpgZjzF6oMXcCDBP1Hbm8ohs7JNWB2ETCClqOzWe7fDBcuH2fr7RGlFEB1z+rSys0r vVwA== X-Gm-Message-State: AJIora+a9ly7qzt89tJZnuRODptOlUXjCDLM8Yi+m3oDti5CAI5QP586 CKKcETp0oiDX3+VV0rKMBYi5h3U= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:903:20d4:b0:16b:da9d:975a with SMTP id i20-20020a17090320d400b0016bda9d975amr25520398plb.119.1657658862026; Tue, 12 Jul 2022 13:47:42 -0700 (PDT) Date: Tue, 12 Jul 2022 13:47:40 -0700 In-Reply-To: <20220712184225.52429-2-flaniel@linux.microsoft.com> Message-Id: Mime-Version: 1.0 References: <20220712184225.52429-1-flaniel@linux.microsoft.com> <20220712184225.52429-2-flaniel@linux.microsoft.com> Subject: Re: [RFC PATCH v1 1/1] bpftool: Add generating command to C dumped file. From: sdf@google.com To: Francis Laniel Cc: bpf@vger.kernel.org, Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , open list Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12, Francis Laniel wrote: > This commit adds the following lines to file generated by dump: > /* > * File generated by bpftool using: > * bpftool btf dump file /sys/kernel/btf/vmlinux format c > * DO NOT EDIT. > */ > This warns users to not edit the file and documents the command used to > generate the file. > Signed-off-by: Francis Laniel > --- > tools/bpf/bpftool/btf.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > index 7e6accb9d9f7..eecfc27370c3 100644 > --- a/tools/bpf/bpftool/btf.c > +++ b/tools/bpf/bpftool/btf.c > @@ -415,7 +415,8 @@ static void __printf(2, 0) btf_dump_printf(void *ctx, > } > static int dump_btf_c(const struct btf *btf, > - __u32 *root_type_ids, int root_type_cnt) > + __u32 *root_type_ids, int root_type_cnt, > + int argc, char **argv) > { > struct btf_dump *d; > int err = 0, i; > @@ -425,6 +426,14 @@ static int dump_btf_c(const struct btf *btf, > if (err) > return err; > + printf("/*\n"); > + printf(" * File generated by bpftool using:\n"); > + printf(" * bpftool btf dump"); [..] > + for (i = 0; i < argc; i++) > + printf(" %s", argv[i]); Do we really need that complexity to preserve the arguments? For skeletons we're simply doing: /* THIS FILE IS AUTOGENERATED BY BPFTOOL! */ So probably the same should be fine here? Also, while at it, might be worth adding SPDX license comment? So let's align with whatever we have in gen.c ? > + printf("\n"); > + printf(" * DO NOT EDIT.\n"); > + printf(" */\n"); > printf("#ifndef __VMLINUX_H__\n"); > printf("#define __VMLINUX_H__\n"); > printf("\n"); > @@ -507,8 +516,10 @@ static bool btf_is_kernel_module(__u32 btf_id) > static int do_dump(int argc, char **argv) > { > struct btf *btf = NULL, *base = NULL; > + char **orig_argv = argv; > __u32 root_type_ids[2]; > int root_type_cnt = 0; > + int orig_argc = argc; > bool dump_c = false; > __u32 btf_id = -1; > const char *src; > @@ -649,7 +660,8 @@ static int do_dump(int argc, char **argv) > err = -ENOTSUP; > goto done; > } > - err = dump_btf_c(btf, root_type_ids, root_type_cnt); > + err = dump_btf_c(btf, root_type_ids, root_type_cnt, > + orig_argc, orig_argv); > } else { > err = dump_btf_raw(btf, root_type_ids, root_type_cnt); > } > -- > 2.25.1