Skip to content

Commit 40ec00a

Browse files
Alexei Starovoitovborkmann
authored andcommitted
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, ...); Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 3e8ce29 commit 40ec00a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/bpf/map_in_map.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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)
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)
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

0 commit comments

Comments
 (0)