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>
                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)
        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);