From 4667226bb08b06c70df9e4508d8304ffb4ba0e2d Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sat, 17 Jul 2021 17:57:11 +0200 Subject: tcp: Fix partial (ACK) message coalescing, ACK timeout, MSG_MORE flag setting Signed-off-by: Stefano Brivio --- tcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index dec2df3..86cb92c 100644 --- a/tcp.c +++ b/tcp.c @@ -363,7 +363,7 @@ #define WINDOW_DEFAULT 14600 /* RFC 6928 */ #define SYN_TIMEOUT 240000 /* ms */ -#define ACK_TIMEOUT 10000 +#define ACK_TIMEOUT 2000 #define ACK_INTERVAL 50 #define ACT_TIMEOUT 7200000 #define FIN_TIMEOUT 240000 @@ -1403,6 +1403,9 @@ int tcp_tap_handler(struct ctx *c, int af, void *addr, if (off < sizeof(*th) || off > __len) break; + if (!i && (!th->ack || len != off)) + break; + __this = ntohl(th->ack_seq); if (!i || __this - __seq_max < MAX_WINDOW) @@ -1515,7 +1518,7 @@ int tcp_tap_handler(struct ctx *c, int af, void *addr, if (skip < len - off && tcp_send_to_sock(c, conn, msg[0].l4h + off + skip, len - off - skip, - th->psh ? 0 : MSG_MORE)) + (count > 1) ? MSG_MORE : 0)) return 1; if (count == 1) -- cgit v1.2.3