From: David Ahern Date: Wed, 26 Apr 2017 14:58:22 +0000 (-0700) Subject: net: vrf: Do not allow looback to be moved to a VRF X-Git-Tag: v4.12-rc1~129^2~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26d31ac11fa47a0ee8dc4c64136ea34feda57e3e;p=platform%2Fkernel%2Flinux-exynos.git net: vrf: Do not allow looback to be moved to a VRF Moving the loopback into a VRF breaks networking for the default VRF. Since the VRF device is the loopback for VRF domains, there is no reason to move the loopback. Given the repercussions, block attempts to set lo into a VRF. Signed-off-by: David Ahern Reviewed-by: Greg Rose Signed-off-by: David S. Miller --- diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index aa5d304..ceda586 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -877,6 +877,12 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev) { int ret; + /* do not allow loopback device to be enslaved to a VRF. + * The vrf device acts as the loopback for the vrf. + */ + if (port_dev == dev_net(dev)->loopback_dev) + return -EOPNOTSUPP; + port_dev->priv_flags |= IFF_L3MDEV_SLAVE; ret = netdev_master_upper_dev_link(port_dev, dev, NULL, NULL); if (ret < 0)