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 489625A0271 for ; Fri, 2 Feb 2024 15:11:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706883115; 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=zZrISkRtPe4vV1HSE3H30OKsd8mQunHepTJWORDYZH8=; b=E3/sLD773iPIO54j5DxwKv8/hhgGPAuBxxm8Ogm+Yzp7UGGDNr17wXhb0MXb/SUXqmTniP BnSzReR5cc+JNe62GDwPf2AQ6SNt5TS/CpqX0WKOQYGiMSRrHbK9grrwL/xEOA4etk6EE1 xBnOsOk6NkKJkYtnMrK3m/JVMvlsigI= 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-216-zra6WGwgMCmwBmt3Z5Y1Ew-1; Fri, 02 Feb 2024 09:11:54 -0500 X-MC-Unique: zra6WGwgMCmwBmt3Z5Y1Ew-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 B8A4D85A58A for ; Fri, 2 Feb 2024 14:11:53 +0000 (UTC) Received: from virtlab218.virt.lab.eng.bos.redhat.com (virtlab218.virt.lab.eng.bos.redhat.com [10.19.152.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id A118E40C95AD; Fri, 2 Feb 2024 14:11:53 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 09/24] tcp: extract buffer management from tcp_conn_tap_mss() Date: Fri, 2 Feb 2024 15:11:36 +0100 Message-ID: <20240202141151.3762941-10-lvivier@redhat.com> In-Reply-To: <20240202141151.3762941-1-lvivier@redhat.com> References: <20240202141151.3762941-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: QBOUI3JJIXN7PFVDTN5WCXPFZ54P5NVM X-Message-ID-Hash: QBOUI3JJIXN7PFVDTN5WCXPFZ54P5NVM 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 20ad8a4e5271..cdbceed65033 100644 --- a/tcp.c +++ b/tcp.c @@ -1813,6 +1813,14 @@ 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_tap_mss() - Get MSS value advertised by tap/guest * @conn: Connection pointer @@ -1832,10 +1840,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.42.0