On Wed, May 26, 2021 at 8:57 AM Alexander Lobakin <alexandr.lobakin@xxxxxxxxx> wrote: > > > >Well likely libbpf would do the rewrite I think. > > So your proposal is to not compose metadata according to the prog's > request, but rather reprogram the prog itself to access metadata > accordingly? Sounds very nice. > > If follow this path, is it something like this? > > 1. Driver exposes the fields layout (e.g. Rx/Tx descriptor fields) > via BTF to the BPF layer. > 2. When an XDP prog is attached, BPF reprograms it to look for the > required fields at the right offset. The driver doesn't need to expose it directly via ndo. There is already generic support for BTF in modules and support for encoding btf_id for further use inside verifier and other components. I think the driver can simply do: BTF_ID_LIST(known_packet_fields) and the bpf core will pick it from there. While libbpf will do a CO-RE style re-write when driver layout changes. Ideally bpf core doesn't need to be involved and it's done completely in libbpf.