netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice
@ 2017-06-30 13:19 Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading Sabrina Dubroca
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

This patchset adds a new netdevice feature to toggle tunnel offloads
via ethtool. This is useful if the offload is causing issues, for
example if the hardware is buggy.

The feature is added to all devices providing the ->ndo_udp_tunnel_add
op, and enabled by default to preserve current behavior.

When the administrator disables this feature on a device, all
currently offloaded ports are cleared from the device.  When the
feature is turned on, the stack notifies the device about all current
ports.

Sabrina Dubroca (6):
  net: add new netdevice feature for tunnel offloading
  net: check tunnel offload feature before calling tunnel ndo ndo
  net: add infrastructure to un-offload UDP tunnel port
  net: call udp_tunnel_get_rx_info when NETIF_F_TUNNEL_OFFLOAD is
    toggled
  geneve/vxlan: add support for NETDEV_UDP_TUNNEL_DROP_INFO
  geneve/vxlan: offload ports on register/unregister events

 drivers/net/geneve.c            | 24 ++++++++++++++++++------
 drivers/net/vxlan.c             | 31 ++++++++++++++++++++++---------
 include/linux/netdev_features.h |  2 ++
 include/linux/netdevice.h       |  1 +
 include/net/udp_tunnel.h        |  8 ++++++++
 net/core/dev.c                  | 28 +++++++++++++++++++++++++++-
 net/core/ethtool.c              |  1 +
 net/ipv4/udp_tunnel.c           | 25 ++++++++++++++++++++++++-
 8 files changed, 103 insertions(+), 17 deletions(-)

-- 
2.13.2

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

* [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  2017-06-30 15:50   ` Jiri Benc
  2017-06-30 13:19 ` [PATCH net-next 2/6] net: check tunnel offload feature before calling tunnel ndo ndo Sabrina Dubroca
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

This adds a new netdevice feature, so that tunnel offloading can be
disabled by the administrator on some netdevices, using the
"tunnel-offload" ethtool feature.

This feature is set for all devices that provide ndo_udp_tunnel_add.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 include/linux/netdev_features.h | 2 ++
 net/core/dev.c                  | 6 ++++++
 net/core/ethtool.c              | 1 +
 3 files changed, 9 insertions(+)

diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 1d4737cffc71..40a098e40d5d 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -76,6 +76,7 @@ enum {
 	NETIF_F_HW_TC_BIT,		/* Offload TC infrastructure */
 	NETIF_F_HW_ESP_BIT,		/* Hardware ESP transformation offload */
 	NETIF_F_HW_ESP_TX_CSUM_BIT,	/* ESP with TX checksum offload */
+	NETIF_F_TUNNEL_OFFLOAD_BIT,     /* Tunnel offloads */
 
 	/*
 	 * Add your fresh new feature above and remember to update
@@ -140,6 +141,7 @@ enum {
 #define NETIF_F_HW_TC		__NETIF_F(HW_TC)
 #define NETIF_F_HW_ESP		__NETIF_F(HW_ESP)
 #define NETIF_F_HW_ESP_TX_CSUM	__NETIF_F(HW_ESP_TX_CSUM)
+#define	NETIF_F_TUNNEL_OFFLOAD  __NETIF_F(TUNNEL_OFFLOAD)
 
 #define for_each_netdev_feature(mask_addr, bit)	\
 	for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT)
diff --git a/net/core/dev.c b/net/core/dev.c
index a91572aa73d5..d97f7b39df23 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7505,6 +7505,12 @@ int register_netdevice(struct net_device *dev)
 	 */
 	dev->hw_features |= NETIF_F_SOFT_FEATURES;
 	dev->features |= NETIF_F_SOFT_FEATURES;
+
+	if (dev->netdev_ops->ndo_udp_tunnel_add) {
+		dev->features |= NETIF_F_TUNNEL_OFFLOAD;
+		dev->hw_features |= NETIF_F_TUNNEL_OFFLOAD;
+	}
+
 	dev->wanted_features = dev->features & dev->hw_features;
 
 	if (!(dev->flags & IFF_LOOPBACK))
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 03111a2d6653..b693421d5d71 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -106,6 +106,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
 	[NETIF_F_HW_TC_BIT] =		 "hw-tc-offload",
 	[NETIF_F_HW_ESP_BIT] =		 "esp-hw-offload",
 	[NETIF_F_HW_ESP_TX_CSUM_BIT] =	 "esp-tx-csum-hw-offload",
+	[NETIF_F_TUNNEL_OFFLOAD_BIT] =	 "tunnel-offload",
 };
 
 static const char
-- 
2.13.2

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

* [PATCH net-next 2/6] net: check tunnel offload feature before calling tunnel ndo ndo
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 3/6] net: add infrastructure to un-offload UDP tunnel port Sabrina Dubroca
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

If NETIF_F_TUNNEL_OFFLOAD was disabled on a given netdevice, skip the
tunnel offload ndo call during tunnel port creation and deletion.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/ipv4/udp_tunnel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
index 58bd39fb14b4..fc8336fddadf 100644
--- a/net/ipv4/udp_tunnel.c
+++ b/net/ipv4/udp_tunnel.c
@@ -82,7 +82,8 @@ void udp_tunnel_push_rx_port(struct net_device *dev, struct socket *sock,
 	struct sock *sk = sock->sk;
 	struct udp_tunnel_info ti;
 
-	if (!dev->netdev_ops->ndo_udp_tunnel_add)
+	if (!dev->netdev_ops->ndo_udp_tunnel_add ||
+	    !(dev->features & NETIF_F_TUNNEL_OFFLOAD))
 		return;
 
 	ti.type = type;
@@ -109,6 +110,8 @@ void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
 	for_each_netdev_rcu(net, dev) {
 		if (!dev->netdev_ops->ndo_udp_tunnel_add)
 			continue;
+		if (!(dev->features & NETIF_F_TUNNEL_OFFLOAD))
+			continue;
 		dev->netdev_ops->ndo_udp_tunnel_add(dev, &ti);
 	}
 	rcu_read_unlock();
@@ -131,6 +134,8 @@ void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type)
 	for_each_netdev_rcu(net, dev) {
 		if (!dev->netdev_ops->ndo_udp_tunnel_del)
 			continue;
+		if (!(dev->features & NETIF_F_TUNNEL_OFFLOAD))
+			continue;
 		dev->netdev_ops->ndo_udp_tunnel_del(dev, &ti);
 	}
 	rcu_read_unlock();
-- 
2.13.2

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

* [PATCH net-next 3/6] net: add infrastructure to un-offload UDP tunnel port
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 2/6] net: check tunnel offload feature before calling tunnel ndo ndo Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 4/6] net: call udp_tunnel_get_rx_info when NETIF_F_TUNNEL_OFFLOAD is toggled Sabrina Dubroca
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

This adds a new NETDEV_UDP_TUNNEL_DROP_INFO event, similar to
NETDEV_UDP_TUNNEL_PUSH_INFO, to signal to un-offload ports.

This also adds udp_tunnel_drop_rx_port(), which calls
ndo_udp_tunnel_del.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 include/linux/netdevice.h |  1 +
 include/net/udp_tunnel.h  |  8 ++++++++
 net/ipv4/udp_tunnel.c     | 18 ++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 85f01d673340..75cd0c31357d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2307,6 +2307,7 @@ struct netdev_lag_lower_state_info {
 #define NETDEV_PRECHANGEUPPER	0x001A
 #define NETDEV_CHANGELOWERSTATE	0x001B
 #define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C
+#define NETDEV_UDP_TUNNEL_DROP_INFO	0x001D
 #define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E
 
 int register_netdevice_notifier(struct notifier_block *nb);
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index 02c5be037451..10cce0dd4450 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -115,6 +115,8 @@ struct udp_tunnel_info {
 /* Notify network devices of offloadable types */
 void udp_tunnel_push_rx_port(struct net_device *dev, struct socket *sock,
 			     unsigned short type);
+void udp_tunnel_drop_rx_port(struct net_device *dev, struct socket *sock,
+			     unsigned short type);
 void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type);
 void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type);
 
@@ -124,6 +126,12 @@ static inline void udp_tunnel_get_rx_info(struct net_device *dev)
 	call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev);
 }
 
+static inline void udp_tunnel_drop_rx_info(struct net_device *dev)
+{
+	ASSERT_RTNL();
+	call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev);
+}
+
 /* Transmit the skb using UDP encapsulation. */
 void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
 			 __be32 src, __be32 dst, __u8 tos, __u8 ttl,
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c
index fc8336fddadf..c5fd4350251f 100644
--- a/net/ipv4/udp_tunnel.c
+++ b/net/ipv4/udp_tunnel.c
@@ -94,6 +94,24 @@ void udp_tunnel_push_rx_port(struct net_device *dev, struct socket *sock,
 }
 EXPORT_SYMBOL_GPL(udp_tunnel_push_rx_port);
 
+void udp_tunnel_drop_rx_port(struct net_device *dev, struct socket *sock,
+			     unsigned short type)
+{
+	struct sock *sk = sock->sk;
+	struct udp_tunnel_info ti;
+
+	if (!dev->netdev_ops->ndo_udp_tunnel_del ||
+	    !(dev->features & NETIF_F_TUNNEL_OFFLOAD))
+		return;
+
+	ti.type = type;
+	ti.sa_family = sk->sk_family;
+	ti.port = inet_sk(sk)->inet_sport;
+
+	dev->netdev_ops->ndo_udp_tunnel_del(dev, &ti);
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_drop_rx_port);
+
 /* Notify netdevs that UDP port started listening */
 void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
 {
-- 
2.13.2

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

* [PATCH net-next 4/6] net: call udp_tunnel_get_rx_info when NETIF_F_TUNNEL_OFFLOAD is toggled
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
                   ` (2 preceding siblings ...)
  2017-06-30 13:19 ` [PATCH net-next 3/6] net: add infrastructure to un-offload UDP tunnel port Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 5/6] geneve/vxlan: add support for NETDEV_UDP_TUNNEL_DROP_INFO Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 6/6] geneve/vxlan: offload ports on register/unregister events Sabrina Dubroca
  5 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

NETIF_F_TUNNEL_OFFLOAD is special, in that we need to do more than just
flip the bit in dev->features. When disabling we must also clear
currently offloaded ports from the device, and when enabling we must
tell the device to offload the ports it can.

Because vxlan stores its sockets in a hashtable and they are inserted
at the head of per-bucket lists, switching the feature off and then on
can result in a different set of ports being offloaded (depending on
the HW's limits).

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/core/dev.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index d97f7b39df23..ba805fba38dd 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -144,6 +144,7 @@
 #include <linux/netfilter_ingress.h>
 #include <linux/crash_dump.h>
 #include <linux/sctp.h>
+#include <net/udp_tunnel.h>
 
 #include "net-sysfs.h"
 
@@ -7302,8 +7303,27 @@ int __netdev_update_features(struct net_device *dev)
 	netdev_for_each_lower_dev(dev, lower, iter)
 		netdev_sync_lower_features(dev, lower, features);
 
-	if (!err)
+	if (!err) {
+		netdev_features_t diff = features ^ dev->features;
+
+		if (diff & NETIF_F_TUNNEL_OFFLOAD) {
+			/* udp_tunnel_{get,drop}_rx_info both need
+			 * NETIF_F_TUNNEL_OFFLOAD enabled on the
+			 * device, or they won't do anything.
+			 * Thus we need to update dev->features
+			 * *before* calling udp_tunnel_get_rx_info,
+			 * but *after* calling udp_tunnel_drop_rx_info.
+			 */
+			if (features & NETIF_F_TUNNEL_OFFLOAD) {
+				dev->features = features;
+				udp_tunnel_get_rx_info(dev);
+			} else {
+				udp_tunnel_drop_rx_info(dev);
+			}
+		}
+
 		dev->features = features;
+	}
 
 	return err < 0 ? 0 : 1;
 }
-- 
2.13.2

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

* [PATCH net-next 5/6] geneve/vxlan: add support for NETDEV_UDP_TUNNEL_DROP_INFO
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
                   ` (3 preceding siblings ...)
  2017-06-30 13:19 ` [PATCH net-next 4/6] net: call udp_tunnel_get_rx_info when NETIF_F_TUNNEL_OFFLOAD is toggled Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  2017-06-30 13:19 ` [PATCH net-next 6/6] geneve/vxlan: offload ports on register/unregister events Sabrina Dubroca
  5 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

And call udp_tunnel_drop_rx_port() to handle that event.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 drivers/net/geneve.c | 19 +++++++++++++------
 drivers/net/vxlan.c  | 25 +++++++++++++++++--------
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index eb77201cb718..ba89dc69cb07 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -998,16 +998,22 @@ static struct device_type geneve_type = {
  * supply the listening GENEVE udp ports. Callers are expected
  * to implement the ndo_udp_tunnel_add.
  */
-static void geneve_push_rx_ports(struct net_device *dev)
+static void geneve_offload_rx_ports(struct net_device *dev, bool push)
 {
 	struct net *net = dev_net(dev);
 	struct geneve_net *gn = net_generic(net, geneve_net_id);
 	struct geneve_sock *gs;
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(gs, &gn->sock_list, list)
-		udp_tunnel_push_rx_port(dev, gs->sock,
-					UDP_TUNNEL_TYPE_GENEVE);
+	list_for_each_entry_rcu(gs, &gn->sock_list, list) {
+		if (push) {
+			udp_tunnel_push_rx_port(dev, gs->sock,
+						UDP_TUNNEL_TYPE_GENEVE);
+		} else {
+			udp_tunnel_drop_rx_port(dev, gs->sock,
+						UDP_TUNNEL_TYPE_GENEVE);
+		}
+	}
 	rcu_read_unlock();
 }
 
@@ -1410,8 +1416,9 @@ static int geneve_netdevice_event(struct notifier_block *unused,
 {
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 
-	if (event == NETDEV_UDP_TUNNEL_PUSH_INFO)
-		geneve_push_rx_ports(dev);
+	if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
+	    event == NETDEV_UDP_TUNNEL_DROP_INFO)
+		geneve_offload_rx_ports(dev, event == NETDEV_UDP_TUNNEL_PUSH_INFO);
 
 	return NOTIFY_DONE;
 }
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index fd0ff97e3d81..03baa87a70f7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2603,7 +2603,7 @@ static struct device_type vxlan_type = {
  * supply the listening VXLAN udp ports. Callers are expected
  * to implement the ndo_udp_tunnel_add.
  */
-static void vxlan_push_rx_ports(struct net_device *dev)
+static void vxlan_offload_rx_ports(struct net_device *dev, bool push)
 {
 	struct vxlan_sock *vs;
 	struct net *net = dev_net(dev);
@@ -2612,11 +2612,19 @@ static void vxlan_push_rx_ports(struct net_device *dev)
 
 	spin_lock(&vn->sock_lock);
 	for (i = 0; i < PORT_HASH_SIZE; ++i) {
-		hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist)
-			udp_tunnel_push_rx_port(dev, vs->sock,
-						(vs->flags & VXLAN_F_GPE) ?
-						UDP_TUNNEL_TYPE_VXLAN_GPE :
-						UDP_TUNNEL_TYPE_VXLAN);
+		hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) {
+			unsigned short type;
+
+			if (vs->flags & VXLAN_F_GPE)
+				type = UDP_TUNNEL_TYPE_VXLAN_GPE;
+			else
+				type = UDP_TUNNEL_TYPE_VXLAN;
+
+			if (push)
+				udp_tunnel_push_rx_port(dev, vs->sock, type);
+			else
+				udp_tunnel_drop_rx_port(dev, vs->sock, type);
+		}
 	}
 	spin_unlock(&vn->sock_lock);
 }
@@ -3619,8 +3627,9 @@ static int vxlan_netdevice_event(struct notifier_block *unused,
 
 	if (event == NETDEV_UNREGISTER)
 		vxlan_handle_lowerdev_unregister(vn, dev);
-	else if (event == NETDEV_UDP_TUNNEL_PUSH_INFO)
-		vxlan_push_rx_ports(dev);
+	else if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
+		 event == NETDEV_UDP_TUNNEL_DROP_INFO)
+		vxlan_offload_rx_ports(dev, event == NETDEV_UDP_TUNNEL_PUSH_INFO);
 
 	return NOTIFY_DONE;
 }
-- 
2.13.2

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

* [PATCH net-next 6/6] geneve/vxlan: offload ports on register/unregister events
  2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
                   ` (4 preceding siblings ...)
  2017-06-30 13:19 ` [PATCH net-next 5/6] geneve/vxlan: add support for NETDEV_UDP_TUNNEL_DROP_INFO Sabrina Dubroca
@ 2017-06-30 13:19 ` Sabrina Dubroca
  5 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-06-30 13:19 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Benc, Hannes Frederic Sowa, Sabrina Dubroca

This improves consistency of handling when moving a netdev to another
netns. Most drivers currently do a full reset when the device goes up,
so that will flush the offload state anyway.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 drivers/net/geneve.c |  7 ++++++-
 drivers/net/vxlan.c  | 10 +++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index ba89dc69cb07..258c07a94915 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1417,8 +1417,13 @@ static int geneve_netdevice_event(struct notifier_block *unused,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 
 	if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
-	    event == NETDEV_UDP_TUNNEL_DROP_INFO)
+	    event == NETDEV_UDP_TUNNEL_DROP_INFO) {
 		geneve_offload_rx_ports(dev, event == NETDEV_UDP_TUNNEL_PUSH_INFO);
+	} else if (event == NETDEV_UNREGISTER) {
+		geneve_offload_rx_ports(dev, false);
+	} else if (event == NETDEV_REGISTER) {
+		geneve_offload_rx_ports(dev, true);
+	}
 
 	return NOTIFY_DONE;
 }
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 03baa87a70f7..805db76b6e7e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -3625,11 +3625,15 @@ static int vxlan_netdevice_event(struct notifier_block *unused,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 	struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
 
-	if (event == NETDEV_UNREGISTER)
+	if (event == NETDEV_UNREGISTER) {
+		vxlan_offload_rx_ports(dev, false);
 		vxlan_handle_lowerdev_unregister(vn, dev);
-	else if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
-		 event == NETDEV_UDP_TUNNEL_DROP_INFO)
+	} else if (event == NETDEV_REGISTER) {
+		vxlan_offload_rx_ports(dev, true);
+	} else if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
+		   event == NETDEV_UDP_TUNNEL_DROP_INFO) {
 		vxlan_offload_rx_ports(dev, event == NETDEV_UDP_TUNNEL_PUSH_INFO);
+	}
 
 	return NOTIFY_DONE;
 }
-- 
2.13.2

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

* Re: [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading
  2017-06-30 13:19 ` [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading Sabrina Dubroca
@ 2017-06-30 15:50   ` Jiri Benc
  2017-07-04 14:37     ` Sabrina Dubroca
  0 siblings, 1 reply; 9+ messages in thread
From: Jiri Benc @ 2017-06-30 15:50 UTC (permalink / raw)
  To: Sabrina Dubroca; +Cc: netdev, Hannes Frederic Sowa

On Fri, 30 Jun 2017 15:19:45 +0200, Sabrina Dubroca wrote:
> This adds a new netdevice feature, so that tunnel offloading can be
> disabled by the administrator on some netdevices, using the
> "tunnel-offload" ethtool feature.
> 
> This feature is set for all devices that provide ndo_udp_tunnel_add.

This patchset looks great, Sabrina! A few comments below.

> --- a/include/linux/netdev_features.h
> +++ b/include/linux/netdev_features.h
> @@ -76,6 +76,7 @@ enum {
>  	NETIF_F_HW_TC_BIT,		/* Offload TC infrastructure */
>  	NETIF_F_HW_ESP_BIT,		/* Hardware ESP transformation offload */
>  	NETIF_F_HW_ESP_TX_CSUM_BIT,	/* ESP with TX checksum offload */
> +	NETIF_F_TUNNEL_OFFLOAD_BIT,     /* Tunnel offloads */

"Tunnel offload" is very broad. Could we be more specific, e.g. "RSS
tunnel offload" or such? NETIF_F_HW_TUNNEL_RSS?

> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -106,6 +106,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
>  	[NETIF_F_HW_TC_BIT] =		 "hw-tc-offload",
>  	[NETIF_F_HW_ESP_BIT] =		 "esp-hw-offload",
>  	[NETIF_F_HW_ESP_TX_CSUM_BIT] =	 "esp-tx-csum-hw-offload",
> +	[NETIF_F_TUNNEL_OFFLOAD_BIT] =	 "tunnel-offload",
>  };

And here, too. "rss-tunnel-offload"?

Thanks!

 Jiri

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

* Re: [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading
  2017-06-30 15:50   ` Jiri Benc
@ 2017-07-04 14:37     ` Sabrina Dubroca
  0 siblings, 0 replies; 9+ messages in thread
From: Sabrina Dubroca @ 2017-07-04 14:37 UTC (permalink / raw)
  To: Jiri Benc; +Cc: netdev, Hannes Frederic Sowa

2017-06-30, 17:50:01 +0200, Jiri Benc wrote:
> On Fri, 30 Jun 2017 15:19:45 +0200, Sabrina Dubroca wrote:
> > This adds a new netdevice feature, so that tunnel offloading can be
> > disabled by the administrator on some netdevices, using the
> > "tunnel-offload" ethtool feature.
> > 
> > This feature is set for all devices that provide ndo_udp_tunnel_add.
> 
> This patchset looks great, Sabrina! A few comments below.
> 
> > --- a/include/linux/netdev_features.h
> > +++ b/include/linux/netdev_features.h
> > @@ -76,6 +76,7 @@ enum {
> >  	NETIF_F_HW_TC_BIT,		/* Offload TC infrastructure */
> >  	NETIF_F_HW_ESP_BIT,		/* Hardware ESP transformation offload */
> >  	NETIF_F_HW_ESP_TX_CSUM_BIT,	/* ESP with TX checksum offload */
> > +	NETIF_F_TUNNEL_OFFLOAD_BIT,     /* Tunnel offloads */
> 
> "Tunnel offload" is very broad. Could we be more specific, e.g. "RSS
> tunnel offload" or such? NETIF_F_HW_TUNNEL_RSS?

Yeah, "tunnel offload" is too broad. But RSS isn't correct here, since
that's not the only thing that devices do with that feature.

Maybe "udp tunnel rx port" instead? Although, as Hannes pointed out
yesterday, we're not really sure that drivers/devices will only use it
for RX purposes either.


> > --- a/net/core/ethtool.c
> > +++ b/net/core/ethtool.c
> > @@ -106,6 +106,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
> >  	[NETIF_F_HW_TC_BIT] =		 "hw-tc-offload",
> >  	[NETIF_F_HW_ESP_BIT] =		 "esp-hw-offload",
> >  	[NETIF_F_HW_ESP_TX_CSUM_BIT] =	 "esp-tx-csum-hw-offload",
> > +	[NETIF_F_TUNNEL_OFFLOAD_BIT] =	 "tunnel-offload",
> >  };
> 
> And here, too. "rss-tunnel-offload"?

Yep, I'll update all that when we figure out a reasonable name.


Another thing I was thinking about would be to modify ethtool to show
these UDP tunneling features as a hierarchy (like we already have for
tx-checksumming). Both for this new feature and the existing
tx-udp_tnl-*.


Thanks for the comments,

-- 
Sabrina

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

end of thread, other threads:[~2017-07-04 14:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-30 13:19 [PATCH net-next 0/6] Allow to switch off UDP-based tunnel offloads per netdevice Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 1/6] net: add new netdevice feature for tunnel offloading Sabrina Dubroca
2017-06-30 15:50   ` Jiri Benc
2017-07-04 14:37     ` Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 2/6] net: check tunnel offload feature before calling tunnel ndo ndo Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 3/6] net: add infrastructure to un-offload UDP tunnel port Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 4/6] net: call udp_tunnel_get_rx_info when NETIF_F_TUNNEL_OFFLOAD is toggled Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 5/6] geneve/vxlan: add support for NETDEV_UDP_TUNNEL_DROP_INFO Sabrina Dubroca
2017-06-30 13:19 ` [PATCH net-next 6/6] geneve/vxlan: offload ports on register/unregister events Sabrina Dubroca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).