From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JRm66Vfi; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 169515A0272 for ; Thu, 05 Mar 2026 01:38:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772671133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Az1jIjVxFTLdeRveonuk7TIoSI7k7v81/gUdkgMwNP0=; b=JRm66Vfiee1Neuny/W/N/4MhUI0GRgFfHorZ88+v36LfjudRFNQusPWPQgJeM4kdRqHL7i 8KEz2oFv3MrWu+SsXQvgJAnS57+j+LZe4IglBfmSO0IAPJ/SN2jlW/Cvtb0pIfvifkfQKg Kt8HVdyRyJu7Vr3IYtidM33GwNqIatA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-qx4WVAHTMsqCkZQJqy7jvQ-1; Wed, 04 Mar 2026 19:38:52 -0500 X-MC-Unique: qx4WVAHTMsqCkZQJqy7jvQ-1 X-Mimecast-MFC-AGG-ID: qx4WVAHTMsqCkZQJqy7jvQ_1772671131 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4837246211bso86365555e9.0 for ; Wed, 04 Mar 2026 16:38:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772671131; x=1773275931; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Az1jIjVxFTLdeRveonuk7TIoSI7k7v81/gUdkgMwNP0=; b=h6m+xSRvoAHfL/lJSYTmb2G/mPakr0pfZ/gzFMCXZEZzqQt0/Cdk+BkLl+I3lFZFX4 KKowGHfy92NuAM4MDfUjrjiE1Y3f4DtzYPtBxB03PO3HsuoXj5VOAM/1Og+YJgyf0CZk BPRxMHASABazrber+b+eFoQdwfb6IstId2Yni6B9XPTZ0boBN4U1uadV8+ggmuiK2r69 73qZznegjnqh3DQnSC3kDprDLoJWmroXO5TecQuJbiIAPVdkpB5MIfPiarupEIcAvhOx DpU6rLTE0ApL6VT5M09unV7c9Nploo8ui1g9ZdhLfSlsfx/efFaO6QlRKjvaH1uDnQiM vI/w== X-Gm-Message-State: AOJu0Yy75bU/SK9LigPXrKfoHwCrBxGxEJniXXg76lIVOnAN93lXrE00 uJvxMs/0ZHJ668mxq6ewCxp4YwE7pU3ZEv4PGr8PozjYHuOPnBINtV60nuWGSeN2q+zBqGUXBqj LK4lNxZpV6Y7Q3Ft6fJc+WFbSgzF8C1tWrYnu5lJYnZ8PieK2wM8bwQ== X-Gm-Gg: ATEYQzzU3mKGzHhxNgel0I8limT1VYOQ8b0k/5AJHSvLNe3JTURlP3tZrdbeYi5ix6S q8sYGXs3jutQjyClX1xAVy3DtHsa44C9lhP3w9dpOvjrQ65hPvYiv+sTGWeynEYDUk49Nu65ZvN GMJXWzPJ629Zh4XL4MpPfQ/2EyTNhVg0N+9LlZSTLx/PoCijpxpQe1Qglo03szLqhxdeRpipqHO L60abatC0i25tI/8XDLHyR0kAemsZQSaA9r0+l4hRm49V1bAuPQL3ppz3zZHG/a65kxoDCP4p7D pU9dRYaWS/877Nk+uSxqTZQ+ywg3Nb9ma4OyScsqIv5BDI8sLC2M2AeLJ/mLzD1A+/28ZkMZW6p 673ueyepsF5LJlBU3bWtl/aGOSdX2YcNpZ84f/DTMiFNsRWm8kA== X-Received: by 2002:a05:600c:1f85:b0:47e:e712:aa88 with SMTP id 5b1f17b1804b1-4851989f765mr73162655e9.31.1772671131168; Wed, 04 Mar 2026 16:38:51 -0800 (PST) X-Received: by 2002:a05:600c:1f85:b0:47e:e712:aa88 with SMTP id 5b1f17b1804b1-4851989f765mr73162395e9.31.1772671130744; Wed, 04 Mar 2026 16:38:50 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4851fae02a8sm5308175e9.5.2026.03.04.16.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 16:38:50 -0800 (PST) From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH] vu_common: Always set num_buffers in virtio-net header Message-ID: <20260305013849.45023c9b@elisabeth> In-Reply-To: <20260303151734.1582315-1-lvivier@redhat.com> References: <20260303151734.1582315-1-lvivier@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Thu, 05 Mar 2026 01:38:50 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tICx1T5lJONe-TAJPRdOSdeWkAnfMvTp34X4yyrYMKA_1772671131 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: STCI3L66LA5FDM57XTHVTEKAIMAZQAWO X-Message-ID-Hash: STCI3L66LA5FDM57XTHVTEKAIMAZQAWO X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 3 Mar 2026 16:17:34 +0100 Laurent Vivier 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 Applied. -- Stefano