This series adds support for UDP segmentation offload feature in TUN device according to the VIRTIO specification Yuri Benditovich (4): virtio-net: add definitions for host USO feature virtio-net: add support of UDP segmentation (USO) on the host tun: define feature bit for USO support tun: indicate support for USO feature drivers/net/tun.c | 2 +- include/linux/virtio_net.h | 5 +++++ include/uapi/linux/if_tun.h | 1 + include/uapi/linux/virtio_net.h | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) -- 2.26.3
Yuri Benditovich
2021-May-11 04:42 UTC
[PATCH 1/4] virtio-net: add definitions for host USO feature
Define feature bit and GSO type according to the VIRTIO specification. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/uapi/linux/virtio_net.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 3f55a4215f11..a556ac735d7f 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -57,6 +57,7 @@ * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO packets */ #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 +131,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 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.26.3
Yuri Benditovich
2021-May-11 04:42 UTC
[PATCH 2/4] virtio-net: add support of UDP segmentation (USO) on the host
Large UDP packet provided by the guest with GSO type set to VIRTIO_NET_HDR_GSO_UDP_L4 will be divided to several UDP packets according to the gso_size field. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/linux/virtio_net.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index b465f8f3e554..4ecf9a1ca912 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h @@ -51,6 +51,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; } -- 2.26.3
Yuri Benditovich
2021-May-11 04:42 UTC
[PATCH 3/4] tun: define feature bit for USO support
User mode software can probe this bit to check whether the USO feature is supported by TUN/TAP device. Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- include/uapi/linux/if_tun.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h index 454ae31b93c7..24f246920dd5 100644 --- a/include/uapi/linux/if_tun.h +++ b/include/uapi/linux/if_tun.h @@ -88,6 +88,7 @@ #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_USO 0x20 /* I can handle USO packets */ /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */ #define TUN_PKT_STRIP 0x0001 -- 2.26.3
Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com> --- drivers/net/tun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 84f832806313..a35054f9d941 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2812,7 +2812,7 @@ static int set_offload(struct tun_struct *tun, unsigned long arg) arg &= ~(TUN_F_TSO4|TUN_F_TSO6); } - arg &= ~TUN_F_UFO; + arg &= ~(TUN_F_UFO|TUN_F_USO); } /* This gives the user a way to test for new features in future by -- 2.26.3