Thread (7 messages) 7 messages, 3 authors, 2021-03-26

Re: [PATCH v3 bpf-next] libbpf: add bpf object kern_version attribute setter

From: Andrii Nakryiko <hidden>
Date: 2021-03-25 20:40:00

On Thu, Mar 25, 2021 at 1:01 PM Rafael David Tinoco
[off-list ref] wrote:
quoted
quoted
Unfortunately some distros don't have their kernel version defined
accurately in <linux/version.h> due to different long term support
reasons.

It is important to have a way to override the bpf kern_version
attribute during runtime: some old kernels might still check for
kern_version attribute during bpf_prog_load().

Signed-off-by: Rafael David Tinoco <redacted>
---
  tools/lib/bpf/libbpf.c   | 10 ++++++++++
  tools/lib/bpf/libbpf.h   |  1 +
  tools/lib/bpf/libbpf.map |  1 +
  3 files changed, 12 insertions(+)
Hi Andrii and Rafael,

Did you consider making kernel version an attribute of the load
API, bpf_prog_load_xattr()? This feels slightly more natural
to me, to tell the API the kernel you need at load time.
Hi John,

This is how I'm using:
https://github.com/rafaeldtinoco/portablebpf/blob/master/mine.c#L285
quoted
Although, I don't use the skeleton pieces so maybe it would be
awkward for that usage.
having a xxx_bpf object:

xxx_bpf__open_and_load() -> xxx_bpf__load() ->
bpf_object__load_skeleton() -> bpf_object_load() -> bpf_object__loadxattr()

We would have to add kern_version to 'bpf_object_skeleton' struct, to be
passed to 'bpf_object__load_skeleton()' to have it passed on.

I'll let Andrii to see what he prefers.
See my reply to John. What he asked for already exists. Having a test
would be nice, but selftests/bpf don't have an infrastructure to even
perform this test, so I don't think it's worth it.

So in summary, LGTM. I'll apply it once bpf-next is ready to accept new patches.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Note:

Reason for all this (including the legacy kprobe logic, in other commit)
is to continue the
https://github.com/rafaeldtinoco/conntracker/tree/poc-cmd project,
making sure it supports 4.x kernels. Still adding bpf support to it
(identify task/pid per flow) and will replace the libnf* usage with bpf
after that.

Thanks
-rafaeldtinoco
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help