Commit e47d0bf8 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Daniel Borkmann

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 --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}}
Suggested-by: default avatarQuentin Monnet <quentin@isovalent.com>
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20211116000448.2918854-1-sdf@google.com
parent a5bdc363
...@@ -93,6 +93,7 @@ static int do_version(int argc, char **argv) ...@@ -93,6 +93,7 @@ static int do_version(int argc, char **argv)
jsonw_name(json_wtr, "features"); jsonw_name(json_wtr, "features");
jsonw_start_object(json_wtr); /* features */ jsonw_start_object(json_wtr); /* features */
jsonw_bool_field(json_wtr, "libbfd", has_libbfd); 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_bool_field(json_wtr, "skeletons", has_skeletons);
jsonw_end_object(json_wtr); /* features */ jsonw_end_object(json_wtr); /* features */
...@@ -106,6 +107,10 @@ static int do_version(int argc, char **argv) ...@@ -106,6 +107,10 @@ static int do_version(int argc, char **argv)
printf(" libbfd"); printf(" libbfd");
nb_features++; nb_features++;
} }
if (!legacy_libbpf) {
printf("%s libbpf_strict", nb_features++ ? "," : "");
nb_features++;
}
if (has_skeletons) if (has_skeletons)
printf("%s skeletons", nb_features++ ? "," : ""); printf("%s skeletons", nb_features++ ? "," : "");
printf("\n"); printf("\n");
...@@ -400,6 +405,7 @@ int main(int argc, char **argv) ...@@ -400,6 +405,7 @@ int main(int argc, char **argv)
{ "legacy", no_argument, NULL, 'l' }, { "legacy", no_argument, NULL, 'l' },
{ 0 } { 0 }
}; };
bool version_requested = false;
int opt, ret; int opt, ret;
last_do_help = do_help; last_do_help = do_help;
...@@ -414,7 +420,8 @@ int main(int argc, char **argv) ...@@ -414,7 +420,8 @@ int main(int argc, char **argv)
options, NULL)) >= 0) { options, NULL)) >= 0) {
switch (opt) { switch (opt) {
case 'V': case 'V':
return do_version(argc, argv); version_requested = true;
break;
case 'h': case 'h':
return do_help(argc, argv); return do_help(argc, argv);
case 'p': case 'p':
...@@ -479,6 +486,9 @@ int main(int argc, char **argv) ...@@ -479,6 +486,9 @@ int main(int argc, char **argv)
if (argc < 0) if (argc < 0)
usage(); usage();
if (version_requested)
return do_version(argc, argv);
ret = cmd_select(cmds, argc, argv, do_help); ret = cmd_select(cmds, argc, argv, do_help);
if (json_output) if (json_output)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment