Skip to content

How to work with BPF_MAP_TYPE_ARRAY_OF_MAPS? #1658

Answered by ti-mo
thediveo asked this question in Q&A
Discussion options

You must be logged in to vote

@thediveo Could you elaborate on what you want to accomplish on the Go side? I assume you want to create new inner maps and store them in the outer map? Either way, the example we have in testdata is quite representative, but this is an alternative version that doesn't explicitly declare the inner map as a separate map in the ELF:

struct {
	__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
	__type(key, uint32_t);
	__type(value, uint32_t);
	__uint(max_entries, 16);
	__array(values, struct {
		__uint(type, BPF_MAP_TYPE_HASH);
		__type(key, uint64_t);
		__type(value, uint64_t);
		__uint(max_entries, 1024);
	});
} outer_map __section(".maps");

Are the inner maps automatically created for all entries…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@thediveo
Comment options

@ti-mo
Comment options

@thediveo
Comment options

@thediveo
Comment options

@ti-mo
Comment options

Answer selected by ti-mo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants