"bpftool prog list" command displays eBPF program name if available. Also, the crash "bpf -m|-M" options display eBPF map name. But the "bpf -p|-P" options don't display its name. It would be useful in finding the program which we want to see. Signed-off-by: Kazuhito Hagio <k-hagio-ab@xxxxxxx> --- bpf.c | 12 ++++++++++++ defs.h | 1 + help.c | 3 ++- symbols.c | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bpf.c b/bpf.c index 39ced88..cb6b0ed 100644 --- a/bpf.c +++ b/bpf.c @@ -194,6 +194,7 @@ bpf_init(struct bpf_info *bpf) MEMBER_OFFSET_INIT(bpf_prog_pages, "bpf_prog", "pages"); MEMBER_OFFSET_INIT(bpf_prog_aux_load_time, "bpf_prog_aux", "load_time"); MEMBER_OFFSET_INIT(bpf_prog_aux_user, "bpf_prog_aux", "user"); + MEMBER_OFFSET_INIT(bpf_prog_aux_name, "bpf_prog_aux", "name"); MEMBER_OFFSET_INIT(bpf_map_key_size, "bpf_map", "key_size"); MEMBER_OFFSET_INIT(bpf_map_value_size, "bpf_map", "value_size"); MEMBER_OFFSET_INIT(bpf_map_max_entries, "bpf_map", "max_entries"); @@ -452,6 +453,17 @@ do_bpf(ulong flags, ulong prog_id, ulong map_id, int radix) bpf_prog_gpl_compatible(buf1, (ulong)bpf->proglist[i].value); fprintf(fp, " GPL_COMPATIBLE: %s", buf1); + fprintf(fp, " NAME: "); + if (VALID_MEMBER(bpf_prog_aux_name)) { + BCOPY(&bpf->bpf_prog_aux_buf[OFFSET(bpf_prog_aux_name)], buf1, 16); + buf1[16] = NULLCHAR; + if (strlen(buf1)) + fprintf(fp, "\"%s\"", buf1); + else + fprintf(fp, "(unused)"); + } else + fprintf(fp, "(unknown)"); + fprintf(fp, " UID: "); if (VALID_MEMBER(bpf_prog_aux_user) && VALID_MEMBER(user_struct_uid)) { user = ULONG(bpf->bpf_prog_aux_buf + OFFSET(bpf_prog_aux_user)); diff --git a/defs.h b/defs.h index fbd19b0..e852ddf 100644 --- a/defs.h +++ b/defs.h @@ -2078,6 +2078,7 @@ struct offset_table { /* stash of commonly-used offsets */ long bpf_map_memory; long bpf_map_memory_pages; long bpf_map_memory_user; + long bpf_prog_aux_name; }; struct size_table { /* stash of commonly-used sizes */ diff --git a/help.c b/help.c index 5c313af..eda5ce9 100644 --- a/help.c +++ b/help.c @@ -2412,7 +2412,8 @@ char *help_bpf[] = { " -p ID displays the basic information specific to the program ID, plus the", " size in bytes of its translated bytecode, the size in bytes of its", " jited code, the number of bytes locked into memory, the time that", -" the program was loaded, whether it is GPL compatible, and its UID.", +" the program was loaded, whether it is GPL compatible, its name", +" string, and its UID.", " -P same as -p, but displays the basic and extra data for all programs.", " -m ID displays the basic information specific to the map ID, plus the", " size in bytes of its key and value, the maximum number of key-value", diff --git a/symbols.c b/symbols.c index f1f659b..9c3032d 100644 --- a/symbols.c +++ b/symbols.c @@ -10494,6 +10494,8 @@ dump_offset_table(char *spec, ulong makestruct) OFFSET(bpf_prog_aux_load_time)); fprintf(fp, " bpf_prog_aux_user: %ld\n", OFFSET(bpf_prog_aux_user)); + fprintf(fp, " bpf_prog_aux_name: %ld\n", + OFFSET(bpf_prog_aux_name)); fprintf(fp, " user_struct_uid: %ld\n", OFFSET(user_struct_uid)); -- 2.24.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility