Message ID | 20180425174108.6586-4-jolsa@kernel.org |
---|---|
State | Changes Requested, archived |
Delegated to: | BPF Maintainers |
Headers | show |
Series | bpf: Store/dump license string for loaded program | expand |
On Wed, 25 Apr 2018 19:41:08 +0200, Jiri Olsa wrote: > @@ -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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); 3 nit picks: Other "fields" are separated by two spaces between each other: 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible ^^ ^^ X loaded_at Apr 25/11:20 uid 0 ^^ xlated 16B not jited memlock 4096B ^^ ^^ Could you also update the example outputs in the man page: tools/bpf/bpftool/Documentation/bpftool-prog.rst Sorry about the bike shedding but I would also vote for: "[not] GPL compatible" rather than "license GPL [NON] compatible" for brevity..
On 04/25/2018 11:03 PM, Jakub Kicinski wrote: > On Wed, 25 Apr 2018 19:41:08 +0200, Jiri Olsa wrote: >> @@ -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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); > > 3 nit picks: > > Other "fields" are separated by two spaces between each other: > > 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible > ^^ ^^ X > loaded_at Apr 25/11:20 uid 0 > ^^ > xlated 16B not jited memlock 4096B > ^^ ^^ > > Could you also update the example outputs in the man page: > > tools/bpf/bpftool/Documentation/bpftool-prog.rst > > Sorry about the bike shedding but I would also vote for: > > "[not] GPL compatible" > > rather than > > "license GPL [NON] compatible" > > for brevity.. While we're at it, can we also squeeze this whole thing a bit? Feels like huge string wasted for very little information compared to the rest of the dump. Just append the string "gpl" at the end of the line if info->gpl_compatible is set, otherwise just add nothing. This also allows to naturally grep for it e.g. `bpftool p | grep gpl` if you need a quick summary. Thanks, Daniel
On Wed, Apr 25, 2018 at 11:14:30PM +0200, Daniel Borkmann wrote: > On 04/25/2018 11:03 PM, Jakub Kicinski wrote: > > On Wed, 25 Apr 2018 19:41:08 +0200, Jiri Olsa wrote: > >> @@ -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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); > > > > 3 nit picks: > > > > Other "fields" are separated by two spaces between each other: > > > > 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible > > ^^ ^^ X > > loaded_at Apr 25/11:20 uid 0 > > ^^ > > xlated 16B not jited memlock 4096B > > ^^ ^^ > > > > Could you also update the example outputs in the man page: > > > > tools/bpf/bpftool/Documentation/bpftool-prog.rst > > > > Sorry about the bike shedding but I would also vote for: > > > > "[not] GPL compatible" > > > > rather than > > > > "license GPL [NON] compatible" > > > > for brevity.. > > While we're at it, can we also squeeze this whole thing a bit? Feels like > huge string wasted for very little information compared to the rest of the > dump. Just append the string "gpl" at the end of the line if info->gpl_compatible > is set, otherwise just add nothing. This also allows to naturally grep > for it e.g. `bpftool p | grep gpl` if you need a quick summary. that's fine with me.. so 'gpl' in here: 5: tracepoint name func tag 57cd311f2e27366b gpl loaded_at Apr 26/09:37 uid 0 xlated 16B not jited memlock 4096B and keeping tyhe whole name in json output: [{ "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 } ] how about that? thanks, jirka
On Wed, Apr 25, 2018 at 02:03:46PM -0700, Jakub Kicinski wrote: > On Wed, 25 Apr 2018 19:41:08 +0200, Jiri Olsa wrote: > > @@ -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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); > > 3 nit picks: > > Other "fields" are separated by two spaces between each other: > > 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible > ^^ ^^ X > loaded_at Apr 25/11:20 uid 0 > ^^ > xlated 16B not jited memlock 4096B > ^^ ^^ > will change > Could you also update the example outputs in the man page: > > tools/bpf/bpftool/Documentation/bpftool-prog.rst oops, I always forget that.. will do thanks, jirka
On 04/26/2018 09:39 AM, Jiri Olsa wrote: > On Wed, Apr 25, 2018 at 11:14:30PM +0200, Daniel Borkmann wrote: >> On 04/25/2018 11:03 PM, Jakub Kicinski wrote: >>> On Wed, 25 Apr 2018 19:41:08 +0200, Jiri Olsa wrote: >>>> @@ -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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); >>> >>> 3 nit picks: >>> >>> Other "fields" are separated by two spaces between each other: >>> >>> 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible >>> ^^ ^^ X >>> loaded_at Apr 25/11:20 uid 0 >>> ^^ >>> xlated 16B not jited memlock 4096B >>> ^^ ^^ >>> >>> Could you also update the example outputs in the man page: >>> >>> tools/bpf/bpftool/Documentation/bpftool-prog.rst >>> >>> Sorry about the bike shedding but I would also vote for: >>> >>> "[not] GPL compatible" >>> >>> rather than >>> >>> "license GPL [NON] compatible" >>> >>> for brevity.. >> >> While we're at it, can we also squeeze this whole thing a bit? Feels like >> huge string wasted for very little information compared to the rest of the >> dump. Just append the string "gpl" at the end of the line if info->gpl_compatible >> is set, otherwise just add nothing. This also allows to naturally grep >> for it e.g. `bpftool p | grep gpl` if you need a quick summary. > > that's fine with me.. so 'gpl' in here: > > 5: tracepoint name func tag 57cd311f2e27366b gpl > loaded_at Apr 26/09:37 uid 0 > xlated 16B not jited memlock 4096B > > and keeping tyhe whole name in json output: > > [{ > "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 > } > ] > > how about that? Sounds good, thanks Jiri!
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 548adb9b7317..b8b4341a1342 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_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(" license GPL %scompatible", info->gpl_compatible ? "" : "NON "); printf("\n"); if (info->load_time) {
Display the license GPL NON/compatible string in bpftool prog command, like: # bpftool prog list 3: kprobe name func_begin tag 57cd311f2e27366b license GPL NON compatible loaded_at Apr 25/11:20 uid 0 xlated 16B not jited memlock 4096B # bpftool prog list 4: kprobe name func_begin tag 57cd311f2e27366b license GPL compatible loaded_at Apr 25/11:20 uid 0 xlated 16B not jited memlock 4096B # bpftool prog show --json [{"id":3,"type":"kprobe","name":"func ... ,"gpl_compatible":false,"loade... Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- tools/bpf/bpftool/prog.c | 3 +++ 1 file changed, 3 insertions(+)