Re: Accessing userspace created persistent eBPF maps from kernel bpf restricted C

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

 



>From what I've learned building my own XDP loader, it seems like the
kernel only takes a bock of eBPF instructions. For any references to
maps, the instructions need to have been "fixed up" (if they came from
a source like an elf file) to appropriately reference the file
descriptors for any maps. As far as I can tell, those file descriptors
are the userspace file descriptors for the maps in the loading program

> The samples and test cases have examples showing how user space
> programs can pin maps and get pinned maps as FDs.  However, how would
> one access a user-space created pinned map from kernel space, without
> having to statically have a 'maps' section defined (and depend on the
> elf loader)?

You should be able to write a small userspace program that opens the
pinned maps and uses those file descriptors to create or fixup an eBPF
program from any source (elf or not), so long as you have a way to
tell which instructions need to be fixed up. (ELF puts this
information into the relocation sections.)

samples/bpf/bpf_load.c has an example of how to do the fixing up using
the relocation information from an elf file. Take a look at the
parse_relo_and_apply() function for how to adjust the eBPF
instructions.

--Zvi



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux