Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2012 19:12:23 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r231404 - stable/8/sys/netinet
Message-ID:  <201202101912.q1AJCNu0089215@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Fri Feb 10 19:12:23 2012
New Revision: 231404
URL: http://svn.freebsd.org/changeset/base/231404

Log:
  MFC r218219:
  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.
  From rrs@.

Modified:
  stable/8/sys/netinet/sctp_pcb.c
  stable/8/sys/netinet/sctp_pcb.h
  stable/8/sys/netinet/sctp_sysctl.c
  stable/8/sys/netinet/sctp_usrreq.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/boot/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)

Modified: stable/8/sys/netinet/sctp_pcb.c
==============================================================================
--- stable/8/sys/netinet/sctp_pcb.c	Fri Feb 10 19:10:09 2012	(r231403)
+++ stable/8/sys/netinet/sctp_pcb.c	Fri Feb 10 19:12:23 2012	(r231404)
@@ -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
 }
 
 

Modified: stable/8/sys/netinet/sctp_pcb.h
==============================================================================
--- stable/8/sys/netinet/sctp_pcb.h	Fri Feb 10 19:10:09 2012	(r231403)
+++ stable/8/sys/netinet/sctp_pcb.h	Fri Feb 10 19:12:23 2012	(r231404)
@@ -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

Modified: stable/8/sys/netinet/sctp_sysctl.c
==============================================================================
--- stable/8/sys/netinet/sctp_sysctl.c	Fri Feb 10 19:10:09 2012	(r231403)
+++ stable/8/sys/netinet/sctp_sysctl.c	Fri Feb 10 19:12:23 2012	(r231404)
@@ -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, ou
 #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

Modified: stable/8/sys/netinet/sctp_usrreq.c
==============================================================================
--- stable/8/sys/netinet/sctp_usrreq.c	Fri Feb 10 19:10:09 2012	(r231403)
+++ stable/8/sys/netinet/sctp_usrreq.c	Fri Feb 10 19:12:23 2012	(r231404)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202101912.q1AJCNu0089215>