summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-09-24 02:59:47 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-09-24 02:59:47 +0000
commit31e2f59e8c8a6fa052489381e45a195e88ce638c (patch)
tree986bd8c580c587575ac30f491bb3ca9e441f0d75 /sys/kern/uipc_socket.c
parent1e5d893cfbeb506fb1db4168cecd4a2484185f27 (diff)
TCP send and recv buffer scaling.
Send buffer is scaled by not accounting unacknowledged on the wire data against the buffer limit. Receive buffer scaling is done similar to FreeBSD -- measure the delay * bandwith product and base the buffer on that. The problem is that our RTT measurment is coarse so it overshoots on low delay links. This does not matter that much since the recvbuffer is almost always empty. Add a back pressure mechanism to control the amount of memory assigned to socketbuffers that kicks in when 80% of the cluster pool is used. Increases the download speed from 300kB/s to 4.4MB/s on ftp.eu.openbsd.org. Based on work by markus@ and djm@. OK dlg@, henning@, put it in deraadt@
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 5c2e7448bb0..53648922f37 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.83 2010/07/03 04:44:51 guenther Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.84 2010/09/24 02:59:45 claudio Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1036,19 +1036,21 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0)
switch (optname) {
case SO_SNDBUF:
- if (sbcheckreserve(cnt, so->so_snd.sb_hiwat) ||
+ if (sbcheckreserve(cnt, so->so_snd.sb_wat) ||
sbreserve(&so->so_snd, cnt)) {
error = ENOBUFS;
goto bad;
}
+ so->so_snd.sb_wat = cnt;
break;
case SO_RCVBUF:
- if (sbcheckreserve(cnt, so->so_rcv.sb_hiwat) ||
+ if (sbcheckreserve(cnt, so->so_rcv.sb_wat) ||
sbreserve(&so->so_rcv, cnt)) {
error = ENOBUFS;
goto bad;
}
+ so->so_rcv.sb_wat = cnt;
break;
case SO_SNDLOWAT: