From 7a6e1b5c49d5f6e35f01c8f379034eb6f26a3c2a Mon Sep 17 00:00:00 2001 From: deuce <> Date: Mon, 13 Apr 2020 23:21:38 +0000 Subject: [PATCH] Check if TCP timestamps are enabled, and if they are, subtract 12 from the MSS for the packet size. Fixes problem with telnet server where large transfers were full packets followed by a 12 byte packet. Also removes hack in webserver that always assumed timestamps were enabled. The Win32 code has not been tested, but is assumed to work perfectly. --- src/sbbs3/main.cpp | 20 ++++++++++++++++++++ src/sbbs3/websrvr.c | 22 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 6d1ed57057..1fb634d112 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -2297,6 +2297,26 @@ void output_thread(void* arg) &i, &sl)) { /* Check for sanity... */ if(i>100) { +#ifdef _WIN32 +#ifdef TCP_TIMESTAMPS + DWORD ts; + sl = sizeof(ts); + if (!getsockopt(sbbs->client_socket, IPPROTO_TCP, TCP_TIMESTAMPS, (char *)&ts, &sl)) { + if (ts) + i -= 12; + } +#endif +#else +#if (defined(TCP_INFO) && defined(TCPI_OPT_TIMESTAMPS)) + struct tcp_info tcpi; + + sl = sizeof(tcpi); + if (!getsockopt(sbbs->client_socket, IPPROTO_TCP, TCP_INFO,&tcpi, &sl)) { + if (tcpi.tcpi_options & TCPI_OPT_TIMESTAMPS) + i -= 12; + } +#endif +#endif sbbs->outbuf.highwater_mark=i; lprintf(LOG_DEBUG,"Autotuning outbuf highwater mark to %d based on MSS",i); mss=sbbs->outbuf.highwater_mark; diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c index c702ab1218..f1ac6bea81 100644 --- a/src/sbbs3/websrvr.c +++ b/src/sbbs3/websrvr.c @@ -6286,7 +6286,27 @@ void http_output_thread(void *arg) if(!getsockopt(session->socket, IPPROTO_TCP, TCP_MAXSEG, (char*)&i, &sl)) { /* Check for sanity... */ if(i>100) { - obuf->highwater_mark=i-12; +#ifdef _WIN32 +#ifdef TCP_TIMESTAMPS + DWORD ts; + sl = sizeof(ts); + if (!getsockopt(session->socket, IPPROTO_TCP, TCP_TIMESTAMPS, (char *)&ts, &sl)) { + if (ts) + i -= 12; + } +#endif +#else +#if (defined(TCP_INFO) && defined(TCPI_OPT_TIMESTAMPS)) + struct tcp_info tcpi; + + sl = sizeof(tcpi); + if (!getsockopt(session->socket, IPPROTO_TCP, TCP_INFO,&tcpi, &sl)) { + if (tcpi.tcpi_options & TCPI_OPT_TIMESTAMPS) + i -= 12; + } +#endif +#endif + obuf->highwater_mark=i; lprintf(LOG_DEBUG,"%04d Autotuning outbuf highwater mark to %d based on MSS" ,session->socket,i); mss=obuf->highwater_mark; -- GitLab