Skip to content

Commit

Permalink
macvlan: Support creating macvlans from macvlans
Browse files Browse the repository at this point in the history
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 <ebiederm@aristanetworks.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Biederman authored and David S. Miller committed Mar 13, 2009
1 parent f7efb6c commit b0832a2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b0832a2

Please sign in to comment.