[PATCH 3/3] tools bpftool: Display license in prog show/list

From: Jiri Olsa
Date: Mon Apr 23 2018 - 03:00:08 EST


Display the license string in bpftool prog command, like:

# bpftool prog list
1: kprobe name func_begin tag 59bef35a42fda602 license GPL
loaded_at Apr 22/15:46 uid 0
xlated 272B not jited memlock 4096B map_ids 1

# bpftool prog show --json
[{"id":1,"type":"kprobe","name":"fun ... ,"license":"GPL", ... ]

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/bpf/bpftool/prog.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 548adb9b7317..ea5ede899cf7 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -235,6 +235,8 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)
info->tag[0], info->tag[1], info->tag[2], info->tag[3],
info->tag[4], info->tag[5], info->tag[6], info->tag[7]);

+ jsonw_string_field(json_wtr, "license", info->license);
+
print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);

if (info->load_time) {
@@ -295,8 +297,10 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)
printf("tag ");
fprint_hex(stdout, info->tag, BPF_TAG_SIZE, "");
print_dev_plain(info->ifindex, info->netns_dev, info->netns_ino);
+ printf(" license %s", info->license);
printf("\n");

+
if (info->load_time) {
char buf[32];

--
2.13.6