Re: XDP-hints: Howto support multiple BTF types per packet basis?

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

 





On 09/09/2021 20.19, Andrii Nakryiko wrote:
Depending on what IDs we are talking about (sorry, I don't follow this
thread very closely, so if you are curious about some aspects of BTF
or libbpf APIs, it would be good to have a specific questions with
some context). BTF as kernel object has it's own ID allocated through
idr, so yes, they are unique. so vmlinux BTF object will have it's own
ID, while each module's BTF will have it's own.

But if we are talking about BTF type IDs, that's entirely different
thing. BTF type IDs start from 1 (0 is reserved for special 'VOID'
type) all the way to number of types in vmlinux BTF. Then each module
extends vmlinx BTF starting at N + 1 and going to N + M, where N is
number of BTF types in vmlinux BTF and M is number of added types in
module BTF.

So in that regard each module has BTF type IDs that are overlapping
with other modules, which is why for unique fetching of BTF types from
modules you also need BTF object FD or ID of a module BTF, and then
BTF type ID within that module. But as I said, I didn't follow along
closely, so not sure if I'm answering the right question, sorry.

Thanks for answering. This N vmlinux IDs + M module IDs was important to know, thanks for correcting my understanding on this, as this does affect our ideas for using BTF for XDP-hints.

This "just" means that the BTF ID will be per driver. I think we can still make this work, as the AF_XDP userspace program will already need to bind to a device. Thus, we can still send a simple btf_id in metadata, and AF_XDP prog will just have device-map with expected btf_id's from this device (to validate if it knows howto decode contents). It is slightly more annoying for my xdp_frame + cpumap use-case, as it can get XDP_REDIRECT'ed frames from many net_devices, but we do have xdp_frame->dev_rx (net_device) avail, so I can resolve this.

--Jesper

Finding some random BTF ID in two module and notice they point to different types.

 # bpftool btf dump file /sys/kernel/btf/ixgbe | grep 95905
 [95905] FUNC 'ixgbe_set_rx_mode' type_id=95829 linkage=static

 # bpftool btf dump file /sys/kernel/btf/igc | grep 95905
 [95905] FUNC 'igc_ethtool_get_link_ksettings' type_id=95904 linkage=static





[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