diff options
author | tuexen <tuexen@FreeBSD.org> | 2014-11-01 10:35:45 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2014-11-01 10:35:45 +0000 |
commit | 1a120e5b15fafa033d35d47ff2a1e66ae634a624 (patch) | |
tree | abec86f44d1948eb691806711665cb36f5824ecb /sys/netinet | |
parent | b68d08643b98891f9821813e0d94960f344118de (diff) | |
download | FreeBSD-src-1a120e5b15fafa033d35d47ff2a1e66ae634a624.zip FreeBSD-src-1a120e5b15fafa033d35d47ff2a1e66ae634a624.tar.gz |
Don't zero the stats before they are read out.
MFC after: 3 days
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/sctp_sysctl.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c index b0b0378..1ca5983 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -636,26 +636,27 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) int error; #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) - struct sctpstat sb_temp; struct sctpstat *sarry; struct sctpstat sb; int cpu; + #endif + struct sctpstat sb_temp; if ((req->newptr != NULL) && (req->newlen != sizeof(struct sctpstat))) { return (EINVAL); } - -#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) - memset(&sb, 0, sizeof(sb)); - memset(&sb_temp, 0, sizeof(sb_temp)); + memset(&sb_temp, 0, sizeof(struct sctpstat)); if (req->newptr != NULL) { - error = SYSCTL_IN(req, &sb_temp, sizeof(sb_temp)); - if (error != 0) + error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat)); + if (error != 0) { return (error); + } } +#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) + memset(&sb, 0, sizeof(sb)); for (cpu = 0; cpu < mp_maxid; cpu++) { sarry = &SCTP_BASE_STATS[cpu]; if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { @@ -783,15 +784,19 @@ sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; - if (req->newptr != NULL) + if (req->newptr != NULL) { memcpy(sarry, &sb_temp, sizeof(struct sctpstat)); + } } error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); #else - error = SYSCTL_IN(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); - if (error) - return (error); error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); + if (error != 0) { + return (error); + } + if (req->newptr != NULL) { + memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat)); + } #endif return (error); } |