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=E7+Lr9HS; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5918F5A0619 for ; Mon, 03 Nov 2025 12:00:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1762167657; bh=QuBx7TIUbws/WnGMFLlVF1/4e9TxFFpEZxWzP6gxLQk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E7+Lr9HSDPfrCsbcVbMAjG90Nbo+MLGVLLSkUrHniAlbW/pqoSUiHiR8KVI+FujgH affaV75XaCfYrEg4BlfcTxSNQk+gYCKI2NLDUAPodv6VWVlCnWkG6XDWCrv6DZzgZz WR/lCR6CAWLiVMSkiV6uwc+4n4N2ynHqp17H4BlNqEU68LOEVjpiCDERRT5JZBckbh fEN+cdnArFPULU1zQqZBMHXTAMRVR0k6OLceVrpVjvEqS3RZCMTo5i7pZklZ5bQIrL HI0OaC4jdqS8/C7ENb6g2vZZwrUmcz/iYWZPMa3HaliDjZqo8e5r8qgk+ZDUTCTcYQ Y5LZ9yq4XTR5Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4d0TCY2WDmz4wDC; Mon, 03 Nov 2025 22:00:57 +1100 (AEDT) Date: Mon, 3 Nov 2025 22:00:44 +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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rcP8cF+cykiU4Tyf" Content-Disposition: inline In-Reply-To: <20251103101612.1412079-2-sbrivio@redhat.com> Message-ID-Hash: YEUOD32Q4HE4T2UXSOSTX6HZ6RO2KD2A X-Message-ID-Hash: YEUOD32Q4HE4T2UXSOSTX6HZ6RO2KD2A 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: --rcP8cF+cykiU4Tyf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 03, 2025 at 11:16:08AM +0100, Stefano Brivio wrote: > 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. Plus this is essentially a slow path anyway. >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D166 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > 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 l2len) > { > 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; > + } > + > switch (c->mode) { > case MODE_PASST: > iov[iovcnt] =3D IOV_OF_LVALUE(vnet_len); > --=20 > 2.43.0 >=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 --rcP8cF+cykiU4Tyf Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkIi0wACgkQzQJF27ox 2GdF7w//Xy7OjPLIzQgy2MQmVu36anl+u0c7R32foV9sQOCMkqM/2NYJ3GdZOudv 8oOicOxAo2AMDgj24Hx3eFHlfV8O/x129u95ZbExDPSXTpUu+Ix7Nra986Woz7Hn vayurIYdQw0KJw4hNHR338FrawVxmUHtEOnaH7B+IvaX/WuNA8o5/wp2xfKW1Fog MNom7PIVqPlRrMIaRrdD+PoM/dGCU/KDYQxR4xXesAoH5+xSQRgF6JpcY0vq5EF6 K/rSP6/wESzAX/MNbFV5OsHKJfdSKOMSRH0oxcY4wXIQXRC7/GH/vXXKHoI+ru1C YFBTq5rZt4GdcdIIX4iOya6ESkbNmxzKp0qfltqc/C+y8ysAc+h9MoUf1Rcutt4N Yuq1WudUdbf60PenpLXxeD3C4MSx/EEIZpIXqn5+zERk7eqwlDIoTS6H9gfddSuV /NYX2XgBethh3QHiFcAZtdM5BiU6pm42avobyaFBcFDV3wRNeuq9oVopEWDXGsmJ nxla6tNUHv66RH7O+aBa3X18tvFVMJPxNhMelm74JJ5CLfMuL+RzLXM1zM0Cu9ax LzR3zlOfoPjf06PZI6F0LrwZ8vvc0jyNtw371oVI7YiZNmUeG6kHwX68sIEcFxYF F4Cyx/EezBb6250vA9pI6iu9ipUZRTMwLBEwV8K3Pd0hCrvJcXs= =rrjN -----END PGP SIGNATURE----- --rcP8cF+cykiU4Tyf--