Before I present my matter; I have read this Map sharing between different ebpf program types previously asked question which does not seem to answer my question.
Now, what I am doing is, I have two BPF programs, one for XDP and other for TC (No Userspace program). I have created the map in TC program and pinned it to global namespace
struct bpf_elf_map cnt_map __section("maps") = {
.type = BPF_MAP_TYPE_ARRAY,
.size_key = sizeof(uint32_t),
.size_value = sizeof(uint32_t),
.pinning = PIN_GLOBAL_NS,
.max_elem = 2,
};
Now, I want to access the same map in my XDP code. The document says that the pinned object can be obtained using BPF_OBJ_GET
, but what all I could find is the userspace version of this.
So, I need to know, how can two kernel space BPF programs can share a map? If it's possible with BPF_OBJ_GET
to get the pinned object (in my case it's a map), then how? Or is there any other way of doing it?
A code example of how to access the pinned object in other kernel space BPF program is really appreciated since I am new to XDP/BPF or tc/BPF.
Thanks.