summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_output.c
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2015-07-13 23:11:37 +0000
committerbluhm <bluhm@openbsd.org>2015-07-13 23:11:37 +0000
commit72b3c704c8fc74d075f043610149f353a1628c0c (patch)
treef34d1d50a6e239f516176cf9c77241a873eed144 /sys/netinet/tcp_output.c
parentDo not attempt to configure octhci, superseded by dwc2 (diff)
downloadwireguard-openbsd-72b3c704c8fc74d075f043610149f353a1628c0c.tar.xz
wireguard-openbsd-72b3c704c8fc74d075f043610149f353a1628c0c.zip
Avoid a situation where we do not set the tcp persist timer after
a zero window condition. If you send a 0-length packet, but there is data is the socket buffer, and neither the rexmt or persist timer is already set, then activate the persist timer. From FreeBSD revision 284941; OK deraadt@ markus@ mikeb@ claudio@
Diffstat (limited to 'sys/netinet/tcp_output.c')
-rw-r--r--sys/netinet/tcp_output.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 734403d0c61..f52ea666340 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_output.c,v 1.112 2015/06/30 15:30:17 mpi Exp $ */
+/* $OpenBSD: tcp_output.c,v 1.113 2015/07/13 23:11:37 bluhm Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@@ -1008,6 +1008,32 @@ send:
tp->t_rxtshift = 0;
}
}
+
+ if (len == 0 && so->so_snd.sb_cc &&
+ TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0 &&
+ TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
+ /*
+ * Avoid a situation where we do not set persist timer
+ * after a zero window condition. For example:
+ * 1) A -> B: packet with enough data to fill the window
+ * 2) B -> A: ACK for #1 + new data (0 window
+ * advertisement)
+ * 3) A -> B: ACK for #2, 0 len packet
+ *
+ * In this case, A will not activate the persist timer,
+ * because it chose to send a packet. Unless tcp_output
+ * is called for some other reason (delayed ack timer,
+ * another input packet from B, socket syscall), A will
+ * not send zero window probes.
+ *
+ * So, if you send a 0-length packet, but there is data
+ * in the socket buffer, and neither the rexmt or
+ * persist timer is already set, then activate the
+ * persist timer.
+ */
+ tp->t_rxtshift = 0;
+ tcp_setpersist(tp);
+ }
} else
if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
tp->snd_max = tp->snd_nxt + len;