tcp: Request retransmission with updated sequence also on partial write to socket

If we couldn't write the whole batch of received packets to the socket,
and we have missing segments, we still need to request their
retransmission right away, otherwise it will take ages for the guest to
figure out we're missing them.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-09-14 07:15:08 +02:00
parent a616357c86
commit 9af8e0a1a7

19
tcp.c
View file

@ -2088,13 +2088,8 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
return; return;
} }
if (keep != -1) {
tcp_send_to_tap(c, conn, ACK, NULL, 0);
tcp_send_to_tap(c, conn, ACK, NULL, 0);
}
if (!iov_i) if (!iov_i)
goto fin_check; goto out;
mh.msg_iovlen = iov_i; mh.msg_iovlen = iov_i;
eintr: eintr:
@ -2114,14 +2109,16 @@ eintr:
if (len < (seq_from_tap - conn->seq_from_tap)) { if (len < (seq_from_tap - conn->seq_from_tap)) {
conn->seq_from_tap += len; conn->seq_from_tap += len;
tcp_send_to_tap(c, conn, ZERO_WINDOW, NULL, 0); tcp_send_to_tap(c, conn, ZERO_WINDOW, NULL, 0);
return; } else {
conn->seq_from_tap += len;
} }
conn->seq_from_tap += len; out:
if (keep != -1) {
fin_check: tcp_send_to_tap(c, conn, ACK, NULL, 0);
if (keep != -1) tcp_send_to_tap(c, conn, ACK, NULL, 0);
return; return;
}
if (ack) { if (ack) {
if (conn->state == ESTABLISHED_SOCK_FIN_SENT && if (conn->state == ESTABLISHED_SOCK_FIN_SENT &&