diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-01-26 06:45:31 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-01-26 16:30:59 +0100 |
commit | be265eef0631217e6566781d388ae078c4797752 (patch) | |
tree | e2e53742621534c718c1995e9f519a2c401cb6cd /tcp.c | |
parent | 34872fadec608a6305ab9bcdd15592282cb194a5 (diff) | |
download | passt-be265eef0631217e6566781d388ae078c4797752.tar passt-be265eef0631217e6566781d388ae078c4797752.tar.gz passt-be265eef0631217e6566781d388ae078c4797752.tar.bz2 passt-be265eef0631217e6566781d388ae078c4797752.tar.lz passt-be265eef0631217e6566781d388ae078c4797752.tar.xz passt-be265eef0631217e6566781d388ae078c4797752.tar.zst passt-be265eef0631217e6566781d388ae078c4797752.zip |
tcp: Don't round down MSS to >= 64KiB page size, but clamp it in any case
On some architectures, the page size is bigger than the maximum size
of an Ethernet frame.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1671,7 +1671,7 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn, int flags, } if (flags & SYN) { - uint16_t mss; + int mss; /* Options: MSS, NOP and window scale (8 bytes) */ optlen = 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 = MIN(mss, PAGE_SIZE); - else + else if (mss > PAGE_SIZE) mss = ROUND_DOWN(mss, PAGE_SIZE); } - *(uint16_t *)data = htons(mss); + *(uint16_t *)data = htons(MIN(USHRT_MAX, mss)); data += OPT_MSS_LEN - 2; th->doff += OPT_MSS_LEN / 4; |