Skip to contentSkip to conversation

macvlan: Allow other mode macvlans in addition to passthru

RFC New Helmut Schaa 1 participant 1 message Dec 20, 2013

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

RFC 1/1 macvlan: Allow other mode macvlans in addition to passthru

This allows a passthru macvlan to coexist with other macvlans. For example the passthru macvlan can be put into a bridge while concurrently using a private macvlan.

The passthru interface will not get frames destined for other macvlan interfaces but everything else.

---
 drivers/net/macvlan.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/net/macvlan.c +5 -8
index acf9379..1f6dae8c 100644
@@ -230,11 +230,11 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
 		return RX_HANDLER_PASS;
 	}
 
-	if (port->passthru)
+	vlan = macvlan_hash_lookup(port, eth->h_dest);
+
+	if (vlan == NULL && port->passthru)
 		vlan = list_first_or_null_rcu(&port->vlans,
 					      struct macvlan_dev, list);
-	else
-		vlan = macvlan_hash_lookup(port, eth->h_dest);
 	if (vlan == NULL)
 		return RX_HANDLER_PASS;
 
@@ -843,10 +843,6 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 	}
 	port = macvlan_port_get_rtnl(lowerdev);
 
-	/* Only 1 macvlan device can be created in passthru mode */
-	if (port->passthru)
-		return -EINVAL;
-
 	vlan->lowerdev = lowerdev;
 	vlan->dev      = dev;
 	vlan->port     = port;
@@ -862,7 +858,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 		vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
 
 	if (vlan->mode == MACVLAN_MODE_PASSTHRU) {
-		if (port->count)
+		/* Only a single passthru interface is allowed */
+		if (port->passthru)
 			return -EINVAL;
 		port->passthru = true;
 		eth_hw_addr_inherit(dev, lowerdev);
Signature · 1 line
1.8.1.4