2014-04-24 09:05:27

by Kusanagi Kouichi

[permalink] [raw]
Subject: [PATCH] veth: Allow a peer to be up at creation time

Currently, a veth peer cannot be up at creation time.

# ip link add type veth peer up
RTNETLINK answers: Transport endpoint is not connected

Signed-off-by: Kusanagi Kouichi <[email protected]>
---
drivers/net/veth.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index b4a10bc..aa87afc 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -373,10 +373,6 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,

netif_carrier_off(peer);

- err = rtnl_configure_link(peer, ifmp);
- if (err < 0)
- goto err_configure_peer;
-
/*
* register dev last
*
@@ -407,11 +403,16 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,

priv = netdev_priv(peer);
rcu_assign_pointer(priv->peer, dev);
+
+ err = rtnl_configure_link(peer, ifmp);
+ if (err < 0)
+ goto err_configure_peer;
+
return 0;

-err_register_dev:
- /* nothing to do */
err_configure_peer:
+ unregister_netdevice(dev);
+err_register_dev:
unregister_netdevice(peer);
return err;

--
2.0.0.rc0


2014-04-24 20:42:28

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] veth: Allow a peer to be up at creation time

From: Kusanagi Kouichi <[email protected]>
Date: Thu, 24 Apr 2014 17:56:06 +0900

> Currently, a veth peer cannot be up at creation time.
>
> # ip link add type veth peer up
> RTNETLINK answers: Transport endpoint is not connected
>
> Signed-off-by: Kusanagi Kouichi <[email protected]>

I do not think this is sufficient.

There are many problems if you signal an error after we do:

err = register_netdevice(dev);

For one thing, you aren't unregistering 'dev' in that error path,
furthermore, priv->peer points to the netdevice you are unregistering.

I think this cannot be done, what you aim to achieve, and we just
simply have to live with the current semantics. Bring the device
up after you have created it.