summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2011-02-03 11:52:22 +0000
committerrrs <rrs@FreeBSD.org>2011-02-03 11:52:22 +0000
commit4d632ac7a73ec1c318e0c2aeca0d01609a52dcc6 (patch)
treeb5821cc4586f3c279069f54470f7cbef91c71f88
parentd2daebca5a3e66dcf1823aec44dcbeb61f5fe78e (diff)
downloadFreeBSD-src-4d632ac7a73ec1c318e0c2aeca0d01609a52dcc6.zip
FreeBSD-src-4d632ac7a73ec1c318e0c2aeca0d01609a52dcc6.tar.gz
Fix the per CPU stats so that:
1) They don't use the giant "MAX_CPU" define and instead are allocated dynamically based on mp_ncpus 2) Will zero with the netstat -z -s -p sctp 3) Will be properly handled by both the sctp_init and finish (the multi-net stuff was incorrectly bzero'ing in sctp_init the wrong size.. the bzero is now moved to the right places). And of course the free is put in at the very end. MFC after: 3 Months
-rw-r--r--sys/netinet/sctp_pcb.c14
-rw-r--r--sys/netinet/sctp_pcb.h6
-rw-r--r--sys/netinet/sctp_sysctl.c22
-rw-r--r--sys/netinet/sctp_usrreq.c5
4 files changed, 39 insertions, 8 deletions
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index d9efe17..44de6a5 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -1,5 +1,8 @@
/*-
* Copyright (c) 2001-2008, 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:
@@ -5599,11 +5602,18 @@ sctp_pcb_init()
#if defined(SCTP_LOCAL_TRACE_BUF)
bzero(&SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
#endif
+#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+ SCTP_MALLOC(SCTP_BASE_STATS, struct sctpstat *,
+ (mp_ncpus * sizeof(struct sctpstat)),
+ SCTP_M_MCORE);
+#endif
(void)SCTP_GETTIME_TIMEVAL(&tv);
#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+ bzero(SCTP_BASE_STATS, (sizeof(struct sctpstat) * mp_ncpus));
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = (uint32_t) tv.tv_sec;
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = (uint32_t) tv.tv_usec;
#else
+ bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat));
SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t) tv.tv_sec;
SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t) tv.tv_usec;
#endif
@@ -5846,7 +5856,9 @@ sctp_pcb_finish(void)
SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_ephash), SCTP_BASE_INFO(hashmark));
if (SCTP_BASE_INFO(sctp_tcpephash) != NULL)
SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_tcpephash), SCTP_BASE_INFO(hashtcpmark));
-
+#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+ SCTP_FREE(SCTP_BASE_STATS, SCTP_M_MCORE);
+#endif
}
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index fb7857e..44b2fa8 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -1,6 +1,8 @@
/*-
* Copyright (c) 2001-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:
*
@@ -240,7 +242,7 @@ struct sctp_base_info {
*/
struct sctp_epinfo sctppcbinfo;
#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
- struct sctpstat sctpstat[MAXCPU];
+ struct sctpstat *sctpstat;
#else
struct sctpstat sctpstat;
#endif
diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c
index 350b0f8..ca62d10 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
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 6abeb38..894c875 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -1,5 +1,8 @@
/*-
* Copyright (c) 2001-2008, 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:
@@ -60,8 +63,6 @@ sctp_init(void)
{
u_long sb_max_adj;
- bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat));
-
/* Initialize and modify the sysctled variables */
sctp_init_sysctls();
if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE)
OpenPOWER on IntegriCloud