2022-09-07 13:15:34

by Andrew Melnichenko

[permalink] [raw]
Subject: [PATCH v3 0/6] TUN/VirtioNet USO features support.

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

New types for virtio-net already in virtio-net specification:
https://github.com/oasis-tcs/virtio-spec/issues/120

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

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.

Andrew Melnychenko (1):
udp: allow header check for dodgy GSO_UDP_L4 packets.

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 | 5 +++++
net/ipv4/udp_offload.c | 2 +-
7 files changed, 47 insertions(+), 8 deletions(-)

--
2.37.2


2022-09-07 13:27:26

by Andrew Melnichenko

[permalink] [raw]
Subject: [PATCH v3 1/6] udp: allow header check for dodgy GSO_UDP_L4 packets.

Packets from TAP devices with USO offload converts
to GSO_UDP_L4 & GSO_DODGY sk buffers.
Added changes allow skipping segmentation for DODGY/ROBUST packets.

Signed-off-by: Jason Wang <[email protected]>
Signed-off-by: Andrew Melnychenko <[email protected]>
---
net/ipv4/udp_offload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 6d1a4bec2614..8e002419b4d5 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -387,7 +387,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
if (!pskb_may_pull(skb, sizeof(struct udphdr)))
goto out;

- if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
+ if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST))
return __udp_gso_segment(skb, features, false);

mss = skb_shinfo(skb)->gso_size;
--
2.37.2

2022-09-07 13:34:06

by Andrew Melnichenko

[permalink] [raw]
Subject: [PATCH v3 4/6] uapi/linux/virtio_net.h: Added USO types.

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 <[email protected]>
---
include/uapi/linux/virtio_net.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 29ced55514d4..5156a420564f 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -57,6 +57,10 @@
* Steering */
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
#define VIRTIO_NET_F_NOTF_COAL 53 /* Guest can handle notifications coalescing */
+#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 */
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
@@ -130,6 +134,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.37.2

2022-09-08 00:55:18

by David Ahern

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] udp: allow header check for dodgy GSO_UDP_L4 packets.

On 9/7/22 6:50 AM, Andrew Melnychenko wrote:
> diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> index 6d1a4bec2614..8e002419b4d5 100644
> --- a/net/ipv4/udp_offload.c
> +++ b/net/ipv4/udp_offload.c
> @@ -387,7 +387,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
> if (!pskb_may_pull(skb, sizeof(struct udphdr)))
> goto out;
>
> - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
> + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST))

that line needs to be wrapped.

> return __udp_gso_segment(skb, features, false);
>
> mss = skb_shinfo(skb)->gso_size;

2022-09-08 02:00:44

by David Ahern

[permalink] [raw]
Subject: Re: [PATCH v3 0/6] TUN/VirtioNet USO features support.

On 9/7/22 6:50 AM, Andrew Melnychenko 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 the transmission of large UDP packets.

Please spell out USO at least once in the cover letter to make sure the
acronym is clear.

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

Why is that and what is needed for Linux to differentiate between the 2
protocols?

> 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.
>
> New types for virtio-net already in virtio-net specification:
> https://github.com/oasis-tcs/virtio-spec/issues/120
>
> Test it WIP Qemu https://github.com/daynix/qemu/tree/USOv3
>
> 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.
>
> Andrew Melnychenko (1):
> udp: allow header check for dodgy GSO_UDP_L4 packets.
>
> 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 | 5 +++++
> net/ipv4/udp_offload.c | 2 +-
> 7 files changed, 47 insertions(+), 8 deletions(-)
>

2022-09-08 20:36:41

by Andrew Melnichenko

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] udp: allow header check for dodgy GSO_UDP_L4 packets.

Hi all,

On Thu, Sep 8, 2022 at 3:40 AM David Ahern <[email protected]> wrote:
>
> On 9/7/22 6:50 AM, Andrew Melnychenko wrote:
> > diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
> > index 6d1a4bec2614..8e002419b4d5 100644
> > --- a/net/ipv4/udp_offload.c
> > +++ b/net/ipv4/udp_offload.c
> > @@ -387,7 +387,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
> > if (!pskb_may_pull(skb, sizeof(struct udphdr)))
> > goto out;
> >
> > - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
> > + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST))
>
> that line needs to be wrapped.

Ok, I'll wrap it.

>
> > return __udp_gso_segment(skb, features, false);
> >
> > mss = skb_shinfo(skb)->gso_size;
>

2022-09-08 20:56:06

by Andrew Melnichenko

[permalink] [raw]
Subject: Re: [PATCH v3 0/6] TUN/VirtioNet USO features support.

Hi all,

On Thu, Sep 8, 2022 at 3:44 AM David Ahern <[email protected]> wrote:
>
> On 9/7/22 6:50 AM, Andrew Melnychenko 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 the transmission of large UDP packets.
>
> Please spell out USO at least once in the cover letter to make sure the
> acronym is clear.

USO - UDP Segmentation Offload. Ability to split UDP packets into
several segments.
Allows sending/receiving big UDP packets. At some point, it looks like
UFO(fragmentation),
but each segment contains a UDP header.

>
> >
> > 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.
>
> Why is that and what is needed for Linux to differentiate between the 2
> protocols?

Well, this feature requires for Windows VM guest interaction. Windows may have
a separate configuration for USO4/USO6. Currently, we support Windows guests
with enabled USO4 and USO6 simultaneously.
To implement this on Linux host, will require at least one additional
netdev feature
and changes in Linux network stack. Discussion about that will be in
the future after
some research.

>
> > 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.
> >
> > New types for virtio-net already in virtio-net specification:
> > https://github.com/oasis-tcs/virtio-spec/issues/120
> >
> > Test it WIP Qemu https://github.com/daynix/qemu/tree/USOv3
> >
> > 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.
> >
> > Andrew Melnychenko (1):
> > udp: allow header check for dodgy GSO_UDP_L4 packets.
> >
> > 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 | 5 +++++
> > net/ipv4/udp_offload.c | 2 +-
> > 7 files changed, 47 insertions(+), 8 deletions(-)
> >
>