netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: oss-drivers@netronome.com,
	Quentin Monnet <quentin.monnet@netronome.com>,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 8/8] tools: bpftool: add a command to display bpftool version
Date: Thu, 19 Oct 2017 15:46:26 -0700	[thread overview]
Message-ID: <20171019224626.31608-9-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20171019224626.31608-1-jakub.kicinski@netronome.com>

From: Quentin Monnet <quentin.monnet@netronome.com>

This command can be used to print the version of the tool, which is in
fact the version from Linux taken from usr/include/linux/version.h.

Example usage:

    $ bpftool version
    bpftool v4.14.0

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/Documentation/bpftool.rst |  2 ++
 tools/bpf/bpftool/main.c                    | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/Documentation/bpftool.rst b/tools/bpf/bpftool/Documentation/bpftool.rst
index f1df1893fb54..45ad8baf1915 100644
--- a/tools/bpf/bpftool/Documentation/bpftool.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool.rst
@@ -14,6 +14,8 @@ SYNOPSIS
 
 	**bpftool** batch file *FILE*
 
+	**bpftool** version
+
 	*OBJECT* := { **map** | **program** }
 
 	*MAP-COMMANDS* :=
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 8662199ee050..814d19e1b53f 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -37,6 +37,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <linux/bpf.h>
+#include <linux/version.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -62,13 +63,23 @@ static int do_help(int argc, char **argv)
 	fprintf(stderr,
 		"Usage: %s OBJECT { COMMAND | help }\n"
 		"       %s batch file FILE\n"
+		"       %s version\n"
 		"\n"
 		"       OBJECT := { prog | map }\n",
-		bin_name, bin_name);
+		bin_name, bin_name, bin_name);
 
 	return 0;
 }
 
+static int do_version(int argc, char **argv)
+{
+	printf("%s v%d.%d.%d\n", bin_name,
+	       LINUX_VERSION_CODE >> 16,
+	       LINUX_VERSION_CODE >> 8 & 0xf,
+	       LINUX_VERSION_CODE & 0xf);
+	return 0;
+}
+
 int cmd_select(const struct cmd *cmds, int argc, char **argv,
 	       int (*help)(int argc, char **argv))
 {
@@ -128,6 +139,7 @@ static const struct cmd cmds[] = {
 	{ "batch",	do_batch },
 	{ "prog",	do_prog },
 	{ "map",	do_map },
+	{ "version",	do_version },
 	{ 0 }
 };
 
-- 
2.14.1

  parent reply	other threads:[~2017-10-19 22:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 22:46 [PATCH net-next 0/8] tools: bpftool: add a "version" command, and fix several items Jakub Kicinski
2017-10-19 22:46 ` [PATCH net-next 1/8] tools: bpftool: add pointer to file argument to print_hex() Jakub Kicinski
2017-10-20 10:55   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 2/8] tools: bpftool: fix return value when all eBPF programs have been shown Jakub Kicinski
2017-10-20 10:55   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 3/8] tools: bpftool: use err() instead of info() if there are too many insns Jakub Kicinski
2017-10-20 10:55   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 4/8] tools: bpftool: add `bpftool prog help` as real command i.r.t exit code Jakub Kicinski
2017-10-20 10:56   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 5/8] tools: bpftool: print only one error message on byte parsing failure Jakub Kicinski
2017-10-20 10:56   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 6/8] tools: bpftool: print all relevant byte opcodes for "load double word" Jakub Kicinski
2017-10-20  9:59   ` David Laight
2017-10-20 15:50     ` Quentin Monnet
2017-10-20 16:12       ` Daniel Borkmann
2017-10-20 16:41         ` Quentin Monnet
2017-10-20 10:56   ` Daniel Borkmann
2017-10-19 22:46 ` [PATCH net-next 7/8] tools: bpftool: show that `opcodes` or `file FILE` should be exclusive Jakub Kicinski
2017-10-20 10:56   ` Daniel Borkmann
2017-10-19 22:46 ` Jakub Kicinski [this message]
2017-10-20 10:57   ` [PATCH net-next 8/8] tools: bpftool: add a command to display bpftool version Daniel Borkmann
2017-10-19 23:42 ` [PATCH net-next 0/8] tools: bpftool: add a "version" command, and fix several items Alexei Starovoitov
2017-10-22  1:11 ` David Miller

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=20171019224626.31608-9-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=quentin.monnet@netronome.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).