public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>,
	Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH v2 4/5] tcp, udp: Pad batched frames to 60 bytes (802.3 minimum) in non-vhost-user modes
Date: Fri, 5 Dec 2025 12:27:49 +0100	[thread overview]
Message-ID: <20251205122749.53b101ea@elisabeth> (raw)
In-Reply-To: <20251205064842.42abd0d5@elisabeth>

On Fri, 5 Dec 2025 06:48:42 +0100
Stefano Brivio <sbrivio@redhat.com> wrote:

> On Fri,  5 Dec 2025 01:51:56 +0100
> Stefano Brivio <sbrivio@redhat.com> wrote:
> 
> > Add a further iovec frame part, TCP_IOV_ETH_PAD for TCP and
> > UDP_IOV_ETH_PAD for UDP, after the payload, make that point to a
> > zero-filled buffer, and send out a part of it if needed to reach
> > the minimum frame length given by 802.3, that is, 60 bytes altogether.
> > 
> > The frames we might need to pad are IPv4 only (the IPv6 header is
> > larger), and are typically TCP ACK segments but can also be small
> > data segments or datagrams.
> > 
> > Link: https://bugs.passt.top/show_bug.cgi?id=166
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > Reviewed-by: Laurent Vivier <lvivier@redhat.com>  
> 
> ...for some reason, in combination with the previous series with TCP
> throughput fixes, this patch now seems to break basic transfers ("large
> transfer", IPv4, guest to host), with passt only.

Whoa, it turns out I didn't test this one at all, sorry for that, I
don't know how it happened.

This "clearly" needs:

---
diff --git a/tcp.c b/tcp.c
index c5486bc..7140b22 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1037,7 +1037,7 @@ void tcp_fill_headers(const struct ctx *c, struct tcp_tap_conn *conn,
 	else
 		tcp_update_csum(psum, th, payload);
 
-	tap_hdr_update(taph, l3len + sizeof(struct ethhdr));
+	tap_hdr_update(taph, MAX(l3len + sizeof(struct ethhdr), ETH_ZLEN));
 }
 
 /**
diff --git a/udp.c b/udp.c
index f32f553..08bec50 100644
--- a/udp.c
+++ b/udp.c
@@ -381,19 +381,25 @@ static void udp_tap_prepare(const struct mmsghdr *mmh,
 	struct ethhdr *eh = (*tap_iov)[UDP_IOV_ETH].iov_base;
 	struct udp_payload_t *bp = &udp_payload[idx];
 	struct udp_meta_t *bm = &udp_meta[idx];
-	size_t l4len;
+	size_t l4len, l2len;
 
 	eth_update_mac(eh, NULL, tap_omac);
 	if (!inany_v4(&toside->eaddr) || !inany_v4(&toside->oaddr)) {
 		l4len = udp_update_hdr6(&bm->ip6h, bp, toside,
 					mmh[idx].msg_len, no_udp_csum);
-		tap_hdr_update(&bm->taph, l4len + sizeof(bm->ip6h) + ETH_HLEN);
+
+		l2len = MAX(l4len + sizeof(bm->ip6h) + ETH_HLEN, ETH_ZLEN);
+		tap_hdr_update(&bm->taph, l2len);
+
 		eh->h_proto = htons_constant(ETH_P_IPV6);
 		(*tap_iov)[UDP_IOV_IP] = IOV_OF_LVALUE(bm->ip6h);
 	} else {
 		l4len = udp_update_hdr4(&bm->ip4h, bp, toside,
 					mmh[idx].msg_len, no_udp_csum);
-		tap_hdr_update(&bm->taph, l4len + sizeof(bm->ip4h) + ETH_HLEN);
+
+		l2len = MAX(l4len + sizeof(bm->ip4h) + ETH_HLEN, ETH_ZLEN);
+		tap_hdr_update(&bm->taph, l2len);
+
 		eh->h_proto = htons_constant(ETH_P_IP);
 		(*tap_iov)[UDP_IOV_IP] = IOV_OF_LVALUE(bm->ip4h);
 	}
---

on top. I'll respin the whole series in a bit (once I addressed David's
comments to 5/5 as well).

-- 
Stefano


  reply	other threads:[~2025-12-05 11:27 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 if needed 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
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 [this message]
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=20251205122749.53b101ea@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /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).