Re: [RFC PATCH 0/2] Add btf__field_exists

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

 





On 6.04.22 г. 2:37 ч., Andrii Nakryiko wrote:
The problem is that what you've implemented is not a user-space
equivalent of bpf_core_xxx() macros. CO-RE has extra logic around
___<flavor> suffixes, extra type checks, etc, etc. Helper you are
adding does a very straightforward strings check, which isn't hard to
implement and it doesn't have to be a set in stone API. So I'm a bit
hesitant to add this.

But I can share what I did in similar situations where I had to do
some CO-RE check both on BPF side and know its result in user-space. I
built a separate very simple BPF skeleton and all it did was perform
various feature checks (including those that require CO-RE) and then
returned the result through global variables. You can then trigger
such BPF feature-checking program either through bpf_prog_test_run or
through whatever other means (I actually did a simple sys_enter
program in my case). See [0] for BPF program side and [1] for
user-space activation/consumption of that.

The benefit of this approach is that there is no way BPF and
user-space sides can get "out of sync" in terms of their feature
checking. With skeleton it's also extremely simple to do all this.

   [0]https://github.com/anakryiko/retsnoop/blob/master/src/calib_feat.bpf.c
   [1]https://github.com/anakryiko/retsnoop/blob/master/src/mass_attacher.c#L483-L529



That's indeed neat, however what is the minimum kernel version required to have global variables work ? AFAIU one requirement is to use a recent-enough libbpf which supports the skeleton functionality which is fine, userspace components can be updated somewhat easily than target kernels.



[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