aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-03-27 14:56:34 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-03-29 13:47:07 +0200
commit4e73e9bd655c8ebb3e253284f51d4349eea1cc5c (patch)
tree680864efaf7627cf595ae42e5ee78bc219ef9d46 /tcp.c
parent085672f77cce3e91a116ac39cff581bca64ba50a (diff)
downloadpasst-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar.gz
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar.bz2
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar.lz
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar.xz
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.tar.zst
passt-4e73e9bd655c8ebb3e253284f51d4349eea1cc5c.zip
tcp: Don't special case the handling of the ack of a syn
TCP treats the SYN packets as though they occupied 1 byte in the logical data stream described by the sequence numbers. That is, the very first ACK (or SYN-ACK) each side sends should acknowledge a sequence number one greater than the initial sequence number given in the SYN or SYN-ACK it's responding to. In passt we were tracking that by advancing conn->seq_to_tap by one when we send a SYN or SYN-ACK (in tcp_send_flag()). However, we also initialized conn->seq_ack_from_tap, representing the acks we've already seen from the tap side, to ISN+1, meaning we treated it has having acknowledged the SYN before it actually did. There were apparently reasons for this in earlier versions, but it causes problems now. Because of this when we actually did receive the initial ACK or SYN-ACK, we wouldn't see the acknoweldged serial number as advancing, and so wouldn't clear the ACK_FROM_TAP_DUE flag. In most cases we'd get away because subsequent packets would clear the flag. However if one (or both) sides didn't send any data, the other side would (correctly) keep sending ISN+1 as the acknowledged sequence number, meaning we would never clear the ACK_FROM_TAP_DUE flag. That would mean we'd treat the connection as if we needed to retransmit (although we had 0 bytes to retransmit), and eventaully (after around 30s) reset the connection due to too many retransmits. Specifically this could cause the iperf3 throughput tests in the testsuite to fail if set for a long enough test period. Correct this by initializing conn->seq_ack_from_tap to the ISN and only advancing it when we actually get the first ACK (or SYN-ACK). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tcp.c b/tcp.c
index d82c62e..bbdee60 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2096,7 +2096,7 @@ static void tcp_conn_from_tap(struct ctx *c, int af, const void *addr,
conn->seq_ack_to_tap = conn->seq_from_tap;
tcp_seq_init(c, conn, now);
- conn->seq_ack_from_tap = conn->seq_to_tap + 1;
+ conn->seq_ack_from_tap = conn->seq_to_tap;
tcp_hash_insert(c, conn);
@@ -2754,7 +2754,7 @@ static void tcp_tap_conn_from_sock(struct ctx *c, union epoll_ref ref,
tcp_seq_init(c, conn, now);
tcp_hash_insert(c, conn);
- conn->seq_ack_from_tap = conn->seq_to_tap + 1;
+ conn->seq_ack_from_tap = conn->seq_to_tap;
conn->wnd_from_tap = WINDOW_DEFAULT;