-
Hi everyone, I have a strange problem trying to store a map in the map. struct client_inner_map {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(max_entries, MAX_MAP_ENTRIES);
__type(key, __u16); // dstport
__type(value, struct in6_addr[10]);
} client_inner_map SEC(".maps");
struct client_outer_map {
__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
__uint(max_entries, MAX_MAP_ENTRIES);
__uint(pinning, LIBBPF_PIN_BY_NAME);
__type(key, __u32); // domain_name id
__array(values, struct client_inner_map);
} client_outer_map SEC(".maps"); definition in my userspace application: func NewClientMap() *ClientMap {
outerMapSpec := &ebpf.MapSpec{
Name: "client_outer_map",
Type: ebpf.HashOfMaps,
KeySize: 4,
ValueSize: 4,
MaxEntries: 1024,
Pinning: ebpf.PinByName,
Contents: make([]ebpf.MapKV, len(config.Params.Services)),
InnerMap: &ebpf.MapSpec{
Name: "client_inner_map",
Type: ebpf.LRUHash,
KeySize: 2,
ValueSize: 160,
MaxEntries: 1,
},
}
return &ClientMap{
outerMapSpec: outerMapSpec,
}
} This has worked completely fine. struct sidlist_data {
__u32 sidlist_size;
struct in6_addr sidlist[10];
};
struct client_inner_map {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(max_entries, MAX_MAP_ENTRIES);
__type(key, __u16);
__type(value, struct sidlist_data);
} client_inner_map SEC(".maps");
struct client_outer_map {
__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
__uint(max_entries, MAX_MAP_ENTRIES);
__uint(pinning, LIBBPF_PIN_BY_NAME);
__type(key, __u32);
__array(values, struct client_inner_map);
} client_outer_map SEC(".maps"); I am also updating the userspace definition accordingly (change ValueSize to 164). I have investigated the problem and found out that the problem occurs when storing the FD of the inner map in the outer map. Maybe someone sees the problem and can help me... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
My guess is that the size of the inner map value isn't Why are you manually crafting the |
Beta Was this translation helpful? Give feedback.
Did you write the SidListData by hand or use bpf2go?
Try using the generated functions to get access to a
CollectionSpec
, that should be what you need:ebpf/examples/kprobe/bpf_bpfel.go
Line 35 in 5bb4c2f
It would also be helpful if you dump the BTF of your compiled code via
bpftool btf dump file ...
(IIRC)