[PATCH -next 2/5] bpf: Remove map_push_elem callbacks with -EOPNOTSUPP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove redundant map_push_elem callbacks with return -EOPNOTSUPP. We can
directly return -EOPNOTSUPP when calling the unimplemented callbacks.

Signed-off-by: Xiaomeng Zhang <zhangxiaomeng13@xxxxxxxxxx>
---
 kernel/bpf/arena.c   | 6 ------
 kernel/bpf/helpers.c | 5 ++++-
 kernel/bpf/syscall.c | 5 ++++-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index 0aaefa5d6b09..7ee98aeccf3c 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -62,11 +62,6 @@ u64 bpf_arena_get_user_vm_start(struct bpf_arena *arena)
 	return arena ? arena->user_vm_start : 0;
 }
 
-static long arena_map_push_elem(struct bpf_map *map, void *value, u64 flags)
-{
-	return -EOPNOTSUPP;
-}
-
 static long arena_map_pop_elem(struct bpf_map *map, void *value)
 {
 	return -EOPNOTSUPP;
@@ -398,7 +393,6 @@ const struct bpf_map_ops arena_map_ops = {
 	.map_mmap = arena_map_mmap,
 	.map_get_unmapped_area = arena_get_unmapped_area,
 	.map_get_next_key = arena_map_get_next_key,
-	.map_push_elem = arena_map_push_elem,
 	.map_pop_elem = arena_map_pop_elem,
 	.map_lookup_elem = arena_map_lookup_elem,
 	.map_update_elem = arena_map_update_elem,
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 0f429171de6d..000409c8308a 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -88,7 +88,10 @@ const struct bpf_func_proto bpf_map_delete_elem_proto = {
 
 BPF_CALL_3(bpf_map_push_elem, struct bpf_map *, map, void *, value, u64, flags)
 {
-	return map->ops->map_push_elem(map, value, flags);
+	if (map->ops->map_push_elem)
+		return map->ops->map_push_elem(map, value, flags);
+	else
+		return -EOPNOTSUPP;
 }
 
 const struct bpf_func_proto bpf_map_push_elem_proto = {
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e6e859f71c5d..79a118ea9270 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -281,7 +281,10 @@ static int bpf_map_update_value(struct bpf_map *map, struct file *map_file,
 	} else if (map->map_type == BPF_MAP_TYPE_QUEUE ||
 		   map->map_type == BPF_MAP_TYPE_STACK ||
 		   map->map_type == BPF_MAP_TYPE_BLOOM_FILTER) {
-		err = map->ops->map_push_elem(map, value, flags);
+		if (map->ops->map_push_elem)
+			err = map->ops->map_push_elem(map, value, flags);
+		else
+			err = -EOPNOTSUPP;
 	} else {
 		err = bpf_obj_pin_uptrs(map->record, value);
 		if (!err) {
-- 
2.34.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux