All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] macvlan: disable LRO on lowerdev instead of a macvlan
@ 2013-11-08 13:40 Michal Kubecek
  2013-11-08 13:41 ` [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions Michal Kubecek
  2013-11-08 13:41 ` [PATCH net 2/2] macvlan: disable LRO on lower device instead of macvlan Michal Kubecek
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Kubecek @ 2013-11-08 13:40 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Patrick McHardy

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(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions
  2013-11-08 13:40 [PATCH net 0/2] macvlan: disable LRO on lowerdev instead of a macvlan Michal Kubecek
@ 2013-11-08 13:41 ` Michal Kubecek
  2013-11-08 15:06   ` John Fastabend
  2013-11-08 13:41 ` [PATCH net 2/2] macvlan: disable LRO on lower device instead of macvlan Michal Kubecek
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Kubecek @ 2013-11-08 13:41 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Patrick McHardy

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.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 drivers/net/macvlan.c      |  2 +-
 include/linux/if_macvlan.h | 26 ++++++++++++++++++++++++++
 include/uapi/linux/if.h    |  1 +
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 9bf46bd..3bdac0a 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -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;
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index ddd33fd..8f355f9 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -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 */
diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index 1ec407b..d8e48f8 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -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 */
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] macvlan: disable LRO on lower device instead of macvlan
  2013-11-08 13:40 [PATCH net 0/2] macvlan: disable LRO on lowerdev instead of a macvlan Michal Kubecek
  2013-11-08 13:41 ` [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions Michal Kubecek
@ 2013-11-08 13:41 ` Michal Kubecek
  1 sibling, 0 replies; 5+ messages in thread
From: Michal Kubecek @ 2013-11-08 13:41 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Patrick McHardy

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).

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/core/dev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3430b1e..4af02a9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions
  2013-11-08 13:41 ` [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions Michal Kubecek
@ 2013-11-08 15:06   ` John Fastabend
  2013-11-08 15:23     ` Michal Kubecek
  0 siblings, 1 reply; 5+ messages in thread
From: John Fastabend @ 2013-11-08 15:06 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: netdev, David S. Miller, Patrick McHardy

On 11/8/2013 5:41 AM, Michal Kubecek wrote:
> 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.
>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
> ---
>   drivers/net/macvlan.c      |  2 +-
>   include/linux/if_macvlan.h | 26 ++++++++++++++++++++++++++
>   include/uapi/linux/if.h    |  1 +
>   3 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 9bf46bd..3bdac0a 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -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;
> diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
> index ddd33fd..8f355f9 100644
> --- a/include/linux/if_macvlan.h
> +++ b/include/linux/if_macvlan.h
> @@ -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 <john.r.fastabend@intel.com>
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions
  2013-11-08 15:06   ` John Fastabend
@ 2013-11-08 15:23     ` Michal Kubecek
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Kubecek @ 2013-11-08 15:23 UTC (permalink / raw)
  To: John Fastabend; +Cc: netdev, David S. Miller, Patrick McHardy

On Fri, Nov 08, 2013 at 07:06:15AM -0800, John Fastabend wrote:
> 
> 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 <john.r.fastabend@intel.com>
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-08 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 13:40 [PATCH net 0/2] macvlan: disable LRO on lowerdev instead of a macvlan Michal Kubecek
2013-11-08 13:41 ` [PATCH net 1/2] macvlan: introduce IFF_MACVLAN flag and helper functions Michal Kubecek
2013-11-08 15:06   ` John Fastabend
2013-11-08 15:23     ` Michal Kubecek
2013-11-08 13:41 ` [PATCH net 2/2] macvlan: disable LRO on lower device instead of macvlan Michal Kubecek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.