aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/veth.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2012-08-08 17:53:03 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-09 19:18:07 -0400
commite6f8f1a739b652c56e6f959d6714d92e05621e21 (patch)
treec586da6003b73a0b356380c6f6302e21426be0ef /drivers/net/veth.c
parent9c7dafbfab1554705f85523fead578aa1a3d338c (diff)
veth: Allow to create peer link with given ifindex
The ifinfomsg is in there (thanks kaber@ for foreseeing this long time ago), so take the given ifidex and register netdev with it. Ben noticed, that this code path previously ignored ifmp->ifi_index and userland could be passing in garbage. Thus it may now fail occasionally because the value clashes with an existing interface. To address this it's assumed that if the caller specifies the ifindex for the veth master device, then it's aware of this possibility and should explicitly specify (or set to 0 for auto-assignment) the peer's ifindex as well. With this the compatibility with old tools not setting ifindex is preserved. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r--drivers/net/veth.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 5852361032c4..e522ff70444c 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -348,6 +348,9 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
348 if (tbp[IFLA_ADDRESS] == NULL) 348 if (tbp[IFLA_ADDRESS] == NULL)
349 eth_hw_addr_random(peer); 349 eth_hw_addr_random(peer);
350 350
351 if (ifmp && (dev->ifindex != 0))
352 peer->ifindex = ifmp->ifi_index;
353
351 err = register_netdevice(peer); 354 err = register_netdevice(peer);
352 put_net(net); 355 put_net(net);
353 net = NULL; 356 net = NULL;