Re: [PATCH v4 net-next 7/8] tun: enable gso over UDP tunnel support.
From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-06-19 17:42:01
On 6/19/25 6:02 PM, Akihiko Odaki wrote:
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. /P