From 1ac0d52820e0cfd6c7f301e3f5d5717cda4dea88 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sat, 16 Oct 2021 16:58:16 +0200 Subject: [PATCH] tcp: Arm tcp_data_noack on insufficient window too, don't reset if ACK doesn't match ...and while at it, reverse the operands in the window equality comparison to detect the need for fast re-transmit: it's easier to read this way. Signed-off-by: Stefano Brivio --- tcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index 35e2093..6b256bf 100644 --- a/tcp.c +++ b/tcp.c @@ -2156,6 +2156,7 @@ static int tcp_data_from_sock(struct ctx *c, struct tcp_tap_conn *conn, if (!conn->wnd_from_tap || already_sent >= conn->wnd_from_tap) { tcp_tap_epoll_mask(c, conn, conn->events | EPOLLET); + conn->tap_data_noack = *now; return 0; } @@ -2374,7 +2375,7 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn, /* Fast re-transmit */ retr = !len && !th->fin && ack_seq == max_ack_seq && - max_ack_seq_wnd == ntohs(th->window); + ntohs(th->window) == max_ack_seq_wnd; max_ack_seq_wnd = ntohs(th->window); max_ack_seq = ack_seq; @@ -2435,7 +2436,8 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn, if (ack) { conn->ts_ack_from_tap = *now; - conn->tap_data_noack = ((struct timespec) { 0, 0 }); + if (max_ack_seq == conn->seq_to_tap) + conn->tap_data_noack = ((struct timespec) { 0, 0 }); tcp_sock_consume(conn, max_ack_seq); }