Skip to contentSkip to conversation

net: vrf: Do not allow looback to be moved to a VRF

PATCH Applied David Ahern 3 participants 3 messages Apr 26, 2017 – Apr 27, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/net/vrf.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/vrf.c +6 -0
index aa5d30428bba..ceda5861da78 100644
@@ -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)
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · David Ahern

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.

---
 drivers/net/vrf.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/vrf.c +0 -0
index aa5d30428bba..ceda5861da78 100644
@@ -877,6 +877,12 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)
 {
 	int ret;

drivers/net/vrf.c static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev) · line 888

Quoted 10 lines
drivers/net/vrf.c +6 -0
 
+	/* 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)

I think that's a great idea.

maintainer Applied
#2 lore raw
In reply to David Ahern

From: David Ahern <[email protected]>
Date: Wed, 26 Apr 2017 07:58:22 -0700

Quoted 6 lines

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.

Applied, thanks David.