diff mbox

[net-next] ip_tunnel: don't add tunnel twice

Message ID 53744B76.3080101@cn.fujitsu.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Duan Jiong May 15, 2014, 5:07 a.m. UTC
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().

Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---
 net/ipv4/ip_tunnel.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

David Miller May 16, 2014, 3:10 a.m. UTC | #1
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Thu, 15 May 2014 13:07:02 +0800

> 
> 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().
> 
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>

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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Duan Jiong May 16, 2014, 5:06 a.m. UTC | #2
于 2014年05月16日 11:10, David Miller 写道:
> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> Date: Thu, 15 May 2014 13:07:02 +0800
> 
>>
>> 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().
>>
>> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> 
> 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
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 16, 2014, 8:58 p.m. UTC | #3
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Fri, 16 May 2014 13:06:47 +0800

> 于 2014年05月16日 11:10, David Miller 写道:
>> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>> Date: Thu, 15 May 2014 13:07:02 +0800
>> 
>>>
>>> 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().
>>>
>>> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>> 
>> 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.

Aha, I see, thanks for explaining.

Patch applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index b3f8597..e83af0f 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -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) {