From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 12/22] tcp: Don't round down MSS to >= 64KiB page size, but clamp it in any case Date: Fri, 28 Jan 2022 19:33:47 +0100 Message-ID: <20220128183357.3407606-13-sbrivio@redhat.com> In-Reply-To: <20220128183357.3407606-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3839867562265848898==" --===============3839867562265848898== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On some architectures, the page size is bigger than the maximum size of an Ethernet frame. Signed-off-by: Stefano Brivio --- tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcp.c b/tcp.c index 18f07b6..36c2bb5 100644 --- a/tcp.c +++ b/tcp.c @@ -1671,7 +1671,7 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_ta= p_conn *conn, int flags, } =20 if (flags & SYN) { - uint16_t mss; + int mss; =20 /* Options: MSS, NOP and window scale (8 bytes) */ optlen =3D OPT_MSS_LEN + 1 + OPT_WS_LEN; @@ -1691,10 +1691,10 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_= tap_conn *conn, int flags, if (c->low_wmem && !conn->local && !tcp_rtt_dst_low(conn)) mss =3D MIN(mss, PAGE_SIZE); - else + else if (mss > PAGE_SIZE) mss =3D ROUND_DOWN(mss, PAGE_SIZE); } - *(uint16_t *)data =3D htons(mss); + *(uint16_t *)data =3D htons(MIN(USHRT_MAX, mss)); =20 data +=3D OPT_MSS_LEN - 2; th->doff +=3D OPT_MSS_LEN / 4; --=20 2.33.0 --===============3839867562265848898==--