Skip to contentSkip to conversation

bpf: Use the IS_FD_ARRAY() macro in map_update_elem()

PATCH Applied Mickaël Salaün 2 participants 2 messages Jan 25, 2018 – Jan 26, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Use the IS_FD_ARRAY() macro in map_update_elem()

Make the code more readable.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
---
 kernel/bpf/syscall.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/bpf/syscall.c +1 -4
index 5bdb0cc84ad2..e24aa3241387 100644
@@ -709,10 +709,7 @@ static int map_update_elem(union bpf_attr *attr)
 		err = bpf_percpu_hash_update(map, key, value, attr->flags);
 	} else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) {
 		err = bpf_percpu_array_update(map, key, value, attr->flags);
-	} else if (map->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_PROG_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_CGROUP_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS) {
+	} else if (IS_FD_ARRAY(map)) {
 		rcu_read_lock();
 		err = bpf_fd_array_map_update_elem(map, f.file, key, value,
 						   attr->flags);
Signature · 1 line
2.15.1
#1 lore raw
Quoted 14 lines · Mickaël Salaün

Make the code more readable.

Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
---
 kernel/bpf/syscall.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/bpf/syscall.c +0 -0
index 5bdb0cc84ad2..e24aa3241387 100644

kernel/bpf/syscall.c static int map_update_elem(union bpf_attr *attr) · line 712

Quoted 8 lines
kernel/bpf/syscall.c +1 -4
@@ -709,10 +709,7 @@ static int map_update_elem(union bpf_attr *attr)
 		err = bpf_percpu_hash_update(map, key, value, attr->flags);
 	} else if (map->map_type == BPF_MAP_TYPE_PERCPU_ARRAY) {
 		err = bpf_percpu_array_update(map, key, value, attr->flags);
-	} else if (map->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_PROG_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_CGROUP_ARRAY ||
-		   map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS) {
+	} else if (IS_FD_ARRAY(map)) {

Applied to bpf-next, thank you Mickael.