Skip to content

Commit e8a6585

Browse files
Hou TaoAlexei Starovoitov
authored andcommitted
bpf: Add is_fd_htab() helper
Add is_fd_htab() helper to check whether the map is htab of maps. Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 2c30417 commit e8a6585

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
@@ -175,6 +175,11 @@ static bool htab_is_percpu(const struct bpf_htab *htab)
175175
htab->map.map_type == BPF_MAP_TYPE_LRU_PERCPU_HASH;
176176
}
177177

178+
static inline bool is_fd_htab(const struct bpf_htab *htab)
179+
{
180+
return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS;
181+
}
182+
178183
static inline void *htab_elem_value(struct htab_elem *l, u32 key_size)
179184
{
180185
return l->key + round_up(key_size, 8);
@@ -974,8 +979,7 @@ static void pcpu_init_value(struct bpf_htab *htab, void __percpu *pptr,
974979

975980
static bool fd_htab_map_needs_adjust(const struct bpf_htab *htab)
976981
{
977-
return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS &&
978-
BITS_PER_LONG == 64;
982+
return is_fd_htab(htab) && BITS_PER_LONG == 64;
979983
}
980984

981985
static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
@@ -1810,7 +1814,7 @@ __htab_map_lookup_and_delete_batch(struct bpf_map *map,
18101814
}
18111815
} else {
18121816
value = htab_elem_value(l, key_size);
1813-
if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS) {
1817+
if (is_fd_htab(htab)) {
18141818
struct bpf_map **inner_map = value;
18151819

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

0 commit comments

Comments
 (0)