summaryrefslogtreecommitdiff
path: root/kernel/bpf
diff options
context:
space:
mode:
authorBjörn Töpel <bjorn.topel@intel.com>2019-08-15 12:30:14 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2019-08-18 00:24:45 +0300
commit36cc34358caf631115e1566485fffed3cf4196b5 (patch)
treed620399395987e1a16c5972eb97c8b2fd7725623 /kernel/bpf
parent0402acd683c678874df6bdbc23530ca07ea19353 (diff)
downloadlinux-36cc34358caf631115e1566485fffed3cf4196b5.tar.xz
xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAP
The XSKMAP did not honor the BPF_EXIST/BPF_NOEXIST flags when updating an entry. This patch addresses that. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/xskmap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 16031d489173..4cc28e226398 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -226,8 +226,6 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
return -EINVAL;
if (unlikely(i >= m->map.max_entries))
return -E2BIG;
- if (unlikely(map_flags == BPF_NOEXIST))
- return -EEXIST;
sock = sockfd_lookup(fd, &err);
if (!sock)
@@ -257,6 +255,12 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
if (old_xs == xs) {
err = 0;
goto out;
+ } else if (old_xs && map_flags == BPF_NOEXIST) {
+ err = -EEXIST;
+ goto out;
+ } else if (!old_xs && map_flags == BPF_EXIST) {
+ err = -ENOENT;
+ goto out;
}
xsk_map_sock_add(xs, node);
WRITE_ONCE(*map_entry, xs);