bpf: return EOPNOTSUPP when map lookup isn't supported
authorPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Tue, 9 Oct 2018 01:04:50 +0000 (10:04 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Oct 2018 04:52:20 +0000 (21:52 -0700)
Return ERR_PTR(-EOPNOTSUPP) from map_lookup_elem() methods of below
map types:
- BPF_MAP_TYPE_PROG_ARRAY
- BPF_MAP_TYPE_STACK_TRACE
- BPF_MAP_TYPE_XSKMAP
- BPF_MAP_TYPE_SOCKMAP/BPF_MAP_TYPE_SOCKHASH

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/arraymap.c
kernel/bpf/sockmap.c
kernel/bpf/stackmap.c
kernel/bpf/xskmap.c

index dded84cbe814a1ba246b31c343802f083eaab624..24583da9ffd18127c3fcd7297b77f12ee988e67d 100644 (file)
@@ -449,7 +449,7 @@ static void fd_array_map_free(struct bpf_map *map)
 
 static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key)
 {
-       return NULL;
+       return ERR_PTR(-EOPNOTSUPP);
 }
 
 /* only called from syscall */
index d37a1a0a6e1e7483745db7a7bf704153ddb8dd77..5d0677d808ae758e97cf06b15e67f32a12ca2571 100644 (file)
@@ -2096,7 +2096,7 @@ int sockmap_get_from_fd(const union bpf_attr *attr, int type,
 
 static void *sock_map_lookup(struct bpf_map *map, void *key)
 {
-       return NULL;
+       return ERR_PTR(-EOPNOTSUPP);
 }
 
 static int sock_map_update_elem(struct bpf_map *map,
index 8061a439ef18c67e74269d9e1222f41a95e0ff3a..b2ade10f7ec3ebfca7fb26719660c372198f4fd8 100644 (file)
@@ -505,7 +505,7 @@ const struct bpf_func_proto bpf_get_stack_proto = {
 /* Called from eBPF program */
 static void *stack_map_lookup_elem(struct bpf_map *map, void *key)
 {
-       return NULL;
+       return ERR_PTR(-EOPNOTSUPP);
 }
 
 /* Called from syscall */
index 9f8463afda9c857b868181938e9baecfd991a473..ef0b7b6ef8a58edab2e281d85b263ff4e3416cb8 100644 (file)
@@ -154,7 +154,7 @@ void __xsk_map_flush(struct bpf_map *map)
 
 static void *xsk_map_lookup_elem(struct bpf_map *map, void *key)
 {
-       return NULL;
+       return ERR_PTR(-EOPNOTSUPP);
 }
 
 static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,