Skip to contentSkip to conversation

ip_tunnel: don't add tunnel twice

PATCH In review Duan Jiong 2 participants 4 messages May 15, 2014 – May 16, 2014

Subsystems (3)
lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH 1/1 ip_tunnel: don't add tunnel twice

When using command "ip tunnel add" to add a tunnel, the tunnel will be added twice, through ip_tunnel_create() and ip_tunnel_update().

Because the second is unnecessary, so we can just break after adding tunnel through ip_tunnel_create().

---
 net/ipv4/ip_tunnel.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/ipv4/ip_tunnel.c +2 -4
index b3f8597..e83af0f 100644
@@ -755,10 +755,8 @@ int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd)
 
 		if (!t && (cmd == SIOCADDTUNNEL)) {
 			t = ip_tunnel_create(net, itn, p);
-			if (IS_ERR(t)) {
-				err = PTR_ERR(t);
-				break;
-			}
+			err = PTR_ERR_OR_ZERO(t);
+			break;
 		}
 		if (dev != itn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {
 			if (t != NULL) {
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

From: Duan Jiong <[email protected]>
Date: Thu, 15 May 2014 13:07:02 +0800

Quoted 8 lines

When using command "ip tunnel add" to add a tunnel, the tunnel will be added twice, through ip_tunnel_create() and ip_tunnel_update().

Because the second is unnecessary, so we can just break after adding tunnel through ip_tunnel_create().

ip_tunnel_update() seems to do some things tha ip_tunnel_create() does not.

For example, setting dev->dev_addr[] and dev->broadcast[] from the ipv4 parms if appropriate.

I think you need to rethink this change.

author
#2 lore raw
Quoted 12 lines · David Miller

From: Duan Jiong <[email protected]>
Date: Thu, 15 May 2014 13:07:02 +0800

Quoted 8 lines

When using command "ip tunnel add" to add a tunnel, the tunnel will be added twice, through ip_tunnel_create() and ip_tunnel_update().

Because the second is unnecessary, so we can just break after adding tunnel through ip_tunnel_create().

Quoted 7 lines

ip_tunnel_update() seems to do some things tha ip_tunnel_create() does not.

For example, setting dev->dev_addr[] and dev->broadcast[] from the ipv4 parms if appropriate.

I think you need to rethink this change.

When registering tunnel link, function register_netdevice() will call dev->netdev_ops->ndo_init, actually the virtual function ndo_init will do some same things the ip_tunnel_update() does, such as the above you mentioned.

So i think you don't need to worry about that.

Thanks,
Duan

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw

From: Duan Jiong <[email protected]>
Date: Fri, 16 May 2014 13:06:47 +0800

Quoted 19 lines
Quoted 18 lines · David Miller

From: Duan Jiong <[email protected]>
Date: Thu, 15 May 2014 13:07:02 +0800

Quoted 8 lines

When using command "ip tunnel add" to add a tunnel, the tunnel will be added twice, through ip_tunnel_create() and ip_tunnel_update().

Because the second is unnecessary, so we can just break after adding tunnel through ip_tunnel_create().

ip_tunnel_update() seems to do some things tha ip_tunnel_create() does not.

For example, setting dev->dev_addr[] and dev->broadcast[] from the ipv4 parms if appropriate.

Quoted 8 lines
Quoted 1 line

I think you need to rethink this change.

When registering tunnel link, function register_netdevice() will call dev->netdev_ops->ndo_init, actually the virtual function ndo_init will do some same things the ip_tunnel_update() does, such as the above you mentioned.

So i think you don't need to worry about that.

Aha, I see, thanks for explaining.

Patch applied.