From: Stefano Brivio <sbrivio@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] vu_common: Always set num_buffers in virtio-net header
Date: Thu, 05 Mar 2026 01:38:50 +0100 (CET) [thread overview]
Message-ID: <20260305013849.45023c9b@elisabeth> (raw)
In-Reply-To: <20260303151734.1582315-1-lvivier@redhat.com>
On Tue, 3 Mar 2026 16:17:34 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> Legacy virtio used two different header formats: struct virtio_net_hdr
> (10 bytes) when VIRTIO_NET_F_MRG_RXBUF was not negotiated, and
> struct virtio_net_hdr_mrg_rxbuf (12 bytes) when it was. The
> num_buffers field only existed in the larger header.
>
> Modern virtio (VIRTIO_F_VERSION_1, i.e. virtio 1.0+) always uses the
> 12-byte struct virtio_net_hdr_mrg_rxbuf header regardless of whether
> VIRTIO_NET_F_MRG_RXBUF is negotiated, so num_buffers is always present
> in the header. passt only supports modern virtio and dies if
> VIRTIO_F_VERSION_1 is not negotiated (vhost_user.c), and VNET_HLEN is
> unconditionally defined as sizeof(struct virtio_net_hdr_mrg_rxbuf).
>
> The virtio specification (v1.1, section 5.1.6) requires that:
>
> "The device MUST set num_buffers to 1 if VIRTIO_NET_F_MRG_RXBUF has
> not been negotiated."
>
> vu_set_vnethdr() only set num_buffers when VIRTIO_NET_F_MRG_RXBUF was
> negotiated. When it was not, num_buffers was left uninitialised,
> violating the spec.
>
> Since vu_collect() already limits buffer collection to a single element
> when VIRTIO_NET_F_MRG_RXBUF is not negotiated, num_buffers passed by
> callers is guaranteed to be 1 in that case. We can therefore
> unconditionally set num_buffers, which makes the vdev parameter
> unnecessary.
>
> Drop the vdev parameter from vu_set_vnethdr() and update all callers.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Applied.
--
Stefano
prev parent reply other threads:[~2026-03-05 0:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 15:17 Laurent Vivier
2026-03-04 1:44 ` David Gibson
2026-03-05 0:38 ` Stefano Brivio [this message]
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=20260305013849.45023c9b@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).