linux/drivers
Daniel Borkmann eef51113f8 netkit: Add netkit notifier to check for unregistering devices
Add a netdevice notifier in netkit to watch for NETDEV_UNREGISTER events.
If the target device is indeed NETREG_UNREGISTERING and previously leased
a queue to a netkit device, then collect the related netkit devices and
batch-unregister_netdevice_many() them.

If this would not be done, then the netkit device would hold a reference
on the physical device preventing it from going away. However, in case of
both io_uring zero-copy as well as AF_XDP this situation is handled
gracefully and the allocated resources are torn down.

In the case where mentioned infra is used through netkit, the applications
have a reference on netkit, and netkit in turn holds a reference on the
physical device. In order to have netkit release the reference on the
physical device, we need such watcher to then unregister the netkit ones.

This is generally quite similar to the dependency handling in case of
tunnels (e.g. vxlan bound to a underlying netdev) where the tunnel device
gets removed along with the physical device.

  # ip a
  [...]
  4: enp10s0f0np0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
      link/ether e8:eb:d3:a3:43:f6 brd ff:ff:ff:ff:ff:ff
      inet 10.0.0.2/24 scope global enp10s0f0np0
         valid_lft forever preferred_lft forever
  [...]
  8: nk@NONE: <BROADCAST,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
      link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
  [...]

  # rmmod mlx5_ib
  # rmmod mlx5_core

  [  309.261822] mlx5_core 0000:0a:00.0 mlx5_0: Port: 1 Link DOWN
  [  344.235236] mlx5_core 0000:0a:00.1: E-Switch: Unload vfs: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  344.246948] mlx5_core 0000:0a:00.1: E-Switch: Disable: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  344.463754] mlx5_core 0000:0a:00.1: E-Switch: Disable: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  344.770155] mlx5_core 0000:0a:00.1: E-Switch: cleanup
  [  345.345709] mlx5_core 0000:0a:00.0: E-Switch: Unload vfs: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  345.357524] mlx5_core 0000:0a:00.0: E-Switch: Disable: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  350.995989] mlx5_core 0000:0a:00.0: E-Switch: Disable: mode(LEGACY), nvfs(0), necvfs(0), active vports(0)
  [  351.574396] mlx5_core 0000:0a:00.0: E-Switch: cleanup

  # ip a
  [...]
  [ both enp10s0f0np0 and nk gone ]
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Co-developed-by: David Wei <dw@davidwei.uk>
Signed-off-by: David Wei <dw@davidwei.uk>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20260115082603.219152-12-daniel@iogearbox.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-01-20 11:58:50 +01:00
..
accel
accessibility
acpi
amba
android
ata
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-01-08 11:38:33 -08:00
auxdisplay
base
bcma
block block-6.19-20260109 2026-01-09 15:42:46 -10:00
bluetooth
bus
cache
cdrom
cdx
char
clk
clocksource
comedi
connector
counter
cpufreq
cpuidle
crypto
cxl
dax
dca
devfreq
dibs
dio
dma
dma-buf
dpll dpll: zl3073x: Implement device mode setting support 2026-01-19 12:04:57 -08:00
edac
eisa
extcon
firewire
firmware
fpga
fsi
fwctl
gnss
gpib
gpio gpio: shared: fix a false-positive sharing detection with reset-gpios 2026-01-09 09:56:46 +01:00
gpu amd-drm-fixes-6.19-2026-01-06: 2026-01-08 10:34:27 +10:00
greybus
hid hid-for-linus-2026010801 2026-01-08 07:44:48 -08:00
hsi
hte
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
idle
iio
infiniband bnxt_en: Update FW interface to 1.10.3.151 2026-01-10 15:19:50 -08:00
input
interconnect
iommu iommupt: Make pt_feature() always_inline 2026-01-10 10:50:45 +01:00
ipack
irqchip Revert "irqchip/riscv-imsic: Embed the vector array in lpriv" 2026-01-09 16:10:05 +01:00
isdn
leds
macintosh
mailbox
mcb
md
media [GIT PULL for v6.19-rc6] media fixes 2026-01-14 08:18:01 -08:00
memory
memstick
message
mfd
misc Char/Misc driver fixes for 6.19-rc5 2026-01-11 07:27:44 -10:00
mmc
most
mtd treewide: Update email address 2026-01-11 06:09:11 -10:00
mux
net netkit: Add netkit notifier to check for unregistering devices 2026-01-20 11:58:50 +01:00
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
parisc
parport
pci soc: fixes for 6.19 2026-01-09 15:11:45 -10:00
pcmcia
peci
perf
phy phy: add phy_get_rx_polarity() and phy_get_tx_polarity() 2026-01-14 18:16:05 +05:30
pinctrl
platform
pmdomain
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
resctrl arm_mpam: Stop using uninitialized variables in __ris_msmon_read() 2026-01-08 19:03:15 +00:00
reset
rpmsg
rtc
s390
sbus
scsi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
ufs
uio treewide: Update email address 2026-01-11 06:09:11 -10:00
usb
vdpa
vfio
vhost
video
virt
virtio
w1
watchdog
xen
zorro
Kconfig
Makefile