Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macvlan: Support creating macvtaps from macvlans

When running in a network namespace whose only link to the outside
world is a macvlan device, not being able to create a macvtap off of
it is a real pain.

So modify macvtap creation to automatically forward a creation of a
macvtap on a macvlan to become a creation of a macvtap on the
underlying network device, just like is currently done with
macvlan-on-macvlan devices.

v2: Use netif_is_macvlan and macvlan_dev_real_dev helpers to make it
more clear what we're doing.

Signed-off-by: Kevin Wallace <kevin@pentabarf.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kevin Wallace and committed by
David S. Miller
d70f2cf5 426e1fa3

+3 -5
+3 -5
drivers/net/macvlan.c
··· 820 820 if (lowerdev == NULL) 821 821 return -ENODEV; 822 822 823 - /* When creating macvlans on top of other macvlans - use 823 + /* When creating macvlans or macvtaps on top of other macvlans - use 824 824 * the real device as the lowerdev. 825 825 */ 826 - if (lowerdev->rtnl_link_ops == dev->rtnl_link_ops) { 827 - struct macvlan_dev *lowervlan = netdev_priv(lowerdev); 828 - lowerdev = lowervlan->lowerdev; 829 - } 826 + if (netif_is_macvlan(lowerdev)) 827 + lowerdev = macvlan_dev_real_dev(lowerdev); 830 828 831 829 if (!tb[IFLA_MTU]) 832 830 dev->mtu = lowerdev->mtu;