From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=Rm2ZsLfx; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D915D5A061A for ; Mon, 03 Nov 2025 12:03:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1762167821; bh=itBElhNrwccixuij5Hbwpev3i5cBdp4oPDXCSncLJyU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Rm2ZsLfxKnck8n4S26EUphsj3EiMLXf/vpxbv8M7BR1arzLeuZIOZHDPIrCdR00BS 1yiTC/220BLe1rtpjmj0bYtH0T8eOyX7wnfRMHBXv8SsZEe2ubgzIUW0JAmguoWM+T U66GodCj0zKrGmpeh/ZHY2VT5Z1v44waO5hN1Vn3NZK8yg84LHk/OkmHm1C29gb2ya pEV7KS8vK1mJ8PEmawK0tjSVxMxpRWDbVRjbXh/WyE2PZx2XJTSgVgwhWhnqiDqhUQ EYghJrEqrb4/oxSp7fzxdD2d4M0gSwkHTeqJ4XiOlok26hrn8rFw1xk1ix9dEdMjZg dwsG81ebP3FuA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4d0TGj5l1jz4wDC; Mon, 03 Nov 2025 22:03:41 +1100 (AEDT) Date: Mon, 3 Nov 2025 22:02:31 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [RFC PATCH 1/5] tap: Pad non-batched frames to 802.3 minimum (60 bytes) if needed Message-ID: References: <20251103101612.1412079-1-sbrivio@redhat.com> <20251103101612.1412079-2-sbrivio@redhat.com> <20251103112013.4e1adf82@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9wi8tyJG7aDcDad6" Content-Disposition: inline In-Reply-To: <20251103112013.4e1adf82@elisabeth> Message-ID-Hash: NDRLNBNEBLNXT4PKNPM4NJKG2ENRPLPJ X-Message-ID-Hash: NDRLNBNEBLNXT4PKNPM4NJKG2ENRPLPJ X-MailFrom: dgibson@gandalf.ozlabs.org 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, Laurent Vivier 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: --9wi8tyJG7aDcDad6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 03, 2025 at 11:20:13AM +0100, Stefano Brivio wrote: > On Mon, 3 Nov 2025 11:16:08 +0100 > Stefano Brivio wrote: >=20 > > IEEE 802.3 requires a minimum frame payload of 46 bytes, without a > > 802.1Q tag. Add padding for the simple tap_send_single() case using > > a zero-filled 60-byte buffer and copying data to it if needed. > >=20 > > In theory, we could add a further element in the iovec array, say: > >=20 > > uint8_t padding[ETH_ZLEN] =3D { 0 }; > > struct iovec iov[3]; > >=20 > > ... > >=20 > > if (l2len < ETH_ZLEN) { > > iov[iovcnt].iov_base =3D (void *)padding; > > iov[iovcnt].iov_len =3D ETH_ZLEN - l2len; > > iovcnt++; > > } > >=20 > > and avoid a copy, but that would substantially complicate the > > vhost-user path, and it's questionable whether passing a reference > > to a further buffer actually causes lower overhead than the simple > > copy. > >=20 > > Link: https://bugs.passt.top/show_bug.cgi?id=3D166 > > Signed-off-by: Stefano Brivio > > --- > > tap.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > >=20 > > diff --git a/tap.c b/tap.c > > index bb139d6..8d8d84b 100644 > > --- a/tap.c > > +++ b/tap.c > > @@ -131,9 +131,16 @@ unsigned long tap_l2_max_len(const struct ctx *c) > > void tap_send_single(const struct ctx *c, const void *data, size_t l2l= en) > > { > > uint32_t vnet_len =3D htonl(l2len); > > + uint8_t padded[ETH_ZLEN] =3D { 0 }; > > struct iovec iov[2]; > > size_t iovcnt =3D 0; > > =20 > > + if (l2len < ETH_ZLEN) { > > + memcpy(padded, data, l2len); > > + data =3D padded; > > + l2len =3D ETH_ZLEN; > > + } >=20 > Sorry, botched rebase, this should update vnet_len as well, which I > missed on the first attempt. I'll fix this in the next spin. Oh... yeah... should have caught that, oops. >=20 > > + > > switch (c->mode) { > > case MODE_PASST: > > iov[iovcnt] =3D IOV_OF_LVALUE(vnet_len); >=20 > --=20 > Stefano >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --9wi8tyJG7aDcDad6 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkIi8YACgkQzQJF27ox 2Gea2w/+OVCHNvco5ILOts+F/SV9lLuaR5TsDd3x8+QdDfs2BKgCcObrlGwtFGFF JRTsaa2PlNOuH4XoV+cEJXTIhHmdURKxKo4MEfLTzSIRJ08Nn8GNGNfdUgbIjxFp V1Nks9dhO0ITNYHnlQIvF9E7L7F8QkCjjZS/DEzt6ofCMjyrxgP1ZRA5SbRroj2I 4ep57SPZS/5uLuBtm3Go7NOFb6WglqeFt4xrFt2qMTay8J5GQJ8iLV7lyXe7zxRL CVPwuSN+lWyzEhkQtO0tv3Fmlv4VxAN3EuN3rRpfKca4YcYOe0GpnutDW+7DLka0 mvtSKRNKuqh9V79MvFYVxQUeQsHK9T60OL/YVFaik87JmTxXxF3B/QIa2PtCb1EA azqAn27KnltIt7ELgOPnbZmTpVjwHHydxDw+mqE23QUc4N6HqM1eD8gAMv2KLv+U GZEeyn1MnWhYrC9mo7QPFcsOhu5t9a66MevTUTw8j1GcxPVSd+Hm5kDZWZac7uiR ow95QkaWFLmZDL0fQHC82GmxG1uBBDMimUUP8vjjfDx2lP34UDCGaLeHCFsOSQv7 r0bRthiieRQOs5jV64dyF0vU91dnG4DIXclD6TEOBWlVqolOViknArVJoqz3A6Q9 NOkcEBleXyTgh/fWYf8heqpxV6jeGR/QBwdZHY25v9AmeUVWOsA= =rHlD -----END PGP SIGNATURE----- --9wi8tyJG7aDcDad6--