On 5/27/20 8:57 AM, Toke Høiland-Jørgensen wrote: > > Either way you're creating a contract where the kernel says "first four > bytes is the ifindex, second four bytes is the fd/id". BTF just makes > that explicit, and allows userspace to declare that it agrees this is > what the fields should mean. And gives us more flexibility when > extending the API later than just adding stuff at the end and looking at > the size... > >> You need to know precisely which 4 bytes is the program fd that needs >> to be looked up, and that AFAIK is beyond the scope of BTF. > > Exactly - BTF is a way for userspace to explicitly tell the kernel "I am > going to put the fd into these four bytes of the value field", instead > of the kernel implicitly assuming it's always bytes 5-8. >
Really, I should define that struct in uapi/linux/bpf.h. The ifindex field has special meaning: the kernel needs to convert it to a net_device. The prog_fd field has special meaning: it should map to a bpf program. This use case is not in BTF's scope. But, prove me wrong. Ideas are cheap; code is hard. Show me the code that implements your idea.