Skip to content

Commit 7a0ef69

Browse files
Jakub Kicinskiborkmann
authored andcommitted
bpf: offload: allow array map offload
The special handling of different map types is left to the driver. Allow offload of array maps by simply adding it to accepted types. For nfp we have to make sure array elements are not deleted. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 3285264 commit 7a0ef69

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

drivers/net/ethernet/netronome/nfp/bpf/offload.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ nfp_bpf_map_get_next_key(struct bpf_offloaded_map *offmap,
176176
static int
177177
nfp_bpf_map_delete_elem(struct bpf_offloaded_map *offmap, void *key)
178178
{
179+
if (offmap->map.map_type == BPF_MAP_TYPE_ARRAY)
180+
return -EINVAL;
179181
return nfp_bpf_ctrl_del_entry(offmap, key);
180182
}
181183

kernel/bpf/offload.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ struct bpf_map *bpf_map_offload_map_alloc(union bpf_attr *attr)
299299

300300
if (!capable(CAP_SYS_ADMIN))
301301
return ERR_PTR(-EPERM);
302-
if (attr->map_type != BPF_MAP_TYPE_HASH)
302+
if (attr->map_type != BPF_MAP_TYPE_ARRAY &&
303+
attr->map_type != BPF_MAP_TYPE_HASH)
303304
return ERR_PTR(-EINVAL);
304305

305306
offmap = kzalloc(sizeof(*offmap), GFP_USER);

0 commit comments

Comments
 (0)