aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--tcp_buf.c3
-rw-r--r--tcp_conn.h10
2 files changed, 11 insertions, 2 deletions
diff --git a/tcp_buf.c b/tcp_buf.c
index 72c4541..ee8c7ce 100644
--- a/tcp_buf.c
+++ b/tcp_buf.c
@@ -335,6 +335,9 @@ int tcp_buf_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn,
struct iovec *iov;
uint32_t seq;
+ if (!mss)
+ return 0;
+
/* Set up buffer descriptors we'll fill completely and partially. */
fill_bufs = DIV_ROUND_UP(wnd_scaled - already_sent, mss);
if (fill_bufs > TCP_FRAMES) {
diff --git a/tcp_conn.h b/tcp_conn.h
index e3c5534..3173ddb 100644
--- a/tcp_conn.h
+++ b/tcp_conn.h
@@ -51,8 +51,14 @@ struct tcp_tap_conn {
#define TCP_MSS_BITS 14
unsigned int tap_mss :TCP_MSS_BITS;
-#define MSS_SET(conn, mss) (conn->tap_mss = (mss >> (16 - TCP_MSS_BITS)))
-#define MSS_GET(conn) (conn->tap_mss << (16 - TCP_MSS_BITS))
+
+ /* Clamp non-zero MSS < 4 to 1 to avoid rounding to zero */
+#define MSS_SET(conn, mss) \
+ (conn->tap_mss = (mss) ? MAX(1, (mss) >> (16 - TCP_MSS_BITS)) : 0)
+
+ /* tap_mss is stored as 1 for any non-zero MSS value <= 4 */
+#define MSS_GET(conn) \
+ ((conn->tap_mss == 1) ? 1 : (conn->tap_mss << (16 - TCP_MSS_BITS)))
#define RTT_EXP_BITS 4
unsigned int rtt_exp :RTT_EXP_BITS;