bpf: Append prog->aux->name in bpf_get_prog_name()
This patch makes the bpf_prog's name available in kallsyms. The new format is bpf_prog_tag[_name]. Sample kallsyms from running selftests/bpf/test_progs: [root@arch-fb-vm1 ~]# egrep ' bpf_prog_[0-9a-fA-F]{16}' /proc/kallsyms ffffffffa0048000 t bpf_prog_dabf0207d1992486_test_obj_id ffffffffa0038000 t bpf_prog_a04f5eef06a7f555__123456789ABCDE ffffffffa0050000 t bpf_prog_a04f5eef06a7f555 Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
067cae4777
Коммит
368211fb92
|
@ -309,12 +309,25 @@ bpf_get_prog_addr_region(const struct bpf_prog *prog,
|
|||
|
||||
static void bpf_get_prog_name(const struct bpf_prog *prog, char *sym)
|
||||
{
|
||||
const char *end = sym + KSYM_NAME_LEN;
|
||||
|
||||
BUILD_BUG_ON(sizeof("bpf_prog_") +
|
||||
sizeof(prog->tag) * 2 + 1 > KSYM_NAME_LEN);
|
||||
sizeof(prog->tag) * 2 +
|
||||
/* name has been null terminated.
|
||||
* We should need +1 for the '_' preceding
|
||||
* the name. However, the null character
|
||||
* is double counted between the name and the
|
||||
* sizeof("bpf_prog_") above, so we omit
|
||||
* the +1 here.
|
||||
*/
|
||||
sizeof(prog->aux->name) > KSYM_NAME_LEN);
|
||||
|
||||
sym += snprintf(sym, KSYM_NAME_LEN, "bpf_prog_");
|
||||
sym = bin2hex(sym, prog->tag, sizeof(prog->tag));
|
||||
*sym = 0;
|
||||
if (prog->aux->name[0])
|
||||
snprintf(sym, (size_t)(end - sym), "_%s", prog->aux->name);
|
||||
else
|
||||
*sym = 0;
|
||||
}
|
||||
|
||||
static __always_inline unsigned long
|
||||
|
|
Загрузка…
Ссылка в новой задаче