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=BdZNJZpf; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 732265A0619 for ; Fri, 05 Dec 2025 04:34:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764905657; bh=k+6wJ4FCy331ZFnOLwSrcXFJV66JS0buctO9TILJfng=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BdZNJZpfoy+uPLk6m6pOvr0B4h/tZp5oD85K4JQHcNhin36CRCjp/kwpRJQT3hlzd B6cwtomOzWz3QXd2D3xLamki7fcUrUxKf88tqE129lNyO6MdRYMdV2juoxMP1KDEyy t5LM6rmltshKbMPN6RisVJkMxcTN/YKJJIk3/KSRQefNk1yyM4m6mOEmyFmKNeD0k+ 9a/RS6OiuVqbFlZwDziz3+4I6bEtnFL265c2v4oJkFE51ug2gwhVyLynheKY+vE4ST ZzafTD9nkT8NrxajMyM/MTG5TtgorhXL2+TRsu6HKNtWwB7b3S2la8Rxwa1KF6WStM uYmXORCFaOY+g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dMxnP0xlsz4wHW; Fri, 05 Dec 2025 14:34:17 +1100 (AEDT) Date: Fri, 5 Dec 2025 14:23:46 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 1/5] tap: Pad non-batched frames to 802.3 minimum (60 bytes) if needed Message-ID: References: <20251205005157.2577523-1-sbrivio@redhat.com> <20251205005157.2577523-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vl1QiVHxWzzO8eod" Content-Disposition: inline In-Reply-To: <20251205005157.2577523-2-sbrivio@redhat.com> Message-ID-Hash: MI533ZGJWVLGJ6CM5YNUYILWZNS6FEPT X-Message-ID-Hash: MI533ZGJWVLGJ6CM5YNUYILWZNS6FEPT 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: --vl1QiVHxWzzO8eod Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 05, 2025 at 01:51:53AM +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. >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D166 > Signed-off-by: Stefano Brivio > Reviewed-by: Laurent Vivier Reviewed-by: David Gibson > --- > tap.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/tap.c b/tap.c > index 44b0644..e3ea61c 100644 > --- a/tap.c > +++ b/tap.c > @@ -130,9 +130,18 @@ 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; > + uint32_t vnet_len; > + > + if (l2len < ETH_ZLEN) { > + memcpy(padded, data, l2len); > + data =3D padded; > + l2len =3D ETH_ZLEN; > + } > + > + vnet_len =3D htonl(l2len); > =20 > switch (c->mode) { > case MODE_PASST: > --=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 --vl1QiVHxWzzO8eod Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkyUEEACgkQzQJF27ox 2Gf6kA//S8dhnotWl3CYxS1XIG+8s19pGQVo4sTXVhOwonKUV13Ne5Af1Q2tb85W ZEfqhE4P4hg3dGiMQ8IuxBnie3s7kdh9DjtnhZGYYtWnQssWLxBxVfOhLvGSgdA/ 58iWnrVzyOANZaKCu2biJKffugIXUUJSPUUKfJGXlHB53mQ5qivgSY5PBIXK8xBL IGpEW4LIpOmlecNjmQ8QQgr7YpSAsQRS76Sbp4scUTtWsfx3NrcNsyPi7aa2qHXe rdi5udpeIMK6DlQIWPzZEpTDnwxXLNP2tK36qpE2RsTFgnt+bi5M5d5NYB30HNwl QyOk4tS3qgy3quGC0x4K6gQKwREg5LF86LkwfWmfPaL7yayuSjrb1NCUFKYmXmmV 4CiWVUSbWC9LW0vp+MrrlsbnEZ8GGKnDRjvURwyuEKeCDfBspVcb8RsM+nPi6P4Y yuedDCu9ps7nZ2cT7HUtjF+x/LCIz6UNi0Af1tA4jRjaUbXcv8wbwsXrxea/AOdc va9lM3StQ7CCxZ4W8pMTMC/GoD8BxzT8bvMJV/UCxaV7w2tl+0yCNTKO/i/oY+GV PpFVqhOcW6jJP6vLRmV/eccqv+hof7DEE0IKp15NqMtLICpLCI5NJvA2iwuxXGQR FAIdForHM6bELKn51lIRyR31JTnhpDolWBdib0uyZw5lSBGx0kM= =f8Ge -----END PGP SIGNATURE----- --vl1QiVHxWzzO8eod--