bpftool: add current libbpf_strict mode to version output
Subsystems (4)
PATCH 1/1 bpftool: add current libbpf_strict mode to version output
+ 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}}
--- tools/bpf/bpftool/main.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/bpf/bpftool/main.c +5 -0
@@ -93,6 +93,7 @@ static int do_version(int argc, char **argv)jsonw_name (json_wtr,"features" );jsonw_start_object (json_wtr);/* features */ jsonw_bool_field (json_wtr,"libbfd" , has_libbfd); +jsonw_bool_field (json_wtr,"libbpf_strict" , !legacy_libbpf);jsonw_bool_field (json_wtr,"skeletons" , has_skeletons);jsonw_end_object (json_wtr);/* features */
@@ -106,6 +107,10 @@ static int do_version(int argc, char **argv)printf (" libbfd" ); nb_features++; } +if (!legacy_libbpf) { +printf ("%s libbpf_strict" , nb_features++ ?"," :"" ); + nb_features++; + }if (has_skeletons)printf ("%s skeletons" , nb_features++ ?"," :"" );printf ("\n" );
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
2021-11-12 08:44 UTC-0800 ~ Stanislav Fomichev <[email protected]>
Quoted 10 lines
+ 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}}
Nice, thanks!
The following doesn't work as expected, though:
$ ./bpftool --version --legacy
./bpftool v5.15.0
features: libbfd, libbpf_strict, skeletonsThis is because we run do_version() immediately when parsing --version, and we don't parse --legacy in that case. Could we postpone do_version() until after we have parsed all options, so that the output from the above is consistent with e.g. "bpftool --legacy --version"?
Thanks,
Quentin
Quoted 16 lines · Quentin Monnet
2021-11-12 08:44 UTC-0800 ~ Stanislav Fomichev <[email protected]>
Quoted 10 lines
+ 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}}Nice, thanks!
The following doesn't work as expected, though:
Quoted 8 lines
$ ./bpftool --version --legacy ./bpftool v5.15.0 features: libbfd, libbpf_strict, skeletonsThis is because we run
do_version()immediately when parsing --version, and we don't parse --legacy in that case. Could we postponedo_version()until after we have parsed all options, so that the output from the above is consistent with e.g. "bpftool --legacy --version"?
Oh, good find! Let me move some code around to fix that.