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 <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-10-16 16:58:16 +02:00
parent 85038e9410
commit 1ac0d52820

6
tcp.c
View file

@ -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) { if (!conn->wnd_from_tap || already_sent >= conn->wnd_from_tap) {
tcp_tap_epoll_mask(c, conn, conn->events | EPOLLET); tcp_tap_epoll_mask(c, conn, conn->events | EPOLLET);
conn->tap_data_noack = *now;
return 0; return 0;
} }
@ -2374,7 +2375,7 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
/* Fast re-transmit */ /* Fast re-transmit */
retr = !len && !th->fin && retr = !len && !th->fin &&
ack_seq == max_ack_seq && 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_wnd = ntohs(th->window);
max_ack_seq = ack_seq; 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) { if (ack) {
conn->ts_ack_from_tap = *now; 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); tcp_sock_consume(conn, max_ack_seq);
} }