Trying to create map with char array field invalid field error
Solution 1:
The key and value should be __u32
:
struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(__u32));
} my_map SEC(".maps");
And you can then push your events to that map as usual:
bpf_perf_event_output(ctx, &my_map, 0, &data, sizeof(data));
The bpf_perf_event_output
helper takes the size of events as argument, so it doesn't need to be a static parameter in the map.