aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-05 19:51:03 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-05 20:02:03 +0200
commitd565082f84134cc22814bf959b8491e92353ab0b (patch)
tree8ecbdc3f6eadfad2c7a20310f8d938bb024557af /tcp.c
parenteda446ba54417396ee0379fa597af302a359452b (diff)
downloadpasst-d565082f84134cc22814bf959b8491e92353ab0b.tar
passt-d565082f84134cc22814bf959b8491e92353ab0b.tar.gz
passt-d565082f84134cc22814bf959b8491e92353ab0b.tar.bz2
passt-d565082f84134cc22814bf959b8491e92353ab0b.tar.lz
passt-d565082f84134cc22814bf959b8491e92353ab0b.tar.xz
passt-d565082f84134cc22814bf959b8491e92353ab0b.tar.zst
passt-d565082f84134cc22814bf959b8491e92353ab0b.zip
tcp: Simplify ACK-sending conditions in tcp_data_from_tap()
Now that we have a proper function checking when and how to send ACKs and window updates, we don't need to duplicate this logic in tcp_data_from_tap(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/tcp.c b/tcp.c
index fba118b..6752a59 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2324,7 +2324,7 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
struct tap_l4_msg *msg, int count,
struct timespec *now)
{
- int i, iov_i, ack = 0, fin = 0, psh = 0, retr = 0, keep = -1;
+ int i, iov_i, ack = 0, fin = 0, retr = 0, keep = -1;
struct msghdr mh = { .msg_iov = tcp_tap_iov };
uint32_t max_ack_seq = conn->seq_ack_from_tap;
uint16_t max_ack_seq_wnd = conn->wnd_from_tap;
@@ -2382,9 +2382,6 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
if (th->fin)
fin = 1;
- if (th->psh)
- psh = 1;
-
if (!len)
continue;
@@ -2411,11 +2408,8 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_tap_conn *conn,
* ^ seq
* (offset < 0)
*/
- if (SEQ_GE(seq_offset, 0) && SEQ_LE(seq + len, seq_from_tap)) {
- /* Force sending ACK, sender might have lost one */
- psh = 1;
+ if (SEQ_GE(seq_offset, 0) && SEQ_LE(seq + len, seq_from_tap))
continue;
- }
if (SEQ_LT(seq_offset, 0)) {
if (keep == -1)
@@ -2469,20 +2463,22 @@ eintr:
goto eintr;
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- tcp_send_to_tap(c, conn, UPDATE_WINDOW, now);
+ tcp_send_to_tap(c, conn, 0, now);
return;
}
tcp_rst(c, conn);
return;
}
+
if (n < (seq_from_tap - conn->seq_from_tap)) {
partial_send = 1;
- tcp_send_to_tap(c, conn, UPDATE_WINDOW, now);
+ conn->seq_from_tap += n;
+ tcp_send_to_tap(c, conn, 0, now);
+ } else {
+ conn->seq_from_tap += n;
}
- conn->seq_from_tap += n;
-
out:
if (keep != -1) {
if (conn->seq_dup_ack != conn->seq_from_tap) {
@@ -2511,14 +2507,7 @@ out:
tcp_send_to_tap(c, conn, ACK, now);
}
} else {
- int ack_to_tap = timespec_diff_ms(now, &conn->ts_ack_to_tap);
- int ack_offset = conn->seq_from_tap - conn->seq_ack_to_tap;
-
- if (c->mode == MODE_PASTA ||
- psh || SEQ_GE(ack_offset, conn->wnd_to_tap * 2 / 3) ||
- ack_to_tap > ACK_INTERVAL) {
- tcp_send_to_tap(c, conn, psh ? FORCE_ACK : 0, now);
- }
+ tcp_send_to_tap(c, conn, 0, now);
}
}