From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 690365A0269 for ; Thu, 26 Nov 2026 01:13:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795652014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=06bM0If20GPSoLUkSALN7SAy9cshpvaOPa4gWxq9atU=; b=Phncwlv4xRGt3bmrAYRQtnTCXqR4gy7h7VFFJmS/392vBeytOF20bDhQYctSKi3KmWko4w syU4Htwrlw2hUVTQIJ7p5RpsYTpRSiCfzwvlQ8qDWKzGsGq7SD5MEOzFl6VKWHzvQVPC09 jioaBCInQeql5NkA4ObUS+oJyYSF3+0= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-IkVfFvSNOM-H1FaK8ZoW7Q-1; Thu, 26 Nov 2026 00:13:30 +0000 X-MC-Unique: IkVfFvSNOM-H1FaK8ZoW7Q-1 X-Mimecast-MFC-AGG-ID: IkVfFvSNOM-H1FaK8ZoW7Q_1795652009 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 28743195605E; Thu, 26 Nov 2026 00:13:29 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A9F1D3001EAF; Thu, 26 Nov 2026 00:13:27 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH] tcp_buf: Don't fill the slot reserved for duplicate ACKs with data Date: Wed, 25 Nov 2026 19:13:27 -0500 Message-ID: <20261126001327.4136475-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: UNBvmXYL-b7aj2LsFwOelllqNVbuj0jxIQoeovtjiSk_1795652009 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: TALXVAW2SPKA7YUBJMHVKC6JS5K6W6HM X-Message-ID-Hash: TALXVAW2SPKA7YUBJMHVKC6JS5K6W6HM X-MailFrom: jmaloy@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 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: Since commit db7fb06f710e ("tcp_buf: Always reserve slot for possible duplicate ACK flag in the same batch"), tcp_data_to_tap() flushes the batch when only one free slot is left. However, in passt mode, tcp_buf_data_from_sock() can still receive into all TCP_FRAMES_MEM buffers at once, meaning that if it gets more than TCP_FRAMES_MEM - 1 segments, tcp_data_to_tap() flushes after the second last one, and then continues with building the last frame in slot 0. This has the consequence that the last segment is forwarded to the guest with the payload of the first segment, which we just sent, instead of the one we received into the last slot. We limit the number of buffers we receive into to TCP_FRAMES_MEM - 1, so that a whole batch of data frames always fits before the reserved slot. This also fixes a clang-tidy 23 warning in tcp_buf_data_from_sock(), as the check on available slots there can now be false. Fixes: db7fb06f710e ("tcp_buf: Always reserve slot for possible duplicate ACK flag in the same batch") Signed-off-by: Jon Maloy --- tcp_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcp_buf.c b/tcp_buf.c index 0780a327..c9d675e3 100644 --- a/tcp_buf.c +++ b/tcp_buf.c @@ -35,7 +35,7 @@ #define TCP_FRAMES_MEM 128 #define TCP_FRAMES \ - (c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM) + (c->mode == MODE_PASTA ? 1 : TCP_FRAMES_MEM - 1) /* Static buffers */ -- 2.56.1