From: Eric Biederman Date: Fri, 13 Mar 2009 20:15:37 +0000 (-0700) Subject: macvlan: Support creating macvlans from macvlans X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b0832a2961022a076c812384435b5f0290b3fc91;p=linux-beck.git macvlan: Support creating macvlans from macvlans When running in a network namespace whose only link to the outside world is a macvlan device, not being able to create another macvlan is a real pain. So modify macvlan creation to allow automatically forward a creation of a macvlan on a macvlan to become a creation of a macvlan on the underlying network device. Signed-off-by: Eric Biederman Acked-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 7e24b5048686..b5241fc0f512 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -461,12 +461,13 @@ static int macvlan_newlink(struct net_device *dev, if (lowerdev == NULL) return -ENODEV; - /* Don't allow macvlans on top of other macvlans - its not really - * wrong, but lockdep can't handle it and its not useful for anything - * you couldn't do directly on top of the real device. + /* When creating macvlans on top of other macvlans - use + * the real device as the lowerdev. */ - if (lowerdev->rtnl_link_ops == dev->rtnl_link_ops) - return -ENODEV; + if (lowerdev->rtnl_link_ops == dev->rtnl_link_ops) { + struct macvlan_dev *lowervlan = netdev_priv(lowerdev); + lowerdev = lowervlan->lowerdev; + } if (!tb[IFLA_MTU]) dev->mtu = lowerdev->mtu;