diff options
author | Randall Stewart <rrs@FreeBSD.org> | 2011-02-03 11:52:22 +0000 |
---|---|---|
committer | Randall Stewart <rrs@FreeBSD.org> | 2011-02-03 11:52:22 +0000 |
commit | ae26e0a472ae50ea75a9cf23bb8b1cf1dfc2045e (patch) | |
tree | b5821cc4586f3c279069f54470f7cbef91c71f88 /sys/netinet/sctp_sysctl.c | |
parent | 32ecf620285e971bdc39a43766a8487e8189afcc (diff) | |
download | src-test2-ae26e0a472ae50ea75a9cf23bb8b1cf1dfc2045e.tar.gz src-test2-ae26e0a472ae50ea75a9cf23bb8b1cf1dfc2045e.zip |
Notes
Diffstat (limited to 'sys/netinet/sctp_sysctl.c')
-rw-r--r-- | sys/netinet/sctp_sysctl.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c index 350b0f85ebda..ca62d10c315b 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -1,5 +1,8 @@ /*- * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and + * Michael Tuexen, tuexen@fh-muenster.de + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -648,8 +651,18 @@ static int sysctl_stat_get(SYSCTL_HANDLER_ARGS) { int cpu, error; - struct sctpstat sb, *sarry; - + struct sctpstat sb, *sarry, *cpin = NULL; + + if ((req->newptr) && (req->newlen == sizeof(struct sctpstat))) { + /* + * User wants us to clear or at least reset the counters to + * the specified values. + */ + cpin = (struct sctpstat *)req->newptr; + } else if (req->newptr) { + /* Must be a stat structure */ + return (EINVAL); + } memset(&sb, 0, sizeof(sb)); for (cpu = 0; cpu < mp_ncpus; cpu++) { sarry = &SCTP_BASE_STATS[cpu]; @@ -789,6 +802,9 @@ sysctl_stat_get(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 (cpin) { + memcpy(sarry, cpin, sizeof(struct sctpstat)); + } } error = SYSCTL_OUT(req, &sb, sizeof(sb)); return (error); @@ -1099,7 +1115,7 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_UINT | CTLFLAG_RW #endif #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, - CTLTYPE_STRUCT | CTLFLAG_RD, + CTLTYPE_STRUCT | CTLFLAG_RW, 0, 0, sysctl_stat_get, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); #else |