diff options
Diffstat (limited to 'tcp.c')
| -rw-r--r-- | tcp.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -2091,7 +2091,9 @@ static int tcp_data_from_tap(const struct ctx *c, struct tcp_tap_conn *conn, tcp_tap_window_update(c, conn, max_ack_seq_wnd, now); - if (retr) { + if (retr && !conn->retries) { + conn->retries++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", conn->seq_ack_from_tap, conn->seq_to_tap); @@ -2427,6 +2429,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, /* Established connections not accepting data from tap */ if (conn->events & TAP_FIN_RCVD) { + uint32_t prev_ack = conn->seq_ack_from_tap; + uint16_t prev_wnd = conn->wnd_from_tap; bool fin_only, retr; size_t dlen; @@ -2442,7 +2446,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, fin_only = (conn->events & TAP_FIN_SENT) && conn->seq_to_tap == conn->seq_ack_from_tap + 1; - retr = th->ack && !th->fin && !fin_only && + retr = th->ack && !th->fin && !fin_only && !conn->retries && ntohl(th->ack_seq) == conn->seq_ack_from_tap && ntohs(th->window) == conn->wnd_from_tap; @@ -2454,6 +2458,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, now); if (retr) { + conn->retries++; + flow_trace(conn, "fast re-transmit, ACK: %u, previous sequence: %u", ntohl(th->ack_seq), conn->seq_to_tap); @@ -2462,8 +2468,11 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, return -1; } - if (tcp_tap_window_update(c, conn, ntohs(th->window), now) || - retr) + /* An unchanged ACK and window must not restart the timer. */ + if (tcp_tap_window_update(c, conn, ntohs(th->window), now) && + (retr || + prev_ack != conn->seq_ack_from_tap || + prev_wnd != conn->wnd_from_tap)) tcp_data_from_sock(c, conn, now); if (conn->seq_ack_from_tap == conn->seq_to_tap) { |
