Skip to contentSkip to conversation

macvlan: disable LRO on lowerdev instead of a macvlan

PATCH Superseded Michal Kubecek 2 participants 5 messages Nov 8, 2013

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover macvlan: disable LRO on lowerdev instead of a macvlan

A customer of ours encountered a problem with LRO on an ixgbe network card. Analysis showed that it was a known conflict of forwarding and LRO but the forwarding was enabled in an LXC container where only a macvlan was, not the ethernet device itself.

I believe the solution is exactly the same as what we do for "normal" (802.1q) VLAN devices: if dev_disable_lro() is called for such device, LRO is disabled on the underlying "real" device instead.

Michal Kubecek (2):
macvlan: introduce IFF_MACVLAN flag and helper functions
macvlan: disable LRO on lower device instead of macvlan

 drivers/net/macvlan.c      |  2 +-
 include/linux/if_macvlan.h | 26 ++++++++++++++++++++++++++
 include/uapi/linux/if.h    |  1 +
 net/core/dev.c             |  5 +++++
 4 files changed, 33 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 macvlan: introduce IFF_MACVLAN flag and helper functions

Introduce IFF_MACVLAN flag to recognize macvlan devices and two helper functions, is_macvlan_dev() and macvlan_dev_real_dev(). These work like similar functions for 802.1q VLAN devices.

---
 drivers/net/macvlan.c      |  2 +-
 include/linux/if_macvlan.h | 26 ++++++++++++++++++++++++++
 include/uapi/linux/if.h    |  1 +
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
index 9bf46bd..3bdac0a 100644
@@ -685,7 +685,7 @@ void macvlan_common_setup(struct net_device *dev)
 	ether_setup(dev);
 
 	dev->priv_flags	       &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
-	dev->priv_flags	       |= IFF_UNICAST_FLT;
+	dev->priv_flags	       |= IFF_UNICAST_FLT | IFF_MACVLAN;
 	dev->netdev_ops		= &macvlan_netdev_ops;
 	dev->destructor		= free_netdev;
 	dev->header_ops		= &macvlan_hard_header_ops;
include/linux/if_macvlan.h +26 -0
index ddd33fd..8f355f9 100644
@@ -118,4 +118,30 @@ extern int macvlan_link_register(struct rtnl_link_ops *ops);
 extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
 				      struct net_device *dev);
 
+#if IS_ENABLED(CONFIG_MACVLAN)
+static inline bool is_macvlan_dev(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_MACVLAN;
+}
+
+static inline struct net_device *
+macvlan_dev_real_dev(const struct net_device *dev)
+{
+	struct macvlan_dev *macvlan = netdev_priv(dev);
+
+	return macvlan->lowerdev;
+}
+#else
+static inline bool is_macvlan_dev(struct net_device *dev)
+{
+	return false;
+}
+
+static inline struct net_device *
+macvlan_dev_real_dev(const struct net_device *dev)
+{
+	return NULL;
+}
+#endif
+
 #endif /* _LINUX_IF_MACVLAN_H */
include/uapi/linux/if.h +1 -0
index 1ec407b..d8e48f8 100644
@@ -83,6 +83,7 @@
 #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
 #define IFF_LIVE_ADDR_CHANGE 0x100000	/* device supports hardware address
 					 * change when it's running */
+#define IFF_MACVLAN	0x200000	/* macvlan device */
 
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 2/2 macvlan: disable LRO on lower device instead of macvlan

In reply to Michal Kubecek

A macvlan device has always LRO disabled so that calling dev_disable_lro() on it does nothing. If we need to disable LRO e.g. because

- the macvlan device is inserted into a bridge
- IPv6 forwarding is enabled for it
- it is in a different namespace than lowerdev and IPv4 forwarding is enabled in it

we need to disable LRO on its underlying device instead (as we do for 802.1q VLAN devices).

---
 net/core/dev.c | 5 +++++
 1 file changed, 5 insertions(+)
net/core/dev.c +5 -0
index 3430b1e..4af02a9 100644
@@ -131,6 +131,7 @@
 #include <linux/static_key.h>
 #include <linux/hashtable.h>
 #include <linux/vmalloc.h>
+#include <linux/if_macvlan.h>
 
 #include "net-sysfs.h"
 
@@ -1425,6 +1426,10 @@ void dev_disable_lro(struct net_device *dev)
 	if (is_vlan_dev(dev))
 		dev = vlan_dev_real_dev(dev);
 
+	/* the same for macvlan devices */
+	if (is_macvlan_dev(dev))
+		dev = macvlan_dev_real_dev(dev);
+
 	dev->wanted_features &= ~NETIF_F_LRO;
 	netdev_update_features(dev);
 
Signature · 1 line
1.8.1.4
#2 lore raw

Re: [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions

In reply to Michal Kubecek
Quoted 29 lines · Michal Kubecek

Introduce IFF_MACVLAN flag to recognize macvlan devices and two helper functions, is_macvlan_dev() and macvlan_dev_real_dev(). These work like similar functions for 802.1q VLAN devices.

---
  drivers/net/macvlan.c      |  2 +-
  include/linux/if_macvlan.h | 26 ++++++++++++++++++++++++++
  include/uapi/linux/if.h    |  1 +
  3 files changed, 28 insertions(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
index 9bf46bd..3bdac0a 100644
@@ -685,7 +685,7 @@ void macvlan_common_setup(struct net_device *dev)
  	ether_setup(dev);
 
  	dev->priv_flags	       &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
-	dev->priv_flags	       |= IFF_UNICAST_FLT;
+	dev->priv_flags	       |= IFF_UNICAST_FLT | IFF_MACVLAN;
  	dev->netdev_ops		= &macvlan_netdev_ops;
  	dev->destructor		= free_netdev;
  	dev->header_ops		= &macvlan_hard_header_ops;
include/linux/if_macvlan.h +0 -0
index ddd33fd..8f355f9 100644

include/linux/if_macvlan.h extern int macvlan_link_register(struct rtnl_link_ops *ops); · line 126

Quoted 9 lines
include/linux/if_macvlan.h +6 -0
@@ -118,4 +118,30 @@ extern int macvlan_link_register(struct rtnl_link_ops *ops);
  extern netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
  				      struct net_device *dev);
 
+#if IS_ENABLED(CONFIG_MACVLAN)
+static inline bool is_macvlan_dev(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_MACVLAN;
+}
+

I just added this to netdevice.h here,

+static inline bool netif_is_macvlan(struct net_device *dev) +{
+ return dev->priv_flags & IFF_MACVLAN;
+}
+

although I didn't wrap it in the IS_ENABLED if/else, but a bitmask in slow path probably doesn't matter. As a precedent none of the other netif_is_* bitmasks are wrapped like this.

The patch is

commit 2a47fa45d4dfbc54659d28de311a1f764b296a3c

Author: John Fastabend <[email protected]>
Date:   Wed Nov 6 09:54:52 2013 -0800

ixgbe: enable l2 forwarding acceleration for macvlans

I think you need to respin the patch with just the macvlan_dev_real_dev() part.

Thanks,
John

#3 lore raw

Re: [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions

Quoted 16 lines · John Fastabend

I just added this to netdevice.h here,

include/linux/if_macvlan.h +5 -0
+static inline bool netif_is_macvlan(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_MACVLAN;
+}
+

although I didn't wrap it in the IS_ENABLED if/else, but a bitmask in slow path probably doesn't matter. As a precedent none of the other netif_is_* bitmasks are wrapped like this.

The patch is

commit 2a47fa45d4dfbc54659d28de311a1f764b296a3c

Quoted 8 lines
Author: John Fastabend <[email protected]>
Date:   Wed Nov 6 09:54:52 2013 -0800

ixgbe: enable l2 forwarding acceleration for macvlans

I think you need to respin the patch with just the macvlan_dev_real_dev() part.

My patch also conflicts with

a6cc0cfa net: Add layer 2 hardware acceleration operations for macvlan devices

which introduced the IFF_MACVLAN flags (but sets it in macvlan_common_newlink()). Both of yours are in net-next while mine are against net (as 2/2 is a bugfix) which is why I didn't notice them. I'm not sure what to do in such case.

Michal Kubecek