diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-11-17 11:08:19 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-11-17 23:24:00 +0100 |
commit | 3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509 (patch) | |
tree | 01f077c21dbc2039e5d13bea4e5024968150e412 | |
parent | 8ae00f8d5d0c482fd450e2c70592b0dbd293d4fa (diff) | |
download | passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar.gz passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar.bz2 passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar.lz passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar.xz passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.tar.zst passt-3a93acc7c4c0eb26eab4f6a2362ce89fb4b70509.zip |
tcp: Acknowledge keep-alive segments, ignore them for the restpodman24572
RFC 9293, 3.8.4 says:
Implementers MAY include "keep-alives" in their TCP implementations
(MAY-5), although this practice is not universally accepted. Some
TCP implementations, however, have included a keep-alive mechanism.
To confirm that an idle connection is still active, these
implementations send a probe segment designed to elicit a response
from the TCP peer. Such a segment generally contains SEG.SEQ =
SND.NXT-1 and may or may not contain one garbage octet of data. If
keep-alives are included, the application MUST be able to turn them
on or off for each TCP connection (MUST-24), and they MUST default to
off (MUST-25).
but currently, tcp_data_from_tap() is not aware of this and will
schedule a fast re-transmit on the second keep-alive (because it's
also a duplicate ACK), ignoring the fact that the sequence number was
rewinded to SND.NXT-1.
Send ACK segments when we receive those segments, reset the activity
timeout, and ignore them for the rest. We can't affect the outbound
keep-alive behaviour, other than enabling or disabling keep-alives
with SO_KEEPALIVE, because it's controlled by sysctls.
Link: https://github.com/containers/podman/discussions/24572
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | tcp.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1763,6 +1763,20 @@ static int tcp_data_from_tap(const struct ctx *c, struct tcp_tap_conn *conn, continue; seq = ntohl(th->seq); + if (SEQ_LT(seq, conn->seq_from_tap) && len <= 1) { + flow_trace(conn, + "keep-alive sequence: %u, previous: %u", + seq, conn->seq_from_tap); + + tcp_send_flag(c, conn, ACK); + tcp_timer_ctl(c, conn); + + if (p->count == 1) + return 1; + + continue; + } + ack_seq = ntohl(th->ack_seq); if (th->ack) { |