From: Paolo Abeni <pabeni@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: netdev@vger.kernel.org,
"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Yuri Benditovich" <yuri.benditovich@daynix.com>,
"Akihiko Odaki" <akihiko.odaki@daynix.com>
Subject: Re: [PATCH RFC v3 7/8] tun: enable gso over UDP tunnel support.
Date: Thu, 12 Jun 2025 13:03:16 +0200 [thread overview]
Message-ID: <b7099b02-f0d4-492c-a15b-2a93a097d3f5@redhat.com> (raw)
In-Reply-To: <CACGkMEtExmmfmtd0+6YwgjuiWR-T5RvfcnHEbmH=ewqNXHPHYA@mail.gmail.com>
On 6/12/25 6:55 AM, Jason Wang wrote:
> On Fri, Jun 6, 2025 at 7:46 PM Paolo Abeni <pabeni@redhat.com> wrote:
>> @@ -1720,8 +1732,16 @@ 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);
>> + int parsed_size;
>>
>> - hdr_len = tun_vnet_hdr_get(vnet_hdr_sz, tun->flags, from, &gso);
>> + if (vnet_hdr_sz < TUN_VNET_TNL_SIZE) {
>
> I still don't understand why we need to duplicate netdev features in
> flags, and it seems to introduce unnecessary complexities. Can we
> simply check dev->features instead?
>
> I think I've asked before, for example, we don't duplicate gso and
> csum for non tunnel packets.
My fear was that if
- the guest negotiated VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO
- tun stores the negotiated offload info netdev->features
- the tun netdev UDP tunnel feature is disabled via ethtool
tun may end-up sending to the guest packets without filling the tnl hdr,
which should be safe, as the driver should not use such info as no GSO
over UDP packets will go through, but is technically against the
specification.
The current implementation always zero the whole virtio net hdr space,
so there is no such an issue.
Still the additional complexity is ~5 lines and makes all the needed
information available on a single int, which is quite nice performance
wise. Do you have strong feeling against it?
>> @@ -2426,7 +2460,16 @@ 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 tun offloads are enabled if the provided 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)
>> + flags = tun->flags | TUN_VNET_TNL_MASK;
>> + else
>> + flags = tun->flags & ~TUN_VNET_TNL_MASK;
>
> I'm not sure I get the point that we need dynamics of
> TUN_VNET_TNL_MASK here. We know if tunnel gso and its csum or enabled
> or not,
How does tun know about VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO or
VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM?
The user-space does not tell the tun device about any of the host
offload features. Plain/baremetal GSO information are always available
in the basic virtio net header, so there is no size check, but the
overall behavior is similar - tun assumes the features have been
negotiated if the relevant bits are present in the header.
Here before checking the relevant bit we ensures we have enough vitio
net hdr data - that makes the follow-up test simpler.
> and we know the vnet_hdr_sz here, we can simply drop the
> packet with less header.
That looks prone migration or connectivity issue, and different from the
current general behavior of always accepting any well formed packet even
if shorter than what is actually negotiated (i.e. tun accepts packets
with just virtio_net_hdr header even when V1 has been negotiated).
/P
next prev parent reply other threads:[~2025-06-12 11:03 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 11:45 [PATCH RFC v3 0/8] virtio: introduce GSO over UDP tunnel Paolo Abeni
2025-06-06 11:45 ` [PATCH RFC v3 1/8] virtio: introduce extended features Paolo Abeni
2025-06-08 5:49 ` Akihiko Odaki
2025-06-12 8:50 ` Paolo Abeni
2025-06-12 0:50 ` Jason Wang
2025-06-12 9:05 ` Paolo Abeni
2025-06-06 11:45 ` [PATCH RFC v3 2/8] virtio_pci_modern: allow configuring " Paolo Abeni
2025-06-12 0:57 ` Jason Wang
2025-06-12 9:34 ` Paolo Abeni
2025-06-06 11:45 ` [PATCH RFC v3 3/8] vhost-net: " Paolo Abeni
2025-06-08 6:16 ` Akihiko Odaki
2025-06-14 7:27 ` Paolo Abeni
2025-06-16 8:57 ` Akihiko Odaki
2025-06-16 10:27 ` Paolo Abeni
2025-06-12 1:31 ` Jason Wang
2025-06-06 11:45 ` [PATCH RFC v3 4/8] virtio_net: add supports for extended offloads Paolo Abeni
2025-06-06 11:45 ` [PATCH RFC v3 5/8] net: implement virtio helpers to handle UDP GSO tunneling Paolo Abeni
2025-06-12 3:53 ` Jason Wang
2025-06-12 10:10 ` Paolo Abeni
2025-06-16 3:17 ` Jason Wang
2025-06-06 11:45 ` [PATCH RFC v3 6/8] virtio_net: enable gso over UDP tunnel support Paolo Abeni
2025-06-12 4:05 ` Jason Wang
2025-06-12 10:17 ` Paolo Abeni
2025-06-16 3:20 ` Jason Wang
2025-06-16 14:44 ` Paolo Abeni
2025-06-06 11:45 ` [PATCH RFC v3 7/8] tun: " Paolo Abeni
2025-06-12 4:55 ` Jason Wang
2025-06-12 11:03 ` Paolo Abeni [this message]
2025-06-14 10:21 ` Paolo Abeni
2025-06-16 4:53 ` Jason Wang
2025-06-16 10:17 ` Paolo Abeni
2025-06-16 10:43 ` Paolo Abeni
2025-06-17 2:56 ` Jason Wang
2025-06-17 3:24 ` Jason Wang
2025-06-14 8:04 ` Paolo Abeni
2025-06-16 5:34 ` Jason Wang
2025-06-06 11:45 ` [PATCH RFC v3 8/8] vhost/net: " Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7099b02-f0d4-492c-a15b-2a93a097d3f5@redhat.com \
--to=pabeni@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).