OSDN Git Service

tools, bpftool: Display license GPL compatible in prog show/list
authorJiri Olsa <jolsa@kernel.org>
Thu, 26 Apr 2018 08:18:01 +0000 (10:18 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 26 Apr 2018 20:39:22 +0000 (22:39 +0200)
Display the license "gpl" string in bpftool prog command, like:

  # bpftool prog list
  5: tracepoint  name func  tag 57cd311f2e27366b  gpl
          loaded_at Apr 26/09:37  uid 0
          xlated 16B  not jited  memlock 4096B

  # bpftool --json --pretty prog show
  [{
          "id": 5,
          "type": "tracepoint",
          "name": "func",
          "tag": "57cd311f2e27366b",
          "gpl_compatible": true,
          "loaded_at": "Apr 26/09:37",
          "uid": 0,
          "bytes_xlated": 16,
          "jited": false,
          "bytes_memlock": 4096
      }
  ]

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/Documentation/bpftool-prog.rst
tools/bpf/bpftool/prog.c

index 67ca6c6..43d34a5 100644 (file)
@@ -95,7 +95,7 @@ EXAMPLES
 **# bpftool prog show**
 ::
 
-  10: xdp  name some_prog  tag 005a3d2123620c8b
+  10: xdp  name some_prog  tag 005a3d2123620c8b  gpl
        loaded_at Sep 29/20:11  uid 0
        xlated 528B  jited 370B  memlock 4096B  map_ids 10
 
@@ -108,6 +108,7 @@ EXAMPLES
                 "id": 10,
                 "type": "xdp",
                 "tag": "005a3d2123620c8b",
+                "gpl_compatible": true,
                 "loaded_at": "Sep 29/20:11",
                 "uid": 0,
                 "bytes_xlated": 528,
index 548adb9..e71a0a1 100644 (file)
@@ -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_bool_field(json_wtr, "gpl_compatible", info->gpl_compatible);
+
        print_dev_json(info->ifindex, info->netns_dev, info->netns_ino);
 
        if (info->load_time) {
@@ -295,6 +297,7 @@ 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("%s", info->gpl_compatible ? "  gpl" : "");
        printf("\n");
 
        if (info->load_time) {