Skip to contentSkip to conversation

net: sit: unregister_netdevice on newlink's error path

PATCH In review Jakub Kicinski 2 participants 3 messages Jan 14, 2021

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: sit: unregister_netdevice on newlink's error path

We need to unregister the netdevice if config failed. .ndo_uninit takes care of most of the heavy lifting.

This was uncovered by recent commit c269a24ce057 ("net: make free_netdev() more lenient with unregistering devices"). Previously the partially-initialized device would be left in the system.

Reported-and-tested-by [email protected]
Fixes e2f1f072db8d ("sit: allow to configure 6rd tunnels via netlink")
---
 net/ipv6/sit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/sit.c +4 -1
index 2da0ee703779..440175bc2e89 100644
@@ -1645,8 +1645,11 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
 	}
 
 #ifdef CONFIG_IPV6_SIT_6RD
-	if (ipip6_netlink_6rd_parms(data, &ip6rd))
+	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
 		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
+		if (err)
+			unregister_netdevice_queue(dev, NULL);
+	}
 #endif
 
 	return err;
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#1 lore raw

Le 14/01/2021 à 02:29, Jakub Kicinski a écrit :
[snip]

net/ipv6/sit.c static int ipip6_newlink(struct net *src_net, struct net_device *dev, · line 1650

Quoted 10 lines
net/ipv6/sit.c +2 -1
@@ -1645,8 +1645,11 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
 	}
 
 #ifdef CONFIG_IPV6_SIT_6RD
-	if (ipip6_netlink_6rd_parms(data, &ip6rd))
+	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
 		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
+		if (err)

nit: I would prefer 'if (err < 0)' to be consistent with the rest of the sit code, but it's purely aesthetic (ipip6_tunnel_update_6rd() returns a negative value or 0).

With or without this:

Quoted 6 lines
net/ipv6/sit.c +2 -0
+			unregister_netdevice_queue(dev, NULL);
+	}
 #endif
 
 	return err;
author maintainer
#2 lore raw
Quoted 7 lines · On Thu, 14 Jan 2021 09:49:48 +0100 Nicolas Dichtel wrote:

Le 14/01/2021 à 02:29, Jakub Kicinski a écrit :
[snip]

Quoted 5 lines
net/ipv6/sit.c +0 -0
@@ -1645,8 +1645,11 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
 	}
 
Quoted 8 lines

net/ipv6/sit.c static int ipip6_newlink(struct net *src_net, struct net_device *dev, · line 1650

Quoted 5 lines
net/ipv6/sit.c +2 -1
 #ifdef CONFIG_IPV6_SIT_6RD
-	if (ipip6_netlink_6rd_parms(data, &ip6rd))
+	if (ipip6_netlink_6rd_parms(data, &ip6rd)) {
 		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
+		if (err)  

nit: I would prefer 'if (err < 0)' to be consistent with the rest of the sit code, but it's purely aesthetic (ipip6_tunnel_update_6rd() returns a negative value or 0).

Done.

Quoted 2 lines

With or without this:

Thanks for the review, applied!