Skip to contentSkip to conversation

Minor macvlan source mode cleanups

PATCH In review Alexander Duyck 2 participants 4 messages Oct 13, 2017 – Oct 15, 2017

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

cover Minor macvlan source mode cleanups

So this patch series is just a few minor cleanups for macvlan source mode. The first patch addresses double receives when a packet is being routed to the macvlan destination address, and the other addresses the pkt_type being updated in cases where it most likely should not be.

---

Alexander Duyck (2):
macvlan: Only deliver one copy of the frame to the macvlan interface
macvlan: Only update pkt_type if destination MAC address matches

 drivers/net/macvlan.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 macvlan: Only deliver one copy of the frame to the macvlan interface

From: Alexander Duyck <[email protected]>

This patch intoduces a slight adjustment for macvlan to address the fact that in source mode I was seeing two copies of any packet addressed to the macvlan interface being delivered where there should have been only one.

The issue appears to be that one copy was delivered based on the source MAC address and then the second copy was being delivered based on the destination MAC address. To fix it I am just treating a unicast address match as though it is not a match since source based macvlan isn't supposed to be matching based on the destination MAC anyway.

Fixes 79cf79abce71 ("macvlan: add source mode")
---
 drivers/net/macvlan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
index d2aea961e0f4..fb1c9e095d0c 100644
@@ -480,7 +480,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
 					      struct macvlan_dev, list);
 	else
 		vlan = macvlan_hash_lookup(port, eth->h_dest);
-	if (vlan == NULL)
+	if (!vlan || vlan->mode == MACVLAN_MODE_SOURCE)
 		return RX_HANDLER_PASS;
 
 	dev = vlan->dev;
#2 lore raw

PATCH 2/2 macvlan: Only update pkt_type if destination MAC address matches

In reply to Alexander Duyck

From: Alexander Duyck <[email protected]>

This patch updates the pkt_type to PACKET_HOST only if the destination MAC address matches on the on the source based macvlan. It didn't make sense to be updating broadcast, multicast, and non-local destined frames with PACKET_HOST.

---
 drivers/net/macvlan.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/macvlan.c +3 -1
index fb1c9e095d0c..b0cd866915d7 100644
@@ -413,7 +413,9 @@ static void macvlan_forward_source_one(struct sk_buff *skb,
 
 	len = nskb->len + ETH_HLEN;
 	nskb->dev = dev;
-	nskb->pkt_type = PACKET_HOST;
+
+	if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest, dev->dev_addr))
+		nskb->pkt_type = PACKET_HOST;
 
 	ret = netif_rx(nskb);
 	macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, false);
maintainer
#3 lore raw
In reply to Alexander Duyck

From: Alexander Duyck <[email protected]>
Date: Fri, 13 Oct 2017 13:40:18 -0700

Quoted 4 lines

So this patch series is just a few minor cleanups for macvlan source mode. The first patch addresses double receives when a packet is being routed to the macvlan destination address, and the other addresses the pkt_type being updated in cases where it most likely should not be.

Series applied, thanks.