首页 > 解决方案 > ebpf 遍历多个映射

问题描述

我想创建一个地图数组,以便可以遍历它们。例如,我有下面的三个固定地图。

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");

我如何遍历这三个地图?我尝试制作一个 void 指针数组,但之后我无法直接访问地图,因为它们都是自己的类型。

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

我也尝试过使用 BPF_ARRAY_OF_MAPS,但我不知道如何使用它

标签: ebpfbcc

解决方案


推荐阅读