History

bpf: Remember BTF of inner maps.

BTF is required for 'struct bpf_timer' to be recognized inside map value. The bpf timers are supported inside inner maps. Remember 'struct btf *' in inner_map_meta to make it available to the verifier in the sequence: struct bpf_map *inner_map = bpf_map_lookup_elem(&outer_map, ...); if (inner_map) timer = bpf_map_lookup_elem(&inner_map, ...);

Alexei Starovoitov committed 5 years ago

Commit 40ec00a1 parent 3e8ce291 file · +6 −0Browse files

Unified · Split

kernel/bpf/map_in_map.c+6−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 */
44 #include <linux/slab.h>
55 #include <linux/bpf.h>
6+#include <linux/btf.h>
67
78 #include "map_in_map.h"
89
@@ -51,6 +52,10 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd) · 42 unmodified lines
5152 inner_map_meta->max_entries = inner_map->max_entries;
5253 inner_map_meta->spin_lock_off = inner_map->spin_lock_off;
5354 inner_map_meta->timer_off = inner_map->timer_off;
55+ if (inner_map->btf) {
56+ btf_get(inner_map->btf);
57+ inner_map_meta->btf = inner_map->btf;
58+ }
5459
5560 /* Misc members not needed in bpf_map_meta_equal() check. */
5661 inner_map_meta->ops = inner_map->ops;
@@ -66,6 +71,7 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd) · 9 unmodified lines
6671
6772 void bpf_map_meta_free(struct bpf_map *map_meta)
6873 {
74+ btf_put(map_meta->btf);
6975 kfree(map_meta);
7076 }
7177

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t