All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-12 11:23 ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously).
It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can
enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now.
For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
In the future, there would be a mechanism to control UDP_L4 GSO separately.

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Also, there is a known issue with transmitting packages between two guests.
Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew (5):
  uapi/linux/if_tun.h: Added new offload types for USO4/6.
  driver/net/tun: Added features for USO.
  uapi/linux/virtio_net.h: Added USO types.
  linux/virtio_net.h: Support USO offload in vnet header.
  drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 10 ++++++++--
 drivers/net/tun.c               |  8 +++++++-
 drivers/net/virtio_net.c        | 19 +++++++++++++++----
 include/linux/virtio_net.h      |  9 +++++++++
 include/uapi/linux/if_tun.h     |  2 ++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 45 insertions(+), 7 deletions(-)

-- 
2.35.1


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

* [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-12 11:23 ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously).
It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can
enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now.
For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
In the future, there would be a mechanism to control UDP_L4 GSO separately.

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Also, there is a known issue with transmitting packages between two guests.
Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew (5):
  uapi/linux/if_tun.h: Added new offload types for USO4/6.
  driver/net/tun: Added features for USO.
  uapi/linux/virtio_net.h: Added USO types.
  linux/virtio_net.h: Support USO offload in vnet header.
  drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 10 ++++++++--
 drivers/net/tun.c               |  8 +++++++-
 drivers/net/virtio_net.c        | 19 +++++++++++++++----
 include/linux/virtio_net.h      |  9 +++++++++
 include/uapi/linux/if_tun.h     |  2 ++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 45 insertions(+), 7 deletions(-)

-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [RFC PATCH v2 1/5] uapi/linux/if_tun.h: Added new offload types for USO4/6.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-12 11:23   ` Andrew Melnychenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added 2 additional offlloads for USO(IPv4 & IPv6).
Separate offloads are required for Windows VM guests,
g.e. Windows may set USO rx only for IPv4.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/if_tun.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 454ae31b93c7..e147dcb46d5c 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -88,6 +88,8 @@
 #define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */
 #define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */
 #define TUN_F_UFO	0x10	/* I can handle UFO packets */
+#define TUN_F_USO4	0x20	/* I can handle USO for IPv4 packets */
+#define TUN_F_USO6	0x40	/* I can handle USO for IPv6 packets */
 
 /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
 #define TUN_PKT_STRIP	0x0001
-- 
2.35.1


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

* [RFC PATCH v2 1/5] uapi/linux/if_tun.h: Added new offload types for USO4/6.
@ 2022-05-12 11:23   ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added 2 additional offlloads for USO(IPv4 & IPv6).
Separate offloads are required for Windows VM guests,
g.e. Windows may set USO rx only for IPv4.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/if_tun.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 454ae31b93c7..e147dcb46d5c 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -88,6 +88,8 @@
 #define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */
 #define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */
 #define TUN_F_UFO	0x10	/* I can handle UFO packets */
+#define TUN_F_USO4	0x20	/* I can handle USO for IPv4 packets */
+#define TUN_F_USO6	0x40	/* I can handle USO for IPv6 packets */
 
 /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
 #define TUN_PKT_STRIP	0x0001
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [RFC PATCH v2 2/5] driver/net/tun: Added features for USO.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-12 11:23   ` Andrew Melnychenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added support for USO4 and USO6.
For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously.
USO enables NETIF_F_GSO_UDP_L4.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/tap.c | 10 ++++++++--
 drivers/net/tun.c |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index c3d42062559d..eae7c2c13713 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -955,6 +955,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if ((arg & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
+			features |= NETIF_F_GSO_UDP_L4;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -965,7 +969,8 @@ static int set_offload(struct tap_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) ||
+	    (feature_mask & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -1089,7 +1094,8 @@ static long tap_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_UFO))
+			    TUN_F_TSO_ECN | TUN_F_UFO |
+			    TUN_F_USO4 | TUN_F_USO6))
 			return -EINVAL;
 
 		rtnl_lock();
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index dbe4c0a4be2c..ecad1bdee717 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -185,7 +185,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_GSO_UDP_L4)
 
 	int			align;
 	int			vnet_hdr_sz;
@@ -2861,6 +2861,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 		}
 
 		arg &= ~TUN_F_UFO;
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
+			features |= NETIF_F_GSO_UDP_L4;
+			arg &= ~(TUN_F_USO4 | TUN_F_USO6);
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
-- 
2.35.1


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

* [RFC PATCH v2 2/5] driver/net/tun: Added features for USO.
@ 2022-05-12 11:23   ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added support for USO4 and USO6.
For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously.
USO enables NETIF_F_GSO_UDP_L4.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/tap.c | 10 ++++++++--
 drivers/net/tun.c |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index c3d42062559d..eae7c2c13713 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -955,6 +955,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if ((arg & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
+			features |= NETIF_F_GSO_UDP_L4;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -965,7 +969,8 @@ static int set_offload(struct tap_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) ||
+	    (feature_mask & (TUN_F_USO4 | TUN_F_USO6)) == (TUN_F_USO4 | TUN_F_USO6))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -1089,7 +1094,8 @@ static long tap_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_UFO))
+			    TUN_F_TSO_ECN | TUN_F_UFO |
+			    TUN_F_USO4 | TUN_F_USO6))
 			return -EINVAL;
 
 		rtnl_lock();
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index dbe4c0a4be2c..ecad1bdee717 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -185,7 +185,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_GSO_UDP_L4)
 
 	int			align;
 	int			vnet_hdr_sz;
@@ -2861,6 +2861,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 		}
 
 		arg &= ~TUN_F_UFO;
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
+			features |= NETIF_F_GSO_UDP_L4;
+			arg &= ~(TUN_F_USO4 | TUN_F_USO6);
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [RFC PATCH v2 3/5] uapi/linux/virtio_net.h: Added USO types.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-12 11:23   ` Andrew Melnychenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added new GSO type for USO: VIRTIO_NET_HDR_GSO_UDP_L4.
Feature VIRTIO_NET_F_HOST_USO allows to enable NETIF_F_GSO_UDP_L4.
Separated VIRTIO_NET_F_GUEST_USO4 & VIRTIO_NET_F_GUEST_USO6 features
required for Windows guests.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/virtio_net.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 3f55a4215f11..c654feb1ed9b 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -56,6 +56,9 @@
 #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
 					 * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
+#define VIRTIO_NET_F_GUEST_USO4	54	/* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */
 
 #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
 #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
 #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */
 #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */
 #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4	5	/* GSO frame, IPv4& IPv6 UDP (USO) */
 #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */
 	__u8 gso_type;
 	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */
-- 
2.35.1


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

* [RFC PATCH v2 3/5] uapi/linux/virtio_net.h: Added USO types.
@ 2022-05-12 11:23   ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Added new GSO type for USO: VIRTIO_NET_HDR_GSO_UDP_L4.
Feature VIRTIO_NET_F_HOST_USO allows to enable NETIF_F_GSO_UDP_L4.
Separated VIRTIO_NET_F_GUEST_USO4 & VIRTIO_NET_F_GUEST_USO6 features
required for Windows guests.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/virtio_net.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 3f55a4215f11..c654feb1ed9b 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -56,6 +56,9 @@
 #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
 					 * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
+#define VIRTIO_NET_F_GUEST_USO4	54	/* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */
 
 #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
 #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
 #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */
 #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */
 #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4	5	/* GSO frame, IPv4& IPv6 UDP (USO) */
 #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */
 	__u8 gso_type;
 	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [RFC PATCH v2 4/5] linux/virtio_net.h: Support USO offload in vnet header.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-12 11:23   ` Andrew Melnychenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Now, it's possible to convert USO vnet packets from/to skb.
Added support for GSO_UDP_L4 offload.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/linux/virtio_net.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index a960de68ac69..bdf8de2cdd93 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -15,6 +15,7 @@ static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
 	case VIRTIO_NET_HDR_GSO_TCPV6:
 		return protocol == cpu_to_be16(ETH_P_IPV6);
 	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
 		return protocol == cpu_to_be16(ETH_P_IP) ||
 		       protocol == cpu_to_be16(ETH_P_IPV6);
 	default:
@@ -31,6 +32,7 @@ static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
 	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
 	case VIRTIO_NET_HDR_GSO_TCPV4:
 	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
 		skb->protocol = cpu_to_be16(ETH_P_IP);
 		break;
 	case VIRTIO_NET_HDR_GSO_TCPV6:
@@ -69,6 +71,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
 			ip_proto = IPPROTO_UDP;
 			thlen = sizeof(struct udphdr);
 			break;
+		case VIRTIO_NET_HDR_GSO_UDP_L4:
+			gso_type = SKB_GSO_UDP_L4;
+			ip_proto = IPPROTO_UDP;
+			thlen = sizeof(struct udphdr);
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -182,6 +189,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP_L4)
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP_L4;
 		else
 			return -EINVAL;
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
-- 
2.35.1


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

* [RFC PATCH v2 4/5] linux/virtio_net.h: Support USO offload in vnet header.
@ 2022-05-12 11:23   ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Now, it's possible to convert USO vnet packets from/to skb.
Added support for GSO_UDP_L4 offload.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/linux/virtio_net.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index a960de68ac69..bdf8de2cdd93 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -15,6 +15,7 @@ static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
 	case VIRTIO_NET_HDR_GSO_TCPV6:
 		return protocol == cpu_to_be16(ETH_P_IPV6);
 	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
 		return protocol == cpu_to_be16(ETH_P_IP) ||
 		       protocol == cpu_to_be16(ETH_P_IPV6);
 	default:
@@ -31,6 +32,7 @@ static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
 	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
 	case VIRTIO_NET_HDR_GSO_TCPV4:
 	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
 		skb->protocol = cpu_to_be16(ETH_P_IP);
 		break;
 	case VIRTIO_NET_HDR_GSO_TCPV6:
@@ -69,6 +71,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
 			ip_proto = IPPROTO_UDP;
 			thlen = sizeof(struct udphdr);
 			break;
+		case VIRTIO_NET_HDR_GSO_UDP_L4:
+			gso_type = SKB_GSO_UDP_L4;
+			ip_proto = IPPROTO_UDP;
+			thlen = sizeof(struct udphdr);
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -182,6 +189,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP_L4)
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP_L4;
 		else
 			return -EINVAL;
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* [RFC PATCH v2 5/5] drivers/net/virtio_net.c: Added USO support.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-12 11:23   ` Andrew Melnychenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/virtio_net.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cbba9d2e8f32..17fb8be7e4f7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -60,13 +60,17 @@ static const unsigned long guest_offloads[] = {
 	VIRTIO_NET_F_GUEST_TSO6,
 	VIRTIO_NET_F_GUEST_ECN,
 	VIRTIO_NET_F_GUEST_UFO,
-	VIRTIO_NET_F_GUEST_CSUM
+	VIRTIO_NET_F_GUEST_CSUM,
+	VIRTIO_NET_F_GUEST_USO4,
+	VIRTIO_NET_F_GUEST_USO6
 };
 
 #define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
-				(1ULL << VIRTIO_NET_F_GUEST_UFO))
+				(1ULL << VIRTIO_NET_F_GUEST_UFO)  | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO4) | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO6))
 
 struct virtnet_stat_desc {
 	char desc[ETH_GSTRING_LEN];
@@ -2867,7 +2871,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
 		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
-		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6))) {
 		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
 		return -EOPNOTSUPP;
 	}
@@ -3507,6 +3513,8 @@ 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_USO))
+			dev->hw_features |= NETIF_F_GSO_UDP_L4;
 
 		dev->features |= NETIF_F_GSO_ROBUST;
 
@@ -3552,7 +3560,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 	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_UFO))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO) ||
+	    (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) &&
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6)))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -3780,6 +3790,7 @@ static struct virtio_device_id id_table[] = {
 	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_UFO, \
+	VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_GUEST_USO4, VIRTIO_NET_F_GUEST_USO6, \
 	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, \
-- 
2.35.1


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

* [RFC PATCH v2 5/5] drivers/net/virtio_net.c: Added USO support.
@ 2022-05-12 11:23   ` Andrew Melnychenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnychenko @ 2022-05-12 11:23 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, mst, jasowang, netdev,
	linux-kernel, virtualization
  Cc: yan, yuri.benditovich

Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/virtio_net.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cbba9d2e8f32..17fb8be7e4f7 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -60,13 +60,17 @@ static const unsigned long guest_offloads[] = {
 	VIRTIO_NET_F_GUEST_TSO6,
 	VIRTIO_NET_F_GUEST_ECN,
 	VIRTIO_NET_F_GUEST_UFO,
-	VIRTIO_NET_F_GUEST_CSUM
+	VIRTIO_NET_F_GUEST_CSUM,
+	VIRTIO_NET_F_GUEST_USO4,
+	VIRTIO_NET_F_GUEST_USO6
 };
 
 #define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
-				(1ULL << VIRTIO_NET_F_GUEST_UFO))
+				(1ULL << VIRTIO_NET_F_GUEST_UFO)  | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO4) | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO6))
 
 struct virtnet_stat_desc {
 	char desc[ETH_GSTRING_LEN];
@@ -2867,7 +2871,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
 		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
-		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6))) {
 		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
 		return -EOPNOTSUPP;
 	}
@@ -3507,6 +3513,8 @@ 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_USO))
+			dev->hw_features |= NETIF_F_GSO_UDP_L4;
 
 		dev->features |= NETIF_F_GSO_ROBUST;
 
@@ -3552,7 +3560,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 	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_UFO))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO) ||
+	    (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) &&
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6)))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -3780,6 +3790,7 @@ static struct virtio_device_id id_table[] = {
 	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_UFO, \
+	VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_GUEST_USO4, VIRTIO_NET_F_GUEST_USO6, \
 	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, \
-- 
2.35.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-05-12 11:23 ` Andrew Melnychenko
@ 2022-05-17  6:32   ` Jason Wang
  -1 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-05-17  6:32 UTC (permalink / raw)
  To: Andrew Melnychenko
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
>
> Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> Technically they enable NETIF_F_GSO_UDP_L4
> (and only if USO4 & USO6 are set simultaneously).
> It allows to transmission of large UDP packets.
>
> Different features USO4 and USO6 are required for qemu where Windows guests can
> enable disable USO receives for IPv4 and IPv6 separately.
> On the other side, Linux can't really differentiate USO4 and USO6, for now.
> For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> In the future, there would be a mechanism to control UDP_L4 GSO separately.
>
> Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
>
> New types for VirtioNet already on mailing:
> https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
>
> Also, there is a known issue with transmitting packages between two guests.

Could you explain this more? It looks like a bug. (Or any pointer to
the discussion)

Thanks

> Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
>
> Andrew (5):
>   uapi/linux/if_tun.h: Added new offload types for USO4/6.
>   driver/net/tun: Added features for USO.
>   uapi/linux/virtio_net.h: Added USO types.
>   linux/virtio_net.h: Support USO offload in vnet header.
>   drivers/net/virtio_net.c: Added USO support.
>
>  drivers/net/tap.c               | 10 ++++++++--
>  drivers/net/tun.c               |  8 +++++++-
>  drivers/net/virtio_net.c        | 19 +++++++++++++++----
>  include/linux/virtio_net.h      |  9 +++++++++
>  include/uapi/linux/if_tun.h     |  2 ++
>  include/uapi/linux/virtio_net.h |  4 ++++
>  6 files changed, 45 insertions(+), 7 deletions(-)
>
> --
> 2.35.1
>


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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-17  6:32   ` Jason Wang
  0 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-05-17  6:32 UTC (permalink / raw)
  To: Andrew Melnychenko
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
>
> Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> Technically they enable NETIF_F_GSO_UDP_L4
> (and only if USO4 & USO6 are set simultaneously).
> It allows to transmission of large UDP packets.
>
> Different features USO4 and USO6 are required for qemu where Windows guests can
> enable disable USO receives for IPv4 and IPv6 separately.
> On the other side, Linux can't really differentiate USO4 and USO6, for now.
> For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> In the future, there would be a mechanism to control UDP_L4 GSO separately.
>
> Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
>
> New types for VirtioNet already on mailing:
> https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
>
> Also, there is a known issue with transmitting packages between two guests.

Could you explain this more? It looks like a bug. (Or any pointer to
the discussion)

Thanks

> Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
>
> Andrew (5):
>   uapi/linux/if_tun.h: Added new offload types for USO4/6.
>   driver/net/tun: Added features for USO.
>   uapi/linux/virtio_net.h: Added USO types.
>   linux/virtio_net.h: Support USO offload in vnet header.
>   drivers/net/virtio_net.c: Added USO support.
>
>  drivers/net/tap.c               | 10 ++++++++--
>  drivers/net/tun.c               |  8 +++++++-
>  drivers/net/virtio_net.c        | 19 +++++++++++++++----
>  include/linux/virtio_net.h      |  9 +++++++++
>  include/uapi/linux/if_tun.h     |  2 ++
>  include/uapi/linux/virtio_net.h |  4 ++++
>  6 files changed, 45 insertions(+), 7 deletions(-)
>
> --
> 2.35.1
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-05-17  6:32   ` Jason Wang
@ 2022-05-24 11:06     ` Andrew Melnichenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-05-24 11:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

Hi all,

The issue is that host segments packets between guests on the same host.
Tests show that it happens because SKB_GSO_DODGY skb offload in
virtio_net_hdr_from_skb().
To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
The solution with DODGY/PARTIAL offload looks like a dirty hack, so
for now, I've lived it as it is for further investigation.


On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> >
> > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > Technically they enable NETIF_F_GSO_UDP_L4
> > (and only if USO4 & USO6 are set simultaneously).
> > It allows to transmission of large UDP packets.
> >
> > Different features USO4 and USO6 are required for qemu where Windows guests can
> > enable disable USO receives for IPv4 and IPv6 separately.
> > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> >
> > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> >
> > New types for VirtioNet already on mailing:
> > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> >
> > Also, there is a known issue with transmitting packages between two guests.
>
> Could you explain this more? It looks like a bug. (Or any pointer to
> the discussion)
>
> Thanks
>
> > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> >
> > Andrew (5):
> >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> >   driver/net/tun: Added features for USO.
> >   uapi/linux/virtio_net.h: Added USO types.
> >   linux/virtio_net.h: Support USO offload in vnet header.
> >   drivers/net/virtio_net.c: Added USO support.
> >
> >  drivers/net/tap.c               | 10 ++++++++--
> >  drivers/net/tun.c               |  8 +++++++-
> >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> >  include/linux/virtio_net.h      |  9 +++++++++
> >  include/uapi/linux/if_tun.h     |  2 ++
> >  include/uapi/linux/virtio_net.h |  4 ++++
> >  6 files changed, 45 insertions(+), 7 deletions(-)
> >
> > --
> > 2.35.1
> >
>

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-24 11:06     ` Andrew Melnichenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-05-24 11:06 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

Hi all,

The issue is that host segments packets between guests on the same host.
Tests show that it happens because SKB_GSO_DODGY skb offload in
virtio_net_hdr_from_skb().
To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
The solution with DODGY/PARTIAL offload looks like a dirty hack, so
for now, I've lived it as it is for further investigation.


On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> >
> > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > Technically they enable NETIF_F_GSO_UDP_L4
> > (and only if USO4 & USO6 are set simultaneously).
> > It allows to transmission of large UDP packets.
> >
> > Different features USO4 and USO6 are required for qemu where Windows guests can
> > enable disable USO receives for IPv4 and IPv6 separately.
> > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> >
> > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> >
> > New types for VirtioNet already on mailing:
> > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> >
> > Also, there is a known issue with transmitting packages between two guests.
>
> Could you explain this more? It looks like a bug. (Or any pointer to
> the discussion)
>
> Thanks
>
> > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> >
> > Andrew (5):
> >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> >   driver/net/tun: Added features for USO.
> >   uapi/linux/virtio_net.h: Added USO types.
> >   linux/virtio_net.h: Support USO offload in vnet header.
> >   drivers/net/virtio_net.c: Added USO support.
> >
> >  drivers/net/tap.c               | 10 ++++++++--
> >  drivers/net/tun.c               |  8 +++++++-
> >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> >  include/linux/virtio_net.h      |  9 +++++++++
> >  include/uapi/linux/if_tun.h     |  2 ++
> >  include/uapi/linux/virtio_net.h |  4 ++++
> >  6 files changed, 45 insertions(+), 7 deletions(-)
> >
> > --
> > 2.35.1
> >
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-05-24 11:06     ` Andrew Melnichenko
@ 2022-05-26  6:56       ` Jason Wang
  -1 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-05-26  6:56 UTC (permalink / raw)
  To: Andrew Melnichenko
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

[-- Attachment #1: Type: text/plain, Size: 2719 bytes --]

On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> Hi all,
>
> The issue is that host segments packets between guests on the same host.
> Tests show that it happens because SKB_GSO_DODGY skb offload in
> virtio_net_hdr_from_skb().
> To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> for now, I've lived it as it is for further investigation.

Ok, I managed to find the previous discussion. It looks to me the
reason is that __udp_gso_segment will segment dodgy packets
unconditionally.

I wonder if the attached patch works? (compile test only).

Thanks

>
>
> On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > >
> > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > Technically they enable NETIF_F_GSO_UDP_L4
> > > (and only if USO4 & USO6 are set simultaneously).
> > > It allows to transmission of large UDP packets.
> > >
> > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > enable disable USO receives for IPv4 and IPv6 separately.
> > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > >
> > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > >
> > > New types for VirtioNet already on mailing:
> > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > >
> > > Also, there is a known issue with transmitting packages between two guests.
> >
> > Could you explain this more? It looks like a bug. (Or any pointer to
> > the discussion)
> >
> > Thanks
> >
> > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > >
> > > Andrew (5):
> > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > >   driver/net/tun: Added features for USO.
> > >   uapi/linux/virtio_net.h: Added USO types.
> > >   linux/virtio_net.h: Support USO offload in vnet header.
> > >   drivers/net/virtio_net.c: Added USO support.
> > >
> > >  drivers/net/tap.c               | 10 ++++++++--
> > >  drivers/net/tun.c               |  8 +++++++-
> > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > >  include/linux/virtio_net.h      |  9 +++++++++
> > >  include/uapi/linux/if_tun.h     |  2 ++
> > >  include/uapi/linux/virtio_net.h |  4 ++++
> > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > >
> > > --
> > > 2.35.1
> > >
> >
>

[-- Attachment #2: 0001-udp-allow-header-check-for-dodgy-GSO_UDP_L4-packets.patch --]
[-- Type: application/octet-stream, Size: 1247 bytes --]

From 4ced6ff3a8ea13b069dd3087ab22d252696e1def Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Thu, 26 May 2022 14:29:17 +0800
Subject: [PATCH] udp: allow header check for dodgy GSO_UDP_L4 packets
Content-type: text/plain

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/ipv4/udp_offload.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 6d1a4bec2614..9579886ce557 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -280,6 +280,15 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 	if (gso_skb->len <= sizeof(*uh) + mss)
 		return ERR_PTR(-EINVAL);
 
+	if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) {
+		/* Packet is from an untrusted source, reset gso_segs. */
+
+		skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len, mss);
+
+		segs = NULL;
+		goto out;
+	}
+
 	skb_pull(gso_skb, sizeof(*uh));
 
 	/* clear destructor to avoid skb_segment assigning it to tail */
@@ -361,6 +370,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 		else
 			WARN_ON_ONCE(refcount_sub_and_test(-delta, &sk->sk_wmem_alloc));
 	}
+out:
 	return segs;
 }
 EXPORT_SYMBOL_GPL(__udp_gso_segment);
-- 
2.25.1


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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-26  6:56       ` Jason Wang
  0 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-05-26  6:56 UTC (permalink / raw)
  To: Andrew Melnichenko
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

[-- Attachment #1: Type: text/plain, Size: 2719 bytes --]

On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> Hi all,
>
> The issue is that host segments packets between guests on the same host.
> Tests show that it happens because SKB_GSO_DODGY skb offload in
> virtio_net_hdr_from_skb().
> To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> for now, I've lived it as it is for further investigation.

Ok, I managed to find the previous discussion. It looks to me the
reason is that __udp_gso_segment will segment dodgy packets
unconditionally.

I wonder if the attached patch works? (compile test only).

Thanks

>
>
> On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > >
> > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > Technically they enable NETIF_F_GSO_UDP_L4
> > > (and only if USO4 & USO6 are set simultaneously).
> > > It allows to transmission of large UDP packets.
> > >
> > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > enable disable USO receives for IPv4 and IPv6 separately.
> > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > >
> > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > >
> > > New types for VirtioNet already on mailing:
> > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > >
> > > Also, there is a known issue with transmitting packages between two guests.
> >
> > Could you explain this more? It looks like a bug. (Or any pointer to
> > the discussion)
> >
> > Thanks
> >
> > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > >
> > > Andrew (5):
> > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > >   driver/net/tun: Added features for USO.
> > >   uapi/linux/virtio_net.h: Added USO types.
> > >   linux/virtio_net.h: Support USO offload in vnet header.
> > >   drivers/net/virtio_net.c: Added USO support.
> > >
> > >  drivers/net/tap.c               | 10 ++++++++--
> > >  drivers/net/tun.c               |  8 +++++++-
> > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > >  include/linux/virtio_net.h      |  9 +++++++++
> > >  include/uapi/linux/if_tun.h     |  2 ++
> > >  include/uapi/linux/virtio_net.h |  4 ++++
> > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > >
> > > --
> > > 2.35.1
> > >
> >
>

[-- Attachment #2: 0001-udp-allow-header-check-for-dodgy-GSO_UDP_L4-packets.patch --]
[-- Type: application/octet-stream, Size: 1247 bytes --]

From 4ced6ff3a8ea13b069dd3087ab22d252696e1def Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Thu, 26 May 2022 14:29:17 +0800
Subject: [PATCH] udp: allow header check for dodgy GSO_UDP_L4 packets
Content-type: text/plain

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/ipv4/udp_offload.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 6d1a4bec2614..9579886ce557 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -280,6 +280,15 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 	if (gso_skb->len <= sizeof(*uh) + mss)
 		return ERR_PTR(-EINVAL);
 
+	if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) {
+		/* Packet is from an untrusted source, reset gso_segs. */
+
+		skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len, mss);
+
+		segs = NULL;
+		goto out;
+	}
+
 	skb_pull(gso_skb, sizeof(*uh));
 
 	/* clear destructor to avoid skb_segment assigning it to tail */
@@ -361,6 +370,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 		else
 			WARN_ON_ONCE(refcount_sub_and_test(-delta, &sk->sk_wmem_alloc));
 	}
+out:
 	return segs;
 }
 EXPORT_SYMBOL_GPL(__udp_gso_segment);
-- 
2.25.1


[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-05-26  6:56       ` Jason Wang
@ 2022-05-26 12:18         ` Andrew Melnichenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-05-26 12:18 UTC (permalink / raw)
  To: Jason Wang
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

I'll check it, thank you!

On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> >
> > Hi all,
> >
> > The issue is that host segments packets between guests on the same host.
> > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > virtio_net_hdr_from_skb().
> > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > for now, I've lived it as it is for further investigation.
>
> Ok, I managed to find the previous discussion. It looks to me the
> reason is that __udp_gso_segment will segment dodgy packets
> unconditionally.
>
> I wonder if the attached patch works? (compile test only).
>
> Thanks
>
> >
> >
> > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > >
> > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > (and only if USO4 & USO6 are set simultaneously).
> > > > It allows to transmission of large UDP packets.
> > > >
> > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > >
> > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > >
> > > > New types for VirtioNet already on mailing:
> > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > >
> > > > Also, there is a known issue with transmitting packages between two guests.
> > >
> > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > the discussion)
> > >
> > > Thanks
> > >
> > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > >
> > > > Andrew (5):
> > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > >   driver/net/tun: Added features for USO.
> > > >   uapi/linux/virtio_net.h: Added USO types.
> > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > >   drivers/net/virtio_net.c: Added USO support.
> > > >
> > > >  drivers/net/tap.c               | 10 ++++++++--
> > > >  drivers/net/tun.c               |  8 +++++++-
> > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > >
> > > > --
> > > > 2.35.1
> > > >
> > >
> >

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-05-26 12:18         ` Andrew Melnichenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-05-26 12:18 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

I'll check it, thank you!

On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> >
> > Hi all,
> >
> > The issue is that host segments packets between guests on the same host.
> > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > virtio_net_hdr_from_skb().
> > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > for now, I've lived it as it is for further investigation.
>
> Ok, I managed to find the previous discussion. It looks to me the
> reason is that __udp_gso_segment will segment dodgy packets
> unconditionally.
>
> I wonder if the attached patch works? (compile test only).
>
> Thanks
>
> >
> >
> > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > >
> > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > (and only if USO4 & USO6 are set simultaneously).
> > > > It allows to transmission of large UDP packets.
> > > >
> > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > >
> > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > >
> > > > New types for VirtioNet already on mailing:
> > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > >
> > > > Also, there is a known issue with transmitting packages between two guests.
> > >
> > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > the discussion)
> > >
> > > Thanks
> > >
> > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > >
> > > > Andrew (5):
> > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > >   driver/net/tun: Added features for USO.
> > > >   uapi/linux/virtio_net.h: Added USO types.
> > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > >   drivers/net/virtio_net.c: Added USO support.
> > > >
> > > >  drivers/net/tap.c               | 10 ++++++++--
> > > >  drivers/net/tun.c               |  8 +++++++-
> > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > >
> > > > --
> > > > 2.35.1
> > > >
> > >
> >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-05-26 12:18         ` Andrew Melnichenko
@ 2022-06-16 11:59           ` Andrew Melnichenko
  -1 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-06-16 11:59 UTC (permalink / raw)
  To: Jason Wang
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

Hi, Jason
Apparently, your patch should work.
For now, I have an issue where segmentation between two guests on one
host still occurs.
Neither previous "hack" nor your patch helps.
Now I'm looking what the issue may be.
If you have some suggestions on where may I look, it would be helpful, thanks!

On Thu, May 26, 2022 at 3:18 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> I'll check it, thank you!
>
> On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> > >
> > > Hi all,
> > >
> > > The issue is that host segments packets between guests on the same host.
> > > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > > virtio_net_hdr_from_skb().
> > > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > > for now, I've lived it as it is for further investigation.
> >
> > Ok, I managed to find the previous discussion. It looks to me the
> > reason is that __udp_gso_segment will segment dodgy packets
> > unconditionally.
> >
> > I wonder if the attached patch works? (compile test only).
> >
> > Thanks
> >
> > >
> > >
> > > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > > >
> > > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > > >
> > > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > > (and only if USO4 & USO6 are set simultaneously).
> > > > > It allows to transmission of large UDP packets.
> > > > >
> > > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > > >
> > > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > > >
> > > > > New types for VirtioNet already on mailing:
> > > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > > >
> > > > > Also, there is a known issue with transmitting packages between two guests.
> > > >
> > > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > > the discussion)
> > > >
> > > > Thanks
> > > >
> > > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > > >
> > > > > Andrew (5):
> > > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > > >   driver/net/tun: Added features for USO.
> > > > >   uapi/linux/virtio_net.h: Added USO types.
> > > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > > >   drivers/net/virtio_net.c: Added USO support.
> > > > >
> > > > >  drivers/net/tap.c               | 10 ++++++++--
> > > > >  drivers/net/tun.c               |  8 +++++++-
> > > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > > >
> > > > > --
> > > > > 2.35.1
> > > > >
> > > >
> > >

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-06-16 11:59           ` Andrew Melnichenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andrew Melnichenko @ 2022-06-16 11:59 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

Hi, Jason
Apparently, your patch should work.
For now, I have an issue where segmentation between two guests on one
host still occurs.
Neither previous "hack" nor your patch helps.
Now I'm looking what the issue may be.
If you have some suggestions on where may I look, it would be helpful, thanks!

On Thu, May 26, 2022 at 3:18 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> I'll check it, thank you!
>
> On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> > >
> > > Hi all,
> > >
> > > The issue is that host segments packets between guests on the same host.
> > > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > > virtio_net_hdr_from_skb().
> > > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > > for now, I've lived it as it is for further investigation.
> >
> > Ok, I managed to find the previous discussion. It looks to me the
> > reason is that __udp_gso_segment will segment dodgy packets
> > unconditionally.
> >
> > I wonder if the attached patch works? (compile test only).
> >
> > Thanks
> >
> > >
> > >
> > > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > > >
> > > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > > >
> > > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > > (and only if USO4 & USO6 are set simultaneously).
> > > > > It allows to transmission of large UDP packets.
> > > > >
> > > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > > >
> > > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > > >
> > > > > New types for VirtioNet already on mailing:
> > > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > > >
> > > > > Also, there is a known issue with transmitting packages between two guests.
> > > >
> > > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > > the discussion)
> > > >
> > > > Thanks
> > > >
> > > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > > >
> > > > > Andrew (5):
> > > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > > >   driver/net/tun: Added features for USO.
> > > > >   uapi/linux/virtio_net.h: Added USO types.
> > > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > > >   drivers/net/virtio_net.c: Added USO support.
> > > > >
> > > > >  drivers/net/tap.c               | 10 ++++++++--
> > > > >  drivers/net/tun.c               |  8 +++++++-
> > > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > > >
> > > > > --
> > > > > 2.35.1
> > > > >
> > > >
> > >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
  2022-06-16 11:59           ` Andrew Melnichenko
@ 2022-06-17  1:30             ` Jason Wang
  -1 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-06-17  1:30 UTC (permalink / raw)
  To: Andrew Melnichenko
  Cc: davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni, mst, netdev,
	linux-kernel, virtualization, Yan Vugenfirer, Yuri Benditovich

On Thu, Jun 16, 2022 at 7:59 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> Hi, Jason
> Apparently, your patch should work.
> For now, I have an issue where segmentation between two guests on one
> host still occurs.
> Neither previous "hack" nor your patch helps.
> Now I'm looking what the issue may be.
> If you have some suggestions on where may I look, it would be helpful, thanks!

I think maybe it's worth tracking which function did the segmentation.

Thanks

>
> On Thu, May 26, 2022 at 3:18 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> >
> > I'll check it, thank you!
> >
> > On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > The issue is that host segments packets between guests on the same host.
> > > > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > > > virtio_net_hdr_from_skb().
> > > > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > > > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > > > for now, I've lived it as it is for further investigation.
> > >
> > > Ok, I managed to find the previous discussion. It looks to me the
> > > reason is that __udp_gso_segment will segment dodgy packets
> > > unconditionally.
> > >
> > > I wonder if the attached patch works? (compile test only).
> > >
> > > Thanks
> > >
> > > >
> > > >
> > > > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > > > >
> > > > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > > > >
> > > > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > > > (and only if USO4 & USO6 are set simultaneously).
> > > > > > It allows to transmission of large UDP packets.
> > > > > >
> > > > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > > > >
> > > > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > > > >
> > > > > > New types for VirtioNet already on mailing:
> > > > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > > > >
> > > > > > Also, there is a known issue with transmitting packages between two guests.
> > > > >
> > > > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > > > the discussion)
> > > > >
> > > > > Thanks
> > > > >
> > > > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > > > >
> > > > > > Andrew (5):
> > > > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > > > >   driver/net/tun: Added features for USO.
> > > > > >   uapi/linux/virtio_net.h: Added USO types.
> > > > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > > > >   drivers/net/virtio_net.c: Added USO support.
> > > > > >
> > > > > >  drivers/net/tap.c               | 10 ++++++++--
> > > > > >  drivers/net/tun.c               |  8 +++++++-
> > > > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > > > >
> > > > > > --
> > > > > > 2.35.1
> > > > > >
> > > > >
> > > >
>


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

* Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
@ 2022-06-17  1:30             ` Jason Wang
  0 siblings, 0 replies; 24+ messages in thread
From: Jason Wang @ 2022-06-17  1:30 UTC (permalink / raw)
  To: Andrew Melnichenko
  Cc: mst, netdev, linux-kernel, virtualization, Yuri Benditovich,
	Eric Dumazet, Yan Vugenfirer, Jakub Kicinski, Paolo Abeni, davem

On Thu, Jun 16, 2022 at 7:59 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> Hi, Jason
> Apparently, your patch should work.
> For now, I have an issue where segmentation between two guests on one
> host still occurs.
> Neither previous "hack" nor your patch helps.
> Now I'm looking what the issue may be.
> If you have some suggestions on where may I look, it would be helpful, thanks!

I think maybe it's worth tracking which function did the segmentation.

Thanks

>
> On Thu, May 26, 2022 at 3:18 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> >
> > I'll check it, thank you!
> >
> > On Thu, May 26, 2022 at 9:56 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > > On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > The issue is that host segments packets between guests on the same host.
> > > > Tests show that it happens because SKB_GSO_DODGY skb offload in
> > > > virtio_net_hdr_from_skb().
> > > > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL
> > > > The solution with DODGY/PARTIAL offload looks like a dirty hack, so
> > > > for now, I've lived it as it is for further investigation.
> > >
> > > Ok, I managed to find the previous discussion. It looks to me the
> > > reason is that __udp_gso_segment will segment dodgy packets
> > > unconditionally.
> > >
> > > I wonder if the attached patch works? (compile test only).
> > >
> > > Thanks
> > >
> > > >
> > > >
> > > > On Tue, May 17, 2022 at 9:32 AM Jason Wang <jasowang@redhat.com> wrote:
> > > > >
> > > > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko <andrew@daynix.com> wrote:
> > > > > >
> > > > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6.
> > > > > > Technically they enable NETIF_F_GSO_UDP_L4
> > > > > > (and only if USO4 & USO6 are set simultaneously).
> > > > > > It allows to transmission of large UDP packets.
> > > > > >
> > > > > > Different features USO4 and USO6 are required for qemu where Windows guests can
> > > > > > enable disable USO receives for IPv4 and IPv6 separately.
> > > > > > On the other side, Linux can't really differentiate USO4 and USO6, for now.
> > > > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 together.
> > > > > > In the future, there would be a mechanism to control UDP_L4 GSO separately.
> > > > > >
> > > > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2
> > > > > >
> > > > > > New types for VirtioNet already on mailing:
> > > > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html
> > > > > >
> > > > > > Also, there is a known issue with transmitting packages between two guests.
> > > > >
> > > > > Could you explain this more? It looks like a bug. (Or any pointer to
> > > > > the discussion)
> > > > >
> > > > > Thanks
> > > > >
> > > > > > Without hacks with skb's GSO - packages are still segmented on the host's postrouting.
> > > > > >
> > > > > > Andrew (5):
> > > > > >   uapi/linux/if_tun.h: Added new offload types for USO4/6.
> > > > > >   driver/net/tun: Added features for USO.
> > > > > >   uapi/linux/virtio_net.h: Added USO types.
> > > > > >   linux/virtio_net.h: Support USO offload in vnet header.
> > > > > >   drivers/net/virtio_net.c: Added USO support.
> > > > > >
> > > > > >  drivers/net/tap.c               | 10 ++++++++--
> > > > > >  drivers/net/tun.c               |  8 +++++++-
> > > > > >  drivers/net/virtio_net.c        | 19 +++++++++++++++----
> > > > > >  include/linux/virtio_net.h      |  9 +++++++++
> > > > > >  include/uapi/linux/if_tun.h     |  2 ++
> > > > > >  include/uapi/linux/virtio_net.h |  4 ++++
> > > > > >  6 files changed, 45 insertions(+), 7 deletions(-)
> > > > > >
> > > > > > --
> > > > > > 2.35.1
> > > > > >
> > > > >
> > > >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2022-06-17  1:30 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 11:23 [RFC PATCH v2 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
2022-05-12 11:23 ` Andrew Melnychenko
2022-05-12 11:23 ` [RFC PATCH v2 1/5] uapi/linux/if_tun.h: Added new offload types for USO4/6 Andrew Melnychenko
2022-05-12 11:23   ` Andrew Melnychenko
2022-05-12 11:23 ` [RFC PATCH v2 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
2022-05-12 11:23   ` Andrew Melnychenko
2022-05-12 11:23 ` [RFC PATCH v2 3/5] uapi/linux/virtio_net.h: Added USO types Andrew Melnychenko
2022-05-12 11:23   ` Andrew Melnychenko
2022-05-12 11:23 ` [RFC PATCH v2 4/5] linux/virtio_net.h: Support USO offload in vnet header Andrew Melnychenko
2022-05-12 11:23   ` Andrew Melnychenko
2022-05-12 11:23 ` [RFC PATCH v2 5/5] drivers/net/virtio_net.c: Added USO support Andrew Melnychenko
2022-05-12 11:23   ` Andrew Melnychenko
2022-05-17  6:32 ` [RFC PATCH v2 0/5] TUN/VirtioNet USO features support Jason Wang
2022-05-17  6:32   ` Jason Wang
2022-05-24 11:06   ` Andrew Melnichenko
2022-05-24 11:06     ` Andrew Melnichenko
2022-05-26  6:56     ` Jason Wang
2022-05-26  6:56       ` Jason Wang
2022-05-26 12:18       ` Andrew Melnichenko
2022-05-26 12:18         ` Andrew Melnichenko
2022-06-16 11:59         ` Andrew Melnichenko
2022-06-16 11:59           ` Andrew Melnichenko
2022-06-17  1:30           ` Jason Wang
2022-06-17  1:30             ` Jason Wang

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