]> git.baikalelectronics.ru Git - kernel.git/commit
xdp: fix hang while unregistering device bound to xdp socket
authorIlya Maximets <i.maximets@samsung.com>
Fri, 28 Jun 2019 08:04:07 +0000 (11:04 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Jul 2019 13:10:55 +0000 (15:10 +0200)
commita14c3cb3adf60ce046a54bd06840e2db14458401
treea9b25a22c509f0c3c5b1a937de24008d0637fc26
parent7c217de76cc8bfc8f306561fdc4190e086b9447a
xdp: fix hang while unregistering device bound to xdp socket

Device that bound to XDP socket will not have zero refcount until the
userspace application will not close it. This leads to hang inside
'netdev_wait_allrefs()' if device unregistering requested:

  # ip link del p1
  < hang on recvmsg on netlink socket >

  # ps -x | grep ip
  5126  pts/0    D+   0:00 ip link del p1

  # journalctl -b

  Jun 05 07:19:16 kernel:
  unregister_netdevice: waiting for p1 to become free. Usage count = 1

  Jun 05 07:19:27 kernel:
  unregister_netdevice: waiting for p1 to become free. Usage count = 1
  ...

Fix that by implementing NETDEV_UNREGISTER event notification handler
to properly clean up all the resources and unref device.

This should also allow socket killing via ss(8) utility.

Fixes: 31cd447ce563 ("xsk: add support for bind for Rx")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/net/xdp_sock.h
net/xdp/xdp_umem.c
net/xdp/xdp_umem.h
net/xdp/xsk.c