xdp-tutorial icon indicating copy to clipboard operation
xdp-tutorial copied to clipboard

Share bpf map between different XDP programs running on different interfaces

Open NirGeller18 opened this issue 2 years ago • 1 comments

Hi there,

I need to share 1 bpf map between 2 different XDP programs loaded on 2 different interfaces. I understand how a map can be shared with a userspace program, but how can one XDP program gain access to a map that was created previously by a different XDP program?

I need to invoke bpf_map_lookup_elem() in the context of one program and get data that was updated by another. Can this be done? is there a working example?

Thanks a lot,

Nir.

NirGeller18 avatar Jan 15 '23 14:01 NirGeller18

Just create both XDP programs in the same source file, that way they can share the reference to the map. Note that you'll have to do any needed cross-CPU synchronisation yourself, either using atomics or locking (depending on what you're using the map for).

tohojo avatar Jan 16 '23 12:01 tohojo