Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for maps of maps #120

Open
alban opened this issue Apr 29, 2018 · 0 comments
Open

Support for maps of maps #120

alban opened this issue Apr 29, 2018 · 0 comments

Comments

@alban
Copy link
Collaborator

alban commented Apr 29, 2018

Maps of maps such as BPF_MAP_TYPE_ARRAY_OF_MAPS are created with bpf() using the flag inner_map_fd.

The kernel bpf library (samples/bpf/bpf_load.h) uses the following bpf_map_def:

struct bpf_map_def {
        unsigned int type;
        unsigned int key_size;
        unsigned int value_size;
        unsigned int max_entries;
        unsigned int map_flags;
        unsigned int inner_map_idx;
        unsigned int numa_node;
};      

inner_map_idx refers to the map index in the same ELF object.

Gobpf does not have any way in its own version of struct bpf_map_def to use inner_map_fd:

typedef struct bpf_map_def {
	unsigned int type;
	unsigned int key_size;
	unsigned int value_size;
	unsigned int max_entries;
	unsigned int map_flags;
	unsigned int pinning;
	char namespace[BUF_SIZE_MAP_NS];
} bpf_map_def;

The kernel uses inner_map_fd to know the type of the inner map in order to let the verifier check that it's used correctly.

iproute2 has support for inner maps but uses a different struct bpf_elf_map with an indirect index:

/* ELF map definition */
struct bpf_elf_map {
	__u32 type;
	__u32 size_key;
	__u32 size_value;
	__u32 max_elem;
	__u32 flags;
	__u32 id;
	__u32 pinning;
	__u32 inner_id;
	__u32 inner_idx;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant