Re: [PATCH bpf-next v2 5/8] libbpf, xsk: select AF_XDP BPF program based on kernel version

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

 



On Wed, Jan 20, 2021 at 7:27 AM Björn Töpel <bjorn.topel@xxxxxxxxx> wrote:
>
> >> Would it make sense with some kind of BPF-specific "supported
> >> features" mechanism? Something else with a bigger scope (whole
> >> kernel)?
> >
> > Heh, in my opinion, yeah. Seems like we'll finally get it for XDP, but
> > for BPF in general the approach has always been probing AFAICT.
> >
> > For the particular case of arguments to helpers, I suppose the verifier
> > could technically validate value ranges for flags arguments, say. That
> > would be nice as an early reject anyway, but I'm not sure if it is
> > possible to add after-the-fact without breaking existing programs
> > because the verifier can't prove the argument is within the valid range.
> > And of course it doesn't help you with compatibility with
> > already-released kernels.
> >
>
> Hmm, think I have a way forward. I'll use BPF_PROG_TEST_RUN.
>
> If the load fail for the new helper, fallback to bpf_redirect_map(). Use
> BPF_PROG_TEST_RUN to make sure that "action via flags" passes.

+1 to Toke's point. No version checks please.
One way to detect is to try prog_load. Search for FEAT_* in libbpf.
Another approach is to scan vmlinux BTF for necessary helpers.
Currently libbpf is relying on the former.
I think going forward would be good to detect features via BTF.
It's going to be much faster and won't create noise for audit that
could be looking at prog_load calls.




[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