Don't zero the stats before they are read out.

MFC after: 3 days
This commit is contained in:
Michael Tuexen 2014-11-01 10:35:45 +00:00
parent 4b52e0d84f
commit f885296d70
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273925

View File

@ -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);
}