[PATCH v2 1/2] net/tap: fix FD leak on netns change
Robin Jarry
rjarry at redhat.com
Fri Nov 6 12:28:26 CET 2026
David Marchand, Nov 06, 2026 at 09:56:
> When a tap interface moves to another namespace, tap_netns_change()
> calls tap_lsc_intr_handle_set(dev, 1) to recreate the LSC interrupt
> without first tearing down the old one. The previous LSC netlink
> socket fd is never closed.
>
> Defer the full LSC teardown and re-registration to an alarm callback
> which runs in the interrupt thread but outside any active source
> context. The alarm switches to the device's network namespace, tears
> down the old LSC handle, sets up a new one (opening a fresh netlink
> socket in the correct namespace), restores the original namespace,
> and forces carrier state back up.
>
> Extract tap_dev_ns_switch/tap_dev_ns_restore helpers to share the
> namespace switch logic between tap_netns_change and the alarm.
>
> Fixes: aae3a38e9e03 ("net/tap: detect namespace change")
> Cc: stable at dpdk.org
>
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> Reviewed-by: Robin Jarry <rjarry at redhat.com>
> ---
> Changes since v1:
> - moved pmd->if_index clearing before trying to change netns,
> - moved alarm registration after netns changes succeed,
> - added second alarm cancel for unregister race with netns change,
> - ignored ENOENT suggestion from AI review,
> - added error logs to please AI review,
>
> ---
> drivers/net/tap/rte_eth_tap.c | 99 +++++++++++++++++++++++++----------
> 1 file changed, 72 insertions(+), 27 deletions(-)
Tested-by: Robin Jarry <rjarry at redhat.com>
More information about the stable
mailing list