align IPv4 teardown with IPv6 and fix driver regressions
Subsystems (5)
v2 cover align IPv4 teardown with IPv6 and fix driver regressions
This series aligns the IPv4 address teardown sequence with IPv6 by clearing dev->ip_ptr early in inetdev_destroy() before freeing the multicast list and individual IP addresses. This prevents RCU readers from accessing a partially destroyed in_device structure.
However, clearing dev->ip_ptr early causes __in_dev_get_rtnl() to return NULL during the notifier loop in inetdev_destroy(). This causes regressions in some drivers (prestera and mac80211) that use this lookup helper in their inetaddr notifier callbacks.
To prevent regressions and maintain bisectability, this series first fixes the affected drivers (Patch 1 and 2) before applying the core IPv4 change (Patch 3).
An audit was performed on all other registered inetaddr and inet6addr notifier listeners, and no other drivers were found to be affected.
Change in v2:
- Split the original single patch into a 3-patch series.
- Patch 1: Teach prestera to ignore duplicate RIF destruction events when the RIF is already gone, rather than returning -EEXIST and aborting the chain.
- Patch 2: Fix mac80211 to use the valid ifa->ifa_dev from the event argument instead of looking it up via the netdevice.
- Patch 3: The original change to clear dev->ip_ptr early.
Yuyang Huang (3):
net: prestera: ignore duplicate RIF destruction events
wifi: mac80211: use ifa_dev from event argument
net: ipv4: clear dev->ip_ptr before destroying inetdev
drivers/net/ethernet/marvell/prestera/prestera_router.c | 6 ++---- net/ipv4/devinet.c | 4 ++-- net/mac80211/main.c | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.55.0.795.g602f6c329a-goog
PATCH v2 1/3 net: prestera: ignore duplicate RIF destruction events
During address teardown, the inetaddr notifier may be called multiple times for the same interface. Ignore NETDEV_DOWN events if the RIF has already been destroyed, rather than returning -EEXIST, which aborts the notifier chain.
--- drivers/net/ethernet/marvell/prestera/prestera_router.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_router.c +2 -4
@@ -1302,10 +1302,8 @@ static int __prestera_inetaddr_port_event(struct net_device *port_dev,dev_hold (port_dev);break ;case NETDEV_DOWN : -if (!re) { -NL_SET_ERR_MSG_MOD (extack,"Can't find RIF" ); -return -EEXIST ; - } +if (!re) +return 0 ;prestera_rif_entry_destroy (port->sw, re);dev_put (port_dev);break ;
Signature · 1 line
2.55.0.795.g602f6c329a-goog
RE: [EXTERNAL] [PATCH net-next v2 1/3] net: prestera: ignore duplicate RIF destruction events
Quoted 38 lines
From: Yuyang Huang <[email protected]>
Sent: Saturday, July 11, 2026 3:54 AM
To: Yuyang Huang <[email protected]>
Cc: David S. Miller <[email protected]>; Andrew Lunn <[email protected]>; David Ahern <[email protected]>; Elad Nachman <[email protected]>; Eric Dumazet <[email protected]>; Ido Schimmel <[email protected]>; Jakub Kicinski <[email protected]>; Johannes Berg <[email protected]>; Paolo Abeni <[email protected]>; Simon Horman <[email protected]>; [email protected]; [email protected]; [email protected]; Kuniyuki Iwashima <[email protected]>
Subject: [EXTERNAL] [PATCH net-next v2 1/3] net: prestera: ignore duplicate RIF destruction eventsDuring address teardown, the inetaddr notifier may be called multiple times for the same interface. Ignore
NETDEV_DOWNevents if the RIF has already been destroyed, rather than returning-EEXIST, which aborts the notifier chain.Cc Ido Schimmel <mailto:[email protected]>Cc Kuniyuki Iwashima <mailto:[email protected]>Signed-off-by Yuyang Huang <mailto:[email protected]>--- drivers/net/ethernet/marvell/prestera/prestera_router.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/net/ethernet/marvell/prestera/prestera_router.c +2
-5@@ -1302,10 +1302,8 @@ static int __prestera_inetaddr_port_event(struct net_device *port_dev,dev_hold (port_dev);break ;case NETDEV_DOWN : -if (!re) { -NL_SET_ERR_MSG_MOD (extack,"Can't find RIF" ); -return -EEXIST ; - } +if (!re) +return 0 ;prestera_rif_entry_destroy (port->sw, re);dev_put (port_dev);break ; --
Quoted 2 lines
2.55.0.795.g602f6c329a-goog
PATCH v2 2/3 wifi: mac80211: use ifa_dev from event argument
In reply to Yuyang HuangDuring address teardown, the netdevice's ip_ptr might be cleared before the inetaddr notifier is called. In this case, __in_dev_get_rtnl() returns NULL, causing the notifier to abort early and fail to update the ARP filter.
Fix this by using the in_device pointer from the event argument (ifa->ifa_dev) which is guaranteed to be valid.
--- net/mac80211/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/mac80211/main.c +1 -3
@@ -588,9 +588,7 @@ static int ieee80211_ifa_changed(struct notifier_block *nb,if (sdata->vif.type !=NL80211_IFTYPE_STATION )return NOTIFY_DONE ; - idev =__in_dev_get_rtnl (sdata->dev); -if (!idev) -return NOTIFY_DONE ; + idev = ifa->ifa_dev; ifmgd = &sdata->u.mgd;
Signature · 1 line
2.55.0.795.g602f6c329a-goog
PATCH v2 3/3 net: ipv4: clear dev->ip_ptr before destroying inetdev
In reply to Yuyang HuangTo prevent RCU readers from accessing a partially destroyed in_device, clear dev->ip_ptr early in inetdev_destroy() before freeing the multicast list and individual IP addresses. This aligns the IPv4 teardown sequence with the IPv6 implementation.
--- net/ipv4/devinet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +2 -2
@@ -322,6 +322,8 @@ static void inetdev_destroy(struct in_device *in_dev) in_dev->dead =1 ; +RCU_INIT_POINTER (dev->ip_ptr,NULL ); +ip_mc_destroy_dev (in_dev);while ((ifa =rtnl_dereference (in_dev->ifa_list)) !=NULL ) {
@@ -329,8 +331,6 @@ static void inetdev_destroy(struct in_device *in_dev)inet_free_ifa (ifa); } -RCU_INIT_POINTER (dev->ip_ptr,NULL ); -devinet_sysctl_unregister (in_dev);neigh_parms_release (&arp_tbl, in_dev->arp_parms);arp_ifdown (dev);
Signature · 1 line
2.55.0.795.g602f6c329a-goog
Re: [PATCH net-next v2 3/3] net: ipv4: clear dev->ip_ptr before destroying inetdev
Quoted 8 lines · Yuyang Huang
To prevent RCU readers from accessing a partially destroyed
in_device, cleardev->ip_ptrearly ininetdev_destroy()before freeing the multicast list and individual IP addresses. This aligns the IPv4 teardown sequence with the IPv6 implementation.Cc Ido Schimmel <[email protected]>Cc Kuniyuki Iwashima <[email protected]>Signed-off-by Yuyang Huang <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Sat, 11 Jul 2026 09:54:01 +0900 you wrote:
This series aligns the IPv4 address teardown sequence with IPv6 by clearing
dev->ip_ptrearly ininetdev_destroy()before freeing the multicast list and individual IP addresses. This prevents RCU readers from accessing a partially destroyedin_devicestructure.However, clearing
dev->ip_ptrearly causes__in_dev_get_rtnl()to return NULL during the notifier loop ininetdev_destroy(). This causes regressions in some drivers (prestera and mac80211) that use this lookup helper in their inetaddr notifier callbacks.[...]
Here is the summary with links:
- [net-next,v2,1/3] net: prestera: ignore duplicate RIF destruction events
https://git.kernel.org/netdev/net-next/c/3cbbc9fa3338 - [net-next,v2,2/3] wifi: mac80211: use ifa_dev from event argument https://git.kernel.org/netdev/net-next/c/e5b14e9ae82b - [net-next,v2,3/3] net: ipv4: clear dev->ip_ptr before destroying inetdev https://git.kernel.org/netdev/net-next/c/aa22336b76b7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html