Replies: 1 comment
-
@efagerho Thanks for the question! Could you please trim it down to the essentials? (most of the code isn't relevant to this issue) Also, including the error message would be useful. There are a few traps when dealing with map-in-maps, you're certainly not alone. :) The for cpu := range cpus {
// Instantiate a new inner flows map for each CPU.
m, err := ebpf.NewMap(udp_routerMapSpecs.PerCpuFlows.InnerMap)
if err != nil {
panic(err)
}
defer m.Close()
// Insert it into the outer map.
if err := objs.udp_routerMaps.PerCpuFlows.Update(&cpu, m, ebpf.UpdateAny); err != nil {
logger.Error("Inserting map", "cpu", cpu, "error", err)
os.Exit(1)
}
} The error you're getting is probably from struct flows {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 512000);
__type(key, struct flow_key);
__type(value, struct flow_entry);
}
struct {
__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
__uint(max_entries, MAX_CPUs + 1);
__type(key, __u32);
__type(value, __u32);
__array(values, struct flows);
} per_cpu_flows SEC(".maps"); This avoids instantiating a global Also see https://github.com/cilium/ebpf/blob/main/examples/map_in_map/main.go for more MapSpec twiddling. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm testing out ebpf-go for the first time and I'm wondering how to populate an array of maps when loading the program. I have the following XDP program
My Go program for loading it is the following:
However, it fails in the loop, where it's trying to create the flow tables for each CPU. I couldn't find in the manual details on how to initialize such arrays, so I could be doing it wrong. I see with strace one syscall that returns a not supported error, but can't really figure out what operation is causing it.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions