diff options
author | Taeung Song <treeze.taeung@gmail.com> | 2019-01-21 08:06:38 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-01-23 06:27:04 -0500 |
commit | c76e4c228b053eb108e6c3221bef338aa2c98fac (patch) | |
tree | 97150f9540894e081f6ae2649636b5bccef58ea7 /tools/bpf/bpftool/prog.c | |
parent | ffcf7ce9332723cab5ae55575f3a55d1ce559bf3 (diff) |
libbpf: Show supported ELF section names when failing to guess prog/attach type
We need to let users check their wrong ELF section name with proper
ELF section names when they fail to get a prog/attach type from it.
Because users can't realize libbpf guess prog/attach types from given
ELF section names. For example, when a 'cgroup' section name of a
BPF program is used, show available ELF section names(types).
Before:
$ bpftool prog load bpf-prog.o /sys/fs/bpf/prog1
Error: failed to guess program type based on ELF section name cgroup
After:
libbpf: failed to guess program type based on ELF section name 'cgroup'
libbpf: supported section(type) names are: socket kprobe/ kretprobe/ classifier action tracepoint/ raw_tracepoint/ xdp perf_event lwt_in lwt_out lwt_xmit lwt_seg6local cgroup_skb/ingress cgroup_skb/egress cgroup/skb cgroup/sock cgroup/post_bind4 cgroup/post_bind6 cgroup/dev sockops sk_skb/stream_parser sk_skb/stream_verdict sk_skb sk_msg lirc_mode2 flow_dissector cgroup/bind4 cgroup/bind6 cgroup/connect4 cgroup/connect6 cgroup/sendmsg4 cgroup/sendmsg6
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Quentin Monnet <quentin.monnet@netronome.com>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Andrey Ignatov <rdna@fb.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 2d1bb7d6ff51..0640e9bc0ada 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c | |||
@@ -930,10 +930,9 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) | |||
930 | err = libbpf_prog_type_by_name(type, &attr.prog_type, | 930 | err = libbpf_prog_type_by_name(type, &attr.prog_type, |
931 | &expected_attach_type); | 931 | &expected_attach_type); |
932 | free(type); | 932 | free(type); |
933 | if (err < 0) { | 933 | if (err < 0) |
934 | p_err("unknown program type '%s'", *argv); | ||
935 | goto err_free_reuse_maps; | 934 | goto err_free_reuse_maps; |
936 | } | 935 | |
937 | NEXT_ARG(); | 936 | NEXT_ARG(); |
938 | } else if (is_prefix(*argv, "map")) { | 937 | } else if (is_prefix(*argv, "map")) { |
939 | void *new_map_replace; | 938 | void *new_map_replace; |
@@ -1028,11 +1027,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) | |||
1028 | 1027 | ||
1029 | err = libbpf_prog_type_by_name(sec_name, &prog_type, | 1028 | err = libbpf_prog_type_by_name(sec_name, &prog_type, |
1030 | &expected_attach_type); | 1029 | &expected_attach_type); |
1031 | if (err < 0) { | 1030 | if (err < 0) |
1032 | p_err("failed to guess program type based on section name %s\n", | ||
1033 | sec_name); | ||
1034 | goto err_close_obj; | 1031 | goto err_close_obj; |
1035 | } | ||
1036 | } | 1032 | } |
1037 | 1033 | ||
1038 | bpf_program__set_ifindex(pos, ifindex); | 1034 | bpf_program__set_ifindex(pos, ifindex); |