diff options
| author | Andrii Nakryiko <[email protected]> | 2020-01-10 03:42:46 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2020-01-10 05:17:01 +0000 |
| commit | 492ab0205f500ebd20b4f0c9e95a1ba007b0c542 (patch) | |
| tree | 46cf10d9d9f327bc4d67268d1b91934a9303e0b5 /tools/lib/bpf/netlink.c | |
| parent | bpf: Document BPF_F_QUERY_EFFECTIVE flag (diff) | |
| download | kernel-492ab0205f500ebd20b4f0c9e95a1ba007b0c542.tar.gz kernel-492ab0205f500ebd20b4f0c9e95a1ba007b0c542.zip | |
libbpf: Make bpf_map order and indices stable
Currently, libbpf re-sorts bpf_map structs after all the maps are added and
initialized, which might change their relative order and invalidate any
bpf_map pointer or index taken before that. This is inconvenient and
error-prone. For instance, it can cause .kconfig map index to point to a wrong
map.
Furthermore, libbpf itself doesn't rely on any specific ordering of bpf_maps,
so it's just an unnecessary complication right now. This patch drops sorting
of maps and makes their relative positions fixed. If efficient index is ever
needed, it's better to have a separate array of pointers as a search index,
instead of reordering bpf_map struct in-place. This will be less error-prone
and will allow multiple independent orderings, if necessary (e.g., either by
section index or by name).
Fixes: 166750bc1dd2 ("libbpf: Support libbpf-provided extern variables")
Reported-by: Martin KaFai Lau <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/netlink.c')
0 files changed, 0 insertions, 0 deletions
