Commit 36cc3435 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

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: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 0402acd6
...@@ -226,8 +226,6 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, ...@@ -226,8 +226,6 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
return -EINVAL; return -EINVAL;
if (unlikely(i >= m->map.max_entries)) if (unlikely(i >= m->map.max_entries))
return -E2BIG; return -E2BIG;
if (unlikely(map_flags == BPF_NOEXIST))
return -EEXIST;
sock = sockfd_lookup(fd, &err); sock = sockfd_lookup(fd, &err);
if (!sock) if (!sock)
...@@ -257,6 +255,12 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value, ...@@ -257,6 +255,12 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
if (old_xs == xs) { if (old_xs == xs) {
err = 0; err = 0;
goto out; 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); xsk_map_sock_add(xs, node);
WRITE_ONCE(*map_entry, xs); WRITE_ONCE(*map_entry, xs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment