Skip to contentSkip to conversation

Split UFO into v4 and v6 versions.

PATCH In review Vladislav Yasevich 6 participants 53 messages Dec 17, 2014 – Dec 25, 2014

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

cover Split UFO into v4 and v6 versions.

UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for guests. We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

Vladislav Yasevich (10):
core: Split out UFO6 support
net: Correctly mark IPv6 UFO offload type.
ovs: Enable handling of UFO6 packets.
loopback: Turn on UFO6 support.
veth: Enable UFO6 support.
macvlan: Enable UFO6 support.
s2io: Enable UFO6 support.
tun: Re-uanble UFO support.
macvtap: Re-enable UFO support
Revert "drivers/net: Disable UFO through virtio"

 drivers/net/ethernet/neterion/s2io.c |  6 +++---
 drivers/net/loopback.c               |  4 ++--
 drivers/net/macvlan.c                |  2 +-
 drivers/net/macvtap.c                | 20 ++++++++++++++------
 drivers/net/tun.c                    | 26 ++++++++++++++------------
 drivers/net/veth.c                   |  2 +-
 drivers/net/virtio_net.c             | 24 ++++++++++--------------
 include/linux/netdev_features.h      |  7 +++++--
 include/linux/netdevice.h            |  1 +
 include/linux/skbuff.h               |  1 +
 net/core/dev.c                       | 35 +++++++++++++++++++----------------
 net/core/ethtool.c                   |  2 +-
 net/ipv6/ip6_offload.c               |  1 +
 net/ipv6/ip6_output.c                |  4 ++--
 net/ipv6/udp_offload.c               |  3 ++-
 net/mpls/mpls_gso.c                  |  1 +
 net/openvswitch/datapath.c           |  3 ++-
 net/openvswitch/flow.c               |  2 +-
 18 files changed, 81 insertions(+), 63 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/10 core: Split out UFO6 support

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +1 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#2 lore raw

PATCH 1/10 core: Split out UFO6 support

In reply to Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +1 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#3 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 3 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

[...]

include/linux/skbuff.h enum { · line 375

Quoted 9 lines
include/linux/skbuff.h +1 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13

It seems like it would be cleaner to use the names SKB_GSO_UDPV{4,6}, similarly to SKB_GSO_TCPV{4,6}.

Quoted 7 lines
include/linux/skbuff.h +0 -0
 };
 
 #if BITS_PER_LONG > 32
net/core/dev.c +0 -0
index 945bbd0..fa4d2ee 100644

[...]

Quoted 1 line
net/core/dev.c +0 -0
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,

[...]

net/core/dev.c static netdev_features_t netdev_fix_features(struct net_device *dev, · line 5963

Quoted 3 lines
net/core/dev.c +3 -0
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {

You can use !(features & NETIF_F_V4_CSUM) instead of the last two terms.

net/core/dev.c static netdev_features_t netdev_fix_features(struct net_device *dev, · line 5969

Quoted 6 lines
net/core/dev.c +6 -0
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {

[...]

Similarly you can use !(features & NETIF_F_V6_CSUM) instead of the last two terms.

Aside from those minor points, this looks fine.

Ben.

Signature · 2 lines
Ben Hutchings
Absolutum obsoletum. (If it works, it's out of date.) - Stafford Beer

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#4 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

In reply to Vladislav Yasevich
Quoted 3 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

[...]

include/linux/skbuff.h enum { · line 375

Quoted 9 lines
include/linux/skbuff.h +1 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13

It seems like it would be cleaner to use the names SKB_GSO_UDPV{4,6}, similarly to SKB_GSO_TCPV{4,6}.

Quoted 7 lines
include/linux/skbuff.h +0 -0
 };
 
 #if BITS_PER_LONG > 32
net/core/dev.c +0 -0
index 945bbd0..fa4d2ee 100644

[...]

Quoted 1 line
net/core/dev.c +0 -0
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,

[...]

net/core/dev.c static netdev_features_t netdev_fix_features(struct net_device *dev, · line 5963

Quoted 3 lines
net/core/dev.c +3 -0
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {

You can use !(features & NETIF_F_V4_CSUM) instead of the last two terms.

net/core/dev.c static netdev_features_t netdev_fix_features(struct net_device *dev, · line 5969

Quoted 6 lines
net/core/dev.c +6 -0
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {

[...]

Similarly you can use !(features & NETIF_F_V6_CSUM) instead of the last two terms.

Aside from those minor points, this looks fine.

Ben.

Signature · 2 lines
Ben Hutchings
Absolutum obsoletum. (If it works, it's out of date.) - Stafford Beer
#5 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 11 lines · Ben Hutchings
Quoted 3 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

[...]

Quoted 6 lines
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
Quoted 6 lines

include/linux/skbuff.h enum { · line 375

Quoted 3 lines
include/linux/skbuff.h +1 -0
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13

It seems like it would be cleaner to use the names SKB_GSO_UDPV{4,6}, similarly to SKB_GSO_TCPV{4,6}.

I wanted to try to avoid touched ipv4 paths if I could. I could use GSO_UDPV6 though.

Quoted 25 lines
Quoted 8 lines
include/linux/skbuff.h +0 -0
 };
 
 #if BITS_PER_LONG > 32
net/core/dev.c +0 -0
index 945bbd0..fa4d2ee 100644

[...]

Quoted 1 line
net/core/dev.c +0 -0
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,

[...]

net/core/dev.c static netdev_features_t netdev_fix_features(struct net_device *dev, · line 5963

Quoted 3 lines
net/core/dev.c +3 -0
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {

You can use !(features & NETIF_F_V4_CSUM) instead of the last two terms.

Quoted 6 lines
net/core/dev.c +6 -0
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {

[...]

Quoted 2 lines

Similarly you can use !(features & NETIF_F_V6_CSUM) instead of the last two terms.

I made those to look the same as the TSO checks for consistency, but I can change these to be shorter like above.

-vlad

Quoted 5 lines

Aside from those minor points, this looks fine.

Ben.

#6 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

In reply to Vladislav Yasevich
Quoted 70 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644

include/linux/skbuff.h enum { · line 378

Quoted 7 lines
include/linux/skbuff.h +1 -0
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

I think you missed some places that do this, e.g. af_packet sockets.

Quoted 70 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#7 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 77 lines · Michael S. Tsirkin
Quoted 76 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +1 -0
index 6c8b6f6..8538b67 100644
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
Quoted 9 lines

include/linux/skbuff.h enum { · line 378

Quoted 1 line
include/linux/skbuff.h +0 -0
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

I think you missed some places that do this, e.g. af_packet sockets.

I looked at af_packet sockets and they set this only in the event vnet header has been used with a GSO type. In this case, the user already knows the the type.

It is true that with this series af_packets now can't do IPv6 UFO since there is no VIRTIO_NET_HDR_GSO_UDPV6 yet.

I suppose we could do something similar there as we do in tun code/macvtap code. If that's the case, it currently broken as well.

-vlad

Quoted 71 lines
Quoted 71 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#8 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Cc Dave, pls remember to do this next time otherwise your patches won't get merged :)

Quoted 84 lines · Vlad Yasevich
Quoted 83 lines · Michael S. Tsirkin
Quoted 70 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644

include/linux/skbuff.h enum { · line 378

Quoted 7 lines
include/linux/skbuff.h +1 -0
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

Quoted 7 lines
Quoted 3 lines

I think you missed some places that do this, e.g. af_packet sockets.

I looked at af_packet sockets and they set this only in the event vnet header has been used with a GSO type. In this case, the user already knows the the type.

Imagine you are receiving a packet:

                if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
                        switch (vnet_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
                        case VIRTIO_NET_HDR_GSO_TCPV4:
                                gso_type = SKB_GSO_TCPV4;
                                break;
                        case VIRTIO_NET_HDR_GSO_TCPV6:
                                gso_type = SKB_GSO_TCPV6;
                                break;
                        case VIRTIO_NET_HDR_GSO_UDP:
                                gso_type = SKB_GSO_UDP;
                                break;
                        default:
                                goto out_unlock;
                        }

                        if (vnet_hdr.gso_type & VIRTIO_NET_HDR_GSO_ECN)
                                gso_type |= SKB_GSO_TCP_ECN;

                        if (vnet_hdr.gso_size == 0)
                                goto out_unlock;

                }

we used to report UFO6 as SKB_GSO_UDP, we probably should keep doing this, with your patch we select the goto out_unlock path.

Quoted 2 lines

It is true that with this series af_packets now can't do IPv6 UFO since there is no VIRTIO_NET_HDR_GSO_UDPV6 yet.

What do you mean by "do".
Are we talking about sending or receiving packets? You seem to conflate the two.

We always discarded ID on RX.

For tun, this is xmit, so just by saying "this device can not do UFO" you will never get short packets.

Quoted 5 lines

I suppose we could do something similar there as we do in tun code/macvtap code. If that's the case, it currently broken as well.

-vlad

Broken is a big word.

Let's stop conflating two directions.

Here's the way I look at it:

1. Userspace doesn't have a way to get fragment IDs from tun/macvtap/packet sockets. Presumably, not all users need these IDs. E.g. old guests clearly don't.

We should either give them packets stripping the ID, like we always did, or make sure they never get these packets. Second option seems achievable for tun if we
never tell linux it can do UFO, but I don't see
how to do it for macvtap and packet socket.

2. Userspace doesn't have a way to set fragment IDs for tun/macvtap/packet sockets.
Presumably, not all users have these IDs. E.g. old guests clearly don't.

We should either generate our own ID,
like we always did, or make sure we don't accept these packets.
Second option is almost sure to break userspace, so it seems we must do the first one.

3.
Exactly the same two things if you replace userspace with hypervisor and tun/macvtap/packet socket with virtio device.

4.
As a next step, we should add a way for userspace to tell us that it has ids and can handle them.

Quoted 71 lines
Quoted 71 lines
Quoted 71 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#9 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 121 lines · Michael S. Tsirkin

Cc Dave, pls remember to do this next time otherwise your patches won't get merged :)

Quoted 84 lines · Vlad Yasevich
Quoted 83 lines · Michael S. Tsirkin
Quoted 70 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644

include/linux/skbuff.h enum { · line 378

Quoted 7 lines
include/linux/skbuff.h +1 -0
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

Quoted 7 lines
Quoted 3 lines

I think you missed some places that do this, e.g. af_packet sockets.

I looked at af_packet sockets and they set this only in the event vnet header has been used with a GSO type. In this case, the user already knows the the type.

Imagine you are receiving a packet:

                if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
                        switch (vnet_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
                        case VIRTIO_NET_HDR_GSO_TCPV4:
                                gso_type = SKB_GSO_TCPV4;
                                break;
                        case VIRTIO_NET_HDR_GSO_TCPV6:
                                gso_type = SKB_GSO_TCPV6;
                                break;
                        case VIRTIO_NET_HDR_GSO_UDP:
                                gso_type = SKB_GSO_UDP;
                                break;
                        default:
                                goto out_unlock;
                        }

                        if (vnet_hdr.gso_type & VIRTIO_NET_HDR_GSO_ECN)
                                gso_type |= SKB_GSO_TCP_ECN;

                        if (vnet_hdr.gso_size == 0)
                                goto out_unlock;

                }
Quoted 5 lines

we used to report UFO6 as SKB_GSO_UDP, we probably should keep doing this, with your patch we select the goto out_unlock path.

No. The vnet_hdr.gso_type is still going to be VIRTIO_NET_HDR_GSO_UDP since the UDP6 version isn't defined yet. So, it will be marked as GSO_UDP.

This code most likely needs the same workaround as exists in tap and macvtap, i.e select the proxy fragment id and decide what to do with gso_type.

Quoted 5 lines
Quoted 3 lines

It is true that with this series af_packets now can't do IPv6 UFO since there is no VIRTIO_NET_HDR_GSO_UDPV6 yet.

What do you mean by "do".

What I mean is that AF_PACKET sockets currently do not do IPv6 UFO correctly, even after Ben's fixes to tap/macvtap. There is no proxy fragment id selection in af_packet case and we have the same problem Ben was trying address for tap/macvtap.

Quoted 1 line

Are we talking about sending or receiving packets?

I am talking about sending, see above.

Quoted 7 lines

You seem to conflate the two.

We always discarded ID on RX.

For tun, this is xmit, so just by saying "this device can not do UFO" you will never get short packets.

You must mean long packets. This is actually an issue I've been thinking about. With with your suggestion of switching the GSO type for legacy
applications we end up with fragments for IPv6 traffic. As a result,
legacy VMs will see a regression for large IPv6 datagrams.

Quoted 11 lines
Quoted 6 lines

I suppose we could do something similar there as we do in tun code/macvtap code. If that's the case, it currently broken as well.

-vlad

Broken is a big word.

Let's stop conflating two directions.

I am not and was talking only about af_packet as that is what you asked about. There is no tun/macvtap in play here. They are handled separately in their respective drivers.

Quoted 8 lines

Here's the way I look at it:

1. Userspace doesn't have a way to get fragment IDs from tun/macvtap/packet sockets. Presumably, not all users need these IDs. E.g. old guests clearly don't.

Quoted 6 lines

We should either give them packets stripping the ID, like we always did, or make sure they never get these packets. Second option seems achievable for tun if we
never tell linux it can do UFO, but I don't see
how to do it for macvtap and packet socket.

macvtap is slightly problematic, but doable with some tricks. packet socket is an interesting problem. The only way an af_packet socket can receive an skb marked SKB_GSO_UDPV6 is if someone else on the host sent it (like another guest). Since there is are no feature or vnet header length negotiations, it is impossible to tell if an application using this af_packet socket is capable of processing VIRTIO_NET_HDR_GSO_UDPV6 type (yet to be defined).

So, we can either use existing VIRTIO_NET_HDR_GSO_UDP on receive path, add some kind of negotiation logic to packet socket (like storing the application expected vnet header size), or perform IPv6 fragmentation somehow.

Options 1 or 2 are doable.

Quoted 6 lines

2. Userspace doesn't have a way to set fragment IDs for tun/macvtap/packet sockets.
Presumably, not all users have these IDs. E.g. old guests clearly don't.

Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept these packets.
Second option is almost sure to break userspace, so it seems we must do the first one.

Right. This was missing from packet sockets. I can fix it.

-vlad

Quoted 86 lines

3.
Exactly the same two things if you replace userspace with hypervisor and tun/macvtap/packet socket with virtio device.

4.
As a next step, we should add a way for userspace to tell us that it has ids and can handle them.

Quoted 71 lines
Quoted 71 lines
Quoted 71 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#10 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 128 lines · Vlad Yasevich
Quoted 121 lines · Michael S. Tsirkin

Cc Dave, pls remember to do this next time otherwise your patches won't get merged :)

Quoted 84 lines · Vlad Yasevich
Quoted 83 lines · Michael S. Tsirkin
Quoted 70 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644

include/linux/skbuff.h enum { · line 378

Quoted 7 lines
include/linux/skbuff.h +1 -0
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

Quoted 7 lines
Quoted 3 lines

I think you missed some places that do this, e.g. af_packet sockets.

I looked at af_packet sockets and they set this only in the event vnet header has been used with a GSO type. In this case, the user already knows the the type.

Imagine you are receiving a packet:

                if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
                        switch (vnet_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
                        case VIRTIO_NET_HDR_GSO_TCPV4:
                                gso_type = SKB_GSO_TCPV4;
                                break;
                        case VIRTIO_NET_HDR_GSO_TCPV6:
                                gso_type = SKB_GSO_TCPV6;
                                break;
                        case VIRTIO_NET_HDR_GSO_UDP:
                                gso_type = SKB_GSO_UDP;
                                break;
                        default:
                                goto out_unlock;
                        }

                        if (vnet_hdr.gso_type & VIRTIO_NET_HDR_GSO_ECN)
                                gso_type |= SKB_GSO_TCP_ECN;

                        if (vnet_hdr.gso_size == 0)
                                goto out_unlock;

                }
Quoted 5 lines

we used to report UFO6 as SKB_GSO_UDP, we probably should keep doing this, with your patch we select the goto out_unlock path.

Quoted 3 lines

No. The vnet_hdr.gso_type is still going to be VIRTIO_NET_HDR_GSO_UDP since the UDP6 version isn't defined yet. So, it will be marked as GSO_UDP.

I pasted the wrong snippet.
I meant this:

                        /* This is a hint as to how much should be * linear. */
                        vnet_hdr.hdr_len = __cpu_to_virtio16(false, skb_headlen(skb));
                        vnet_hdr.gso_size = __cpu_to_virtio16(false, sinfo->gso_size);
                        if (sinfo->gso_type & SKB_GSO_TCPV4)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                        else if (sinfo->gso_type & SKB_GSO_TCPV6)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                        else if (sinfo->gso_type & SKB_GSO_UDP)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
                        else if (sinfo->gso_type & SKB_GSO_FCOE)
                                goto out_free;
                        else
                                BUG();

so if we get SKB_GSO_UDP we'll get BUG().

Quoted 2 lines

This code most likely needs the same workaround as exists in tap and macvtap, i.e select the proxy fragment id and decide what to do with gso_type.

And fixup type to GSO_UDP6 while we are at it.

Quoted 16 lines
Quoted 5 lines
Quoted 3 lines

It is true that with this series af_packets now can't do IPv6 UFO since there is no VIRTIO_NET_HDR_GSO_UDPV6 yet.

What do you mean by "do".

What I mean is that AF_PACKET sockets currently do not do IPv6 UFO correctly, even after Ben's fixes to tap/macvtap. There is no proxy fragment id selection in af_packet case and we have the same problem Ben was trying address for tap/macvtap.

Quoted 1 line

Are we talking about sending or receiving packets?

I am talking about sending, see above.

Quoted 2 lines

You seem to conflate the two.

Quoted 7 lines
Quoted 5 lines

We always discarded ID on RX.

For tun, this is xmit, so just by saying "this device can not do UFO" you will never get short packets.

You must mean long packets.

Yes.

Quoted 4 lines

This is actually an issue I've been thinking
about. With with your suggestion of switching the GSO type for legacy
applications we end up with fragments for IPv6 traffic. As a result,
legacy VMs will see a regression for large IPv6 datagrams.

I'm not sure what's meant by my suggestion here :)
It seems clear that legacy applications don't want to get IPv6 fragment IDs in virtio header. Either we pass them plain ethernet packets or assume they are ok with discarding the IDs even if we set GSO_UDP.

Quoted 31 lines
Quoted 11 lines
Quoted 6 lines

I suppose we could do something similar there as we do in tun code/macvtap code. If that's the case, it currently broken as well.

-vlad

Broken is a big word.

Let's stop conflating two directions.

I am not and was talking only about af_packet as that is what you asked about. There is no tun/macvtap in play here. They are handled separately in their respective drivers.

Quoted 8 lines

Here's the way I look at it:

1. Userspace doesn't have a way to get fragment IDs from tun/macvtap/packet sockets. Presumably, not all users need these IDs. E.g. old guests clearly don't.

Quoted 6 lines

We should either give them packets stripping the ID, like we always did, or make sure they never get these packets. Second option seems achievable for tun if we
never tell linux it can do UFO, but I don't see
how to do it for macvtap and packet socket.

Quoted 4 lines

macvtap is slightly problematic, but doable with some tricks. packet socket is an interesting problem. The only way an af_packet socket can receive an skb marked SKB_GSO_UDPV6 is if someone else on the host sent it (like another guest).

Or if a NIC set it.

Quoted 11 lines

Since there is are no feature or vnet header length negotiations, it is impossible to tell if an application using this af_packet socket is capable of processing VIRTIO_NET_HDR_GSO_UDPV6 type (yet to be defined).

So, we can either use existing VIRTIO_NET_HDR_GSO_UDP on receive path, add some kind of negotiation logic to packet socket (like storing the application expected vnet header size), or perform IPv6 fragmentation somehow.

Options 1 or 2 are doable.

1 is using VIRTIO_NET_HDR_GSO_UDP and discarding ID, 2 is "some kind of negotiation logic"?
2 can't be enough, you will need 1 as well.

So let's start with 1 as a first step.

Quoted 13 lines
Quoted 6 lines

2. Userspace doesn't have a way to set fragment IDs for tun/macvtap/packet sockets.
Presumably, not all users have these IDs. E.g. old guests clearly don't.

Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept these packets.
Second option is almost sure to break userspace, so it seems we must do the first one.

Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

Quoted 86 lines
Quoted 86 lines

3.
Exactly the same two things if you replace userspace with hypervisor and tun/macvtap/packet socket with virtio device.

4.
As a next step, we should add a way for userspace to tell us that it has ids and can handle them.

Quoted 71 lines
Quoted 71 lines
Quoted 71 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#11 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept
these packets.
Second option is almost sure to break userspace,
so it seems we must do the first one.

Quoted 7 lines
Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

So how doing this in stages:

1. add helper that checks skb GSO type.
If it is SKB_GSO_UDP, check for IPv6, and
generate the fragment ID.

Call this helper in
- virtio net rx path
- tun rx path (get user)
- macvtap tx patch (get user)
- packet socket tx patch (get user)

2. Put back UFO flag everywhere: virtio,tun,macvtap,packet, since we can handle IPv6 now even if it's suboptimal.

Above two seem like smalling patches, appropriate for stable.

Next, work on a new feature to pass
fragment ID in virtio header:

3. split UFO/UFO6 as you did here, but add code
in above 4 places to convert UDP to UDP6,
additionally, add code in
- virtio net tx path
- tun tx path (get user)
- macvtap rx patch (put user)
- packet socket rx patch (put user)
to convert UDP6 to UDP.

step 3 needs to be bisect-clean, somehow.

4. add new field in header, new feature bit for virtio net to gate it, new ioctls to tun,macvtap,packet socket.

These two are more like optimizations, so not stable material.

Signature · 1 line
MST
#12 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 16 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept
these packets.
Second option is almost sure to break userspace,
so it seems we must do the first one.

Quoted 7 lines
Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

Quoted 8 lines

So how doing this in stages:

1. add helper that checks skb GSO type.
If it is SKB_GSO_UDP, check for IPv6, and
generate the fragment ID.

Call this helper in
- virtio net rx path

Why do we need id on rx path? Fragment ID should only be generated on tx.

Quoted 3 lines

- tun rx path (get user)
- macvtap tx patch (get user)
- packet socket tx patch (get user)

The reset makes sense.

Quoted 5 lines

2. Put back UFO flag everywhere: virtio,tun,macvtap,packet, since we can handle IPv6 now even if it's suboptimal.

Above two seem like smalling patches, appropriate for stable.

OK.

Quoted 6 lines

Next, work on a new feature to pass
fragment ID in virtio header:

3. split UFO/UFO6 as you did here, but add code
in above 4 places to convert UDP to UDP6,

Doing so will adversely impact IPv6 UFO performance for legacy guests. I know how many times I've seen mail wrt patch xyz caused %X regression in my setup and how we've reverted or tried to fixed things to solve this. If we go with approach, the only "fix' would be to upgrade the guest and that's not available to some users.

-vlad

Quoted 15 lines

additionally, add code in
- virtio net tx path
- tun tx path (get user)
- macvtap rx patch (put user)
- packet socket rx patch (put user)
to convert UDP6 to UDP.

step 3 needs to be bisect-clean, somehow.

4. add new field in header, new feature bit for virtio net to gate it, new ioctls to tun,macvtap,packet socket.

These two are more like optimizations, so not stable material.

#13 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 19 lines · Vlad Yasevich
Quoted 18 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept
these packets.
Second option is almost sure to break userspace,
so it seems we must do the first one.

Quoted 7 lines
Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

So how doing this in stages:

Quoted 8 lines
Quoted 6 lines

1. add helper that checks skb GSO type.
If it is SKB_GSO_UDP, check for IPv6, and
generate the fragment ID.

Call this helper in
- virtio net rx path

Why do we need id on rx path? Fragment ID should only be generated on tx.

So that all GSO_UDP6 packets have fragment ID as appropriate. It's similar to how we fill it on rx in tun, is it not?

Quoted 20 lines
Quoted 3 lines

- tun rx path (get user)
- macvtap tx patch (get user)
- packet socket tx patch (get user)

The reset makes sense.

Quoted 5 lines

2. Put back UFO flag everywhere: virtio,tun,macvtap,packet, since we can handle IPv6 now even if it's suboptimal.

Above two seem like smalling patches, appropriate for stable.

OK.

Quoted 6 lines

Next, work on a new feature to pass
fragment ID in virtio header:

3. split UFO/UFO6 as you did here, but add code
in above 4 places to convert UDP to UDP6,

Quoted 7 lines

Doing so will adversely impact IPv6 UFO performance for legacy guests. I know how many times I've seen mail wrt patch xyz caused %X regression in my setup and how we've reverted or tried to fixed things to solve this. If we go with approach, the only "fix' would be to upgrade the guest and that's not available to some users.

-vlad

I think there's some misunderstanding here.

I merely mean that after split, host should always have SKB_GSO_UDP6 set for IPv6.

To make sure legacy userspace/guests don't notice changes, whenever we detect SKB_GSO_UDP6 we should set VIRTIO_NET_HDR_GSO_UDP, and whenever we get VIRTIO_NET_HDR_GSO_UDP we should set either SKB_GSO_UDP6 or SKB_GSO_UDP depending on IP type.

Given this clarification there's no reason to think old guests will regress, correct?

Quoted 15 lines
Quoted 15 lines

additionally, add code in
- virtio net tx path
- tun tx path (get user)
- macvtap rx patch (put user)
- packet socket rx patch (put user)
to convert UDP6 to UDP.

step 3 needs to be bisect-clean, somehow.

4. add new field in header, new feature bit for virtio net to gate it, new ioctls to tun,macvtap,packet socket.

These two are more like optimizations, so not stable material.

#14 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

Quoted 24 lines · Michael S. Tsirkin
Quoted 23 lines · Vlad Yasevich
Quoted 22 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 7 lines
Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept
these packets.
Second option is almost sure to break userspace,
so it seems we must do the first one.

Quoted 7 lines
Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

So how doing this in stages:

1. add helper that checks skb GSO type.
If it is SKB_GSO_UDP, check for IPv6, and
generate the fragment ID.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Call this helper in
- virtio net rx path

Why do we need id on rx path? Fragment ID should only be generated on tx.

So that all GSO_UDP6 packets have fragment ID as appropriate. It's similar to how we fill it on rx in tun, is it not?

Saying "rx in tun" always hurts my head. We fill it in in tun_get_user() which then passed the packet to the kernel for forwarding. The is later used in the forwarding process.

I've been thinking about putting this fragment generation into the GSO
path so there is only 1 spot that ever needs to this. This way it
would only be done if the fragment id is actually needed. For most guest-to-guest comms, the id isn't needed.

Quoted 32 lines
Quoted 22 lines
Quoted 5 lines

- tun rx path (get user)
- macvtap tx patch (get user)
- packet socket tx patch (get user)

The reset makes sense.

Quoted 5 lines

2. Put back UFO flag everywhere: virtio,tun,macvtap,packet, since we can handle IPv6 now even if it's suboptimal.

Above two seem like smalling patches, appropriate for stable.

OK.

Quoted 6 lines

Next, work on a new feature to pass
fragment ID in virtio header:

3. split UFO/UFO6 as you did here, but add code
in above 4 places to convert UDP to UDP6,

Quoted 7 lines

Doing so will adversely impact IPv6 UFO performance for legacy guests. I know how many times I've seen mail wrt patch xyz caused %X regression in my setup and how we've reverted or tried to fixed things to solve this. If we go with approach, the only "fix' would be to upgrade the guest and that's not available to some users.

-vlad

I think there's some misunderstanding here.

Quoted 7 lines

I merely mean that after split, host should always have SKB_GSO_UDP6 set for IPv6.

To make sure legacy userspace/guests don't notice changes, whenever we detect SKB_GSO_UDP6 we should set VIRTIO_NET_HDR_GSO_UDP, and whenever we get VIRTIO_NET_HDR_GSO_UDP we should set either SKB_GSO_UDP6 or SKB_GSO_UDP depending on IP type.

This is the part that introduced the regression. By setting the gso_type to UDP6, we trigger skb_gso_segment() to actually perform IPv6 fragmentation.

I've seen this when passing UDP traffic from 2 fedora19 systems over the kernel that does the above.

-vlad

Quoted 19 lines

Given this clarification there's no reason to think old guests will regress, correct?

Quoted 15 lines
Quoted 15 lines

additionally, add code in
- virtio net tx path
- tun tx path (get user)
- macvtap rx patch (put user)
- packet socket rx patch (put user)
to convert UDP6 to UDP.

step 3 needs to be bisect-clean, somehow.

4. add new field in header, new feature bit for virtio net to gate it, new ioctls to tun,macvtap,packet socket.

These two are more like optimizations, so not stable material.

#15 lore raw

Re: [PATCH 01/10] core: Split out UFO6 support

In reply to Michael S. Tsirkin
Quoted 183 lines · Michael S. Tsirkin
Quoted 128 lines · Vlad Yasevich
Quoted 121 lines · Michael S. Tsirkin

Cc Dave, pls remember to do this next time otherwise your patches won't get merged :)

Quoted 84 lines · Vlad Yasevich
Quoted 83 lines · Michael S. Tsirkin
Quoted 70 lines · Vladislav Yasevich

Split IPv6 support for UFO into its own feature similiar to TSO. This will later allow us to re-enable UFO support for virtio-net devices.

---
 include/linux/netdev_features.h |  7 +++++--
 include/linux/netdevice.h       |  1 +
 include/linux/skbuff.h          |  1 +
 net/core/dev.c                  | 35 +++++++++++++++++++----------------
 net/core/ethtool.c              |  2 +-
 5 files changed, 27 insertions(+), 19 deletions(-)
include/linux/netdev_features.h +5 -2
index dcfdecb..a078945 100644
@@ -48,8 +48,9 @@ enum {
 	NETIF_F_GSO_UDP_TUNNEL_BIT,	/* ... UDP TUNNEL with TSO */
 	NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
 	NETIF_F_GSO_MPLS_BIT,		/* ... MPLS segmentation */
+	NETIF_F_UFO6_BIT,		/* ... UDPv6 fragmentation */
 	/**/NETIF_F_GSO_LAST =		/* last bit, see GSO_MASK */
-		NETIF_F_GSO_MPLS_BIT,
+		NETIF_F_UFO6_BIT,
 
 	NETIF_F_FCOE_CRC_BIT,		/* FCoE CRC32 */
 	NETIF_F_SCTP_CSUM_BIT,		/* SCTP checksum offload */
@@ -109,6 +110,7 @@ enum {
 #define NETIF_F_TSO_ECN		__NETIF_F(TSO_ECN)
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
+#define NETIF_F_UFO6		__NETIF_F(UFO6)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 #define NETIF_F_RXALL		__NETIF_F(RXALL)
@@ -141,7 +143,7 @@ enum {
 
 /* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
-				 NETIF_F_TSO6 | NETIF_F_UFO)
+				 NETIF_F_TSO6 | NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_GEN_CSUM	NETIF_F_HW_CSUM
 #define NETIF_F_V4_CSUM		(NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
@@ -149,6 +151,7 @@ enum {
 #define NETIF_F_ALL_CSUM	(NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
 #define NETIF_F_ALL_TSO 	(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
+#define NETIF_F_ALL_UFO		(NETIF_F_UFO | NETIF_F_UFO6)
 
 #define NETIF_F_ALL_FCOE	(NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
 				 NETIF_F_FSO)
include/linux/netdevice.h +1 -0
index 74fd5d3..86af10a 100644
@@ -3559,6 +3559,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	/* check flags correspondence */
 	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP6    != (NETIF_F_UFO6 >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
 	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
include/linux/skbuff.h +0 -0
index 6c8b6f6..8538b67 100644

include/linux/skbuff.h enum { · line 378

Quoted 7 lines
include/linux/skbuff.h +1 -0
@@ -372,6 +372,7 @@ enum {
 
 	SKB_GSO_MPLS = 1 << 12,
 
+	SKB_GSO_UDP6 = 1 << 13
 };
 
 #if BITS_PER_LONG > 32

So this implies anything getting GSO packets e.g.
from userspace now needs to check IP version to
set GSO type correctly.

Quoted 7 lines
Quoted 3 lines

I think you missed some places that do this, e.g. af_packet sockets.

I looked at af_packet sockets and they set this only in the event vnet header has been used with a GSO type. In this case, the user already knows the the type.

Imagine you are receiving a packet:

                if (vnet_hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
                        switch (vnet_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
                        case VIRTIO_NET_HDR_GSO_TCPV4:
                                gso_type = SKB_GSO_TCPV4;
                                break;
                        case VIRTIO_NET_HDR_GSO_TCPV6:
                                gso_type = SKB_GSO_TCPV6;
                                break;
                        case VIRTIO_NET_HDR_GSO_UDP:
                                gso_type = SKB_GSO_UDP;
                                break;
                        default:
                                goto out_unlock;
                        }

                        if (vnet_hdr.gso_type & VIRTIO_NET_HDR_GSO_ECN)
                                gso_type |= SKB_GSO_TCP_ECN;

                        if (vnet_hdr.gso_size == 0)
                                goto out_unlock;

                }
Quoted 5 lines

we used to report UFO6 as SKB_GSO_UDP, we probably should keep doing this, with your patch we select the goto out_unlock path.

Quoted 3 lines

No. The vnet_hdr.gso_type is still going to be VIRTIO_NET_HDR_GSO_UDP since the UDP6 version isn't defined yet. So, it will be marked as GSO_UDP.

I pasted the wrong snippet.
I meant this:

                        /* This is a hint as to how much should be * linear. */
                        vnet_hdr.hdr_len = __cpu_to_virtio16(false, skb_headlen(skb));
                        vnet_hdr.gso_size = __cpu_to_virtio16(false, sinfo->gso_size);
                        if (sinfo->gso_type & SKB_GSO_TCPV4)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
                        else if (sinfo->gso_type & SKB_GSO_TCPV6)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
                        else if (sinfo->gso_type & SKB_GSO_UDP)
                                vnet_hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
                        else if (sinfo->gso_type & SKB_GSO_FCOE)
                                goto out_free;
                        else
                                BUG();

so if we get SKB_GSO_UDP we'll get BUG().

Quoted 2 lines

This code most likely needs the same workaround as exists in tap and macvtap, i.e select the proxy fragment id and decide what to do with gso_type.

And fixup type to GSO_UDP6 while we are at it.

Quoted 16 lines
Quoted 5 lines
Quoted 3 lines

It is true that with this series af_packets now can't do IPv6 UFO since there is no VIRTIO_NET_HDR_GSO_UDPV6 yet.

What do you mean by "do".

What I mean is that AF_PACKET sockets currently do not do IPv6 UFO correctly, even after Ben's fixes to tap/macvtap. There is no proxy fragment id selection in af_packet case and we have the same problem Ben was trying address for tap/macvtap.

Quoted 1 line

Are we talking about sending or receiving packets?

I am talking about sending, see above.

Quoted 2 lines

You seem to conflate the two.

Quoted 7 lines
Quoted 5 lines

We always discarded ID on RX.

For tun, this is xmit, so just by saying "this device can not do UFO" you will never get short packets.

You must mean long packets.

Quoted 8 lines

Yes.

Quoted 4 lines

This is actually an issue I've been thinking
about. With with your suggestion of switching the GSO type for legacy
applications we end up with fragments for IPv6 traffic. As a result,
legacy VMs will see a regression for large IPv6 datagrams.

I'm not sure what's meant by my suggestion here :)

What I am referring to here is to change the gso_type to UDPV6 in tap/macvtap when passing packet to the host.

Quoted 4 lines

It seems clear that legacy applications don't want to get IPv6 fragment IDs in virtio header. Either we pass them plain ethernet packets or assume they are ok with discarding the IDs even if we set GSO_UDP.

So, I am not try to pass fragment IDs yet. I am trying to make sure that older gueest that assume that UFO == UFO4 + UFO6 continue to work and do not regress. At the same time, I want to enable UFO(4) for new guests.

If we set gso_type to SKB_GSO_UDPV6 before passing the data to the forwarding path of the host, then this will cause IPv6 fragmentation. If we leave gso_type as SKB_GSO_UDP, then older VMs will continue to communicate using large UDP data packets.

Later when VMs support UFO6, when UFO6 is enabled, the fragment id can be communicated. But that's later.

Quoted 32 lines
Quoted 32 lines
Quoted 6 lines
Quoted 6 lines

I suppose we could do something similar there as we do in tun code/macvtap code. If that's the case, it currently broken as well.

Quoted 6 lines
Quoted 1 line

-vlad

Broken is a big word.

Let's stop conflating two directions.

I am not and was talking only about af_packet as that is what you asked about. There is no tun/macvtap in play here. They are handled separately in their respective drivers.

Quoted 14 lines

Here's the way I look at it:

1. Userspace doesn't have a way to get fragment IDs from tun/macvtap/packet sockets. Presumably, not all users need these IDs. E.g. old guests clearly don't.

We should either give them packets stripping the ID, like we always did, or make sure they never get these packets. Second option seems achievable for tun if we
never tell linux it can do UFO, but I don't see
how to do it for macvtap and packet socket.

Quoted 6 lines
Quoted 4 lines

macvtap is slightly problematic, but doable with some tricks. packet socket is an interesting problem. The only way an af_packet socket can receive an skb marked SKB_GSO_UDPV6 is if someone else on the host sent it (like another guest).

Or if a NIC set it.

OK, virtio seems to be the only nic doing this... You are right, I need to cover that scenario.

-vlad

Quoted 130 lines
Quoted 6 lines

Since there is are no feature or vnet header length negotiations, it is impossible to tell if an application using this af_packet socket is capable of processing VIRTIO_NET_HDR_GSO_UDPV6 type (yet to be defined).

Quoted 6 lines

So, we can either use existing VIRTIO_NET_HDR_GSO_UDP on receive path, add some kind of negotiation logic to packet socket (like storing the application expected vnet header size), or perform IPv6 fragmentation somehow.

Options 1 or 2 are doable.

1 is using VIRTIO_NET_HDR_GSO_UDP and discarding ID, 2 is "some kind of negotiation logic"?
2 can't be enough, you will need 1 as well.

So let's start with 1 as a first step.

Quoted 13 lines
Quoted 6 lines

2. Userspace doesn't have a way to set fragment IDs for tun/macvtap/packet sockets.
Presumably, not all users have these IDs. E.g. old guests clearly don't.

Quoted 6 lines

We should either generate our own ID,
like we always did, or make sure we don't accept these packets.
Second option is almost sure to break userspace, so it seems we must do the first one.

Quoted 3 lines

Right. This was missing from packet sockets. I can fix it.

-vlad

Also, this can't be a patch on top, since we don't want bisect to give us configurations which can BUG().

Quoted 86 lines
Quoted 86 lines

3.
Exactly the same two things if you replace userspace with hypervisor and tun/macvtap/packet socket with virtio device.

4.
As a next step, we should add a way for userspace to tell us that it has ids and can handle them.

Quoted 71 lines
Quoted 71 lines
Quoted 71 lines
net/core/dev.c +19 -16
index 945bbd0..fa4d2ee 100644
@@ -5929,6 +5929,12 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_ALL_TSO;
 	}
 
+	/* UFO requires that SG is present as well */
+	if ((features & NETIF_F_ALL_UFO) && !(features & NETIF_F_SG)) {
+		netdev_dbg(dev, "Dropping UFO features since no SG feature.\n");
+		features &= ~NETIF_F_ALL_UFO;
+	}
+
 	if ((features & NETIF_F_TSO) && !(features & NETIF_F_HW_CSUM) &&
 					!(features & NETIF_F_IP_CSUM)) {
 		netdev_dbg(dev, "Dropping TSO features since no CSUM feature.\n");
@@ -5952,24 +5958,21 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~NETIF_F_GSO;
 	}
 
-	/* UFO needs SG and checksumming */
-	if (features & NETIF_F_UFO) {
-		/* maybe split UFO into V4 and V6? */
-		if (!((features & NETIF_F_GEN_CSUM) ||
-		    (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
-			    == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no checksum offload features.\n");
-			features &= ~NETIF_F_UFO;
-		}
-
-		if (!(features & NETIF_F_SG)) {
-			netdev_dbg(dev,
-				"Dropping NETIF_F_UFO since no NETIF_F_SG feature.\n");
-			features &= ~NETIF_F_UFO;
-		}
+	/* UFO also needs checksumming */
+	if ((features & NETIF_F_UFO) && !(features & NETIF_F_GEN_CSUM) &&
+					!(features & NETIF_F_IP_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO;
+	}
+	if ((features & NETIF_F_UFO6) && !(features & NETIF_F_GEN_CSUM) &&
+					 !(features & NETIF_F_IPV6_CSUM)) {
+		netdev_dbg(dev,
+			   "Dropping NETIF_F_UFO6 since no checksum offload features.\n");
+		features &= ~NETIF_F_UFO6;
 	}
 
+
 #ifdef CONFIG_NET_RX_BUSY_POLL
 	if (dev->netdev_ops->ndo_busy_poll)
 		features |= NETIF_F_BUSY_POLL;
net/core/ethtool.c +1 -1
index 06dfb29..93eff41 100644
@@ -223,7 +223,7 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 		return NETIF_F_ALL_TSO;
 	case ETHTOOL_GUFO:
 	case ETHTOOL_SUFO:
-		return NETIF_F_UFO;
+		return NETIF_F_ALL_UFO;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
 		return NETIF_F_GSO;
Signature · 1 line
1.9.3
#16 lore raw

PATCH 2/10 net: Correctly mark IPv6 UFO offload type.

In reply to Vladislav Yasevich

If the device supports UFO6 features, mark the offloaded ipv6 udp traffic appropriately.

---
 net/ipv6/ip6_offload.c | 1 +
 net/ipv6/ip6_output.c  | 4 ++--
 net/ipv6/udp_offload.c | 3 ++-
 net/mpls/mpls_gso.c    | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)
net/ipv6/ip6_offload.c +1 -0
index 01e12d0..bd985d5 100644
@@ -81,6 +81,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
 		       SKB_GSO_UDP_TUNNEL_CSUM |
 		       SKB_GSO_MPLS |
 		       SKB_GSO_TCPV6 |
+		       SKB_GSO_UDP6 |
 		       0)))
 		goto out;
 
net/ipv6/ip6_output.c +2 -2
index 8e950c2..83f5c04 100644
@@ -1089,7 +1089,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
 	 */
 	skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
 				     sizeof(struct frag_hdr)) & ~7;
-	skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
+	skb_shinfo(skb)->gso_type = SKB_GSO_UDP6;
 	ipv6_select_ident(&fhdr, rt);
 	skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
 
@@ -1296,7 +1296,7 @@ emsgsize:
 	if (((length > mtu) ||
 	     (skb && skb_is_gso(skb))) &&
 	    (sk->sk_protocol == IPPROTO_UDP) &&
-	    (rt->dst.dev->features & NETIF_F_UFO)) {
+	    (rt->dst.dev->features & NETIF_F_UFO6)) {
 		err = ip6_ufo_append_data(sk, getfrag, from, length,
 					  hh_len, fragheaderlen,
 					  transhdrlen, mtu, flags, rt);
net/ipv6/udp_offload.c +2 -1
index 6b8f543..00d723e 100644
@@ -39,6 +39,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 		int type = skb_shinfo(skb)->gso_type;
 
 		if (unlikely(type & ~(SKB_GSO_UDP |
+				      SKB_GSO_UDP6 |
 				      SKB_GSO_DODGY |
 				      SKB_GSO_UDP_TUNNEL |
 				      SKB_GSO_UDP_TUNNEL_CSUM |
@@ -47,7 +48,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 				      SKB_GSO_IPIP |
 				      SKB_GSO_SIT |
 				      SKB_GSO_MPLS) ||
-			     !(type & (SKB_GSO_UDP))))
+			     !(type & (SKB_GSO_UDP | SKB_GSO_UDP6))))
 			goto out;
 
 		skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss);
net/mpls/mpls_gso.c +1 -0
index e3545f2..27343f0 100644
@@ -30,6 +30,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
 				~(SKB_GSO_TCPV4 |
 				  SKB_GSO_TCPV6 |
 				  SKB_GSO_UDP |
+				  SKB_GSO_UDP6 |
 				  SKB_GSO_DODGY |
 				  SKB_GSO_TCP_ECN |
 				  SKB_GSO_GRE |
Signature · 1 line
1.9.3
#17 lore raw

PATCH 2/10 net: Correctly mark IPv6 UFO offload type.

In reply to Vladislav Yasevich

If the device supports UFO6 features, mark the offloaded ipv6 udp traffic appropriately.

---
 net/ipv6/ip6_offload.c | 1 +
 net/ipv6/ip6_output.c  | 4 ++--
 net/ipv6/udp_offload.c | 3 ++-
 net/mpls/mpls_gso.c    | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)
net/ipv6/ip6_offload.c +1 -0
index 01e12d0..bd985d5 100644
@@ -81,6 +81,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
 		       SKB_GSO_UDP_TUNNEL_CSUM |
 		       SKB_GSO_MPLS |
 		       SKB_GSO_TCPV6 |
+		       SKB_GSO_UDP6 |
 		       0)))
 		goto out;
 
net/ipv6/ip6_output.c +2 -2
index 8e950c2..83f5c04 100644
@@ -1089,7 +1089,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
 	 */
 	skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
 				     sizeof(struct frag_hdr)) & ~7;
-	skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
+	skb_shinfo(skb)->gso_type = SKB_GSO_UDP6;
 	ipv6_select_ident(&fhdr, rt);
 	skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
 
@@ -1296,7 +1296,7 @@ emsgsize:
 	if (((length > mtu) ||
 	     (skb && skb_is_gso(skb))) &&
 	    (sk->sk_protocol == IPPROTO_UDP) &&
-	    (rt->dst.dev->features & NETIF_F_UFO)) {
+	    (rt->dst.dev->features & NETIF_F_UFO6)) {
 		err = ip6_ufo_append_data(sk, getfrag, from, length,
 					  hh_len, fragheaderlen,
 					  transhdrlen, mtu, flags, rt);
net/ipv6/udp_offload.c +2 -1
index 6b8f543..00d723e 100644
@@ -39,6 +39,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 		int type = skb_shinfo(skb)->gso_type;
 
 		if (unlikely(type & ~(SKB_GSO_UDP |
+				      SKB_GSO_UDP6 |
 				      SKB_GSO_DODGY |
 				      SKB_GSO_UDP_TUNNEL |
 				      SKB_GSO_UDP_TUNNEL_CSUM |
@@ -47,7 +48,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 				      SKB_GSO_IPIP |
 				      SKB_GSO_SIT |
 				      SKB_GSO_MPLS) ||
-			     !(type & (SKB_GSO_UDP))))
+			     !(type & (SKB_GSO_UDP | SKB_GSO_UDP6))))
 			goto out;
 
 		skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss);
net/mpls/mpls_gso.c +1 -0
index e3545f2..27343f0 100644
@@ -30,6 +30,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
 				~(SKB_GSO_TCPV4 |
 				  SKB_GSO_TCPV6 |
 				  SKB_GSO_UDP |
+				  SKB_GSO_UDP6 |
 				  SKB_GSO_DODGY |
 				  SKB_GSO_TCP_ECN |
 				  SKB_GSO_GRE |
Signature · 1 line
1.9.3
#18 lore raw

PATCH 3/10 ovs: Enable handling of UFO6 packets.

In reply to Vladislav Yasevich

Since UFO6 packets can now be identified by SKB_GSO_UDP6, add proper checks to handel UFO6 flows.
Legacy applications may still have UFO6 packets identified by SKB_GSO_UDP, so we need to continue to handle them correclty.

---
 net/openvswitch/datapath.c | 3 ++-
 net/openvswitch/flow.c     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +2 -1
index f9e556b..b43fc60 100644
@@ -334,7 +334,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
 		if (err)
 			break;
 
-		if (skb == segs && gso_type & SKB_GSO_UDP) {
+		if (skb == segs &&
+		    ((gso_type & SKB_GSO_UDP) || (gso_type & SKB_GSO_UDP6))) {
 			/* The initial flow key extracted by ovs_flow_extract()
 			 * in this case is for a first fragment, so we need to
 			 * properly mark later fragments.
net/openvswitch/flow.c +1 -1
index 2b78789..d03adf4 100644
@@ -602,7 +602,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 
 		if (key->ip.frag == OVS_FRAG_TYPE_LATER)
 			return 0;
-		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+		if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6))
 			key->ip.frag = OVS_FRAG_TYPE_FIRST;
 
 		/* Transport layer. */
Signature · 1 line
1.9.3
#19 lore raw

Re: [PATCH 03/10] ovs: Enable handling of UFO6 packets.

Hello.

Quoted 16 lines · Vladislav Yasevich

Since UFO6 packets can now be identified by SKB_GSO_UDP6, add proper checks to handel UFO6 flows.
Legacy applications may still have UFO6 packets identified by SKB_GSO_UDP, so we need to continue to handle them correclty.

---
  net/openvswitch/datapath.c | 3 ++-
  net/openvswitch/flow.c     | 2 +-
  2 files changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +0 -0
index f9e556b..b43fc60 100644

net/openvswitch/datapath.c static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, · line 338

Quoted 6 lines
net/openvswitch/datapath.c +2 -1
@@ -334,7 +334,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
  		if (err)
  			break;
 
-		if (skb == segs && gso_type & SKB_GSO_UDP) {
+		if (skb == segs &&
+		    ((gso_type & SKB_GSO_UDP) || (gso_type & SKB_GSO_UDP6))) {

'gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6)' would be shorter...

net/openvswitch/flow.c static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) · line 605

Quoted 13 lines
net/openvswitch/datapath.c +0 -0
  			/* The initial flow key extracted by ovs_flow_extract()
  			 * in this case is for a first fragment, so we need to
  			 * properly mark later fragments.
net/openvswitch/flow.c +1 -1
index 2b78789..d03adf4 100644
@@ -602,7 +602,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 
  		if (key->ip.frag == OVS_FRAG_TYPE_LATER)
  			return 0;
-		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+		if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6))

.... like here.

[...]

WBR, Sergei

#20 lore raw

Re: [PATCH 03/10] ovs: Enable handling of UFO6 packets.

Quoted 23 lines · Sergei Shtylyov

Hello.

Quoted 19 lines · Vladislav Yasevich

Since UFO6 packets can now be identified by SKB_GSO_UDP6, add proper checks to handel UFO6 flows.
Legacy applications may still have UFO6 packets identified by SKB_GSO_UDP, so we need to continue to handle them correclty.

---
  net/openvswitch/datapath.c | 3 ++-
  net/openvswitch/flow.c     | 2 +-
  2 files changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +0 -0
index f9e556b..b43fc60 100644
@@ -334,7 +334,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
          if (err)
              break;
 
Quoted 5 lines

net/openvswitch/datapath.c static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, · line 338

Quoted 3 lines
net/openvswitch/datapath.c +2 -1
-        if (skb == segs && gso_type & SKB_GSO_UDP) {
+        if (skb == segs &&
+            ((gso_type & SKB_GSO_UDP) || (gso_type & SKB_GSO_UDP6))) {

'gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6)' would be shorter...

Thanks, will do.

-vlad

Quoted 21 lines
Quoted 9 lines
net/openvswitch/datapath.c +0 -0
              /* The initial flow key extracted by ovs_flow_extract()
               * in this case is for a first fragment, so we need to
               * properly mark later fragments.
net/openvswitch/flow.c +0 -0
index 2b78789..d03adf4 100644

net/openvswitch/flow.c static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) · line 605

Quoted 5 lines
net/openvswitch/flow.c +1 -1
@@ -602,7 +602,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 
          if (key->ip.frag == OVS_FRAG_TYPE_LATER)
              return 0;
-        if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+        if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6))
   .... like here.

[...]

WBR, Sergei

#21 lore raw

Re: [PATCH 03/10] ovs: Enable handling of UFO6 packets.

In reply to Vladislav Yasevich
Quoted 2 lines · Vladislav Yasevich

Since UFO6 packets can now be identified by SKB_GSO_UDP6, add proper checks to handel UFO6 flows.

s/handel/handle/

Quoted 38 lines

Legacy applications may still have UFO6 packets identified by SKB_GSO_UDP, so we need to continue to handle them correclty.

---
 net/openvswitch/datapath.c | 3 ++-
 net/openvswitch/flow.c     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +2 -1
index f9e556b..b43fc60 100644
@@ -334,7 +334,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
 		if (err)
 			break;
 
-		if (skb == segs && gso_type & SKB_GSO_UDP) {
+		if (skb == segs &&
+		    ((gso_type & SKB_GSO_UDP) || (gso_type & SKB_GSO_UDP6))) {
 			/* The initial flow key extracted by ovs_flow_extract()
 			 * in this case is for a first fragment, so we need to
 			 * properly mark later fragments.
net/openvswitch/flow.c +1 -1
index 2b78789..d03adf4 100644
@@ -602,7 +602,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)
 
 		if (key->ip.frag == OVS_FRAG_TYPE_LATER)
 			return 0;
-		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+		if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP6))
 			key->ip.frag = OVS_FRAG_TYPE_FIRST;
 
 		/* Transport layer. */
Signature · 1 line
1.9.3
#22 lore raw

PATCH 4/10 loopback: Turn on UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 support.

---
 drivers/net/loopback.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/loopback.c +2 -2
index c76283c..762c28a 100644
@@ -170,10 +170,10 @@ static void loopback_setup(struct net_device *dev)
 	dev->flags		= IFF_LOOPBACK;
 	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
 	netif_keep_dst(dev);
-	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_UFO;
+	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_ALL_UFO;
 	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
 		| NETIF_F_ALL_TSO
-		| NETIF_F_UFO
+		| NETIF_F_ALL_UFO
 		| NETIF_F_HW_CSUM
 		| NETIF_F_RXCSUM
 		| NETIF_F_SCTP_CSUM
Signature · 1 line
1.9.3
#23 lore raw

PATCH 4/10 loopback: Turn on UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 support.

---
 drivers/net/loopback.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/loopback.c +2 -2
index c76283c..762c28a 100644
@@ -170,10 +170,10 @@ static void loopback_setup(struct net_device *dev)
 	dev->flags		= IFF_LOOPBACK;
 	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
 	netif_keep_dst(dev);
-	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_UFO;
+	dev->hw_features	= NETIF_F_ALL_TSO | NETIF_F_ALL_UFO;
 	dev->features 		= NETIF_F_SG | NETIF_F_FRAGLIST
 		| NETIF_F_ALL_TSO
-		| NETIF_F_UFO
+		| NETIF_F_ALL_UFO
 		| NETIF_F_HW_CSUM
 		| NETIF_F_RXCSUM
 		| NETIF_F_SCTP_CSUM
Signature · 1 line
1.9.3
#24 lore raw

PATCH 5/10 veth: Enable UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 feature.

---
 drivers/net/veth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/veth.c +1 -1
index 8ad5965..0052db5 100644
@@ -280,7 +280,7 @@ static const struct net_device_ops veth_netdev_ops = {
 #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_ALL_TSO |    \
 		       NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_HIGHDMA | \
 		       NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL |	    \
-		       NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | NETIF_F_UFO	|   \
+		       NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | NETIF_F_ALL_UFO | \
 		       NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | \
 		       NETIF_F_HW_VLAN_STAG_TX | NETIF_F_HW_VLAN_STAG_RX )
 
Signature · 1 line
1.9.3
#25 lore raw

PATCH 5/10 veth: Enable UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 feature.

---
 drivers/net/veth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/veth.c +1 -1
index 8ad5965..0052db5 100644
@@ -280,7 +280,7 @@ static const struct net_device_ops veth_netdev_ops = {
 #define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_ALL_TSO |    \
 		       NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_HIGHDMA | \
 		       NETIF_F_GSO_GRE | NETIF_F_GSO_UDP_TUNNEL |	    \
-		       NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | NETIF_F_UFO	|   \
+		       NETIF_F_GSO_IPIP | NETIF_F_GSO_SIT | NETIF_F_ALL_UFO | \
 		       NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | \
 		       NETIF_F_HW_VLAN_STAG_TX | NETIF_F_HW_VLAN_STAG_RX )
 
Signature · 1 line
1.9.3
#26 lore raw

PATCH 6/10 macvlan: Enable UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 feature.

---
 drivers/net/macvlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
index bfb0b6e..807b98d 100644
@@ -746,7 +746,7 @@ static struct lock_class_key macvlan_netdev_addr_lock_key;
 
 #define MACVLAN_FEATURES \
 	(NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
-	 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \
+	 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_ALL_UFO | NETIF_F_GSO_ROBUST | \
 	 NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \
 	 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
 
Signature · 1 line
1.9.3
#27 lore raw

PATCH 6/10 macvlan: Enable UFO6 support.

In reply to Vladislav Yasevich

Turn on UFO6 feature.

---
 drivers/net/macvlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
index bfb0b6e..807b98d 100644
@@ -746,7 +746,7 @@ static struct lock_class_key macvlan_netdev_addr_lock_key;
 
 #define MACVLAN_FEATURES \
 	(NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
-	 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \
+	 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_ALL_UFO | NETIF_F_GSO_ROBUST | \
 	 NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \
 	 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
 
Signature · 1 line
1.9.3
#28 lore raw

PATCH 7/10 s2io: Enable UFO6 support.

In reply to Vladislav Yasevich
---
 drivers/net/ethernet/neterion/s2io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/neterion/s2io.c +3 -3
index f5e4b82..d823bb7 100644
@@ -4140,7 +4140,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	frg_len = skb_headlen(skb);
-	if (offload_type == SKB_GSO_UDP) {
+	if (offload_type == SKB_GSO_UDP || offload_type == SKB_GSO_UDP6) {
 		int ufo_size;
 
 		ufo_size = s2io_udp_mss(skb);
@@ -7917,9 +7917,9 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
 	dev->features |= dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
 	if (sp->device_type & XFRAME_II_DEVICE) {
-		dev->hw_features |= NETIF_F_UFO;
+		dev->hw_features |= NETIF_F_ALL_UFO;
 		if (ufo)
-			dev->features |= NETIF_F_UFO;
+			dev->features |= NETIF_F_ALL_UFO;
 	}
 	if (sp->high_dma_flag == true)
 		dev->features |= NETIF_F_HIGHDMA;
Signature · 1 line
1.9.3
#29 lore raw

PATCH 7/10 s2io: Enable UFO6 support.

In reply to Vladislav Yasevich
---
 drivers/net/ethernet/neterion/s2io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/neterion/s2io.c +3 -3
index f5e4b82..d823bb7 100644
@@ -4140,7 +4140,7 @@ static netdev_tx_t s2io_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	frg_len = skb_headlen(skb);
-	if (offload_type == SKB_GSO_UDP) {
+	if (offload_type == SKB_GSO_UDP || offload_type == SKB_GSO_UDP6) {
 		int ufo_size;
 
 		ufo_size = s2io_udp_mss(skb);
@@ -7917,9 +7917,9 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
 	dev->features |= dev->hw_features |
 		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
 	if (sp->device_type & XFRAME_II_DEVICE) {
-		dev->hw_features |= NETIF_F_UFO;
+		dev->hw_features |= NETIF_F_ALL_UFO;
 		if (ufo)
-			dev->features |= NETIF_F_UFO;
+			dev->features |= NETIF_F_ALL_UFO;
 	}
 	if (sp->high_dma_flag == true)
 		dev->features |= NETIF_F_HIGHDMA;
Signature · 1 line
1.9.3
#30 lore raw

PATCH 8/10 tun: Re-uanble UFO support.

In reply to Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist makes sure that two legacy VMs may still communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/tun.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/net/tun.c +14 -12
index 9dd3746..8c32fca 100644
@@ -175,7 +175,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6|NETIF_F_UFO)
 
 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(tun->dev,
-					    "%s: using disabled UFO feature; please fix this program\n",
-					    current->comm);
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This allows legacy application to work.
+				 * Do not change the gso_type as it may
+				 * not be upderstood by legacy applications.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
-		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
 			kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+			else if (sinfo->gso_type & SKB_GSO_UDP)
+				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
+
+		if (arg & TUN_F_UFO) {
+			features |= NETIF_F_UFO;
+			arg &= ~TUN_F_UFO;
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
Signature · 1 line
1.9.3
#31 lore raw

PATCH 8/10 tun: Re-uanble UFO support.

In reply to Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist makes sure that two legacy VMs may still communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/tun.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/net/tun.c +14 -12
index 9dd3746..8c32fca 100644
@@ -175,7 +175,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6|NETIF_F_UFO)
 
 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(tun->dev,
-					    "%s: using disabled UFO feature; please fix this program\n",
-					    current->comm);
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This allows legacy application to work.
+				 * Do not change the gso_type as it may
+				 * not be upderstood by legacy applications.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
-		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
 			kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+			else if (sinfo->gso_type & SKB_GSO_UDP)
+				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
+
+		if (arg & TUN_F_UFO) {
+			features |= NETIF_F_UFO;
+			arg &= ~TUN_F_UFO;
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
Signature · 1 line
1.9.3
#32 lore raw

Re: [PATCH 08/10] tun: Re-uanble UFO support.

subs: re-enable

Quoted 5 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist

s/Thist/this/

Quoted 1 line

makes sure that two legacy VMs may still communicate.

This means IPv6 skbs with UFO (not UFO6) flag set are present in the stack.
If possible, I think it would be better to make GSO type correct: UFO6, and then convert to UFO when copying to guest.

A similar approach should be possible for OVS?

Quoted 31 lines

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/tun.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/net/tun.c +1 -6
index 9dd3746..8c32fca 100644
@@ -175,7 +175,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6|NETIF_F_UFO)
 
 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1159

Quoted 10 lines
drivers/net/tun.c +4 -5
-				netdev_warn(tun->dev,
-					    "%s: using disabled UFO feature; please fix this program\n",
-					    current->comm);
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This allows legacy application to work.
+				 * Do not change the gso_type as it may
+				 * not be upderstood by legacy applications.

Shouldn't we handle legacy applications when passing packets to userspace?

Quoted 31 lines
drivers/net/tun.c +9 -1
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
-		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
 			kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+			else if (sinfo->gso_type & SKB_GSO_UDP)
+				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
+
+		if (arg & TUN_F_UFO) {
+			features |= NETIF_F_UFO;
+			arg &= ~TUN_F_UFO;
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
Signature · 1 line
1.9.3
#33 lore raw

Re: [PATCH 08/10] tun: Re-uanble UFO support.

In reply to Vladislav Yasevich

----- Original Message -----

Quoted 36 lines

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist makes sure that two legacy VMs may still communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/tun.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/net/tun.c +1 -3
index 9dd3746..8c32fca 100644
@@ -175,7 +175,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6|NETIF_F_UFO)
 
 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct tun_struct *tun,
 struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, · line 1157

Quoted 10 lines
drivers/net/tun.c +1 -8
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(tun->dev,
-					    "%s: using disabled UFO feature; please fix this program\n",
-					    current->comm);
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {

This probably means UDPv6 with vlan does not work well, looks like another independent fixe and also for stable.

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1160

Quoted 4 lines
drivers/net/tun.c +4 -0
+				/* This allows legacy application to work.
+				 * Do not change the gso_type as it may
+				 * not be upderstood by legacy applications.
+				 */

Isn't this an issue that we use SKB_GSO_UDP for a UDPv6 packet? Especially consider we want to fix UFOv6 in the future? We probably can use SKB_GSO_UDP6 here and try to fix it in tun_put_user() if a legacy userspace is detected.

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1161

Quoted 1 line
drivers/net/tun.c +0 -0
 				ipv6_proxy_select_ident(skb);

Question still for vlan, is network header correctly set here? Looks like ipv6_proxy_select_ident() depends on correct network header to work.

Quoted 36 lines
drivers/net/tun.c +1 -1
+			}
 			break;
-		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
drivers/net/tun.c +7 -0
 			kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+			else if (sinfo->gso_type & SKB_GSO_UDP)
+				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct *tun,
 unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
+
+		if (arg & TUN_F_UFO) {
+			features |= NETIF_F_UFO;
+			arg &= ~TUN_F_UFO;
+		}
 	}
 

/* This gives the user a way to test for new features in future by
--
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#34 lore raw

Re: [PATCH 08/10] tun: Re-uanble UFO support.

Quoted 44 lines · Jason Wang

----- Original Message -----

Quoted 41 lines

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist makes sure that two legacy VMs may still communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/tun.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/net/tun.c +1 -8
index 9dd3746..8c32fca 100644
@@ -175,7 +175,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6|NETIF_F_UFO)
 
 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct tun_struct *tun,
 struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(tun->dev,
-					    "%s: using disabled UFO feature; please fix this program\n",
Quoted 8 lines

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1156

Quoted 5 lines
drivers/net/tun.c +1 -3
-					    current->comm);
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {

This probably means UDPv6 with vlan does not work well, looks like another independent fixe and also for stable.

Ok. I can split this out.

Quoted 9 lines

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1160

Quoted 4 lines
drivers/net/tun.c +4 -0
+				/* This allows legacy application to work.
+				 * Do not change the gso_type as it may
+				 * not be upderstood by legacy applications.
+				 */

Isn't this an issue that we use SKB_GSO_UDP for a UDPv6 packet? Especially consider we want to fix UFOv6 in the future? We probably can use SKB_GSO_UDP6 here and try to fix it in tun_put_user() if a legacy userspace is detected.

There is a slight problem with this. This will force fragmentation of IPv6 traffic between VMs since UFO6 wouldn't be enabled on a destination device. So, suddenly older VMs will see a performance regression for large UDPv6 traffic.

With this code, a legacy VM will continue to receive large UDPv6 traffic. New VMs will have an updated virtio-net which will reset the gso type on input.

Quoted 5 lines

drivers/net/tun.c static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · line 1161

Quoted 1 line
drivers/net/tun.c +0 -0
 				ipv6_proxy_select_ident(skb);

Question still for vlan, is network header correctly set here? Looks like ipv6_proxy_select_ident() depends on correct network header to work.

drivers/net/tun.c static int set_offload(struct tun_struct *tun, unsigned long arg) · line 1780

Quoted 1 line
drivers/net/tun.c +1 -0
+	

Yes, you are right... I wonder how that worked. I'll re-test.

Thanks
-vlad

		}
Quoted 35 lines
Quoted 35 lines
drivers/net/tun.c +0 -1
 			break;
-		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
drivers/net/tun.c +7 -0
 			kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+			else if (sinfo->gso_type & SKB_GSO_UDP)
+				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct *tun,
 unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
+
+		if (arg & TUN_F_UFO) {
+			features |= NETIF_F_UFO;
+			arg &= ~TUN_F_UFO;
+		}
 	}
 

/* This gives the user a way to test for new features in future by
--
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw

Re: [PATCH 08/10] tun: Re-uanble UFO support.

Quoted 72 lines · Vlad Yasevich
Quoted 53 lines · Jason Wang

----- Original Message -----

Quoted 41 lines

Now that UFO is split into v4 and v6 parts, we can bring back v4 support without any trouble.

Continue to handle legacy applications by selecting the IPv6 fragment id but do not change the gso type. Thist makes sure that two legacy VMs may still communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>

---

  drivers/net/tun.c | 26 ++++++++++++++------------
  1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 9dd3746..8c32fca 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -175,7 +175,7 @@ struct tun_struct {
struct net_device *dev;
netdev_features_t set_features;
#define TUN_USER_FEATURES
(NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
- NETIF_F_TSO6)
+ NETIF_F_TSO6|NETIF_F_UFO)

int vnet_hdr_sz;
int sndbuf;
@@ -1152,20 +1152,15 @@ static ssize_t tun_get_user(struct
tun_struct *tun,
struct tun_file *tfile,
skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; break;
case VIRTIO_NET_HDR_GSO_UDP:
- {
- static bool warned;
-
- if (!warned) {
- warned = true;

Quoted 8 lines

- netdev_warn(tun->dev,
- "%s: using disabled UFO feature; please fix this
program\n",
- current->comm);
- }
skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
- if (skb->protocol == htons(ETH_P_IPV6))
+ if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {

Quoted 3 lines

This probably means UDPv6 with vlan does not work well, looks like
another
independent fixe and also for stable.

Ok. I can split this out.

Quoted 11 lines
Quoted 4 lines

+ /* This allows legacy application to work.
+ * Do not change the gso_type as it may
+ * not be upderstood by legacy applications.
+ */

Isn't this an issue that we use SKB_GSO_UDP for a UDPv6 packet?
Especially
consider we want to fix UFOv6 in the future? We probably can use SKB_GSO_UDP6 here and try to fix it in tun_put_user() if a legacy
userspace
is detected.

Quoted 7 lines

There is a slight problem with this. This will force fragmentation of IPv6 traffic between VMs since UFO6 wouldn't be enabled on a destination device. So, suddenly older VMs will see a performance regression for large UDPv6 traffic.

With this code, a legacy VM will continue to receive large UDPv6 traffic. New VMs will have an updated virtio-net which will reset the gso type on input.

I get the point and that's why you still want ipv6 offload helpers to accept SKB_GSO_UDP. So SKB_GSO_UDP was still ambigious since it can be a UDP6 packet in fact.

I'm not sure, but probably we could just leave the regression of legacy guest as is and fix current kernel. The sooner we eliminate the ambigious the better for future development.

Quoted 54 lines
Quoted 8 lines
Quoted 3 lines

  				ipv6_proxy_select_ident(skb);

Question still for vlan, is network header correctly set here?
Looks like
ipv6_proxy_select_ident() depends on correct network header to work.

Quoted 1 line

+

Yes, you are right... I wonder how that worked. I'll re-test.

Thanks
-vlad

		}
Quoted 39 lines
Quoted 39 lines

break;
- }
default:
tun->dev->stats.rx_frame_errors++; kfree_skb(skb);
@@ -1273,6 +1268,8 @@ static ssize_t tun_put_user(struct
tun_struct *tun,
gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
else if (sinfo->gso_type & SKB_GSO_TCPV6)
gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+ else if (sinfo->gso_type & SKB_GSO_UDP)
+ gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
else {
pr_err("unexpected GSO type: "
"0x%x, gso_size %d, hdr_len %d\n",
@@ -1780,6 +1777,11 @@ static int set_offload(struct tun_struct
*tun,
unsigned long arg)
features |= NETIF_F_TSO6;
arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
}
+
+ if (arg & TUN_F_UFO) {
+ features |= NETIF_F_UFO;
+ arg &= ~TUN_F_UFO;
+ }
}

/* This gives the user a way to test for new features in future
by
--
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe netdev"
in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#36 lore raw

PATCH 9/10 macvtap: Re-enable UFO support

In reply to Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +14 -6
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#37 lore raw

PATCH 9/10 macvtap: Re-enable UFO support

In reply to Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +14 -6
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#38 lore raw

Re: [PATCH 09/10] macvtap: Re-enable UFO support

Quoted 65 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +12 -4
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where

drivers/net/macvtap.c static int set_offload(struct macvtap_queue *q, unsigned long arg) · line 979

Quoted 8 lines
drivers/net/macvtap.c +1 -1
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;

By the way this logic is completely broken, even without your patch, isn't it?

It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO set.

So what happens if I enable TSO only?
LRO gets enabled so I can still get TSO6 packets.

This really should be:

	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
			(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)

fixing this probably should be a separate patch before your series, and Cc stable.

Quoted 11 lines
drivers/net/macvtap.c +1 -1
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#39 lore raw

Re: [PATCH 09/10] macvtap: Re-enable UFO support

Quoted 85 lines · Michael S. Tsirkin
Quoted 65 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +12 -4
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where

drivers/net/macvtap.c static int set_offload(struct macvtap_queue *q, unsigned long arg) · line 979

Quoted 8 lines
drivers/net/macvtap.c +1 -1
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;

By the way this logic is completely broken, even without your patch, isn't it?

It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO set.

So what happens if I enable TSO only?
LRO gets enabled so I can still get TSO6 packets.

Quoted 8 lines

This really should be:

	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
			(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)

fixing this probably should be a separate patch before your series, and Cc stable.

Actually, all this LRO/GRO feature manipulation on the macvtap device is rather pointless as those features aren't really checked at any point on the macvtap receive path. GRO calls are done from napi context on the lowest device, so by the time a packet hits macvtap, GRO/LRO has already been done.

So it doesn't really matter that we disable them incorrectly. I can send a separate patch to clean this up.

Quoted 13 lines
Quoted 13 lines
drivers/net/macvtap.c +1 -1
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#40 lore raw

Re: [PATCH 09/10] macvtap: Re-enable UFO support

Quoted 95 lines · Vlad Yasevich
Quoted 85 lines · Michael S. Tsirkin
Quoted 65 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +12 -4
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where

drivers/net/macvtap.c static int set_offload(struct macvtap_queue *q, unsigned long arg) · line 979

Quoted 8 lines
drivers/net/macvtap.c +1 -1
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;

By the way this logic is completely broken, even without your patch, isn't it?

It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO set.

So what happens if I enable TSO only?
LRO gets enabled so I can still get TSO6 packets.

Quoted 8 lines

This really should be:

	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
			(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)

fixing this probably should be a separate patch before your series, and Cc stable.

Quoted 8 lines

Actually, all this LRO/GRO feature manipulation on the macvtap device is rather pointless as those features aren't really checked at any point on the macvtap receive path. GRO calls are done from napi context on the lowest device, so by the time a packet hits macvtap, GRO/LRO has already been done.

So it doesn't really matter that we disable them incorrectly. I can send a separate patch to clean this up.

Hmm so if userspace says it can't handle TSO packets, it might get them anyway?

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/net/macvtap.c +1 -1
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#41 lore raw

Re: [PATCH 09/10] macvtap: Re-enable UFO support

Quoted 102 lines · Michael S. Tsirkin
Quoted 101 lines · Vlad Yasevich
Quoted 85 lines · Michael S. Tsirkin
Quoted 65 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +12 -4
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where

drivers/net/macvtap.c static int set_offload(struct macvtap_queue *q, unsigned long arg) · line 979

Quoted 8 lines
drivers/net/macvtap.c +1 -1
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;

By the way this logic is completely broken, even without your patch, isn't it?

It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO set.

So what happens if I enable TSO only?
LRO gets enabled so I can still get TSO6 packets.

Quoted 8 lines

This really should be:

	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
			(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)

fixing this probably should be a separate patch before your series, and Cc stable.

Actually, all this LRO/GRO feature manipulation on the macvtap device is rather pointless as those features aren't really checked at any point on the macvtap receive path. GRO calls are done from napi context on the lowest device, so by the time a packet hits macvtap, GRO/LRO has already been done.

Quoted 5 lines
Quoted 2 lines

So it doesn't really matter that we disable them incorrectly. I can send a separate patch to clean this up.

Hmm so if userspace says it can't handle TSO packets, it might get them anyway?

No. It will get individual segments because in macvtap_handle_frame we use user specified features to decide if segmentation needs to be performed or not.

-vlad

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/macvtap.c +1 -1
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#42 lore raw

Re: [PATCH 09/10] macvtap: Re-enable UFO support

In reply to Michael S. Tsirkin
Quoted 102 lines · Michael S. Tsirkin
Quoted 101 lines · Vlad Yasevich
Quoted 85 lines · Michael S. Tsirkin
Quoted 65 lines · Vladislav Yasevich

Now that UFO is split into v4 and v6 parts, we can bring back v4 support. Continue to handle legacy applications by selecting the ipv6 fagment id but do not change the gso type. This allows 2 legacy VMs to continue to communicate.

Based on original work from Ben Hutchings.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/macvtap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/net/macvtap.c +12 -4
index 880cc09..75febd4 100644
@@ -66,7 +66,7 @@ static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;
 
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6)
+		      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
 
@@ -570,11 +570,14 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
-				     current->comm);
 			gso_type = SKB_GSO_UDP;
-			if (skb->protocol == htons(ETH_P_IPV6))
+			if (vlan_get_protocol(skb) == htons(ETH_P_IPV6)) {
+				/* This is to support legacy appliacations.
+				 * Do not change the gso_type as legacy apps
+				 * may not know about the new type.
+				 */
 				ipv6_proxy_select_ident(skb);
+			}
 			break;
 		default:
 			return -EINVAL;
@@ -619,6 +622,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP)
+			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -955,6 +960,9 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		if (arg & TUN_F_UFO)
+			feature_mask |= NETIF_F_UFO;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where

drivers/net/macvtap.c static int set_offload(struct macvtap_queue *q, unsigned long arg) · line 979

Quoted 8 lines
drivers/net/macvtap.c +1 -1
@@ -965,7 +973,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;

By the way this logic is completely broken, even without your patch, isn't it?

It says: enable LRO+GRO if any of NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO set.

So what happens if I enable TSO only?
LRO gets enabled so I can still get TSO6 packets.

Quoted 8 lines

This really should be:

	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO) ==
			(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)

fixing this probably should be a separate patch before your series, and Cc stable.

Actually, all this LRO/GRO feature manipulation on the macvtap device is rather pointless as those features aren't really checked at any point on the macvtap receive path. GRO calls are done from napi context on the lowest device, so by the time a packet hits macvtap, GRO/LRO has already been done.

Quoted 5 lines
Quoted 2 lines

So it doesn't really matter that we disable them incorrectly. I can send a separate patch to clean this up.

Hmm so if userspace says it can't handle TSO packets, it might get them anyway?

No. It will get individual segments because in macvtap_handle_frame we use user specified features to decide if segmentation needs to be performed or not.

-vlad

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/macvtap.c +1 -1
@@ -1066,7 +1074,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN))
+			    TUN_F_TSO_ECN | TUN_F_UFO))
 			return -EINVAL;
 
 		rtnl_lock();
Signature · 1 line
1.9.3
#43 lore raw

PATCH 10/10 Revert "drivers/net: Disable UFO through virtio"

In reply to Vladislav Yasevich

This reverts commit 3d0ad09412ffe00c9afa201d01effdb6023d09b4. Now that we've split UFO into v4 and v6 version, we can turn back UFO support for ipv4. Full IPv6 support will come later as it requires extending vnet header structure.

Any older VM that assumes IPv6 support is included in UFO will continue to use UFO and the host will generate fragment ids for it, thus preserving connectivity.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/virtio_net.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/net/virtio_net.c +10 -14
index b0bc8ea..534b633 100644
@@ -491,17 +491,8 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(dev,
-					    "host using disabled UFO feature; please fix it\n");
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
 			break;
-		}
 		case VIRTIO_NET_HDR_GSO_TCPV6:
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
@@ -890,6 +881,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1749,7 +1742,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
 
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-			dev->hw_features |= NETIF_F_TSO
+			dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
 				| NETIF_F_TSO_ECN | NETIF_F_TSO6;
 		}
 		/* Individual feature bits: what can host handle? */
@@ -1759,9 +1752,11 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->hw_features |= NETIF_F_TSO6;
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
 			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
+			dev->hw_features |= NETIF_F_UFO;
 
 		if (gso)
-			dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
+			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1799,7 +1794,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 	/* If we can receive ANY GSO packets, we must allocate large ones. */
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1993,9 +1989,9 @@ static struct virtio_device_id id_table[] = {
 static unsigned int features[] = {
 	VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
 	VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
-	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
+	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
 	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
-	VIRTIO_NET_F_GUEST_ECN,
+	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
 	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
 	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
Signature · 1 line
1.9.3
#44 lore raw

PATCH 10/10 Revert "drivers/net: Disable UFO through virtio"

In reply to Vladislav Yasevich

This reverts commit 3d0ad09412ffe00c9afa201d01effdb6023d09b4. Now that we've split UFO into v4 and v6 version, we can turn back UFO support for ipv4. Full IPv6 support will come later as it requires extending vnet header structure.

Any older VM that assumes IPv6 support is included in UFO will continue to use UFO and the host will generate fragment ids for it, thus preserving connectivity.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/virtio_net.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/net/virtio_net.c +10 -14
index b0bc8ea..534b633 100644
@@ -491,17 +491,8 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(dev,
-					    "host using disabled UFO feature; please fix it\n");
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
 			break;
-		}
 		case VIRTIO_NET_HDR_GSO_TCPV6:
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
@@ -890,6 +881,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1749,7 +1742,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
 
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-			dev->hw_features |= NETIF_F_TSO
+			dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
 				| NETIF_F_TSO_ECN | NETIF_F_TSO6;
 		}
 		/* Individual feature bits: what can host handle? */
@@ -1759,9 +1752,11 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->hw_features |= NETIF_F_TSO6;
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
 			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
+			dev->hw_features |= NETIF_F_UFO;
 
 		if (gso)
-			dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
+			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1799,7 +1794,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 	/* If we can receive ANY GSO packets, we must allocate large ones. */
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1993,9 +1989,9 @@ static struct virtio_device_id id_table[] = {
 static unsigned int features[] = {
 	VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
 	VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
-	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
+	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
 	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
-	VIRTIO_NET_F_GUEST_ECN,
+	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
 	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
 	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
Signature · 1 line
1.9.3
#45 lore raw

Re: [PATCH 10/10] Revert "drivers/net: Disable UFO through virtio"

Quoted 24 lines · Vladislav Yasevich

This reverts commit 3d0ad09412ffe00c9afa201d01effdb6023d09b4. Now that we've split UFO into v4 and v6 version, we can turn back UFO support for ipv4. Full IPv6 support will come later as it requires extending vnet header structure.

Any older VM that assumes IPv6 support is included in UFO will continue to use UFO and the host will generate fragment ids for it, thus preserving connectivity.

Fixes 88e0e0e5aa7a ("drivers/net: Disable UFO through virtio")
CC Ben Hutchings <[email protected]>
---
 drivers/net/virtio_net.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/net/virtio_net.c +0 -0
index b0bc8ea..534b633 100644
@@ -491,17 +491,8 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:

drivers/net/virtio_net.c static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len) · line 495

Quoted 10 lines
drivers/net/virtio_net.c +0 -8
-		{
-			static bool warned;
-
-			if (!warned) {
-				warned = true;
-				netdev_warn(dev,
-					    "host using disabled UFO feature; please fix it\n");
-			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
 			break;

This might not be true: could be a legacy host.
I think we need to check for IPv6 and set it
correctly to SKB_GSO_UDP/SKB_GSO_UDP6?

Quoted 59 lines
drivers/net/virtio_net.c +10 -6
-		}
 		case VIRTIO_NET_HDR_GSO_TCPV6:
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
@@ -890,6 +881,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
+			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1749,7 +1742,7 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
 
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-			dev->hw_features |= NETIF_F_TSO
+			dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
 				| NETIF_F_TSO_ECN | NETIF_F_TSO6;
 		}
 		/* Individual feature bits: what can host handle? */
@@ -1759,9 +1752,11 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->hw_features |= NETIF_F_TSO6;
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
 			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
+			dev->hw_features |= NETIF_F_UFO;
 
 		if (gso)
-			dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
+			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1799,7 +1794,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 	/* If we can receive ANY GSO packets, we must allocate large ones. */
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1993,9 +1989,9 @@ static struct virtio_device_id id_table[] = {
 static unsigned int features[] = {
 	VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
 	VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
-	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
+	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
 	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
-	VIRTIO_NET_F_GUEST_ECN,
+	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
 	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
 	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
Signature · 1 line
1.9.3
#46 lore raw
In reply to Vladislav Yasevich

----- Original Message -----

Quoted 6 lines

UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

Quoted 7 lines

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for guests. We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is still ambigious. I know it was used to keep compatibility for legacy guest. But what's the future plan? Differentiate UFOv4 and UFOv6 in virtio features and gso type in vnet header looks sufficient?

With the series, we can't send UFOv6 packet but legacy guest can. How about fix the UFOv6 also in this series?

Thanks

Quoted 41 lines

Vladislav Yasevich (10):
core: Split out UFO6 support
net: Correctly mark IPv6 UFO offload type.
ovs: Enable handling of UFO6 packets.
loopback: Turn on UFO6 support.
veth: Enable UFO6 support.
macvlan: Enable UFO6 support.
s2io: Enable UFO6 support.
tun: Re-uanble UFO support.
macvtap: Re-enable UFO support
Revert "drivers/net: Disable UFO through virtio"

 drivers/net/ethernet/neterion/s2io.c |  6 +++---
 drivers/net/loopback.c               |  4 ++--
 drivers/net/macvlan.c                |  2 +-
 drivers/net/macvtap.c                | 20 ++++++++++++++------
 drivers/net/tun.c                    | 26 ++++++++++++++------------
 drivers/net/veth.c                   |  2 +-
 drivers/net/virtio_net.c             | 24 ++++++++++--------------
 include/linux/netdev_features.h      |  7 +++++--
 include/linux/netdevice.h            |  1 +
 include/linux/skbuff.h               |  1 +
 net/core/dev.c                       | 35
 +++++++++++++++++++----------------
 net/core/ethtool.c                   |  2 +-
 net/ipv6/ip6_offload.c               |  1 +
 net/ipv6/ip6_output.c                |  4 ++--
 net/ipv6/udp_offload.c               |  3 ++-
 net/mpls/mpls_gso.c                  |  1 +
 net/openvswitch/datapath.c           |  3 ++-
 net/openvswitch/flow.c               |  2 +-
 18 files changed, 81 insertions(+), 63 deletions(-)

--
1.9.3

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#47 lore raw
In reply to Vladislav Yasevich

----- Original Message -----

Quoted 6 lines

UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

Quoted 7 lines

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for guests. We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is still ambigious. I know it was used to keep compatibility for legacy guest. But what's the future plan? Differentiate UFOv4 and UFOv6 in virtio features and gso type in vnet header looks sufficient?

With the series, we can't send UFOv6 packet but legacy guest can. How about fix the UFOv6 also in this series?

Thanks

Quoted 41 lines

Vladislav Yasevich (10):
core: Split out UFO6 support
net: Correctly mark IPv6 UFO offload type.
ovs: Enable handling of UFO6 packets.
loopback: Turn on UFO6 support.
veth: Enable UFO6 support.
macvlan: Enable UFO6 support.
s2io: Enable UFO6 support.
tun: Re-uanble UFO support.
macvtap: Re-enable UFO support
Revert "drivers/net: Disable UFO through virtio"

 drivers/net/ethernet/neterion/s2io.c |  6 +++---
 drivers/net/loopback.c               |  4 ++--
 drivers/net/macvlan.c                |  2 +-
 drivers/net/macvtap.c                | 20 ++++++++++++++------
 drivers/net/tun.c                    | 26 ++++++++++++++------------
 drivers/net/veth.c                   |  2 +-
 drivers/net/virtio_net.c             | 24 ++++++++++--------------
 include/linux/netdev_features.h      |  7 +++++--
 include/linux/netdevice.h            |  1 +
 include/linux/skbuff.h               |  1 +
 net/core/dev.c                       | 35
 +++++++++++++++++++----------------
 net/core/ethtool.c                   |  2 +-
 net/ipv6/ip6_offload.c               |  1 +
 net/ipv6/ip6_output.c                |  4 ++--
 net/ipv6/udp_offload.c               |  3 ++-
 net/mpls/mpls_gso.c                  |  1 +
 net/openvswitch/datapath.c           |  3 ++-
 net/openvswitch/flow.c               |  2 +-
 18 files changed, 81 insertions(+), 63 deletions(-)

--
1.9.3

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#48 lore raw
Quoted 16 lines · Jason Wang

----- Original Message -----

Quoted 6 lines

UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

Quoted 7 lines

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for guests. We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

Quoted 6 lines

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is still ambigious. I know it was used to keep compatibility for legacy guest. But what's the future plan? Differentiate UFOv4 and UFOv6 in virtio features and gso type in vnet header looks sufficient?

[...]

The IPv6 fragmentation ID needs to be added to the vnet header, to do UFOv6 properly. If it wasn't for that lack, we wouldn't have to split the feature flag.

Ben.

Signature · 2 lines
Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#49 lore raw
Quoted 23 lines · Ben Hutchings
Quoted 16 lines · Jason Wang

----- Original Message -----

Quoted 6 lines

UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

Quoted 7 lines

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for guests. We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

Quoted 6 lines

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is still ambigious. I know it was used to keep compatibility for legacy guest. But what's the future plan? Differentiate UFOv4 and UFOv6 in virtio features and gso type in vnet header looks sufficient?

Quoted 7 lines

[...]

The IPv6 fragmentation ID needs to be added to the vnet header, to do UFOv6 properly. If it wasn't for that lack, we wouldn't have to split the feature flag.

Ben.

Right.

I think a good plan is as follows:

1. add code generating IDs on rx path for virtio,
and re-enable UFO (4+6).

2. Ben's patch doing similar things for tun/macvtap

3. similarly for packet sockets

above seem appropriate for stable

4. 4+6 split, to make it easier for drivers
to identify when fragment ID is needed

5. extend vnet header, and add ways to enable it, when enabled, use that to pass
fragment ID for tun/virtio/vhost/macvtap/packet socket

4 is what this patchset does.

Quoted 3 lines
Signature · 2 lines
Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.
#50 lore raw
Quoted 43 lines · Michael S. Tsirkin
Quoted 33 lines · Ben Hutchings
Quoted 3 lines · Jason Wang

----- Original Message -----

Quoted 1 line

UFO support in the kernel applies to both IPv4 and IPv6

protocols

Quoted 1 line
Quoted 1 line

with the same device feature. However some devices may not be

able

Quoted 1 line
Quoted 1 line

to support one of the offloads. For this we split the UFO

offload

Quoted 1 line
Quoted 1 line

feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part

and

Quoted 4 lines
Quoted 4 lines

this series introduces NETIF_F_UFO6.

As a result of this work, we can now re-enable NETIF_F_UFO on virtio_net devices and restore UDP over IPv4 performance for

guests.

Quoted 9 lines
Quoted 5 lines

We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Without this work, migrating a guest to a 3.18 kernel fails.

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is

still

Quoted 1 line

ambigious. I know it was used to keep compatibility for legacy

guest. But

Quoted 1 line

what's the future plan? Differentiate UFOv4 and UFOv6 in virtio

features and

Quoted 1 line

gso type in vnet header looks sufficient?

[...]

Quoted 7 lines

The IPv6 fragmentation ID needs to be added to the vnet header, to
do
UFOv6 properly. If it wasn't for that lack, we wouldn't have to
split
the feature flag.

Ben.

Quoted 8 lines

Right.

I think a good plan is as follows:

1. add code generating IDs on rx path for virtio,
and re-enable UFO (4+6).

2. Ben's patch doing similar things for tun/macvtap

I wonder whether or not we can do this lazily.

E.g during UFO6 software segment for dodgy packets?

And this can eliminate the effort of duplicating it in all untrusted sources?

Quoted 26 lines

3. similarly for packet sockets

above seem appropriate for stable

4. 4+6 split, to make it easier for drivers
to identify when fragment ID is needed

5. extend vnet header, and add ways to enable it, when enabled, use that to pass
fragment ID for tun/virtio/vhost/macvtap/packet socket

4 is what this patchset does.

Quoted 4 lines

--
Ben Hutchings
If more than one person is responsible for a bug, no one is at
fault.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#51 lore raw
Quoted 39 lines · Jason Wang
Quoted 36 lines · Michael S. Tsirkin
Quoted 18 lines · Ben Hutchings
Quoted 8 lines · Jason Wang
Quoted 8 lines

----- Original Message -----
UFO support in the kernel applies to both IPv4 and IPv6 protocols with the same device feature. However some devices may not be able to support one of the offloads. For this we split the UFO offload feature into 2 pieces. NETIF_F_UFO now controlls the IPv4 part and this series introduces NETIF_F_UFO6.

Quoted 1 line
Quoted 1 line

As a result of this work, we can now re-enable NETIF_F_UFO on

virtio_net devices and restore UDP over IPv4 performance for

guests.

Quoted 5 lines
Quoted 5 lines

We also continue to support legacy guests that assume that UFO6 support included into UFO(4).

Quoted 2 lines
Quoted 2 lines

Without this work, migrating a guest to a 3.18 kernel fails. This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and VIRTIO_NET_F_HDR_GSO_UDP is

still

Quoted 1 line

ambigious. I know it was used to keep compatibility for legacy guest.

But

Quoted 8 lines
Quoted 1 line

what's the future plan? Differentiate UFOv4 and UFOv6 in virtio

features and

Quoted 1 line

gso type in vnet header looks sufficient?

[...]
The IPv6 fragmentation ID needs to be added to the vnet header, to do
UFOv6 properly. If it wasn't for that lack, we wouldn't have to split the feature flag.
Ben.

Right.

I think a good plan is as follows:

1. add code generating IDs on rx path for virtio,
and re-enable UFO (4+6).

Quoted 8 lines
Quoted 1 line

2. Ben's patch doing similar things for tun/macvtap

I wonder whether or not we can do this lazily.

E.g during UFO6 software segment for dodgy packets?

And this can eliminate the effort of duplicating it in all untrusted sources?

But then we'll need to then change it again in step 5, probably by setting some flag?
Might as well do it directly.

Quoted 24 lines
Quoted 24 lines

3. similarly for packet sockets

above seem appropriate for stable

4. 4+6 split, to make it easier for drivers
to identify when fragment ID is needed

5. extend vnet header, and add ways to enable it, when enabled, use that to pass
fragment ID for tun/virtio/vhost/macvtap/packet socket

4 is what this patchset does.

Quoted 2 lines

-- Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#52 lore raw
Quoted 56 lines · Michael S. Tsirkin
Quoted 55 lines · Jason Wang
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · Ben Hutchings
Quoted 2 lines · Jason Wang
Quoted 2 lines

----- Original Message -----
UFO support in the kernel applies to both IPv4 and IPv6

protocols

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

with the same device feature. However some devices may not

be able

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to support one of the offloads. For this we split the UFO

offload

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

feature into 2 pieces. NETIF_F_UFO now controlls the IPv4

part and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

this series introduces NETIF_F_UFO6.

Quoted 1 line
Quoted 1 line

As a result of this work, we can now re-enable

NETIF_F_UFO on

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

virtio_net devices and restore UDP over IPv4 performance for

guests.

Quoted 1 line
Quoted 1 line

We also continue to support legacy guests that assume that

UFO6

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

support included into UFO(4).

Quoted 1 line
Quoted 1 line

Without this work, migrating a guest to a 3.18 kernel

fails.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

This series eliminate the ambiguous NETIF_F_UFO.

But VIRTIO_NET_F_{HOST|GUEST}_UFO and

VIRTIO_NET_F_HDR_GSO_UDP is

Quoted 2 lines
Quoted 2 lines

still

Quoted 1 line

ambigious. I know it was used to keep compatibility for legacy

guest.

Quoted 6 lines
Quoted 6 lines

But

Quoted 1 line

what's the future plan? Differentiate UFOv4 and UFOv6 in virtio

features and

Quoted 1 line

gso type in vnet header looks sufficient?

[...]
The IPv6 fragmentation ID needs to be added to the vnet

header, to do

Quoted 1 line
Quoted 1 line

UFOv6 properly. If it wasn't for that lack, we wouldn't have to

split

Quoted 4 lines
Quoted 2 lines

the feature flag.
Ben.

Quoted 8 lines

Right.

I think a good plan is as follows:

1. add code generating IDs on rx path for virtio,
and re-enable UFO (4+6).

2. Ben's patch doing similar things for tun/macvtap

I wonder whether or not we can do this lazily.

Quoted 7 lines
Quoted 4 lines

E.g during UFO6 software segment for dodgy packets?

And this can eliminate the effort of duplicating it in all untrusted sources?

But then we'll need to then change it again in step 5, probably by setting some flag?

The idea is if no segmentation (either software or hardware), no need for an id.

So looks like dodgy is sufficient since we are sure kernel should set id in all other cases. And we can add the id only when we see it was not set for the ufo packet(legacy guest). This seems not conflict with step 5.

Quoted 33 lines

Might as well do it directly.

Quoted 16 lines
Quoted 16 lines

3. similarly for packet sockets

above seem appropriate for stable

4. 4+6 split, to make it easier for drivers
to identify when fragment ID is needed

5. extend vnet header, and add ways to enable it, when enabled, use that to pass
fragment ID for tun/virtio/vhost/macvtap/packet socket

4 is what this patchset does.

Quoted 10 lines
Quoted 2 lines
Quoted 2 lines

-- Ben Hutchings
If more than one person is responsible for a bug, no one is at

fault.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html