0

I would like to create an array of maps so I can iterate through them. For instance I have the three pinned maps below.

BPF_TABLE_PINNED("hash", struct mapkey, struct output_f, map1, mapSize, "/sys/fs/bpf/map1");
BPF_TABLE_PINNED("hash", struct mapkey, struct output_f, map2, mapSize, "/sys/fs/bpf/map2");
BPF_TABLE_PINNED("hash", struct mapkey, struct output_f, map3, mapSize, "/sys/fs/bpf/map3");

How could I iterate through these three maps? I tried making an array of void pointers, but I can't directly access the map afterwards since they each are their own type.

void* mapArray[] = {&map1, &map2, &map3};

I also tried using BPF_ARRAY_OF_MAPS, but I couldn't figure out how to use it

  • Using `BPF_ARRAY_OF_MAPS` is likely the right approach. Could you share what you wrote for that and what failed? – pchaigno Oct 10 '21 at 16:36
  • @pchaigno I couldn't figure out how to initialize `BPF_ARRAY_OF_MAPS` to start off with holding 3 maps. For instance I would write `BPF_ARRAY_OF_MAPS(maps_array, "map2", 10);`, but I can't figure out how to have it store more than one map. – veryconfusedrobot Oct 11 '21 at 15:28

0 Answers0