Thread (39 messages) 39 messages, 7 authors, 2025-06-24

Re: [PATCH v4 net-next 7/8] tun: enable gso over UDP tunnel support.

From: Akihiko Odaki <hidden>
Date: 2025-06-21 05:04:42

On 2025/06/20 5:30, Paolo Abeni wrote:
On 6/19/25 7:41 PM, Paolo Abeni wrote:
quoted
On 6/19/25 6:02 PM, Akihiko Odaki wrote:
quoted
On 2025/06/18 1:12, Paolo Abeni wrote:
quoted
@@ -2426,7 +2453,17 @@ static int tun_xdp_one(struct tun_struct *tun,
   	if (metasize > 0)
   		skb_metadata_set(skb, metasize);
   
-	if (tun_vnet_hdr_to_skb(tun->flags, skb, gso)) {
+	/*
+	 * Assume tunnel offloads are enabled if the received hdr is large
+	 * enough.
+	 */
+	if (READ_ONCE(tun->vnet_hdr_sz) >= TUN_VNET_TNL_SIZE &&
+	    xdp->data - xdp->data_hard_start >= TUN_VNET_TNL_SIZE)
+		features = NETIF_F_GSO_UDP_TUNNEL |
+			   NETIF_F_GSO_UDP_TUNNEL_CSUM;
xdp->data - xdp->data_hard_start may not represent the header size.

struct tun_xdp_hdr is filled in vhost_net_build_xdp() in
drivers/vhost/net.c. This function sets the two fields with
xdp_prepare_buff(), but the arguments passed to xdp_prepare_buff() does
not seem to represent the exact size of the header.
Indeed the xdp->data - xdp->data_hard_start range additionally contains
some padding and eventually the xdp specific headroom. The problem is
that both info are vhost_net specific and tun can't (or at least shoul)
not be aware of them.

The only IMHO feasible refinement could be using xdp->data_meta instead
of xdp->data when available. Alternatively I could drop entirely the test.
struct tun_xdp_hdr can be extended to contain struct 
virtio_net_hdr_v1_hash_tunnel.
As the vhost_net padding is considerably larger than the largest
possible vnet_hdr_sz, I'll drop entirely the xdp check - so that I can
use the newly introduced tun_vnet_hdr_guest_features() helper here, too.
I think dropping the XDP check is the best option (and leaving struct 
tun_xdp_hdr as is) until vhost_net_build_xdp() gains the UDP tunnel support.

Regards,
Akihiko Odaki
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help