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.133.124]) by passt.top (Postfix) with ESMTP id 30EA85A030A for ; Mon, 27 May 2024 11:10:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716801038; 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=AtSzXmyjYG3uc+9C7CZf9kS4vcDq20GNTvvy+NESPTM=; b=V3TFQp8bAR2igAA9+V02suFr0Nw4Qq3cUfrUsEWm1SY6tBdTaxBPpb+0z4HfSaKmiRzdvA vteMuXkHRNgKiAeccrqzU5bjWjHvRKiknz5xnjWrQ7utAjdcWEosFqNuLW6B3c1nljwm2y nOJt1LroCldtDOViyO2e8TNXHvbGGGw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-x79i86_yN0S7sbkmAfPFfg-1; Mon, 27 May 2024 05:10:34 -0400 X-MC-Unique: x79i86_yN0S7sbkmAfPFfg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 6817D1C0512D for ; Mon, 27 May 2024 09:10:34 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.39.192.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED09940C6DAF; Mon, 27 May 2024 09:10:33 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 3/8] tcp: extract buffer management from tcp_conn_tap_mss() Date: Mon, 27 May 2024 11:10:25 +0200 Message-ID: <20240527091030.772228-4-lvivier@redhat.com> In-Reply-To: <20240527091030.772228-1-lvivier@redhat.com> References: <20240527091030.772228-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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: TM4GWCYQPUJZ7YAQOKT75LAPUA5WR2WI X-Message-ID-Hash: TM4GWCYQPUJZ7YAQOKT75LAPUA5WR2WI 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 b42cef69e8db..85a11e7e05dc 100644 --- a/tcp.c +++ b/tcp.c @@ -1808,6 +1808,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 @@ -1853,10 +1861,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