aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-03-26 16:42:22 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-03-26 09:51:55 +0100
commit16c2d8da0d309e7e6cecc877acfd0f7fb6758d64 (patch)
tree18b410f137aca792912e6e01b84c2b0e42df2999
parent99355e25b9bd59f0e3d59245e10c765e7edfb213 (diff)
downloadpasst-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar.gz
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar.bz2
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar.lz
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar.xz
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.tar.zst
passt-16c2d8da0d309e7e6cecc877acfd0f7fb6758d64.zip
tcp: Rearrange logic for setting ACK flag in tcp_send_flag()
We have different paths for controlling the ACK flag for the SYN and !SYN paths. This amounts to sometimes forcing on the ACK flag in the !SYN path regardless of options. We can rearrange things to explicitly be that which will make things neater for some future changes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tcp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/tcp.c b/tcp.c
index edd3d89..47954d1 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1674,16 +1674,15 @@ static int tcp_send_flag(struct ctx *c, struct tcp_tap_conn *conn, int flags)
*data++ = OPT_WS;
*data++ = OPT_WS_LEN;
*data++ = conn->ws_to_tap;
-
- th->ack = !!(flags & ACK);
} else {
- th->ack = !!(flags & ACK)) ||
- conn->seq_ack_to_tap != prev_ack_to_tap ||
- !prev_wnd_to_tap;
+ if (conn->seq_ack_to_tap != prev_ack_to_tap ||
+ !prev_wnd_to_tap)
+ flags |= ACK;
}
th->doff = (sizeof(*th) + optlen) / 4;
+ th->ack = !!(flags & ACK);
th->rst = !!(flags & RST);
th->syn = !!(flags & SYN);
th->fin = !!(flags & FIN);