[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b8846da-d163-4e89-8c93-f50c333841d8@rsg.ci.i.u-tokyo.ac.jp>
Date: Sat, 21 Jun 2025 14:00:38 +0900
From: Akihiko Odaki <odaki@....ci.i.u-tokyo.ac.jp>
To: Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org
Cc: Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Jason Wang <jasowang@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez
<eperezma@...hat.com>,
Yuri Benditovich <yuri.benditovich@...nix.com>
Subject: Re: [PATCH v4 net-next 7/8] tun: enable gso over UDP tunnel support.
On 2025/06/20 2:27, Paolo Abeni wrote:
> On 6/19/25 5:46 PM, Akihiko Odaki wrote:
>> On 2025/06/19 23:52, Paolo Abeni wrote:
>>> On 6/19/25 4:42 PM, Akihiko Odaki wrote:
>>>> On 2025/06/18 1:12, Paolo Abeni wrote:
>>>>> @@ -1721,7 +1733,12 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
>>>>> if (tun->flags & IFF_VNET_HDR) {
>>>>> int vnet_hdr_sz = READ_ONCE(tun->vnet_hdr_sz);
>>>>>
>>>>> - hdr_len = tun_vnet_hdr_get(vnet_hdr_sz, tun->flags, from, &gso);
>>>>> + if (vnet_hdr_sz >= TUN_VNET_TNL_SIZE)
>>>>> + features = NETIF_F_GSO_UDP_TUNNEL |
>>>>> + NETIF_F_GSO_UDP_TUNNEL_CSUM;
>>>>
>>>> I think you should use tun->set_features instead of tun->vnet_hdr_sz to
>>>> tell if these features are enabled.
>>>
>>> This is the guest -> host direction. tun->set_features refers to the
>>> opposite one. The problem is that tun is not aware of the features
>>> negotiated in the guest -> host direction.
>>>
>>> The current status (for baremetal/plain offload) is allowing any known
>>> feature the other side send - if the virtio header is consistent.
>>> This code follows a similar schema.
>>>
>>> Note that using 'tun->set_features' instead of 'vnet_hdr_sz' the tunz
>>> driver will drop all the (legit) GSO over UDP packet sent by the guest
>>> when the VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO has been negotiated and
>>> VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO has not.
>>
>> This explanation makes sense. In that case I suggest:
>> - creating a new function named tun_vnet_hdr_tnl_get() and
>> - passing vnet_hdr_sz to tun_vnet_hdr_tnl_to_skb()
>>
>> tun_vnet.h contains the virtio-related logic for better code
>> organization and reuse with tap.c. tap.c can reuse the conditionals on
>> vnet_hdr_sz when tap.c gains the UDP tunneling support.
>
> Instead of repeating the test twice (in both tun_vnet_hdr_tnl_to_skb()
> and tun_vnet_hdr_tnl_to_skb(), what about creating a new helper:
>
> tun_vnet_hdr_guest_features(unsigned int vnet_hdr_len)
>
> encapsulating the above logic? That will make also easier to move to the
> 'correct' solution of having the tun/tap devices aware of the features
> negotiated in the guest -> host direction.
netdev_features_t is not used in the other part of the user-to-skb path
so we only need the condition "vnet_hdr_sz >= TUN_VNET_TNL_SIZE";
"features = NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM" can be
simply skipped.
The condition itself is trivial so probably you don't need a helper for it.
For the skb-to-user path, tun_vnet.h already absorbs the reference to
netdev_feature_t in tun_vnet_hdr_tnl_from_skb() and allows reusing it
with tap.c, which is a nice example.
Regards,
Akihiko Odaki
Powered by blists - more mailing lists