bpf: Relax the max_entries check for inner map
Subsystems (12)
v3 cover bpf: Relax the max_entries check for inner map
v3:
- Add map_meta_equal to bpf_map_ops and use it as an explict opt-in support for map-in-map
v2:
- New BPF_MAP_TYPE_FL to minimize code churns (Alexei)
- s/capabilities/properties/ (Andrii)
- Describe WHY in commit log (Andrii)
People has a use case that starts with a smaller inner map first and then replaces it with a larger inner map later when it is needed.
This series allows the outer map to be updated with inner map in different size as long as it is safe (meaning the max_entries is not used in the verification time during prog load).
Please see individual patch for details.
Martin KaFai Lau (3):
bpf: Add map_meta_equal map ops
bpf: Relax max_entries check for most of the inner map types
bpf: selftests: Add test for different inner map size
include/linux/bpf.h | 16 +++++++++ kernel/bpf/arraymap.c | 16 +++++++++ kernel/bpf/bpf_inode_storage.c | 1 + kernel/bpf/cpumap.c | 1 + kernel/bpf/devmap.c | 2 ++ kernel/bpf/hashtab.c | 4 +++ kernel/bpf/lpm_trie.c | 1 + kernel/bpf/map_in_map.c | 24 +++++-------- kernel/bpf/map_in_map.h | 2 -- kernel/bpf/queue_stack_maps.c | 2 ++ kernel/bpf/reuseport_array.c | 1 + kernel/bpf/ringbuf.c | 1 + kernel/bpf/stackmap.c | 1 + kernel/bpf/syscall.c | 1 + net/core/bpf_sk_storage.c | 1 + net/core/sock_map.c | 2 ++ net/xdp/xskmap.c | 8 +++++ .../selftests/bpf/prog_tests/btf_map_in_map.c | 35 ++++++++++++++++++- .../selftests/bpf/progs/test_btf_map_in_map.c | 31 ++++++++++++++++ 19 files changed, 132 insertions(+), 18 deletions(-)
Signature · 1 line
2.24.1
PATCH v3 1/3 bpf: Add map_meta_equal map ops
Some properties of the inner map is used in the verification time. When an inner map is inserted to an outer map at runtime, bpf_map_meta_equal() is currently used to ensure those properties of the inserting inner map stays the same as the verification time.
In particular, the current bpf_map_meta_equal() checks max_entries which turns out to be too restrictive for most of the maps which do not use max_entries during the verification time. It limits the use case that wants to replace a smaller inner map with a larger inner map. There are some maps do use max_entries during verification though. For example, the map_gen_lookup in array_map_ops uses the max_entries to generate the inline lookup code.
To accommodate differences between maps, the map_meta_equal is added to bpf_map_ops. Each map-type can decide what to check when its map is used as an inner map during runtime.
Also, some map types cannot be used as an inner map and they are currently black listed in bpf_map_meta_alloc() in map_in_map.c. It is not unusual that the new map types may not aware that such blacklist exists. This patch enforces an explicit opt-in and only allows a map to be used as an inner map if it has implemented the map_meta_equal ops. It is based on the discussion in [1].
All maps that support inner map has its map_meta_equal points to bpf_map_meta_equal in this patch. A later patch will relax the max_entries check for most maps. bpf_types.h counts 28 map types. This patch adds 23 ".map_meta_equal" by using coccinelle. -5 for
BPF_MAP_TYPE_PROG_ARRAY BPF_MAP_TYPE_(PERCPU)_CGROUP_STORAGE BPF_MAP_TYPE_STRUCT_OPS BPF_MAP_TYPE_ARRAY_OF_MAPS BPF_MAP_TYPE_HASH_OF_MAPS
The "if (inner_map->inner_map_meta)" check in bpf_map_meta_alloc() is moved such that the same error is returned.
[1]: https://lore.kernel.org/bpf/[email protected]/
--- include/linux/bpf.h | 16 ++++++++++++++++ kernel/bpf/arraymap.c | 9 +++++++++ kernel/bpf/bpf_inode_storage.c | 1 + kernel/bpf/cpumap.c | 1 + kernel/bpf/devmap.c | 2 ++ kernel/bpf/hashtab.c | 4 ++++ kernel/bpf/lpm_trie.c | 1 + kernel/bpf/map_in_map.c | 21 ++++++++------------- kernel/bpf/map_in_map.h | 2 -- kernel/bpf/queue_stack_maps.c | 2 ++ kernel/bpf/reuseport_array.c | 1 + kernel/bpf/ringbuf.c | 1 + kernel/bpf/stackmap.c | 1 + kernel/bpf/syscall.c | 1 + net/core/bpf_sk_storage.c | 1 + net/core/sock_map.c | 2 ++ net/xdp/xskmap.c | 1 + 17 files changed, 52 insertions(+), 15 deletions(-)
include/linux/bpf.h +16 -0
@@ -112,6 +112,19 @@ struct bpf_map_ops {void (*map_local_storage_uncharge)(struct bpf_local_storage_map *smap,void *owner,u32 size);struct bpf_local_storage __rcu ** (*map_owner_storage_ptr)(void *owner); + +/* map_meta_equal must be implemented for maps that can be +* used as an inner map. It is a runtime check to ensure +* an inner map can be inserted to an outer map. +* +* Some properties of the inner map has been used during the +* verification time. When inserting an inner map at the runtime, +* map_meta_equal has to ensure the inserting map has the same +* properties that the verifier has used earlier. +*/ +bool (*map_meta_equal)(const struct bpf_map *meta0, +const struct bpf_map *meta1); +/* BTF name and id of struct allocated by map_alloc */ const char *const map_btf_name;int *map_btf_id;
@@ -235,6 +248,9 @@ int map_check_no_btf(const struct bpf_map *map,const struct btf_type *key_type, const struct btf_type *value_type); +bool bpf_map_meta_equal (const struct bpf_map *meta0, +const struct bpf_map *meta1); +extern const struct bpf_map_ops bpf_map_offload_ops;/* function argument constraints */
kernel/bpf/arraymap.c +9 -0
@@ -625,6 +625,7 @@ static const struct bpf_iter_seq_info iter_seq_info = {static int array_map_btf_id;const struct bpf_map_ops array_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = array_map_alloc_check, .map_alloc = array_map_alloc, .map_free = array_map_free,
@@ -647,6 +648,7 @@ const struct bpf_map_ops array_map_ops = {static int percpu_array_map_btf_id;const struct bpf_map_ops percpu_array_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = array_map_alloc_check, .map_alloc = array_map_alloc, .map_free = array_map_free,
@@ -1003,6 +1005,11 @@ static void prog_array_map_free(struct bpf_map *map)fd_array_map_free (map); } +/* prog_array->aux->{type,jited} is a runtime binding. +* Doing static check alone in the verifier is not enough. +* Thus, prog_array_map cannot be used as an inner_map +* and map_meta_equal is not implemented. +*/ static int prog_array_map_btf_id;const struct bpf_map_ops prog_array_map_ops = { .map_alloc_check = fd_array_map_alloc_check,
@@ -1101,6 +1108,7 @@ static void perf_event_fd_array_release(struct bpf_map *map,static int perf_event_array_map_btf_id;const struct bpf_map_ops perf_event_array_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = fd_array_map_alloc_check, .map_alloc = array_map_alloc, .map_free = fd_array_map_free,
@@ -1137,6 +1145,7 @@ static void cgroup_fd_array_free(struct bpf_map *map)static int cgroup_array_map_btf_id;const struct bpf_map_ops cgroup_array_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = fd_array_map_alloc_check, .map_alloc = array_map_alloc, .map_free = cgroup_fd_array_free,
kernel/bpf/bpf_inode_storage.c +1 -0
@@ -235,6 +235,7 @@ static void inode_storage_map_free(struct bpf_map *map)static int inode_storage_map_btf_id;const struct bpf_map_ops inode_storage_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = bpf_local_storage_map_alloc_check, .map_alloc = inode_storage_map_alloc, .map_free = inode_storage_map_free,
kernel/bpf/cpumap.c +1 -0
@@ -658,6 +658,7 @@ static int cpu_map_get_next_key(struct bpf_map *map, void *key, void *next_key)static int cpu_map_btf_id;const struct bpf_map_ops cpu_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = cpu_map_alloc, .map_free = cpu_map_free, .map_delete_elem = cpu_map_delete_elem,
kernel/bpf/devmap.c +2 -0
@@ -751,6 +751,7 @@ static int dev_map_hash_update_elem(struct bpf_map *map, void *key, void *value,static int dev_map_btf_id;const struct bpf_map_ops dev_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = dev_map_alloc, .map_free = dev_map_free, .map_get_next_key = dev_map_get_next_key,
@@ -764,6 +765,7 @@ const struct bpf_map_ops dev_map_ops = {static int dev_map_hash_map_btf_id;const struct bpf_map_ops dev_map_hash_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = dev_map_alloc, .map_free = dev_map_free, .map_get_next_key = dev_map_hash_get_next_key,
kernel/bpf/hashtab.c +4 -0
@@ -1810,6 +1810,7 @@ static const struct bpf_iter_seq_info iter_seq_info = {static int htab_map_btf_id;const struct bpf_map_ops htab_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = htab_map_alloc_check, .map_alloc = htab_map_alloc, .map_free = htab_map_free,
@@ -1827,6 +1828,7 @@ const struct bpf_map_ops htab_map_ops = {static int htab_lru_map_btf_id;const struct bpf_map_ops htab_lru_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = htab_map_alloc_check, .map_alloc = htab_map_alloc, .map_free = htab_map_free,
@@ -1947,6 +1949,7 @@ static void htab_percpu_map_seq_show_elem(struct bpf_map *map, void *key,static int htab_percpu_map_btf_id;const struct bpf_map_ops htab_percpu_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = htab_map_alloc_check, .map_alloc = htab_map_alloc, .map_free = htab_map_free,
@@ -1963,6 +1966,7 @@ const struct bpf_map_ops htab_percpu_map_ops = {static int htab_lru_percpu_map_btf_id;const struct bpf_map_ops htab_lru_percpu_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = htab_map_alloc_check, .map_alloc = htab_map_alloc, .map_free = htab_map_free,
kernel/bpf/lpm_trie.c +1 -0
@@ -732,6 +732,7 @@ static int trie_check_btf(const struct bpf_map *map,static int trie_map_btf_id;const struct bpf_map_ops trie_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = trie_alloc, .map_free = trie_free, .map_get_next_key = trie_get_next_key,
kernel/bpf/map_in_map.c +8 -13
@@ -17,23 +17,17 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)if (IS_ERR (inner_map))return inner_map; -/* prog_array->aux->{type,jited} is a runtime binding. -* Doing static check alone in the verifier is not enough. -*/ -if (inner_map->map_type ==BPF_MAP_TYPE_PROG_ARRAY || - inner_map->map_type ==BPF_MAP_TYPE_CGROUP_STORAGE || - inner_map->map_type ==BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE || - inner_map->map_type ==BPF_MAP_TYPE_STRUCT_OPS ) { -fdput (f); -return ERR_PTR (-ENOTSUPP ); - } -/* Does not support >1 level map-in-map */ if (inner_map->inner_map_meta) {fdput (f);return ERR_PTR (-EINVAL ); } +if (!inner_map->ops->map_meta_equal) { +fdput (f); +return ERR_PTR (-ENOTSUPP ); + } +if (map_value_has_spin_lock (inner_map)) {fdput (f);return ERR_PTR (-ENOTSUPP );
@@ -89,7 +83,7 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map, struct file *map_file /* not used */, int ufd) { -struct bpf_map *inner_map; +struct bpf_map *inner_map, *inner_map_meta;struct fd f; f =fdget (ufd);
@@ -97,7 +91,8 @@ void *bpf_map_fd_get_ptr(struct bpf_map *map,if (IS_ERR (inner_map))return inner_map; -if (bpf_map_meta_equal (map->inner_map_meta, inner_map)) + inner_map_meta = map->inner_map_meta; +if (inner_map_meta->ops->map_meta_equal (inner_map_meta, inner_map))bpf_map_inc (inner_map);else inner_map =ERR_PTR (-EINVAL );
kernel/bpf/map_in_map.h +0 -2
@@ -11,8 +11,6 @@ struct bpf_map;struct bpf_map *bpf_map_meta_alloc (int inner_map_ufd);void bpf_map_meta_free (struct bpf_map *map_meta); -bool bpf_map_meta_equal (const struct bpf_map *meta0, -const struct bpf_map *meta1);void *bpf_map_fd_get_ptr (struct bpf_map *map,struct file *map_file,int ufd);void bpf_map_fd_put_ptr (void *ptr);
kernel/bpf/queue_stack_maps.c +2 -0
@@ -257,6 +257,7 @@ static int queue_stack_map_get_next_key(struct bpf_map *map, void *key,static int queue_map_btf_id;const struct bpf_map_ops queue_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = queue_stack_map_alloc_check, .map_alloc = queue_stack_map_alloc, .map_free = queue_stack_map_free,
@@ -273,6 +274,7 @@ const struct bpf_map_ops queue_map_ops = {static int stack_map_btf_id;const struct bpf_map_ops stack_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = queue_stack_map_alloc_check, .map_alloc = queue_stack_map_alloc, .map_free = queue_stack_map_free,
kernel/bpf/reuseport_array.c +1 -0
@@ -351,6 +351,7 @@ static int reuseport_array_get_next_key(struct bpf_map *map, void *key,static int reuseport_array_map_btf_id;const struct bpf_map_ops reuseport_array_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = reuseport_array_alloc_check, .map_alloc = reuseport_array_alloc, .map_free = reuseport_array_free,
kernel/bpf/ringbuf.c +1 -0
@@ -287,6 +287,7 @@ static __poll_t ringbuf_map_poll(struct bpf_map *map, struct file *filp,static int ringbuf_map_btf_id;const struct bpf_map_ops ringbuf_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = ringbuf_map_alloc, .map_free = ringbuf_map_free, .map_mmap = ringbuf_map_mmap,
kernel/bpf/stackmap.c +1 -0
@@ -839,6 +839,7 @@ static void stack_map_free(struct bpf_map *map)static int stack_trace_map_btf_id;const struct bpf_map_ops stack_trace_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = stack_map_alloc, .map_free = stack_map_free, .map_get_next_key = stack_map_get_next_key,
kernel/bpf/syscall.c +1 -0
@@ -90,6 +90,7 @@ int bpf_check_uarg_tail_zero(void __user *uaddr, }const struct bpf_map_ops bpf_map_offload_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = bpf_map_offload_map_alloc, .map_free = bpf_map_offload_map_free, .map_check_btf = map_check_no_btf,
net/core/bpf_sk_storage.c +1 -0
@@ -335,6 +335,7 @@ sk_storage_ptr(void *owner)static int sk_storage_map_btf_id;const struct bpf_map_ops sk_storage_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc_check = bpf_local_storage_map_alloc_check, .map_alloc = sk_storage_map_alloc, .map_free = sk_storage_map_free,
net/core/sock_map.c +2 -0
@@ -705,6 +705,7 @@ const struct bpf_func_proto bpf_msg_redirect_map_proto = {static int sock_map_btf_id;const struct bpf_map_ops sock_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = sock_map_alloc, .map_free = sock_map_free, .map_get_next_key = sock_map_get_next_key,
@@ -1200,6 +1201,7 @@ const struct bpf_func_proto bpf_msg_redirect_hash_proto = {static int sock_hash_map_btf_id;const struct bpf_map_ops sock_hash_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = sock_hash_alloc, .map_free = sock_hash_free, .map_get_next_key = sock_hash_get_next_key,
net/xdp/xskmap.c +1 -0
@@ -256,6 +256,7 @@ void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,static int xsk_map_btf_id;const struct bpf_map_ops xsk_map_ops = { + .map_meta_equal = bpf_map_meta_equal, .map_alloc = xsk_map_alloc, .map_free = xsk_map_free, .map_get_next_key = xsk_map_get_next_key,
Signature · 1 line
2.24.1
PATCH v3 2/3 bpf: Relax max_entries check for most of the inner map types
In reply to Martin KaFai LauMost of the maps do not use max_entries during verification time. Thus, those map_meta_equal() do not need to enforce max_entries when it is inserted as an inner map during runtime. The max_entries check is removed from the default implementation bpf_map_meta_equal().
The prog_array_map and xsk_map are exception. Its map_gen_lookup uses max_entries to generate inline lookup code. Thus, they will implement its own map_meta_equal() to enforce max_entries. Since there are only two cases now, the max_entries check is not refactored and stays in its own .c file.
--- kernel/bpf/arraymap.c | 9 ++++++++- kernel/bpf/map_in_map.c | 3 +-- net/xdp/xskmap.c | 9 ++++++++- 3 files changed, 17 insertions(+), 4 deletions(-)
kernel/bpf/arraymap.c +8 -1
@@ -487,6 +487,13 @@ static int array_map_mmap(struct bpf_map *map, struct vm_area_struct *vma) vma->vm_pgoff + pgoff); } +static bool array_map_meta_equal (const struct bpf_map *meta0, +const struct bpf_map *meta1) +{ +return meta0->max_entries == meta1->max_entries && +bpf_map_meta_equal (meta0, meta1); +} +struct bpf_iter_seq_array_map_info {struct bpf_map *map;void *percpu_value_buf;
@@ -625,7 +632,7 @@ static const struct bpf_iter_seq_info iter_seq_info = {static int array_map_btf_id;const struct bpf_map_ops array_map_ops = { - .map_meta_equal = bpf_map_meta_equal, + .map_meta_equal = array_map_meta_equal, .map_alloc_check = array_map_alloc_check, .map_alloc = array_map_alloc, .map_free = array_map_free,
kernel/bpf/map_in_map.c +1 -2
@@ -75,8 +75,7 @@ bool bpf_map_meta_equal(const struct bpf_map *meta0,return meta0->map_type == meta1->map_type && meta0->key_size == meta1->key_size && meta0->value_size == meta1->value_size && - meta0->map_flags == meta1->map_flags && - meta0->max_entries == meta1->max_entries; + meta0->map_flags == meta1->map_flags; } void *bpf_map_fd_get_ptr(struct bpf_map *map,
net/xdp/xskmap.c +8 -1
@@ -254,9 +254,16 @@ void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,spin_unlock_bh (&map->lock); } +static bool xsk_map_meta_equal (const struct bpf_map *meta0, +const struct bpf_map *meta1) +{ +return meta0->max_entries == meta1->max_entries && +bpf_map_meta_equal (meta0, meta1); +} +static int xsk_map_btf_id;const struct bpf_map_ops xsk_map_ops = { - .map_meta_equal = bpf_map_meta_equal, + .map_meta_equal = xsk_map_meta_equal, .map_alloc = xsk_map_alloc, .map_free = xsk_map_free, .map_get_next_key = xsk_map_get_next_key,
Signature · 1 line
2.24.1
PATCH v3 3/3 bpf: selftests: Add test for different inner map size
In reply to Martin KaFai LauThis patch tests the inner map size can be different for reuseport_sockarray but has to be the same for arraymap. A new subtest "diff_size" is added for this.
The existing test is moved to a subtest "lookup_update".
--- .../selftests/bpf/prog_tests/btf_map_in_map.c | 35 ++++++++++++++++++- .../selftests/bpf/progs/test_btf_map_in_map.c | 31 ++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c +34 -1
@@ -53,7 +53,7 @@ static int kern_sync_rcu(void)return err; } -void test_btf_map_in_map (void ) +static void test_lookup_update (void ) {int err, key =0 , val, i;struct test_btf_map_in_map *skel;
@@ -143,3 +143,36 @@ void test_btf_map_in_map(void) cleanup:test_btf_map_in_map__destroy (skel); } + +static void test_diff_size (void ) +{ +struct test_btf_map_in_map *skel; +int err, inner_map_fd, zero =0 ; + + skel =test_btf_map_in_map__open_and_load (); +if (CHECK (!skel,"skel_open" ,"failed to open&load skeleton\n" )) +return ; + + inner_map_fd =bpf_map__fd (skel->maps.sockarr_sz2); + err =bpf_map_update_elem (bpf_map__fd (skel->maps.outer_sockarr), &zero, + &inner_map_fd,0 ); +CHECK (err,"outer_sockarr inner map size check" , +"cannot use a different size inner_map\n" ); + + inner_map_fd =bpf_map__fd (skel->maps.inner_map_sz2); + err =bpf_map_update_elem (bpf_map__fd (skel->maps.outer_arr), &zero, + &inner_map_fd,0 ); +CHECK (!err,"outer_arr inner map size check" , +"incorrectly updated with a different size inner_map\n" ); + +test_btf_map_in_map__destroy (skel); +} + +void test_btf_map_in_map (void ) +{ +if (test__start_subtest ("lookup_update" )) +test_lookup_update (); + +if (test__start_subtest ("diff_size" )) +test_diff_size (); +}
tools/testing/selftests/bpf/progs/test_btf_map_in_map.c +31 -0
@@ -11,6 +11,13 @@ struct inner_map { } inner_map1 SEC(".maps"), inner_map2 SEC(".maps"); +struct inner_map_sz2 { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(max_entries, 2); + __type(key, int); + __type(value, int); +} inner_map_sz2 SEC(".maps"); +struct outer_arr { __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); __uint(max_entries, 3);
@@ -50,6 +57,30 @@ struct outer_hash { }, }; +struct sockarr_sz1 { + __uint(type, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY); + __uint(max_entries, 1); + __type(key, int); + __type(value, int); +} sockarr_sz1 SEC(".maps"); + +struct sockarr_sz2 { + __uint(type, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY); + __uint(max_entries, 2); + __type(key, int); + __type(value, int); +} sockarr_sz2 SEC(".maps"); + +struct outer_sockarr_sz1 { + __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); + __uint(max_entries, 1); + __uint(key_size, sizeof(int)); + __uint(value_size, sizeof(int)); + __array(values, struct sockarr_sz1); +} outer_sockarr SEC(".maps") = { + .values = { (void *)&sockarr_sz1 }, +}; +int input =0 ;SEC ("raw_tp/sys_enter" )
Signature · 1 line
2.24.1
Daniel Borkmann
maintainerQuoted 35 lines · Martin KaFai Lau
v3:
- Addmap_meta_equaltobpf_map_opsand use it as an explict opt-in support for map-in-mapv2:
- NewBPF_MAP_TYPE_FLto minimize code churns (Alexei)
- s/capabilities/properties/ (Andrii)
- Describe WHY in commit log (Andrii)People has a use case that starts with a smaller inner map first and then replaces it with a larger inner map later when it is needed.
This series allows the outer map to be updated with inner map in different size as long as it is safe (meaning the
max_entriesis not used in the verification time during prog load).Please see individual patch for details.
Martin KaFai Lau (3):
bpf: Addmap_meta_equalmap ops
bpf: Relaxmax_entriescheck for most of the inner map types
bpf: selftests: Add test for different inner map sizeinclude/linux/bpf.h | 16 +++++++++ kernel/bpf/arraymap.c | 16 +++++++++ kernel/bpf/bpf_inode_storage.c | 1 + kernel/bpf/cpumap.c | 1 + kernel/bpf/devmap.c | 2 ++ kernel/bpf/hashtab.c | 4 +++ kernel/bpf/lpm_trie.c | 1 + kernel/bpf/map_in_map.c | 24 +++++-------- kernel/bpf/map_in_map.h | 2 -- kernel/bpf/queue_stack_maps.c | 2 ++ kernel/bpf/reuseport_array.c | 1 + kernel/bpf/ringbuf.c | 1 +
Quoted 8 lines
kernel/bpf/stackmap.c | 1 + kernel/bpf/syscall.c | 1 + net/core/bpf_sk_storage.c | 1 + net/core/sock_map.c | 2 ++ net/xdp/xskmap.c | 8 +++++ .../selftests/bpf/prog_tests/btf_map_in_map.c | 35 ++++++++++++++++++- .../selftests/bpf/progs/test_btf_map_in_map.c | 31 ++++++++++++++++ 19 files changed, 132 insertions(+), 18 deletions(-)
Looks good to me, applied thanks!