summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-07-11 10:35:44 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-07-11 10:35:44 +0000
commitf00a2710ffcb9cfe5ca8a05fc3ae48077a8845fe (patch)
tree416de45c083a0f9beb21bb6803cbddc8ae987ee2 /sys/netinet
parent148df75c107eebb082988fbe0bc4c1b432b473ec (diff)
Do not increase the size of the socket buffer under memory pressure.
From Simon Mages, ok beck@, claudio@, bluhm@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/tcp_usrreq.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 964e330b405..6eb6efb8f7a 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.131 2016/06/18 10:36:13 vgross Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.132 2016/07/11 10:35:43 mpi Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -977,12 +977,13 @@ void
tcp_update_sndspace(struct tcpcb *tp)
{
struct socket *so = tp->t_inpcb->inp_socket;
- u_long nmax;
+ u_long nmax = so->so_snd.sb_hiwat;
- if (sbchecklowmem())
+ if (sbchecklowmem()) {
/* low on memory try to get rid of some */
- nmax = tcp_sendspace;
- else if (so->so_snd.sb_wat != tcp_sendspace)
+ if (tcp_sendspace < nmax)
+ nmax = tcp_sendspace;
+ } else if (so->so_snd.sb_wat != tcp_sendspace)
/* user requested buffer size, auto-scaling disabled */
nmax = so->so_snd.sb_wat;
else
@@ -1017,10 +1018,11 @@ tcp_update_rcvspace(struct tcpcb *tp)
struct socket *so = tp->t_inpcb->inp_socket;
u_long nmax = so->so_rcv.sb_hiwat;
- if (sbchecklowmem())
+ if (sbchecklowmem()) {
/* low on memory try to get rid of some */
- nmax = tcp_recvspace;
- else if (so->so_rcv.sb_wat != tcp_recvspace)
+ if (tcp_recvspace < nmax)
+ nmax = tcp_recvspace;
+ } else if (so->so_rcv.sb_wat != tcp_recvspace)
/* user requested buffer size, auto-scaling disabled */
nmax = so->so_rcv.sb_wat;
else {