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=Q71UsGSD; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 1AC445A0622 for ; Mon, 03 Nov 2025 11:20:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762165219; 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=dpCoZhbFv39QqNOWpfDfVW6mqgHgpp6vpLE+LX/dXWQ=; b=Q71UsGSDhWUjrxFZgHNeDJSLU5YS7HXqfTZzox37av8XzuhEr0XXCbmzOm/Qd2PExbViuL Li6RgGLRyFuW/B42hsl/kwbTz1E6F1aMLTYB0c/CSlGcNbz5esz+CjarhjhsJW7EPFECRU agxBY83TrnvNnA/qd0KKRwP8U06+x4o= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-d3yGYwfoNC6OG8GTN4lR_g-1; Mon, 03 Nov 2025 05:20:17 -0500 X-MC-Unique: d3yGYwfoNC6OG8GTN4lR_g-1 X-Mimecast-MFC-AGG-ID: d3yGYwfoNC6OG8GTN4lR_g_1762165216 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-429c8d07874so989387f8f.3 for ; Mon, 03 Nov 2025 02:20:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165216; x=1762770016; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dpCoZhbFv39QqNOWpfDfVW6mqgHgpp6vpLE+LX/dXWQ=; b=wXzfVFiwuBWbWhpfAhQ5383U/yMejDk9f89L8nsO3oxziyF+QUrhsFuqr084Txliu1 9Gei6H28bpO4Oi7XBwOgoLsqis96i8Sn1pPYuQ/5vImwqCxd7YKgnGLm7OwxzXtPrxvU j2EBDjrDV2FyyXcgLSoESij0HvJqw/87tgNpZwkEHR4kq0dmYNTq6oz8ebLqVxLt22R0 z1RQDn3L2R4QKrJBD6d+wr+5NYDhHoroAUDdveImaCfjIIjagXHEB8OoYgeMBJl+vVF4 ebGBtALbvTzCVzuROl6tpnH6kqvImwbvNhE19zSU17oRi4Q2GPh4zPpIEiCLvYow2C5o xaJQ== X-Gm-Message-State: AOJu0YwUzjflsXIqPPugp0iyZOvcoozqySRODJjnzqC9YsPNeu9NiPhg 2asQIb6w5OT5poJ8F2zQU5uA03ZY5Pl4nru+4JtC+7LIszyZGJJp24D5+2Wh7btQZzdgVdTKxaM 4A2FjHT5yQ6tuWnNRlmdRKScB3dDKCE5O6VffOfXphE1MatV4WhTj1g== X-Gm-Gg: ASbGncv5NOfNKAtOXTlW68KMVDIsAOuEqUbQaDTJ+NFeAhEEslkUFCi7fpVsLIYBQcA ViZJkk49SYlrc0/G/9uhJwliDOsReEHqOHyH8jUYlurF24JtO2sN3LouuXq9pggm42bqBn6JtL4 rD7arAiyBemDeoTdiaxfEzTzTLI0cAPUGx1GE1Du4+92C8GBtoWeNZUBqBYeeRkeTTOkgJ6z23M 7y1qilByvP+2Xz62eW6DU2KTMYUuoCSBuYSm+ceLOdNYBsxc+s/cMlAJCklHOvyMw7hjpsK3qUV EaM9s64bFNiRU0WvycKFjAuuWMuPGROFyU2w128RrHMiy98kflwawyi0ylhKulpVwFGWguetJeR E6I45QUSxcg== X-Received: by 2002:a05:6000:40ca:b0:427:854:770 with SMTP id ffacd0b85a97d-429bd6a5ec5mr9192511f8f.43.1762165216042; Mon, 03 Nov 2025 02:20:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWwL4A1YIN0QHuFnDk9XiecliZpptiSLW3VvJ+13rgSAeErT39f6q09wYFUpgiSRoUjitOuw== X-Received: by 2002:a05:6000:40ca:b0:427:854:770 with SMTP id ffacd0b85a97d-429bd6a5ec5mr9192488f8f.43.1762165215538; Mon, 03 Nov 2025 02:20:15 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c13f2b5asm19478019f8f.40.2025.11.03.02.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Nov 2025 02:20:15 -0800 (PST) Date: Mon, 3 Nov 2025 11:20:13 +0100 From: Stefano Brivio To: passt-dev@passt.top, Laurent Vivier Subject: Re: [RFC PATCH 1/5] tap: Pad non-batched frames to 802.3 minimum (60 bytes) if needed Message-ID: <20251103112013.4e1adf82@elisabeth> In-Reply-To: <20251103101612.1412079-2-sbrivio@redhat.com> References: <20251103101612.1412079-1-sbrivio@redhat.com> <20251103101612.1412079-2-sbrivio@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 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 48aOlSYKpawmmF_yMSme93K1pC2z9Cb37EYhtAE8h1Q_1762165216 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: VJ4VKE4JPGTO26A33HBQSN4BL3MDMRSF X-Message-ID-Hash: VJ4VKE4JPGTO26A33HBQSN4BL3MDMRSF 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: 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 Mon, 3 Nov 2025 11:16:08 +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 > --- > tap.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > 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 = htonl(l2len); > + uint8_t padded[ETH_ZLEN] = { 0 }; > struct iovec iov[2]; > size_t iovcnt = 0; > > + if (l2len < ETH_ZLEN) { > + memcpy(padded, data, l2len); > + data = padded; > + l2len = ETH_ZLEN; > + } 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. > + > switch (c->mode) { > case MODE_PASST: > iov[iovcnt] = IOV_OF_LVALUE(vnet_len); -- Stefano