Message ID | 20220131211136.71010-3-quentin@isovalent.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | bpftool: Switch to independent versioning scheme | expand |
On Mon, Jan 31, 2022 at 1:11 PM Quentin Monnet <quentin@isovalent.com> wrote: > > To help users check what version of libbpf has been used to compile > bpftool, embed the version number and print it along with bpftool's own > version number. > > Signed-off-by: Quentin Monnet <quentin@isovalent.com> > --- > tools/bpf/bpftool/Documentation/common_options.rst | 3 ++- > tools/bpf/bpftool/Makefile | 2 ++ > tools/bpf/bpftool/main.c | 3 +++ > 3 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst > index 908487b9c2ad..24166733d3ae 100644 > --- a/tools/bpf/bpftool/Documentation/common_options.rst > +++ b/tools/bpf/bpftool/Documentation/common_options.rst > @@ -4,7 +4,8 @@ > Print short help message (similar to **bpftool help**). > > -V, --version > - Print version number (similar to **bpftool version**), and optional > + Print bpftool's version number (similar to **bpftool version**), the > + version of libbpf that was used to compile the binary, and optional > features that were included when bpftool was compiled. Optional > features include linking against libbfd to provide the disassembler > for JIT-ted programs (**bpftool prog dump jited**) and usage of BPF > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile > index 83369f55df61..bd5a8cafac49 100644 > --- a/tools/bpf/bpftool/Makefile > +++ b/tools/bpf/bpftool/Makefile > @@ -42,6 +42,7 @@ LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hash > ifeq ($(BPFTOOL_VERSION),) > BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) > endif > +LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) > why can't you use libbpf_version_string() API instead? > $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR): > $(QUIET_MKDIR)mkdir -p $@ > @@ -84,6 +85,7 @@ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ > -I$(srctree)/tools/include \ > -I$(srctree)/tools/include/uapi > CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' > +CFLAGS += -DLIBBPF_VERSION='"$(LIBBPF_VERSION)"' > ifneq ($(EXTRA_CFLAGS),) > CFLAGS += $(EXTRA_CFLAGS) > endif > diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c > index 9d01fa9de033..4bda73057980 100644 > --- a/tools/bpf/bpftool/main.c > +++ b/tools/bpf/bpftool/main.c > @@ -89,6 +89,8 @@ static int do_version(int argc, char **argv) > > jsonw_name(json_wtr, "version"); > jsonw_printf(json_wtr, "\"%s\"", BPFTOOL_VERSION); > + jsonw_name(json_wtr, "libbpf_version"); > + jsonw_printf(json_wtr, "\"%s\"", LIBBPF_VERSION); > > jsonw_name(json_wtr, "features"); > jsonw_start_object(json_wtr); /* features */ > @@ -102,6 +104,7 @@ static int do_version(int argc, char **argv) > unsigned int nb_features = 0; > > printf("%s v%s\n", bin_name, BPFTOOL_VERSION); > + printf("using libbpf v%s\n", LIBBPF_VERSION); > printf("features:"); > if (has_libbfd) { > printf(" libbfd"); > -- > 2.32.0 >
2022-02-01 22:59 UTC-0800 ~ Andrii Nakryiko <andrii.nakryiko@gmail.com> > On Mon, Jan 31, 2022 at 1:11 PM Quentin Monnet <quentin@isovalent.com> wrote: >> >> To help users check what version of libbpf has been used to compile >> bpftool, embed the version number and print it along with bpftool's own >> version number. >> >> Signed-off-by: Quentin Monnet <quentin@isovalent.com> >> --- >> tools/bpf/bpftool/Documentation/common_options.rst | 3 ++- >> tools/bpf/bpftool/Makefile | 2 ++ >> tools/bpf/bpftool/main.c | 3 +++ >> 3 files changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst >> index 908487b9c2ad..24166733d3ae 100644 >> --- a/tools/bpf/bpftool/Documentation/common_options.rst >> +++ b/tools/bpf/bpftool/Documentation/common_options.rst >> @@ -4,7 +4,8 @@ >> Print short help message (similar to **bpftool help**). >> >> -V, --version >> - Print version number (similar to **bpftool version**), and optional >> + Print bpftool's version number (similar to **bpftool version**), the >> + version of libbpf that was used to compile the binary, and optional >> features that were included when bpftool was compiled. Optional >> features include linking against libbfd to provide the disassembler >> for JIT-ted programs (**bpftool prog dump jited**) and usage of BPF >> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile >> index 83369f55df61..bd5a8cafac49 100644 >> --- a/tools/bpf/bpftool/Makefile >> +++ b/tools/bpf/bpftool/Makefile >> @@ -42,6 +42,7 @@ LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hash >> ifeq ($(BPFTOOL_VERSION),) >> BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) >> endif >> +LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) >> > > why can't you use libbpf_version_string() API instead? I missed it somehow, thanks for the pointer. It seems to be a recent addition to libbpf, and it was probably not present last time I checked for such an API. I'll use it.
diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst index 908487b9c2ad..24166733d3ae 100644 --- a/tools/bpf/bpftool/Documentation/common_options.rst +++ b/tools/bpf/bpftool/Documentation/common_options.rst @@ -4,7 +4,8 @@ Print short help message (similar to **bpftool help**). -V, --version - Print version number (similar to **bpftool version**), and optional + Print bpftool's version number (similar to **bpftool version**), the + version of libbpf that was used to compile the binary, and optional features that were included when bpftool was compiled. Optional features include linking against libbfd to provide the disassembler for JIT-ted programs (**bpftool prog dump jited**) and usage of BPF diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 83369f55df61..bd5a8cafac49 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -42,6 +42,7 @@ LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hash ifeq ($(BPFTOOL_VERSION),) BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) endif +LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR): $(QUIET_MKDIR)mkdir -p $@ @@ -84,6 +85,7 @@ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' +CFLAGS += -DLIBBPF_VERSION='"$(LIBBPF_VERSION)"' ifneq ($(EXTRA_CFLAGS),) CFLAGS += $(EXTRA_CFLAGS) endif diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 9d01fa9de033..4bda73057980 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -89,6 +89,8 @@ static int do_version(int argc, char **argv) jsonw_name(json_wtr, "version"); jsonw_printf(json_wtr, "\"%s\"", BPFTOOL_VERSION); + jsonw_name(json_wtr, "libbpf_version"); + jsonw_printf(json_wtr, "\"%s\"", LIBBPF_VERSION); jsonw_name(json_wtr, "features"); jsonw_start_object(json_wtr); /* features */ @@ -102,6 +104,7 @@ static int do_version(int argc, char **argv) unsigned int nb_features = 0; printf("%s v%s\n", bin_name, BPFTOOL_VERSION); + printf("using libbpf v%s\n", LIBBPF_VERSION); printf("features:"); if (has_libbfd) { printf(" libbfd");
To help users check what version of libbpf has been used to compile bpftool, embed the version number and print it along with bpftool's own version number. Signed-off-by: Quentin Monnet <quentin@isovalent.com> --- tools/bpf/bpftool/Documentation/common_options.rst | 3 ++- tools/bpf/bpftool/Makefile | 2 ++ tools/bpf/bpftool/main.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-)