aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2025-12-04 07:12:54 +0100
committerStefano Brivio <sbrivio@redhat.com>2025-12-08 09:15:36 +0100
commitcf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5 (patch)
tree37cf779a3f638829a93c16234bb8f19538f82620
parent9139e60fd455fafb753c838e554732aed5ecbcd3 (diff)
downloadpasst-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar.gz
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar.bz2
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar.lz
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar.xz
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.tar.zst
passt-cf1925fb7b777d1b4dae4816f30af1fa5c6ebfa5.zip
tcp: Don't limit window to less-than-MSS values, use zero instead
If the sender uses data clumping (including Nagle's algorithm) for Silly Window Syndrome (SWS) avoidance, advertising less than a MSS means the sender might stop sending altogether, and window updates after a low window condition are just as important as they are in a zero-window condition. For simplicity, approximate that limit to zero, as we have an implementation forcing window updates after zero-sized windows. This matches the suggestion from RFC 813, section 4. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--tcp.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tcp.c b/tcp.c
index 4080a1e..8bf1b51 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1158,6 +1158,23 @@ int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn,
else
limit = SNDBUF_GET(conn) - (int)sendq;
+ /* If the sender uses mechanisms to prevent Silly Window
+ * Syndrome (SWS, described in RFC 813 Section 3) it's critical
+ * that, should the window ever become less than the MSS, we
+ * advertise a new value once it increases again to be above it.
+ *
+ * The mechanism to avoid SWS in the kernel is, implicitly,
+ * implemented by Nagle's algorithm (which was proposed after
+ * RFC 813).
+ *
+ * To this end, for simplicity, approximate a window value below
+ * the MSS to zero, as we already have mechanisms in place to
+ * force updates after the window becomes zero. This matches the
+ * suggestion from RFC 813, Section 4.
+ */
+ if (limit < MSS_GET(conn))
+ limit = 0;
+
new_wnd_to_tap = MIN((int)tinfo->tcpi_snd_wnd, limit);
}