diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-04-04 21:11:23 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-04-04 21:11:23 +0000 |
commit | be74a991397634f89ccac363121d95eadde289f7 (patch) | |
tree | c3a8c35b35a68f78a6c70abb3fc25335fb158ed6 | |
parent | aab88e9aaabc81a3811d81da7b9f40b223ad2f17 (diff) |
Correctly inherit and set the watermarks on socketbuffers.
This fixes the NFS problems reported on the mailing list
and ensures that accepted sockets have correct socketbuffer
setting. OK blambert@, henning@
-rw-r--r-- | sys/kern/uipc_socket2.c | 12 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 16 |
2 files changed, 16 insertions, 12 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index c1071fd3e19..6d3ddb84bc8 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.51 2010/09/24 02:59:45 claudio Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.52 2011/04/04 21:11:22 claudio Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -176,8 +176,16 @@ sonewconn(struct socket *head, int connstatus) /* * Inherit watermarks but those may get clamped in low mem situations. */ + if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat)) { + pool_put(&socket_pool, so); + return ((struct socket *)0); + } so->so_snd.sb_wat = head->so_snd.sb_wat; + so->so_snd.sb_lowat = head->so_snd.sb_lowat; + so->so_snd.sb_timeo = head->so_snd.sb_timeo; so->so_rcv.sb_wat = head->so_rcv.sb_wat; + so->so_rcv.sb_lowat = head->so_rcv.sb_lowat; + so->so_rcv.sb_timeo = head->so_rcv.sb_timeo; soqinsque(head, so, soqueue); if ((*so->so_proto->pr_usrreq)(so, PRU_ATTACH, NULL, NULL, NULL, @@ -353,6 +361,8 @@ soreserve(struct socket *so, u_long sndcc, u_long rcvcc) goto bad; if (sbreserve(&so->so_rcv, rcvcc)) goto bad2; + so->so_snd.sb_wat = sndcc; + so->so_rcv.sb_wat = rcvcc; if (so->so_rcv.sb_lowat == 0) so->so_rcv.sb_lowat = 1; if (so->so_snd.sb_lowat == 0) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 11a2012ede0..f5b5096dd9d 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.105 2010/10/10 22:02:50 bluhm Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.106 2011/04/04 21:11:22 claudio Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -652,16 +652,10 @@ tcp_attach(so) struct inpcb *inp; int error; - if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - /* if low on memory only allow smaller then default buffers */ - if (so->so_snd.sb_wat == 0 || - sbcheckreserve(so->so_snd.sb_wat, tcp_sendspace)) - so->so_snd.sb_wat = tcp_sendspace; - if (so->so_rcv.sb_wat == 0 || - sbcheckreserve(so->so_rcv.sb_wat, tcp_recvspace)) - so->so_rcv.sb_wat = tcp_recvspace; - - error = soreserve(so, so->so_snd.sb_wat, so->so_rcv.sb_wat); + if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0 || + sbcheckreserve(so->so_snd.sb_wat, tcp_sendspace) || + sbcheckreserve(so->so_rcv.sb_wat, tcp_recvspace)) { + error = soreserve(so, tcp_sendspace, tcp_recvspace); if (error) return (error); } |