Message ID | 20210618231322.GA27742@165gc.onmicrosoft.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] libbpf: add extra BPF_PROG_TYPE check to bpf_object__probe_loading | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | fail | 9 maintainers not CCed: netdev@vger.kernel.org yhs@fb.com kpsingh@kernel.org daniel@iogearbox.net andrii@kernel.org kafai@fb.com ast@kernel.org john.fastabend@gmail.com songliubraving@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 10 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Fri, Jun 18, 2021 at 4:13 PM jjedwa165 <jonathan.edwards@165gc.onmicrosoft.com> wrote: > > eBPF has been backported for RHEL 7 w/ kernel 3.10-940+ [0]. However > only the following program types are supported [1] > > BPF_PROG_TYPE_KPROBE > BPF_PROG_TYPE_TRACEPOINT > BPF_PROG_TYPE_PERF_EVENT > > For libbpf this causes an EINVAL return during the bpf_object__probe_loading > call which only checks to see if programs of type BPF_PROG_TYPE_SOCKET_FILTER > can load. > > The following will try BPF_PROG_TYPE_TRACEPOINT as a fallback attempt before > erroring out. BPF_PROG_TYPE_KPROBE was not a good candidate because on some > kernels it requires knowledge of the LINUX_VERSION_CODE. > > [0] https://www.redhat.com/en/blog/introduction-ebpf-red-hat-enterprise-linux-7 > [1] https://access.redhat.com/articles/3550581 > > Signed-off-by: jjedwa165 <jonathan.edwards@165gc.onmicrosoft.com> > --- LGTM, but please re-submit with your real first and last name in Signed-off-by. Also add my ack: Acked-by: Andrii Nakryiko <andrii@kernel.org> > tools/lib/bpf/libbpf.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 48c0ade05..1e04ce724 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -4000,6 +4000,10 @@ bpf_object__probe_loading(struct bpf_object *obj) > attr.license = "GPL"; > > ret = bpf_load_program_xattr(&attr, NULL, 0); > + if (ret < 0) { > + attr.prog_type = BPF_PROG_TYPE_TRACEPOINT; > + ret = bpf_load_program_xattr(&attr, NULL, 0); > + } > if (ret < 0) { > ret = errno; > cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); > -- > 2.17.1 >
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 48c0ade05..1e04ce724 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -4000,6 +4000,10 @@ bpf_object__probe_loading(struct bpf_object *obj) attr.license = "GPL"; ret = bpf_load_program_xattr(&attr, NULL, 0); + if (ret < 0) { + attr.prog_type = BPF_PROG_TYPE_TRACEPOINT; + ret = bpf_load_program_xattr(&attr, NULL, 0); + } if (ret < 0) { ret = errno; cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
eBPF has been backported for RHEL 7 w/ kernel 3.10-940+ [0]. However only the following program types are supported [1] BPF_PROG_TYPE_KPROBE BPF_PROG_TYPE_TRACEPOINT BPF_PROG_TYPE_PERF_EVENT For libbpf this causes an EINVAL return during the bpf_object__probe_loading call which only checks to see if programs of type BPF_PROG_TYPE_SOCKET_FILTER can load. The following will try BPF_PROG_TYPE_TRACEPOINT as a fallback attempt before erroring out. BPF_PROG_TYPE_KPROBE was not a good candidate because on some kernels it requires knowledge of the LINUX_VERSION_CODE. [0] https://www.redhat.com/en/blog/introduction-ebpf-red-hat-enterprise-linux-7 [1] https://access.redhat.com/articles/3550581 Signed-off-by: jjedwa165 <jonathan.edwards@165gc.onmicrosoft.com> --- tools/lib/bpf/libbpf.c | 4 ++++ 1 file changed, 4 insertions(+)