From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH v2 1/5] tap: Pad non-batched frames to 802.3 minimum (60 bytes) if needed
Date: Fri, 5 Dec 2025 14:23:46 +1100 [thread overview]
Message-ID: <aTJQQuhrRSjsztT3@zatzit> (raw)
In-Reply-To: <20251205005157.2577523-2-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
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.
>
> In theory, we could add a further element in the iovec array, say:
>
> uint8_t padding[ETH_ZLEN] = { 0 };
> struct iovec iov[3];
>
> ...
>
> if (l2len < ETH_ZLEN) {
> iov[iovcnt].iov_base = (void *)padding;
> iov[iovcnt].iov_len = ETH_ZLEN - l2len;
> iovcnt++;
> }
>
> 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.
>
> Link: https://bugs.passt.top/show_bug.cgi?id=166
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> tap.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> 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 = htonl(l2len);
> + uint8_t padded[ETH_ZLEN] = { 0 };
> struct iovec iov[2];
> size_t iovcnt = 0;
> + uint32_t vnet_len;
> +
> + if (l2len < ETH_ZLEN) {
> + memcpy(padded, data, l2len);
> + data = padded;
> + l2len = ETH_ZLEN;
> + }
> +
> + vnet_len = htonl(l2len);
>
> switch (c->mode) {
> case MODE_PASST:
> --
> 2.43.0
>
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-12-05 3:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 0:51 [PATCH v2 0/5] Pad all inbound frames to 802.3 minimum size " Stefano Brivio
2025-12-05 0:51 ` [PATCH v2 1/5] tap: Pad non-batched frames to 802.3 minimum (60 bytes) " Stefano Brivio
2025-12-05 3:23 ` David Gibson [this message]
2025-12-05 0:51 ` [PATCH v2 2/5] tcp: Fix coding style for comment to enum tcp_iov_parts Stefano Brivio
2025-12-05 0:51 ` [PATCH v2 3/5] udp: Fix coding style for comment to enum udp_iov_idx Stefano Brivio
2025-12-05 0:51 ` [PATCH v2 4/5] tcp, udp: Pad batched frames to 60 bytes (802.3 minimum) in non-vhost-user modes Stefano Brivio
2025-12-05 5:48 ` Stefano Brivio
2025-12-05 11:27 ` Stefano Brivio
2025-12-05 0:51 ` [PATCH v2 5/5] tcp, udp: Pad batched frames for vhost-user modes to 60 bytes (802.3 minimum) Stefano Brivio
2025-12-05 4:07 ` David Gibson
2025-12-06 1:26 ` Stefano Brivio
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=aTJQQuhrRSjsztT3@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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).