Confused about how maps are identified across user/kernel space

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

 



I feel like the answer to this is a pointer to the relevant code, but
since I can't find it...

The basic question is: how does the kernel part of a bpf program
identify its maps (e.g., map_k1, map_k2, map_k3) in a way that the
user space program (e.g., map_u1, map_u2, map_u3) identifies the same
maps and put data in to the right places?  I know bcc and libbpf (from
the kernel tree) are supposed to take care of this magic for us, but
I'd like to better understand how it works.

It's not like there's type checking across the user/kernel space
boundary, but the only information passed in the bpf(2) system call is
the map schema.  I'm surprised there's no "map ID" that gets passed on
both sides to make sure they're talking about the same map.

Looking through samples/bpf/xdp_*, the kernel side of each program
identifies each map by a struct bpf_map_def, which is not a kernel
structure but a (random?) data type from tools/lib/bpf/libbpf.h.
Somehow that gets translated (by the JIT?) into the kernel 'struct
bpf_map' data structure (which contains a critical ID field) but then
the identifier that the userspace gets back after the
bpf(BPF_CREATE_MAP) system call is a file descriptor.

Does it basically come down to declaring the maps in the same order?

Any help here would be appreciated - TIA!

- Rob
.



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

  Powered by Linux