From a616357c864539d366f40ca37b687757c109144f Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 14 Sep 2021 16:54:06 +0200 Subject: tcp: In ESTABLISHED state, acknowledge segments as they're sent to the socket ...instead of waiting for the remote peer to do that -- it's especially important in case we request retransmissions from the guest, but it also helps speeding up slow start. This should probably be a configurable behaviour in the future. Signed-off-by: Stefano Brivio --- tcp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'tcp.c') diff --git a/tcp.c b/tcp.c index 4c6bfd0..e58658e 100644 --- a/tcp.c +++ b/tcp.c @@ -1200,8 +1200,9 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn, if (flags & SYN) { ack_pending = 0; - } else if (conn->no_snd_wnd) { - ack_pending = (conn->seq_from_tap - conn->seq_ack_to_tap) < + } else if (conn->state == ESTABLISHED || conn->no_snd_wnd) { + ack_pending = conn->seq_from_tap != conn->seq_ack_to_tap && + (conn->seq_from_tap - conn->seq_ack_to_tap) < MAX_WINDOW; } else { ack_pending = info.tcpi_bytes_acked > conn->tcpi_acked_last; @@ -1213,8 +1214,12 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn, if (conn->no_snd_wnd) { conn->seq_ack_to_tap = conn->seq_from_tap; } else { - conn->seq_ack_to_tap = info.tcpi_bytes_acked + - conn->seq_init_from_tap; + if (conn->state == ESTABLISHED) + conn->seq_ack_to_tap = conn->seq_from_tap; + else + conn->seq_ack_to_tap = info.tcpi_bytes_acked + + conn->seq_init_from_tap; + conn->tcpi_acked_last = info.tcpi_bytes_acked; } @@ -1770,9 +1775,13 @@ recvmmsg: * 90); } + if (conn->state == ESTABLISHED) + conn->seq_ack_to_tap = conn->seq_from_tap; + else + conn->seq_ack_to_tap = info.tcpi_bytes_acked + + conn->seq_init_from_tap; + conn->tcpi_acked_last = info.tcpi_bytes_acked; - conn->seq_ack_to_tap = info.tcpi_bytes_acked + - conn->seq_init_from_tap; } } else { info.tcpi_snd_wscale = conn->ws; -- cgit v1.2.3