Skip to content

Commit 3775771

Browse files
committed
bpf: Add is_fd_htab() helper
JIRA: https://issues.redhat.com/browse/RHEL-110274 commit e8a6585 Author: Hou Tao <houtao1@huawei.com> Date: Tue Apr 1 14:22:48 2025 +0800 bpf: Add is_fd_htab() helper Add is_fd_htab() helper to check whether the map is htab of maps. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Hou Tao <houtao1@huawei.com> Link: https://lore.kernel.org/r/20250401062250.543403-5-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Viktor Malik <vmalik@redhat.com>
1 parent 7366c55 commit 3775771

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kernel/bpf/hashtab.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ static bool htab_is_percpu(const struct bpf_htab *htab)
194194
htab->map.map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH;
195195
}
196196

197+
static inline bool is_fd_htab(const struct bpf_htab *htab)
198+
{
199+
return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS;
200+
}
201+
197202
static inline void *htab_elem_value(struct htab_elem *l, u32 key_size)
198203
{
199204
return l->key + round_up(key_size, 8);
@@ -1005,8 +1010,7 @@ static void pcpu_init_value(struct bpf_htab *htab, void __percpu *pptr,
10051010

10061011
static bool fd_htab_map_needs_adjust(const struct bpf_htab *htab)
10071012
{
1008-
return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS &&
1009-
BITS_PER_LONG == 64;
1013+
return is_fd_htab(htab) && BITS_PER_LONG == 64;
10101014
}
10111015

10121016
static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
@@ -1845,7 +1849,7 @@ __htab_map_lookup_and_delete_batch(struct bpf_map *map,
18451849
}
18461850
} else {
18471851
value = htab_elem_value(l, key_size);
1848-
if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS) {
1852+
if (is_fd_htab(htab)) {
18491853
struct bpf_map **inner_map = value;
18501854

18511855
/* Actual value is the id of the inner map */

0 commit comments

Comments
 (0)