Skip to content

Commit 77928e6

Browse files
Hou TaoKernel Patches Daemon
authored andcommitted
bpf: Add bpf_map_of_map_fd_sys_lookup_elem() helper
bpf_map_of_map_fd_sys_lookup_elem() returns the map id as the value for map-in-map. It will be used when userspace applications do lookup operations for map-in-map. Signed-off-by: Hou Tao <[email protected]>
1 parent 5c04ab5 commit 77928e6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

kernel/bpf/map_in_map.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,9 @@ void bpf_map_of_map_fd_put_ptr(void *ptr, bool need_defer)
190190
else
191191
bpf_inner_map_element_free_rcu(&element->rcu);
192192
}
193+
194+
u32 bpf_map_of_map_fd_sys_lookup_elem(void *ptr)
195+
{
196+
rcu_read_lock_held();
197+
return ((struct bpf_inner_map_element *)ptr)->map->id;
198+
}

kernel/bpf/map_in_map.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ u32 bpf_map_fd_sys_lookup_elem(void *ptr);
2222

2323
void *bpf_map_of_map_fd_get_ptr(struct bpf_map *map, struct file *map_file, int ufd);
2424
void bpf_map_of_map_fd_put_ptr(void *ptr, bool need_defer);
25+
u32 bpf_map_of_map_fd_sys_lookup_elem(void *ptr);
2526

2627
#endif

0 commit comments

Comments
 (0)