简体   繁体   中英

EBPF access pinned tables

If in my python bcc program I store information in a pinned map, how can I access it from a separate python program?

So I have this pinned map from the reference guide:

BPF_TABLE_PINNED("hash", u64, u64, ids, 1024, "/sys/fs/bpf/ids");

I already tried accessing it like a normal table but I get a raise key error. There isn't any documentation but I found this example that I don't really understand https://github.com/iovisor/bcc/blame/master/examples/cpp/UseExternalMap.cc

If you just want to share a BPF map, you can do that in bcc without explicitly pinning the map. In that case, you need to use BPF_TABLE_SHARED and BPF_TABLE("extern" . For example (drawn from the BPF project polycube ):

# In first program
BPF_TABLE_SHARED("lru_hash", struct st_k, struct st_v, egress_session_table, NAT_MAP_DIM);

# In second program
BPF_TABLE("extern", struct st_k, struct st_v, egress_session_table,
      NAT_MAP_DIM);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM