mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
tools: bpftool: add a command to display bpftool version
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> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8dfbc6d1d2
commit
821cfbb0dc
2 changed files with 15 additions and 1 deletions
|
@ -14,6 +14,8 @@ SYNOPSIS
|
||||||
|
|
||||||
**bpftool** batch file *FILE*
|
**bpftool** batch file *FILE*
|
||||||
|
|
||||||
|
**bpftool** version
|
||||||
|
|
||||||
*OBJECT* := { **map** | **program** }
|
*OBJECT* := { **map** | **program** }
|
||||||
|
|
||||||
*MAP-COMMANDS* :=
|
*MAP-COMMANDS* :=
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/bpf.h>
|
#include <linux/bpf.h>
|
||||||
|
#include <linux/version.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -62,13 +63,23 @@ static int do_help(int argc, char **argv)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s OBJECT { COMMAND | help }\n"
|
"Usage: %s OBJECT { COMMAND | help }\n"
|
||||||
" %s batch file FILE\n"
|
" %s batch file FILE\n"
|
||||||
|
" %s version\n"
|
||||||
"\n"
|
"\n"
|
||||||
" OBJECT := { prog | map }\n",
|
" OBJECT := { prog | map }\n",
|
||||||
bin_name, bin_name);
|
bin_name, bin_name, bin_name);
|
||||||
|
|
||||||
return 0;
|
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 cmd_select(const struct cmd *cmds, int argc, char **argv,
|
||||||
int (*help)(int argc, char **argv))
|
int (*help)(int argc, char **argv))
|
||||||
{
|
{
|
||||||
|
@ -128,6 +139,7 @@ static const struct cmd cmds[] = {
|
||||||
{ "batch", do_batch },
|
{ "batch", do_batch },
|
||||||
{ "prog", do_prog },
|
{ "prog", do_prog },
|
||||||
{ "map", do_map },
|
{ "map", do_map },
|
||||||
|
{ "version", do_version },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue