From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 6850A5A0304 for ; Wed, 29 May 2024 12:19:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716977954; 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=j5FBlpj8Yklm6KUFypdXmaz7eAlP4H0XINvC4AaSfRQ=; b=EVFSCVJ+F7l86IMY3zix2bwjsPjpYec2na29MbzBlPgWmcdZs6SLwnjeS0fDHF19Uh/Nsu QZog7WrD2hCK0l6YkKKDm9+ZhPEa+yOq1ehFuDPZ2K1d/HMKEWB5KPBinekSwWczzEhcwC GI4RwAyHMPKADlwGDl8p7+p0RUNX+fs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-qa9S7BYxPFyMyIUqCVtU3g-1; Wed, 29 May 2024 06:19:13 -0400 X-MC-Unique: qa9S7BYxPFyMyIUqCVtU3g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 007CE857A83 for ; Wed, 29 May 2024 10:19:13 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.39.192.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8557228EA; Wed, 29 May 2024 10:19:12 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v3 03/11] tcp: extract buffer management from tcp_conn_tap_mss() Date: Wed, 29 May 2024 12:19:01 +0200 Message-ID: <20240529101909.1120078-4-lvivier@redhat.com> In-Reply-To: <20240529101909.1120078-1-lvivier@redhat.com> References: <20240529101909.1120078-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 4CS5SERVSOUKKYZYLJESKFZYWPDVOLTZ X-Message-ID-Hash: 4CS5SERVSOUKKYZYLJESKFZYWPDVOLTZ X-MailFrom: lvivier@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: 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: Signed-off-by: Laurent Vivier --- tcp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tcp.c b/tcp.c index a6f43010f58f..c274ea6c4ca4 100644 --- a/tcp.c +++ b/tcp.c @@ -1804,6 +1804,14 @@ static int tcp_conn_new_sock(const struct ctx *c, sa_family_t af) return s; } +static uint16_t tcp_buf_conn_tap_mss(const struct tcp_tap_conn *conn) +{ + if (CONN_V4(conn)) + return MSS4; + + return MSS6; +} + /** * tcp_conn_sock() - Obtain a connectable socket in the host/init namespace * @c: Execution context @@ -1849,10 +1857,7 @@ static uint16_t tcp_conn_tap_mss(const struct tcp_tap_conn *conn, else mss = ret; - if (CONN_V4(conn)) - mss = MIN(MSS4, mss); - else - mss = MIN(MSS6, mss); + mss = MIN(tcp_buf_conn_tap_mss(conn), mss); return MIN(mss, USHRT_MAX); } -- 2.44.0