[PATCH] bpf: Use E2BIG instead of ENOENT

Tao Chen posted 1 patch 2 years, 1 month ago
kernel/bpf/stackmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] bpf: Use E2BIG instead of ENOENT
Posted by Tao Chen 2 years, 1 month ago
Use E2BIG instead of ENOENT when the key size beyond the buckets size,
it seems more meaningful.

Signed-off-by: Tao Chen <chen.dylane@gmail.com>
---
 kernel/bpf/stackmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 458bb80b14d5..b78369bdec8d 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -570,7 +570,7 @@ int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value)
 	u32 id = *(u32 *)key, trace_len;
 
 	if (unlikely(id >= smap->n_buckets))
-		return -ENOENT;
+		return -E2BIG;
 
 	bucket = xchg(&smap->buckets[id], NULL);
 	if (!bucket)
-- 
2.34.1
Re: [PATCH] bpf: Use E2BIG instead of ENOENT
Posted by Alexei Starovoitov 2 years, 1 month ago
On Fri, Nov 3, 2023 at 7:44 PM Tao Chen <chen.dylane@gmail.com> wrote:
>
> Use E2BIG instead of ENOENT when the key size beyond the buckets size,
> it seems more meaningful.

seems more meaningful?
Sorry. That's hardly a reason to break someone's code.