xsk: remove AF_XDP socket from map when the socket is released
authorBjörn Töpel <bjorn.topel@intel.com>
Thu, 15 Aug 2019 09:30:13 +0000 (11:30 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 17 Aug 2019 21:24:45 +0000 (23:24 +0200)
commit0402acd683c678874df6bdbc23530ca07ea19353
tree5232972b02fce35a91ee8e839cc7b1bd3f9e6e34
parent8e46c3534a550782405206c5a1be8d8a721bf45a
xsk: remove AF_XDP socket from map when the socket is released

When an AF_XDP socket is released/closed the XSKMAP still holds a
reference to the socket in a "released" state. The socket will still
use the netdev queue resource, and block newly created sockets from
attaching to that queue, but no user application can access the
fill/complete/rx/tx queues. This results in that all applications need
to explicitly clear the map entry from the old "zombie state"
socket. This should be done automatically.

In this patch, the sockets tracks, and have a reference to, which maps
it resides in. When the socket is released, it will remove itself from
all maps.

Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/net/xdp_sock.h
kernel/bpf/xskmap.c
net/xdp/xsk.c