All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin@isovalent.com>
To: Stanislav Fomichev <sdf@google.com>
Cc: Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH bpf-next v2] bpftool: add current libbpf_strict mode to version output
Date: Mon, 15 Nov 2021 23:34:11 +0000	[thread overview]
Message-ID: <CACdoK4L0YOKXbKdLdBgGpZd_nrVq39wiZ+KoWUtAHP2CsR6RCg@mail.gmail.com> (raw)
In-Reply-To: <20211115193105.1952656-1-sdf@google.com>

On Mon, 15 Nov 2021 at 19:31, Stanislav Fomichev <sdf@google.com> wrote:
>
> + bpftool --legacy --version
> bpftool v5.15.0
> features: libbfd, skeletons
> + bpftool --version
> bpftool v5.15.0
> features: libbfd, libbpf_strict, skeletons
>
> + bpftool --legacy --help
> Usage: bpftool [OPTIONS] OBJECT { COMMAND | help }
>        bpftool batch file FILE
>        bpftool version
>
>        OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }
>        OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug} | {-l|--legacy} |
>                     {-V|--version} }
> + bpftool --help
> Usage: bpftool [OPTIONS] OBJECT { COMMAND | help }
>        bpftool batch file FILE
>        bpftool version
>
>        OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }
>        OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug} | {-l|--legacy} |
>                     {-V|--version} }
>
> + bpftool --legacy
> Usage: bpftool [OPTIONS] OBJECT { COMMAND | help }
>        bpftool batch file FILE
>        bpftool version
>
>        OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }
>        OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug} | {-l|--legacy} |
>                     {-V|--version} }
> + bpftool
> Usage: bpftool [OPTIONS] OBJECT { COMMAND | help }
>        bpftool batch file FILE
>        bpftool version
>
>        OBJECT := { prog | map | link | cgroup | perf | net | feature | btf | gen | struct_ops | iter }
>        OPTIONS := { {-j|--json} [{-p|--pretty}] | {-d|--debug} | {-l|--legacy} |
>                     {-V|--version} }
>
> + bpftool --legacy version
> bpftool v5.15.0
> features: libbfd, skeletons
> + bpftool version
> bpftool v5.15.0
> features: libbfd, libbpf_strict, skeletons
>
> + bpftool --json --legacy version
> {"version":"5.15.0","features":{"libbfd":true,"libbpf_strict":false,"skeletons":true}}
> + bpftool --json version
> {"version":"5.15.0","features":{"libbfd":true,"libbpf_strict":true,"skeletons":true}}
>
> v2:
> - fixes for -h and -V (Quentin Monnet)
>
> Suggested-by: Quentin Monnet <quentin@isovalent.com>
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

The behaviour will change in a few cases where both the help and
version commands and/or options are provided, e.g. "bpftool -h
version" used to print the help and will do the version instead,
"bpftool -V help" changes in an opposite fashion. Given that there's
no practical interest in having both commands/options, and that the
behaviour was not really consistent so far, I consider that this is
not an issue.

However, we now have "bpftool --version" returning -1 (instead of 0).
Any chance we can fix that? Maybe simply something like the change
below instead?

------
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 473791e87f7d..b2e67b0f02cf 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -400,6 +400,7 @@ int main(int argc, char **argv)
         { "legacy",    no_argument,    NULL,    'l' },
         { 0 }
     };
+    bool version_requested = false;
     int opt, ret;

     last_do_help = do_help;
@@ -414,7 +415,8 @@ int main(int argc, char **argv)
                   options, NULL)) >= 0) {
         switch (opt) {
         case 'V':
-            return do_version(argc, argv);
+            version_requested = true;
+            break;
         case 'h':
             return do_help(argc, argv);
         case 'p':
@@ -479,6 +481,9 @@ int main(int argc, char **argv)
     if (argc < 0)
         usage();

+    if (version_requested)
+        return do_version(argc, argv);
+
     ret = cmd_select(cmds, argc, argv, do_help);

     if (json_output)

  reply	other threads:[~2021-11-16  3:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 19:31 [PATCH bpf-next v2] bpftool: add current libbpf_strict mode to version output Stanislav Fomichev
2021-11-15 23:34 ` Quentin Monnet [this message]
2021-11-15 23:54   ` Stanislav Fomichev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACdoK4L0YOKXbKdLdBgGpZd_nrVq39wiZ+KoWUtAHP2CsR6RCg@mail.gmail.com \
    --to=quentin@isovalent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.