summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2003-01-25 15:27:29 +0000
committermarkus <markus@openbsd.org>2003-01-25 15:27:29 +0000
commitf4c7fcbfb8b2939e8f1588bffd15a7a207eba706 (patch)
tree204d3c23ae3b78d13af0c8d522788bef693bf653
parents -> z; thanks naddy@ (diff)
downloadwireguard-openbsd-f4c7fcbfb8b2939e8f1588bffd15a7a207eba706.tar.xz
wireguard-openbsd-f4c7fcbfb8b2939e8f1588bffd15a7a207eba706.zip
don't send more than half of the send buffer space limit in
one tcp segment, improves performance of tcp over interfaces with large mtu (e.g. lo0); based on similar change in netbsd; ok djm, henning, henric, millert, deraadt
-rw-r--r--sys/netinet/tcp_output.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 5523f172ec8..7ce63727feb 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_output.c,v 1.53 2002/08/28 15:43:03 pefo Exp $ */
+/* $OpenBSD: tcp_output.c,v 1.54 2003/01/25 15:27:29 markus Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@@ -220,7 +220,7 @@ tcp_output(tp)
register struct tcpcb *tp;
{
register struct socket *so = tp->t_inpcb->inp_socket;
- register long len, win;
+ register long len, win, txmaxseg;
int off, flags, error;
register struct mbuf *m;
register struct tcphdr *th;
@@ -383,8 +383,17 @@ again:
tcp_setpersist(tp);
}
}
- if (len > tp->t_maxseg) {
- len = tp->t_maxseg;
+
+ /*
+ * Never send more than half a buffer full. This insures that we can
+ * always keep 2 packets on the wire, no matter what SO_SNDBUF is, and
+ * therefore acks will never be delayed unless we run out of data to
+ * transmit.
+ */
+ txmaxseg = ulmin(so->so_snd.sb_hiwat / 2, tp->t_maxseg);
+
+ if (len > txmaxseg) {
+ len = txmaxseg;
sendalot = 1;
}
if (off + len < so->so_snd.sb_cc)
@@ -403,7 +412,7 @@ again:
* to send into a small window), then must resend.
*/
if (len) {
- if (len == tp->t_maxseg)
+ if (len == txmaxseg)
goto send;
if ((idle || tp->t_flags & TF_NODELAY) &&
len + off >= so->so_snd.sb_cc)