Skip to content

Commit 0badd33

Browse files
qmonnetborkmann
authored andcommitted
libbpf: complete list of strings for guessing program type
It seems that the type guessing feature for libbpf, based on the name of the ELF section the program is located in, was inspired from samples/bpf/prog_load.c, which was not used by any sample for loading programs of certain types such as TC actions and classifiers, or LWT-related types. As a consequence, libbpf is not able to guess the type of such programs and to load them automatically if type is not provided to the `bpf_load_prog()` function. Add ELF section names associated to those eBPF program types so that they can be loaded with e.g. bpftool as well. Signed-off-by: Quentin Monnet <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent b7d9923 commit 0badd33

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,12 +1816,17 @@ static const struct {
18161816
BPF_PROG_SEC("socket", BPF_PROG_TYPE_SOCKET_FILTER),
18171817
BPF_PROG_SEC("kprobe/", BPF_PROG_TYPE_KPROBE),
18181818
BPF_PROG_SEC("kretprobe/", BPF_PROG_TYPE_KPROBE),
1819+
BPF_PROG_SEC("classifier", BPF_PROG_TYPE_SCHED_CLS),
1820+
BPF_PROG_SEC("action", BPF_PROG_TYPE_SCHED_ACT),
18191821
BPF_PROG_SEC("tracepoint/", BPF_PROG_TYPE_TRACEPOINT),
18201822
BPF_PROG_SEC("xdp", BPF_PROG_TYPE_XDP),
18211823
BPF_PROG_SEC("perf_event", BPF_PROG_TYPE_PERF_EVENT),
18221824
BPF_PROG_SEC("cgroup/skb", BPF_PROG_TYPE_CGROUP_SKB),
18231825
BPF_PROG_SEC("cgroup/sock", BPF_PROG_TYPE_CGROUP_SOCK),
18241826
BPF_PROG_SEC("cgroup/dev", BPF_PROG_TYPE_CGROUP_DEVICE),
1827+
BPF_PROG_SEC("lwt_in", BPF_PROG_TYPE_LWT_IN),
1828+
BPF_PROG_SEC("lwt_out", BPF_PROG_TYPE_LWT_OUT),
1829+
BPF_PROG_SEC("lwt_xmit", BPF_PROG_TYPE_LWT_XMIT),
18251830
BPF_PROG_SEC("sockops", BPF_PROG_TYPE_SOCK_OPS),
18261831
BPF_PROG_SEC("sk_skb", BPF_PROG_TYPE_SK_SKB),
18271832
};

0 commit comments

Comments
 (0)