diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2023-07-07 16:27:47 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2023-07-07 16:27:47 +0000 |
commit | 14ae7576767ec9bdee0f044ae1e023e3fb00ffff (patch) | |
tree | 9fb48282b8b010c97e777428dbed51fff88c5141 /sys | |
parent | 8c23a9d978e620837931a297353d3bb965d772cd (diff) |
Expand the counters in struct mbstat from u_short to u_long. Use
malloc(9) memory instead of kernel stack for sysctl kern.mbstat.
from yasuoka@; chunk missed in previous commit; OK claudio@ tb@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sysctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2c79d238113..b71f9824be1 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.416 2023/07/02 19:02:27 cheloha Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.417 2023/07/07 16:27:46 bluhm Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -515,20 +515,22 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case KERN_MBSTAT: { extern struct cpumem *mbstat; uint64_t counters[MBSTAT_COUNT]; - struct mbstat mbs; + struct mbstat *mbs; unsigned int i; + int ret; - memset(&mbs, 0, sizeof(mbs)); + mbs = malloc(sizeof(*mbs), M_TEMP, M_WAITOK | M_ZERO); counters_read(mbstat, counters, MBSTAT_COUNT); for (i = 0; i < MBSTAT_TYPES; i++) - mbs.m_mtypes[i] = counters[i]; + mbs->m_mtypes[i] = counters[i]; - mbs.m_drops = counters[MBSTAT_DROPS]; - mbs.m_wait = counters[MBSTAT_WAIT]; - mbs.m_drain = counters[MBSTAT_DRAIN]; + mbs->m_drops = counters[MBSTAT_DROPS]; + mbs->m_wait = counters[MBSTAT_WAIT]; + mbs->m_drain = counters[MBSTAT_DRAIN]; - return (sysctl_rdstruct(oldp, oldlenp, newp, - &mbs, sizeof(mbs))); + ret = sysctl_rdstruct(oldp, oldlenp, newp, mbs, sizeof(*mbs)); + free(mbs, M_TEMP, sizeof(*mbs)); + return (ret); } case KERN_MSGBUFSIZE: case KERN_CONSBUFSIZE: { |