From: Jiri Pirko Date: Sat, 30 Apr 2011 01:28:17 +0000 (+0000) Subject: Revert: veth: remove unneeded ifname code from veth_newlink() X-Git-Tag: v3.0~810^2~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c8c44462ac8ac3f95929328f0c56e9e8b6dd524;p=platform%2Fkernel%2Flinux-amlogic.git Revert: veth: remove unneeded ifname code from veth_newlink() 84c49d8c3e4abefb0a41a77b25aa37ebe8d6b743 ("veth: remove unneeded ifname code from veth_newlink()") caused regression on veth creation. This patch reverts the original one. Reported-by: Michał Mirosław Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 2de9b90..3b99f64 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -403,6 +403,17 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, if (tb[IFLA_ADDRESS] == NULL) random_ether_addr(dev->dev_addr); + if (tb[IFLA_IFNAME]) + nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ); + else + snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d"); + + if (strchr(dev->name, '%')) { + err = dev_alloc_name(dev, dev->name); + if (err < 0) + goto err_alloc_name; + } + err = register_netdevice(dev); if (err < 0) goto err_register_dev; @@ -422,6 +433,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, err_register_dev: /* nothing to do */ +err_alloc_name: err_configure_peer: unregister_netdevice(peer); return err;