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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <rafaeldtinoco@xxxxxxxxxx>
---
  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

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.

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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux