summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2016-09-03 14:17:37 +0000
committerbluhm <bluhm@openbsd.org>2016-09-03 14:17:37 +0000
commit3ff1f68816ee1b6c04c9f9d1eb1c46a6768112dd (patch)
treee157007fc68e89361ce5f11e7f5a6dec6fce231c
parentadd support for Bidirectional Forwarding Detection (RFC 5880/5881). (diff)
downloadwireguard-openbsd-3ff1f68816ee1b6c04c9f9d1eb1c46a6768112dd.tar.xz
wireguard-openbsd-3ff1f68816ee1b6c04c9f9d1eb1c46a6768112dd.zip
Limit all mbuf cluster pools to the same memory size. Having limits
by number would allow the large clusters using too much memory. Set size of mclsizes array explicitly to keep it in sync with mclpools. OK claudio@
-rw-r--r--sys/kern/uipc_mbuf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index c34f5166338..bc8490f23e3 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.226 2016/06/13 21:24:43 bluhm Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.227 2016/09/03 14:17:37 bluhm Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -105,7 +105,7 @@ struct pool mbpool; /* mbuf pool */
struct pool mtagpool;
/* mbuf cluster pools */
-u_int mclsizes[] = {
+u_int mclsizes[MCLPOOLS] = {
MCLBYTES, /* must be at slot 0 */
4 * 1024,
8 * 1024,
@@ -179,15 +179,16 @@ mbinit(void)
void
nmbclust_update(void)
{
- int i;
+ unsigned int i, n;
+
/*
* Set the hard limit on the mclpools to the number of
* mbuf clusters the kernel is to support. Log the limit
* reached message max once a minute.
*/
for (i = 0; i < nitems(mclsizes); i++) {
- (void)pool_sethardlimit(&mclpools[i], nmbclust,
- mclpool_warnmsg, 60);
+ n = (unsigned long long)nmbclust * MCLBYTES / mclsizes[i];
+ (void)pool_sethardlimit(&mclpools[i], n, mclpool_warnmsg, 60);
/*
* XXX this needs to be reconsidered.
* Setting the high water mark to nmbclust is too high
@@ -195,7 +196,7 @@ nmbclust_update(void)
* allocations in interrupt context don't fail or mclgeti()
* drivers may end up with empty rings.
*/
- pool_sethiwat(&mclpools[i], nmbclust);
+ pool_sethiwat(&mclpools[i], n);
}
pool_sethiwat(&mbpool, nmbclust);
}