10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51676Sjpk * Common Development and Distribution License (the "License").
61676Sjpk * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
211735Skcpoon
220Sstevel@tonic-gate /*
2312869SKacheong.Poon@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/stream.h>
280Sstevel@tonic-gate #include <sys/cmn_err.h>
290Sstevel@tonic-gate #define _SUN_TPI_VERSION 2
300Sstevel@tonic-gate #include <sys/tihdr.h>
310Sstevel@tonic-gate #include <sys/ddi.h>
320Sstevel@tonic-gate #include <sys/sunddi.h>
331676Sjpk #include <sys/tsol/tndb.h>
340Sstevel@tonic-gate
350Sstevel@tonic-gate #include <netinet/in.h>
360Sstevel@tonic-gate
370Sstevel@tonic-gate #include <inet/common.h>
380Sstevel@tonic-gate #include <inet/ip.h>
390Sstevel@tonic-gate #include <inet/mib2.h>
400Sstevel@tonic-gate #include <inet/snmpcom.h>
410Sstevel@tonic-gate #include <inet/kstatcom.h>
420Sstevel@tonic-gate #include <inet/ipclassifier.h>
430Sstevel@tonic-gate #include "sctp_impl.h"
440Sstevel@tonic-gate #include "sctp_addr.h"
450Sstevel@tonic-gate
4612869SKacheong.Poon@Sun.COM static void sctp_clr_kstats2(sctp_kstat_t *);
4712869SKacheong.Poon@Sun.COM static void sctp_add_kstats2(sctp_kstat_counter_t *, sctp_kstat_t *);
4812869SKacheong.Poon@Sun.COM static int sctp_snmp_state(sctp_t *);
4912869SKacheong.Poon@Sun.COM static void sctp_sum_mib(sctp_stack_t *, mib2_sctp_t *);
5012869SKacheong.Poon@Sun.COM static void sctp_add_mib(mib2_sctp_t *, mib2_sctp_t *);
511735Skcpoon
520Sstevel@tonic-gate static int
sctp_kstat_update(kstat_t * kp,int rw)530Sstevel@tonic-gate sctp_kstat_update(kstat_t *kp, int rw)
540Sstevel@tonic-gate {
550Sstevel@tonic-gate sctp_named_kstat_t *sctpkp;
560Sstevel@tonic-gate sctp_t *sctp, *sctp_prev;
573448Sdh155122 zoneid_t myzoneid;
583448Sdh155122 netstackid_t stackid = (netstackid_t)(uintptr_t)kp->ks_private;
593448Sdh155122 netstack_t *ns;
603448Sdh155122 sctp_stack_t *sctps;
6112869SKacheong.Poon@Sun.COM mib2_sctp_t sctp_mib;
620Sstevel@tonic-gate
630Sstevel@tonic-gate if (kp == NULL|| kp->ks_data == NULL)
640Sstevel@tonic-gate return (EIO);
650Sstevel@tonic-gate
660Sstevel@tonic-gate if (rw == KSTAT_WRITE)
670Sstevel@tonic-gate return (EACCES);
680Sstevel@tonic-gate
693448Sdh155122 ns = netstack_find_by_stackid(stackid);
703448Sdh155122 if (ns == NULL)
713448Sdh155122 return (-1);
723448Sdh155122 sctps = ns->netstack_sctp;
733448Sdh155122 if (sctps == NULL) {
743448Sdh155122 netstack_rele(ns);
753448Sdh155122 return (-1);
763448Sdh155122 }
7712869SKacheong.Poon@Sun.COM
7812869SKacheong.Poon@Sun.COM /*
7912869SKacheong.Poon@Sun.COM * For all exclusive netstacks, the zone ID is always GLOBAL_ZONEID.
8012869SKacheong.Poon@Sun.COM */
8112869SKacheong.Poon@Sun.COM if (stackid != GLOBAL_NETSTACKID)
8212869SKacheong.Poon@Sun.COM myzoneid = GLOBAL_ZONEID;
8312869SKacheong.Poon@Sun.COM else
8412869SKacheong.Poon@Sun.COM myzoneid = curproc->p_zone->zone_id;
8512869SKacheong.Poon@Sun.COM
8612869SKacheong.Poon@Sun.COM bzero(&sctp_mib, sizeof (sctp_mib));
870Sstevel@tonic-gate
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate * Get the number of current associations and gather their
900Sstevel@tonic-gate * individual set of statistics.
910Sstevel@tonic-gate */
920Sstevel@tonic-gate sctp_prev = NULL;
933448Sdh155122 mutex_enter(&sctps->sctps_g_lock);
9411042SErik.Nordmark@Sun.COM sctp = list_head(&sctps->sctps_g_list);
950Sstevel@tonic-gate while (sctp != NULL) {
960Sstevel@tonic-gate mutex_enter(&sctp->sctp_reflock);
970Sstevel@tonic-gate if (sctp->sctp_condemned) {
980Sstevel@tonic-gate mutex_exit(&sctp->sctp_reflock);
993448Sdh155122 sctp = list_next(&sctps->sctps_g_list, sctp);
1000Sstevel@tonic-gate continue;
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate sctp->sctp_refcnt++;
1030Sstevel@tonic-gate mutex_exit(&sctp->sctp_reflock);
1043448Sdh155122 mutex_exit(&sctps->sctps_g_lock);
1050Sstevel@tonic-gate if (sctp_prev != NULL)
1060Sstevel@tonic-gate SCTP_REFRELE(sctp_prev);
1073448Sdh155122 if (sctp->sctp_connp->conn_zoneid != myzoneid)
1080Sstevel@tonic-gate goto next_sctp;
1090Sstevel@tonic-gate if (sctp->sctp_state == SCTPS_ESTABLISHED ||
1100Sstevel@tonic-gate sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
1110Sstevel@tonic-gate sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
11212869SKacheong.Poon@Sun.COM /*
11312869SKacheong.Poon@Sun.COM * Just bump the local sctp_mib. The number of
11412869SKacheong.Poon@Sun.COM * existing associations is not kept in kernel.
11512869SKacheong.Poon@Sun.COM */
11612869SKacheong.Poon@Sun.COM BUMP_MIB(&sctp_mib, sctpCurrEstab);
1170Sstevel@tonic-gate }
1180Sstevel@tonic-gate
1190Sstevel@tonic-gate if (sctp->sctp_opkts) {
12012869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutSCTPPkts,
1210Sstevel@tonic-gate sctp->sctp_opkts);
1220Sstevel@tonic-gate sctp->sctp_opkts = 0;
1230Sstevel@tonic-gate }
1240Sstevel@tonic-gate
1250Sstevel@tonic-gate if (sctp->sctp_obchunks) {
12612869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutCtrlChunks,
1270Sstevel@tonic-gate sctp->sctp_obchunks);
12810751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_obchunks,
12910751SGeorge.Shepherd@Sun.COM sctp->sctp_obchunks);
1300Sstevel@tonic-gate sctp->sctp_obchunks = 0;
1310Sstevel@tonic-gate }
1320Sstevel@tonic-gate
1330Sstevel@tonic-gate if (sctp->sctp_odchunks) {
13412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutOrderChunks,
1350Sstevel@tonic-gate sctp->sctp_odchunks);
13610751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_odchunks,
13710751SGeorge.Shepherd@Sun.COM sctp->sctp_odchunks);
1380Sstevel@tonic-gate sctp->sctp_odchunks = 0;
1390Sstevel@tonic-gate }
1400Sstevel@tonic-gate
1410Sstevel@tonic-gate if (sctp->sctp_oudchunks) {
14212869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutUnorderChunks,
1430Sstevel@tonic-gate sctp->sctp_oudchunks);
14410751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_oudchunks,
14510751SGeorge.Shepherd@Sun.COM sctp->sctp_oudchunks);
1460Sstevel@tonic-gate sctp->sctp_oudchunks = 0;
1470Sstevel@tonic-gate }
1480Sstevel@tonic-gate
1490Sstevel@tonic-gate if (sctp->sctp_rxtchunks) {
15012869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpRetransChunks,
1510Sstevel@tonic-gate sctp->sctp_rxtchunks);
15210751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_rxtchunks,
15310751SGeorge.Shepherd@Sun.COM sctp->sctp_rxtchunks);
1540Sstevel@tonic-gate sctp->sctp_rxtchunks = 0;
1550Sstevel@tonic-gate }
1560Sstevel@tonic-gate
1570Sstevel@tonic-gate if (sctp->sctp_ipkts) {
15812869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInSCTPPkts,
1593448Sdh155122 sctp->sctp_ipkts);
1600Sstevel@tonic-gate sctp->sctp_ipkts = 0;
1610Sstevel@tonic-gate }
1620Sstevel@tonic-gate
1630Sstevel@tonic-gate if (sctp->sctp_ibchunks) {
16412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInCtrlChunks,
1650Sstevel@tonic-gate sctp->sctp_ibchunks);
16610751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_ibchunks,
16710751SGeorge.Shepherd@Sun.COM sctp->sctp_ibchunks);
1680Sstevel@tonic-gate sctp->sctp_ibchunks = 0;
1690Sstevel@tonic-gate }
1700Sstevel@tonic-gate
1710Sstevel@tonic-gate if (sctp->sctp_idchunks) {
17212869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInOrderChunks,
1730Sstevel@tonic-gate sctp->sctp_idchunks);
17410751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_idchunks,
17510751SGeorge.Shepherd@Sun.COM sctp->sctp_idchunks);
1760Sstevel@tonic-gate sctp->sctp_idchunks = 0;
1770Sstevel@tonic-gate }
1780Sstevel@tonic-gate
1790Sstevel@tonic-gate if (sctp->sctp_iudchunks) {
18012869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInUnorderChunks,
1810Sstevel@tonic-gate sctp->sctp_iudchunks);
18210751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_iudchunks,
18310751SGeorge.Shepherd@Sun.COM sctp->sctp_iudchunks);
1840Sstevel@tonic-gate sctp->sctp_iudchunks = 0;
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate
1870Sstevel@tonic-gate if (sctp->sctp_fragdmsgs) {
18812869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpFragUsrMsgs,
1890Sstevel@tonic-gate sctp->sctp_fragdmsgs);
1900Sstevel@tonic-gate sctp->sctp_fragdmsgs = 0;
1910Sstevel@tonic-gate }
1920Sstevel@tonic-gate
1930Sstevel@tonic-gate if (sctp->sctp_reassmsgs) {
19412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpReasmUsrMsgs,
1950Sstevel@tonic-gate sctp->sctp_reassmsgs);
1960Sstevel@tonic-gate sctp->sctp_reassmsgs = 0;
1970Sstevel@tonic-gate }
1980Sstevel@tonic-gate
1990Sstevel@tonic-gate next_sctp:
2000Sstevel@tonic-gate sctp_prev = sctp;
2013448Sdh155122 mutex_enter(&sctps->sctps_g_lock);
2023448Sdh155122 sctp = list_next(&sctps->sctps_g_list, sctp);
2030Sstevel@tonic-gate }
2043448Sdh155122 mutex_exit(&sctps->sctps_g_lock);
2050Sstevel@tonic-gate if (sctp_prev != NULL)
2060Sstevel@tonic-gate SCTP_REFRELE(sctp_prev);
2070Sstevel@tonic-gate
20812869SKacheong.Poon@Sun.COM sctp_sum_mib(sctps, &sctp_mib);
20912869SKacheong.Poon@Sun.COM
2100Sstevel@tonic-gate /* Copy data from the SCTP MIB */
2110Sstevel@tonic-gate sctpkp = (sctp_named_kstat_t *)kp->ks_data;
2120Sstevel@tonic-gate
2130Sstevel@tonic-gate /* These are from global ndd params. */
2143448Sdh155122 sctpkp->sctpRtoMin.value.ui32 = sctps->sctps_rto_ming;
2153448Sdh155122 sctpkp->sctpRtoMax.value.ui32 = sctps->sctps_rto_maxg;
2163448Sdh155122 sctpkp->sctpRtoInitial.value.ui32 = sctps->sctps_rto_initialg;
2173448Sdh155122 sctpkp->sctpValCookieLife.value.ui32 = sctps->sctps_cookie_life;
2183448Sdh155122 sctpkp->sctpMaxInitRetr.value.ui32 = sctps->sctps_max_init_retr;
2190Sstevel@tonic-gate
22012869SKacheong.Poon@Sun.COM /* Copy data from the local sctp_mib to the provided kstat. */
22112869SKacheong.Poon@Sun.COM sctpkp->sctpCurrEstab.value.i32 = sctp_mib.sctpCurrEstab;
22212869SKacheong.Poon@Sun.COM sctpkp->sctpActiveEstab.value.i32 = sctp_mib.sctpActiveEstab;
22312869SKacheong.Poon@Sun.COM sctpkp->sctpPassiveEstab.value.i32 = sctp_mib.sctpPassiveEstab;
22412869SKacheong.Poon@Sun.COM sctpkp->sctpAborted.value.i32 = sctp_mib.sctpAborted;
22512869SKacheong.Poon@Sun.COM sctpkp->sctpShutdowns.value.i32 = sctp_mib.sctpShutdowns;
22612869SKacheong.Poon@Sun.COM sctpkp->sctpOutOfBlue.value.i32 = sctp_mib.sctpOutOfBlue;
22712869SKacheong.Poon@Sun.COM sctpkp->sctpChecksumError.value.i32 = sctp_mib.sctpChecksumError;
22812869SKacheong.Poon@Sun.COM sctpkp->sctpOutCtrlChunks.value.i64 = sctp_mib.sctpOutCtrlChunks;
22912869SKacheong.Poon@Sun.COM sctpkp->sctpOutOrderChunks.value.i64 = sctp_mib.sctpOutOrderChunks;
23012869SKacheong.Poon@Sun.COM sctpkp->sctpOutUnorderChunks.value.i64 = sctp_mib.sctpOutUnorderChunks;
23112869SKacheong.Poon@Sun.COM sctpkp->sctpRetransChunks.value.i64 = sctp_mib.sctpRetransChunks;
23212869SKacheong.Poon@Sun.COM sctpkp->sctpOutAck.value.i32 = sctp_mib.sctpOutAck;
23312869SKacheong.Poon@Sun.COM sctpkp->sctpOutAckDelayed.value.i32 = sctp_mib.sctpOutAckDelayed;
23412869SKacheong.Poon@Sun.COM sctpkp->sctpOutWinUpdate.value.i32 = sctp_mib.sctpOutWinUpdate;
23512869SKacheong.Poon@Sun.COM sctpkp->sctpOutFastRetrans.value.i32 = sctp_mib.sctpOutFastRetrans;
23612869SKacheong.Poon@Sun.COM sctpkp->sctpOutWinProbe.value.i32 = sctp_mib.sctpOutWinProbe;
23712869SKacheong.Poon@Sun.COM sctpkp->sctpInCtrlChunks.value.i64 = sctp_mib.sctpInCtrlChunks;
23812869SKacheong.Poon@Sun.COM sctpkp->sctpInOrderChunks.value.i64 = sctp_mib.sctpInOrderChunks;
23912869SKacheong.Poon@Sun.COM sctpkp->sctpInUnorderChunks.value.i64 = sctp_mib.sctpInUnorderChunks;
24012869SKacheong.Poon@Sun.COM sctpkp->sctpInAck.value.i32 = sctp_mib.sctpInAck;
24112869SKacheong.Poon@Sun.COM sctpkp->sctpInDupAck.value.i32 = sctp_mib.sctpInDupAck;
24212869SKacheong.Poon@Sun.COM sctpkp->sctpInAckUnsent.value.i32 = sctp_mib.sctpInAckUnsent;
24312869SKacheong.Poon@Sun.COM sctpkp->sctpFragUsrMsgs.value.i64 = sctp_mib.sctpFragUsrMsgs;
24412869SKacheong.Poon@Sun.COM sctpkp->sctpReasmUsrMsgs.value.i64 = sctp_mib.sctpReasmUsrMsgs;
24512869SKacheong.Poon@Sun.COM sctpkp->sctpOutSCTPPkts.value.i64 = sctp_mib.sctpOutSCTPPkts;
24612869SKacheong.Poon@Sun.COM sctpkp->sctpInSCTPPkts.value.i64 = sctp_mib.sctpInSCTPPkts;
24712869SKacheong.Poon@Sun.COM sctpkp->sctpInInvalidCookie.value.i32 = sctp_mib.sctpInInvalidCookie;
24812869SKacheong.Poon@Sun.COM sctpkp->sctpTimRetrans.value.i32 = sctp_mib.sctpTimRetrans;
24912869SKacheong.Poon@Sun.COM sctpkp->sctpTimRetransDrop.value.i32 = sctp_mib.sctpTimRetransDrop;
2500Sstevel@tonic-gate sctpkp->sctpTimHeartBeatProbe.value.i32 =
25112869SKacheong.Poon@Sun.COM sctp_mib.sctpTimHeartBeatProbe;
25212869SKacheong.Poon@Sun.COM sctpkp->sctpTimHeartBeatDrop.value.i32 = sctp_mib.sctpTimHeartBeatDrop;
25312869SKacheong.Poon@Sun.COM sctpkp->sctpListenDrop.value.i32 = sctp_mib.sctpListenDrop;
25412869SKacheong.Poon@Sun.COM sctpkp->sctpInClosed.value.i32 = sctp_mib.sctpInClosed;
2550Sstevel@tonic-gate
2563448Sdh155122 netstack_rele(ns);
2570Sstevel@tonic-gate return (0);
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate
2603448Sdh155122 void *
sctp_kstat_init(netstackid_t stackid)2613448Sdh155122 sctp_kstat_init(netstackid_t stackid)
2620Sstevel@tonic-gate {
2633448Sdh155122 kstat_t *ksp;
2643448Sdh155122
2650Sstevel@tonic-gate sctp_named_kstat_t template = {
2660Sstevel@tonic-gate { "sctpRtoAlgorithm", KSTAT_DATA_INT32, 0 },
2670Sstevel@tonic-gate { "sctpRtoMin", KSTAT_DATA_UINT32, 0 },
2680Sstevel@tonic-gate { "sctpRtoMax", KSTAT_DATA_UINT32, 0 },
2690Sstevel@tonic-gate { "sctpRtoInitial", KSTAT_DATA_UINT32, 0 },
2700Sstevel@tonic-gate { "sctpMaxAssocs", KSTAT_DATA_INT32, 0 },
2710Sstevel@tonic-gate { "sctpValCookieLife", KSTAT_DATA_UINT32, 0 },
2720Sstevel@tonic-gate { "sctpMaxInitRetr", KSTAT_DATA_UINT32, 0 },
2730Sstevel@tonic-gate { "sctpCurrEstab", KSTAT_DATA_INT32, 0 },
2740Sstevel@tonic-gate { "sctpActiveEstab", KSTAT_DATA_INT32, 0 },
2750Sstevel@tonic-gate { "sctpPassiveEstab", KSTAT_DATA_INT32, 0 },
2760Sstevel@tonic-gate { "sctpAborted", KSTAT_DATA_INT32, 0 },
2770Sstevel@tonic-gate { "sctpShutdowns", KSTAT_DATA_INT32, 0 },
2780Sstevel@tonic-gate { "sctpOutOfBlue", KSTAT_DATA_INT32, 0 },
2790Sstevel@tonic-gate { "sctpChecksumError", KSTAT_DATA_INT32, 0 },
2800Sstevel@tonic-gate { "sctpOutCtrlChunks", KSTAT_DATA_INT64, 0 },
2810Sstevel@tonic-gate { "sctpOutOrderChunks", KSTAT_DATA_INT64, 0 },
2820Sstevel@tonic-gate { "sctpOutUnorderChunks", KSTAT_DATA_INT64, 0 },
2830Sstevel@tonic-gate { "sctpRetransChunks", KSTAT_DATA_INT64, 0 },
2840Sstevel@tonic-gate { "sctpOutAck", KSTAT_DATA_INT32, 0 },
2850Sstevel@tonic-gate { "sctpOutAckDelayed", KSTAT_DATA_INT32, 0 },
2860Sstevel@tonic-gate { "sctpOutWinUpdate", KSTAT_DATA_INT32, 0 },
2870Sstevel@tonic-gate { "sctpOutFastRetrans", KSTAT_DATA_INT32, 0 },
2880Sstevel@tonic-gate { "sctpOutWinProbe", KSTAT_DATA_INT32, 0 },
2890Sstevel@tonic-gate { "sctpInCtrlChunks", KSTAT_DATA_INT64, 0 },
2900Sstevel@tonic-gate { "sctpInOrderChunks", KSTAT_DATA_INT64, 0 },
2910Sstevel@tonic-gate { "sctpInUnorderChunks", KSTAT_DATA_INT64, 0 },
2920Sstevel@tonic-gate { "sctpInAck", KSTAT_DATA_INT32, 0 },
2930Sstevel@tonic-gate { "sctpInDupAck", KSTAT_DATA_INT32, 0 },
2940Sstevel@tonic-gate { "sctpInAckUnsent", KSTAT_DATA_INT32, 0 },
2950Sstevel@tonic-gate { "sctpFragUsrMsgs", KSTAT_DATA_INT64, 0 },
2960Sstevel@tonic-gate { "sctpReasmUsrMsgs", KSTAT_DATA_INT64, 0 },
2970Sstevel@tonic-gate { "sctpOutSCTPPkts", KSTAT_DATA_INT64, 0 },
2980Sstevel@tonic-gate { "sctpInSCTPPkts", KSTAT_DATA_INT64, 0 },
2990Sstevel@tonic-gate { "sctpInInvalidCookie", KSTAT_DATA_INT32, 0 },
3000Sstevel@tonic-gate { "sctpTimRetrans", KSTAT_DATA_INT32, 0 },
3010Sstevel@tonic-gate { "sctpTimRetransDrop", KSTAT_DATA_INT32, 0 },
3020Sstevel@tonic-gate { "sctpTimHearBeatProbe", KSTAT_DATA_INT32, 0 },
3030Sstevel@tonic-gate { "sctpTimHearBeatDrop", KSTAT_DATA_INT32, 0 },
3040Sstevel@tonic-gate { "sctpListenDrop", KSTAT_DATA_INT32, 0 },
3050Sstevel@tonic-gate { "sctpInClosed", KSTAT_DATA_INT32, 0 }
3060Sstevel@tonic-gate };
3070Sstevel@tonic-gate
3083448Sdh155122 ksp = kstat_create_netstack(SCTP_MOD_NAME, 0, "sctp", "mib2",
3093448Sdh155122 KSTAT_TYPE_NAMED, NUM_OF_FIELDS(sctp_named_kstat_t), 0, stackid);
3100Sstevel@tonic-gate
31112869SKacheong.Poon@Sun.COM if (ksp == NULL)
3123448Sdh155122 return (NULL);
3130Sstevel@tonic-gate
3140Sstevel@tonic-gate /* These won't change. */
3150Sstevel@tonic-gate template.sctpRtoAlgorithm.value.i32 = MIB2_SCTP_RTOALGO_VANJ;
3160Sstevel@tonic-gate template.sctpMaxAssocs.value.i32 = -1;
3170Sstevel@tonic-gate
3183448Sdh155122 bcopy(&template, ksp->ks_data, sizeof (template));
3193448Sdh155122 ksp->ks_update = sctp_kstat_update;
3203448Sdh155122 ksp->ks_private = (void *)(uintptr_t)stackid;
3213448Sdh155122
3223448Sdh155122 kstat_install(ksp);
3233448Sdh155122 return (ksp);
3243448Sdh155122 }
3250Sstevel@tonic-gate
3263448Sdh155122 /*
32712869SKacheong.Poon@Sun.COM * To set all sctp_stat_t counters to 0.
32812869SKacheong.Poon@Sun.COM */
32912869SKacheong.Poon@Sun.COM static void
sctp_clr_kstats2(sctp_kstat_t * stats)33012869SKacheong.Poon@Sun.COM sctp_clr_kstats2(sctp_kstat_t *stats)
33112869SKacheong.Poon@Sun.COM {
33212869SKacheong.Poon@Sun.COM stats->sctp_add_faddr.value.ui64 = 0;
33312869SKacheong.Poon@Sun.COM stats->sctp_add_timer.value.ui64 = 0;
33412869SKacheong.Poon@Sun.COM stats->sctp_conn_create.value.ui64 = 0;
33512869SKacheong.Poon@Sun.COM stats->sctp_find_next_tq.value.ui64 = 0;
33612869SKacheong.Poon@Sun.COM stats->sctp_fr_add_hdr.value.ui64 = 0;
33712869SKacheong.Poon@Sun.COM stats->sctp_fr_not_found.value.ui64 = 0;
33812869SKacheong.Poon@Sun.COM stats->sctp_output_failed.value.ui64 = 0;
33912869SKacheong.Poon@Sun.COM stats->sctp_rexmit_failed.value.ui64 = 0;
34012869SKacheong.Poon@Sun.COM stats->sctp_send_init_failed.value.ui64 = 0;
34112869SKacheong.Poon@Sun.COM stats->sctp_send_cookie_failed.value.ui64 = 0;
34212869SKacheong.Poon@Sun.COM stats->sctp_send_cookie_ack_failed.value.ui64 = 0;
34312869SKacheong.Poon@Sun.COM stats->sctp_send_err_failed.value.ui64 = 0;
34412869SKacheong.Poon@Sun.COM stats->sctp_send_sack_failed.value.ui64 = 0;
34512869SKacheong.Poon@Sun.COM stats->sctp_send_shutdown_failed.value.ui64 = 0;
34612869SKacheong.Poon@Sun.COM stats->sctp_send_shutdown_ack_failed.value.ui64 = 0;
34712869SKacheong.Poon@Sun.COM stats->sctp_send_shutdown_comp_failed.value.ui64 = 0;
34812869SKacheong.Poon@Sun.COM stats->sctp_send_user_abort_failed.value.ui64 = 0;
34912869SKacheong.Poon@Sun.COM stats->sctp_send_asconf_failed.value.ui64 = 0;
35012869SKacheong.Poon@Sun.COM stats->sctp_send_asconf_ack_failed.value.ui64 = 0;
35112869SKacheong.Poon@Sun.COM stats->sctp_send_ftsn_failed.value.ui64 = 0;
35212869SKacheong.Poon@Sun.COM stats->sctp_send_hb_failed.value.ui64 = 0;
35312869SKacheong.Poon@Sun.COM stats->sctp_return_hb_failed.value.ui64 = 0;
35412869SKacheong.Poon@Sun.COM stats->sctp_ss_rexmit_failed.value.ui64 = 0;
35512869SKacheong.Poon@Sun.COM stats->sctp_cl_connect.value.ui64 = 0;
35612869SKacheong.Poon@Sun.COM stats->sctp_cl_assoc_change.value.ui64 = 0;
35712869SKacheong.Poon@Sun.COM stats->sctp_cl_check_addrs.value.ui64 = 0;
35812869SKacheong.Poon@Sun.COM stats->sctp_reclaim_cnt.value.ui64 = 0;
35912869SKacheong.Poon@Sun.COM stats->sctp_listen_cnt_drop.value.ui64 = 0;
36012869SKacheong.Poon@Sun.COM }
36112869SKacheong.Poon@Sun.COM
36212869SKacheong.Poon@Sun.COM /*
36312869SKacheong.Poon@Sun.COM * To add counters from the per CPU sctp_kstat_counter_t to the stack
36412869SKacheong.Poon@Sun.COM * sctp_kstat_t.
36512869SKacheong.Poon@Sun.COM */
36612869SKacheong.Poon@Sun.COM static void
sctp_add_kstats2(sctp_kstat_counter_t * from,sctp_kstat_t * to)36712869SKacheong.Poon@Sun.COM sctp_add_kstats2(sctp_kstat_counter_t *from, sctp_kstat_t *to)
36812869SKacheong.Poon@Sun.COM {
36912869SKacheong.Poon@Sun.COM to->sctp_add_faddr.value.ui64 += from->sctp_add_faddr;
37012869SKacheong.Poon@Sun.COM to->sctp_add_timer.value.ui64 += from->sctp_add_timer;
37112869SKacheong.Poon@Sun.COM to->sctp_conn_create.value.ui64 += from->sctp_conn_create;
37212869SKacheong.Poon@Sun.COM to->sctp_find_next_tq.value.ui64 += from->sctp_find_next_tq;
37312869SKacheong.Poon@Sun.COM to->sctp_fr_add_hdr.value.ui64 += from->sctp_fr_add_hdr;
37412869SKacheong.Poon@Sun.COM to->sctp_fr_not_found.value.ui64 += from->sctp_fr_not_found;
37512869SKacheong.Poon@Sun.COM to->sctp_output_failed.value.ui64 += from->sctp_output_failed;
37612869SKacheong.Poon@Sun.COM to->sctp_rexmit_failed.value.ui64 += from->sctp_rexmit_failed;
37712869SKacheong.Poon@Sun.COM to->sctp_send_init_failed.value.ui64 += from->sctp_send_init_failed;
37812869SKacheong.Poon@Sun.COM to->sctp_send_cookie_failed.value.ui64 += from->sctp_send_cookie_failed;
37912869SKacheong.Poon@Sun.COM to->sctp_send_cookie_ack_failed.value.ui64 +=
38012869SKacheong.Poon@Sun.COM from->sctp_send_cookie_ack_failed;
38112869SKacheong.Poon@Sun.COM to->sctp_send_err_failed.value.ui64 += from->sctp_send_err_failed;
38212869SKacheong.Poon@Sun.COM to->sctp_send_sack_failed.value.ui64 += from->sctp_send_sack_failed;
38312869SKacheong.Poon@Sun.COM to->sctp_send_shutdown_failed.value.ui64 +=
38412869SKacheong.Poon@Sun.COM from->sctp_send_shutdown_failed;
38512869SKacheong.Poon@Sun.COM to->sctp_send_shutdown_ack_failed.value.ui64 +=
38612869SKacheong.Poon@Sun.COM from->sctp_send_shutdown_ack_failed;
38712869SKacheong.Poon@Sun.COM to->sctp_send_shutdown_comp_failed.value.ui64 +=
38812869SKacheong.Poon@Sun.COM from->sctp_send_shutdown_comp_failed;
38912869SKacheong.Poon@Sun.COM to->sctp_send_user_abort_failed.value.ui64 +=
39012869SKacheong.Poon@Sun.COM from->sctp_send_user_abort_failed;
39112869SKacheong.Poon@Sun.COM to->sctp_send_asconf_failed.value.ui64 += from->sctp_send_asconf_failed;
39212869SKacheong.Poon@Sun.COM to->sctp_send_asconf_ack_failed.value.ui64 +=
39312869SKacheong.Poon@Sun.COM from->sctp_send_asconf_ack_failed;
39412869SKacheong.Poon@Sun.COM to->sctp_send_ftsn_failed.value.ui64 += from->sctp_send_ftsn_failed;
39512869SKacheong.Poon@Sun.COM to->sctp_send_hb_failed.value.ui64 += from->sctp_send_hb_failed;
39612869SKacheong.Poon@Sun.COM to->sctp_return_hb_failed.value.ui64 += from->sctp_return_hb_failed;
39712869SKacheong.Poon@Sun.COM to->sctp_ss_rexmit_failed.value.ui64 += from->sctp_ss_rexmit_failed;
39812869SKacheong.Poon@Sun.COM to->sctp_cl_connect.value.ui64 += from->sctp_cl_connect;
39912869SKacheong.Poon@Sun.COM to->sctp_cl_assoc_change.value.ui64 += from->sctp_cl_assoc_change;
40012869SKacheong.Poon@Sun.COM to->sctp_cl_check_addrs.value.ui64 += from->sctp_cl_check_addrs;
40112869SKacheong.Poon@Sun.COM }
40212869SKacheong.Poon@Sun.COM
40312869SKacheong.Poon@Sun.COM /*
40412869SKacheong.Poon@Sun.COM * Sum up all per CPU tcp_stat_t kstat counters.
40512869SKacheong.Poon@Sun.COM */
40612869SKacheong.Poon@Sun.COM static int
sctp_kstat2_update(kstat_t * kp,int rw)40712869SKacheong.Poon@Sun.COM sctp_kstat2_update(kstat_t *kp, int rw)
40812869SKacheong.Poon@Sun.COM {
40912869SKacheong.Poon@Sun.COM netstackid_t stackid = (netstackid_t)(uintptr_t)kp->ks_private;
41012869SKacheong.Poon@Sun.COM netstack_t *ns;
41112869SKacheong.Poon@Sun.COM sctp_stack_t *sctps;
41212869SKacheong.Poon@Sun.COM sctp_kstat_t *stats;
41312869SKacheong.Poon@Sun.COM int i;
41412869SKacheong.Poon@Sun.COM int cnt;
41512869SKacheong.Poon@Sun.COM
41612869SKacheong.Poon@Sun.COM if (rw == KSTAT_WRITE)
41712869SKacheong.Poon@Sun.COM return (EACCES);
41812869SKacheong.Poon@Sun.COM
41912869SKacheong.Poon@Sun.COM ns = netstack_find_by_stackid(stackid);
42012869SKacheong.Poon@Sun.COM if (ns == NULL)
42112869SKacheong.Poon@Sun.COM return (-1);
42212869SKacheong.Poon@Sun.COM sctps = ns->netstack_sctp;
42312869SKacheong.Poon@Sun.COM if (sctps == NULL) {
42412869SKacheong.Poon@Sun.COM netstack_rele(ns);
42512869SKacheong.Poon@Sun.COM return (-1);
42612869SKacheong.Poon@Sun.COM }
42712869SKacheong.Poon@Sun.COM
42812869SKacheong.Poon@Sun.COM stats = (sctp_kstat_t *)kp->ks_data;
42912869SKacheong.Poon@Sun.COM sctp_clr_kstats2(stats);
43012869SKacheong.Poon@Sun.COM
43112869SKacheong.Poon@Sun.COM /*
43212869SKacheong.Poon@Sun.COM * sctps_sc_cnt may change in the middle of the loop. It is better
43312869SKacheong.Poon@Sun.COM * to get its value first.
43412869SKacheong.Poon@Sun.COM */
43512869SKacheong.Poon@Sun.COM cnt = sctps->sctps_sc_cnt;
43612869SKacheong.Poon@Sun.COM for (i = 0; i < cnt; i++)
43712869SKacheong.Poon@Sun.COM sctp_add_kstats2(&sctps->sctps_sc[i]->sctp_sc_stats, stats);
43812869SKacheong.Poon@Sun.COM
43912869SKacheong.Poon@Sun.COM netstack_rele(ns);
44012869SKacheong.Poon@Sun.COM return (0);
44112869SKacheong.Poon@Sun.COM }
44212869SKacheong.Poon@Sun.COM
44312869SKacheong.Poon@Sun.COM /*
4443448Sdh155122 * The following kstats are for debugging purposes. They keep
4453448Sdh155122 * track of problems which should not happen normally. But in
4463448Sdh155122 * those cases which they do happen, these kstats would be handy
4473448Sdh155122 * for engineers to diagnose the problems. They are not intended
4483448Sdh155122 * to be consumed by customers.
4493448Sdh155122 */
4503448Sdh155122 void *
sctp_kstat2_init(netstackid_t stackid)45112869SKacheong.Poon@Sun.COM sctp_kstat2_init(netstackid_t stackid)
4523448Sdh155122 {
4533448Sdh155122 kstat_t *ksp;
4541735Skcpoon
4553448Sdh155122 sctp_kstat_t template = {
4563448Sdh155122 { "sctp_add_faddr", KSTAT_DATA_UINT64 },
4573448Sdh155122 { "sctp_add_timer", KSTAT_DATA_UINT64 },
4583448Sdh155122 { "sctp_conn_create", KSTAT_DATA_UINT64 },
4593448Sdh155122 { "sctp_find_next_tq", KSTAT_DATA_UINT64 },
4603448Sdh155122 { "sctp_fr_add_hdr", KSTAT_DATA_UINT64 },
4613448Sdh155122 { "sctp_fr_not_found", KSTAT_DATA_UINT64 },
4623448Sdh155122 { "sctp_output_failed", KSTAT_DATA_UINT64 },
4633448Sdh155122 { "sctp_rexmit_failed", KSTAT_DATA_UINT64 },
4643448Sdh155122 { "sctp_send_init_failed", KSTAT_DATA_UINT64 },
4653448Sdh155122 { "sctp_send_cookie_failed", KSTAT_DATA_UINT64 },
4663448Sdh155122 { "sctp_send_cookie_ack_failed", KSTAT_DATA_UINT64 },
4673448Sdh155122 { "sctp_send_err_failed", KSTAT_DATA_UINT64 },
4683448Sdh155122 { "sctp_send_sack_failed", KSTAT_DATA_UINT64 },
4693448Sdh155122 { "sctp_send_shutdown_failed", KSTAT_DATA_UINT64 },
4703448Sdh155122 { "sctp_send_shutdown_ack_failed", KSTAT_DATA_UINT64 },
4713448Sdh155122 { "sctp_send_shutdown_comp_failed", KSTAT_DATA_UINT64 },
4723448Sdh155122 { "sctp_send_user_abort_failed", KSTAT_DATA_UINT64 },
4733448Sdh155122 { "sctp_send_asconf_failed", KSTAT_DATA_UINT64 },
4743448Sdh155122 { "sctp_send_asconf_ack_failed", KSTAT_DATA_UINT64 },
4753448Sdh155122 { "sctp_send_ftsn_failed", KSTAT_DATA_UINT64 },
4763448Sdh155122 { "sctp_send_hb_failed", KSTAT_DATA_UINT64 },
4773448Sdh155122 { "sctp_return_hb_failed", KSTAT_DATA_UINT64 },
4783448Sdh155122 { "sctp_ss_rexmit_failed", KSTAT_DATA_UINT64 },
4793448Sdh155122 { "sctp_cl_connect", KSTAT_DATA_UINT64 },
4803448Sdh155122 { "sctp_cl_assoc_change", KSTAT_DATA_UINT64 },
4813448Sdh155122 { "sctp_cl_check_addrs", KSTAT_DATA_UINT64 },
48212869SKacheong.Poon@Sun.COM { "sctp_reclaim_drop", KSTAT_DATA_UINT64 },
48312869SKacheong.Poon@Sun.COM { "sctp_listen_cnt_drop", KSTAT_DATA_UINT64 },
4843448Sdh155122 };
4853448Sdh155122
4863448Sdh155122 ksp = kstat_create_netstack(SCTP_MOD_NAME, 0, "sctpstat", "net",
48712869SKacheong.Poon@Sun.COM KSTAT_TYPE_NAMED, NUM_OF_FIELDS(template), 0, stackid);
4883448Sdh155122
4893448Sdh155122 if (ksp == NULL)
4903448Sdh155122 return (NULL);
4913448Sdh155122
49212869SKacheong.Poon@Sun.COM bcopy(&template, ksp->ks_data, sizeof (template));
4933448Sdh155122 ksp->ks_private = (void *)(uintptr_t)stackid;
49412869SKacheong.Poon@Sun.COM ksp->ks_update = sctp_kstat2_update;
4953448Sdh155122
4963448Sdh155122 kstat_install(ksp);
4973448Sdh155122 return (ksp);
4983448Sdh155122 }
4993448Sdh155122
5003448Sdh155122 void
sctp_kstat_fini(netstackid_t stackid,kstat_t * ksp)5013448Sdh155122 sctp_kstat_fini(netstackid_t stackid, kstat_t *ksp)
5023448Sdh155122 {
5033448Sdh155122 if (ksp != NULL) {
5043448Sdh155122 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
5053448Sdh155122 kstat_delete_netstack(ksp, stackid);
5061735Skcpoon }
5070Sstevel@tonic-gate }
5080Sstevel@tonic-gate
5090Sstevel@tonic-gate void
sctp_kstat2_fini(netstackid_t stackid,kstat_t * ksp)5103448Sdh155122 sctp_kstat2_fini(netstackid_t stackid, kstat_t *ksp)
5110Sstevel@tonic-gate {
5123448Sdh155122 if (ksp != NULL) {
5133448Sdh155122 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
5143448Sdh155122 kstat_delete_netstack(ksp, stackid);
5151735Skcpoon }
5160Sstevel@tonic-gate }
5170Sstevel@tonic-gate
5180Sstevel@tonic-gate /*
5190Sstevel@tonic-gate * Return SNMP global stats in buffer in mpdata.
5200Sstevel@tonic-gate * Return associatiation table in mp_conn_data,
5210Sstevel@tonic-gate * local address table in mp_local_data, and
5220Sstevel@tonic-gate * remote address table in mp_rem_data.
5230Sstevel@tonic-gate */
5240Sstevel@tonic-gate mblk_t *
sctp_snmp_get_mib2(queue_t * q,mblk_t * mpctl,sctp_stack_t * sctps)5253448Sdh155122 sctp_snmp_get_mib2(queue_t *q, mblk_t *mpctl, sctp_stack_t *sctps)
5260Sstevel@tonic-gate {
5270Sstevel@tonic-gate mblk_t *mpdata, *mp_ret;
5280Sstevel@tonic-gate mblk_t *mp_conn_ctl = NULL;
5290Sstevel@tonic-gate mblk_t *mp_conn_data;
5300Sstevel@tonic-gate mblk_t *mp_conn_tail = NULL;
5310Sstevel@tonic-gate mblk_t *mp_local_ctl = NULL;
5320Sstevel@tonic-gate mblk_t *mp_local_data;
5330Sstevel@tonic-gate mblk_t *mp_local_tail = NULL;
5340Sstevel@tonic-gate mblk_t *mp_rem_ctl = NULL;
5350Sstevel@tonic-gate mblk_t *mp_rem_data;
5360Sstevel@tonic-gate mblk_t *mp_rem_tail = NULL;
5371676Sjpk mblk_t *mp_attr_ctl = NULL;
5381676Sjpk mblk_t *mp_attr_data;
5391676Sjpk mblk_t *mp_attr_tail = NULL;
5400Sstevel@tonic-gate struct opthdr *optp;
5410Sstevel@tonic-gate sctp_t *sctp, *sctp_prev = NULL;
5420Sstevel@tonic-gate sctp_faddr_t *fp;
5430Sstevel@tonic-gate mib2_sctpConnEntry_t sce;
5440Sstevel@tonic-gate mib2_sctpConnLocalEntry_t scle;
5450Sstevel@tonic-gate mib2_sctpConnRemoteEntry_t scre;
5461676Sjpk mib2_transportMLPEntry_t mlp;
5470Sstevel@tonic-gate int i;
5480Sstevel@tonic-gate int l;
5490Sstevel@tonic-gate int scanned = 0;
5500Sstevel@tonic-gate zoneid_t zoneid = Q_TO_CONN(q)->conn_zoneid;
5511676Sjpk conn_t *connp;
5521676Sjpk boolean_t needattr;
5531676Sjpk int idx;
55412869SKacheong.Poon@Sun.COM mib2_sctp_t sctp_mib;
5550Sstevel@tonic-gate
5560Sstevel@tonic-gate /*
5570Sstevel@tonic-gate * Make copies of the original message.
5580Sstevel@tonic-gate * mpctl will hold SCTP counters,
5590Sstevel@tonic-gate * mp_conn_ctl will hold list of connections.
5600Sstevel@tonic-gate */
5610Sstevel@tonic-gate mp_ret = copymsg(mpctl);
5620Sstevel@tonic-gate mp_conn_ctl = copymsg(mpctl);
5630Sstevel@tonic-gate mp_local_ctl = copymsg(mpctl);
5640Sstevel@tonic-gate mp_rem_ctl = copymsg(mpctl);
5651676Sjpk mp_attr_ctl = copymsg(mpctl);
5660Sstevel@tonic-gate
5670Sstevel@tonic-gate mpdata = mpctl->b_cont;
5680Sstevel@tonic-gate
5691676Sjpk if (mp_conn_ctl == NULL || mp_local_ctl == NULL ||
5701676Sjpk mp_rem_ctl == NULL || mp_attr_ctl == NULL || mpdata == NULL) {
5711676Sjpk freemsg(mp_attr_ctl);
5720Sstevel@tonic-gate freemsg(mp_rem_ctl);
5730Sstevel@tonic-gate freemsg(mp_local_ctl);
5740Sstevel@tonic-gate freemsg(mp_conn_ctl);
5750Sstevel@tonic-gate freemsg(mp_ret);
5760Sstevel@tonic-gate freemsg(mpctl);
5770Sstevel@tonic-gate return (NULL);
5780Sstevel@tonic-gate }
5790Sstevel@tonic-gate mp_conn_data = mp_conn_ctl->b_cont;
5800Sstevel@tonic-gate mp_local_data = mp_local_ctl->b_cont;
5810Sstevel@tonic-gate mp_rem_data = mp_rem_ctl->b_cont;
5821676Sjpk mp_attr_data = mp_attr_ctl->b_cont;
5830Sstevel@tonic-gate
58412869SKacheong.Poon@Sun.COM bzero(&sctp_mib, sizeof (sctp_mib));
58512869SKacheong.Poon@Sun.COM
5860Sstevel@tonic-gate /* hostname address parameters are not supported in Solaris */
5870Sstevel@tonic-gate sce.sctpAssocRemHostName.o_length = 0;
5880Sstevel@tonic-gate sce.sctpAssocRemHostName.o_bytes[0] = 0;
5890Sstevel@tonic-gate
5900Sstevel@tonic-gate /* build table of connections -- need count in fixed part */
5910Sstevel@tonic-gate
5921676Sjpk idx = 0;
5933448Sdh155122 mutex_enter(&sctps->sctps_g_lock);
59411042SErik.Nordmark@Sun.COM sctp = list_head(&sctps->sctps_g_list);
5950Sstevel@tonic-gate while (sctp != NULL) {
5960Sstevel@tonic-gate mutex_enter(&sctp->sctp_reflock);
5970Sstevel@tonic-gate if (sctp->sctp_condemned) {
5980Sstevel@tonic-gate mutex_exit(&sctp->sctp_reflock);
5993448Sdh155122 sctp = list_next(&sctps->sctps_g_list, sctp);
6000Sstevel@tonic-gate continue;
6010Sstevel@tonic-gate }
6020Sstevel@tonic-gate sctp->sctp_refcnt++;
6030Sstevel@tonic-gate mutex_exit(&sctp->sctp_reflock);
6043448Sdh155122 mutex_exit(&sctps->sctps_g_lock);
6050Sstevel@tonic-gate if (sctp_prev != NULL)
6060Sstevel@tonic-gate SCTP_REFRELE(sctp_prev);
6070Sstevel@tonic-gate if (sctp->sctp_connp->conn_zoneid != zoneid)
6080Sstevel@tonic-gate goto next_sctp;
6090Sstevel@tonic-gate if (sctp->sctp_state == SCTPS_ESTABLISHED ||
6100Sstevel@tonic-gate sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
6110Sstevel@tonic-gate sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
61212869SKacheong.Poon@Sun.COM /*
61312869SKacheong.Poon@Sun.COM * Just bump the local sctp_mib. The number of
61412869SKacheong.Poon@Sun.COM * existing associations is not kept in kernel.
61512869SKacheong.Poon@Sun.COM */
61612869SKacheong.Poon@Sun.COM BUMP_MIB(&sctp_mib, sctpCurrEstab);
6170Sstevel@tonic-gate }
61812869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutSCTPPkts, sctp->sctp_opkts);
6190Sstevel@tonic-gate sctp->sctp_opkts = 0;
62012869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutCtrlChunks, sctp->sctp_obchunks);
62110751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_obchunks,
62210751SGeorge.Shepherd@Sun.COM sctp->sctp_obchunks);
6230Sstevel@tonic-gate sctp->sctp_obchunks = 0;
62412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutOrderChunks,
62512869SKacheong.Poon@Sun.COM sctp->sctp_odchunks);
62610751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_odchunks,
62710751SGeorge.Shepherd@Sun.COM sctp->sctp_odchunks);
6280Sstevel@tonic-gate sctp->sctp_odchunks = 0;
62912869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpOutUnorderChunks,
6300Sstevel@tonic-gate sctp->sctp_oudchunks);
63110751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_oudchunks,
63210751SGeorge.Shepherd@Sun.COM sctp->sctp_oudchunks);
6330Sstevel@tonic-gate sctp->sctp_oudchunks = 0;
63412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpRetransChunks,
63512869SKacheong.Poon@Sun.COM sctp->sctp_rxtchunks);
63610751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_rxtchunks,
63710751SGeorge.Shepherd@Sun.COM sctp->sctp_rxtchunks);
6380Sstevel@tonic-gate sctp->sctp_rxtchunks = 0;
63912869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInSCTPPkts, sctp->sctp_ipkts);
6400Sstevel@tonic-gate sctp->sctp_ipkts = 0;
64112869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInCtrlChunks, sctp->sctp_ibchunks);
64210751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_ibchunks,
64310751SGeorge.Shepherd@Sun.COM sctp->sctp_ibchunks);
6440Sstevel@tonic-gate sctp->sctp_ibchunks = 0;
64512869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInOrderChunks, sctp->sctp_idchunks);
64610751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_idchunks,
64710751SGeorge.Shepherd@Sun.COM sctp->sctp_idchunks);
6480Sstevel@tonic-gate sctp->sctp_idchunks = 0;
64912869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpInUnorderChunks,
6500Sstevel@tonic-gate sctp->sctp_iudchunks);
65110751SGeorge.Shepherd@Sun.COM UPDATE_LOCAL(sctp->sctp_cum_iudchunks,
65210751SGeorge.Shepherd@Sun.COM sctp->sctp_iudchunks);
6530Sstevel@tonic-gate sctp->sctp_iudchunks = 0;
65412869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpFragUsrMsgs, sctp->sctp_fragdmsgs);
6550Sstevel@tonic-gate sctp->sctp_fragdmsgs = 0;
65612869SKacheong.Poon@Sun.COM SCTPS_UPDATE_MIB(sctps, sctpReasmUsrMsgs, sctp->sctp_reassmsgs);
6570Sstevel@tonic-gate sctp->sctp_reassmsgs = 0;
6580Sstevel@tonic-gate
6590Sstevel@tonic-gate sce.sctpAssocId = ntohl(sctp->sctp_lvtag);
66011042SErik.Nordmark@Sun.COM sce.sctpAssocLocalPort = ntohs(sctp->sctp_connp->conn_lport);
66111042SErik.Nordmark@Sun.COM sce.sctpAssocRemPort = ntohs(sctp->sctp_connp->conn_fport);
6620Sstevel@tonic-gate
6630Sstevel@tonic-gate RUN_SCTP(sctp);
6640Sstevel@tonic-gate if (sctp->sctp_primary != NULL) {
6650Sstevel@tonic-gate fp = sctp->sctp_primary;
6660Sstevel@tonic-gate
667*13009SChandrasekar.Marimuthu@Sun.COM if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
6680Sstevel@tonic-gate sce.sctpAssocRemPrimAddrType =
6690Sstevel@tonic-gate MIB2_SCTP_ADDR_V4;
6700Sstevel@tonic-gate } else {
6710Sstevel@tonic-gate sce.sctpAssocRemPrimAddrType =
6720Sstevel@tonic-gate MIB2_SCTP_ADDR_V6;
6730Sstevel@tonic-gate }
674*13009SChandrasekar.Marimuthu@Sun.COM sce.sctpAssocRemPrimAddr = fp->sf_faddr;
675*13009SChandrasekar.Marimuthu@Sun.COM sce.sctpAssocLocPrimAddr = fp->sf_saddr;
6760Sstevel@tonic-gate sce.sctpAssocHeartBeatInterval = TICK_TO_MSEC(
677*13009SChandrasekar.Marimuthu@Sun.COM fp->sf_hb_interval);
6780Sstevel@tonic-gate } else {
6790Sstevel@tonic-gate sce.sctpAssocRemPrimAddrType = MIB2_SCTP_ADDR_V4;
6800Sstevel@tonic-gate bzero(&sce.sctpAssocRemPrimAddr,
6810Sstevel@tonic-gate sizeof (sce.sctpAssocRemPrimAddr));
6820Sstevel@tonic-gate bzero(&sce.sctpAssocLocPrimAddr,
6830Sstevel@tonic-gate sizeof (sce.sctpAssocLocPrimAddr));
6840Sstevel@tonic-gate sce.sctpAssocHeartBeatInterval =
6853448Sdh155122 sctps->sctps_heartbeat_interval;
6860Sstevel@tonic-gate }
6870Sstevel@tonic-gate
6880Sstevel@tonic-gate /*
6890Sstevel@tonic-gate * Table for local addresses
6900Sstevel@tonic-gate */
6910Sstevel@tonic-gate scanned = 0;
6920Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) {
6930Sstevel@tonic-gate sctp_saddr_ipif_t *obj;
6940Sstevel@tonic-gate
6950Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count == 0)
6960Sstevel@tonic-gate continue;
6970Sstevel@tonic-gate obj = list_head(&sctp->sctp_saddrs[i].sctp_ipif_list);
6980Sstevel@tonic-gate for (l = 0; l < sctp->sctp_saddrs[i].ipif_count; l++) {
6990Sstevel@tonic-gate sctp_ipif_t *sctp_ipif;
7000Sstevel@tonic-gate in6_addr_t addr;
7010Sstevel@tonic-gate
7020Sstevel@tonic-gate sctp_ipif = obj->saddr_ipifp;
7030Sstevel@tonic-gate addr = sctp_ipif->sctp_ipif_saddr;
7040Sstevel@tonic-gate scanned++;
7050Sstevel@tonic-gate scle.sctpAssocId = ntohl(sctp->sctp_lvtag);
7060Sstevel@tonic-gate if (IN6_IS_ADDR_V4MAPPED(&addr)) {
7070Sstevel@tonic-gate scle.sctpAssocLocalAddrType =
7080Sstevel@tonic-gate MIB2_SCTP_ADDR_V4;
7090Sstevel@tonic-gate } else {
7100Sstevel@tonic-gate scle.sctpAssocLocalAddrType =
7110Sstevel@tonic-gate MIB2_SCTP_ADDR_V6;
7120Sstevel@tonic-gate }
7130Sstevel@tonic-gate scle.sctpAssocLocalAddr = addr;
7140Sstevel@tonic-gate (void) snmp_append_data2(mp_local_data,
7150Sstevel@tonic-gate &mp_local_tail, (char *)&scle,
7160Sstevel@tonic-gate sizeof (scle));
7170Sstevel@tonic-gate if (scanned >= sctp->sctp_nsaddrs)
7180Sstevel@tonic-gate goto done;
7190Sstevel@tonic-gate obj = list_next(&sctp->
7200Sstevel@tonic-gate sctp_saddrs[i].sctp_ipif_list, obj);
7210Sstevel@tonic-gate }
7220Sstevel@tonic-gate }
7230Sstevel@tonic-gate done:
7240Sstevel@tonic-gate /*
7250Sstevel@tonic-gate * Table for remote addresses
7260Sstevel@tonic-gate */
727*13009SChandrasekar.Marimuthu@Sun.COM for (fp = sctp->sctp_faddrs; fp; fp = fp->sf_next) {
7280Sstevel@tonic-gate scre.sctpAssocId = ntohl(sctp->sctp_lvtag);
729*13009SChandrasekar.Marimuthu@Sun.COM if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
7300Sstevel@tonic-gate scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V4;
7310Sstevel@tonic-gate } else {
7320Sstevel@tonic-gate scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V6;
7330Sstevel@tonic-gate }
734*13009SChandrasekar.Marimuthu@Sun.COM scre.sctpAssocRemAddr = fp->sf_faddr;
735*13009SChandrasekar.Marimuthu@Sun.COM if (fp->sf_state == SCTP_FADDRS_ALIVE) {
7360Sstevel@tonic-gate scre.sctpAssocRemAddrActive =
7370Sstevel@tonic-gate scre.sctpAssocRemAddrHBActive =
7380Sstevel@tonic-gate MIB2_SCTP_ACTIVE;
7390Sstevel@tonic-gate } else {
7400Sstevel@tonic-gate scre.sctpAssocRemAddrActive =
7410Sstevel@tonic-gate scre.sctpAssocRemAddrHBActive =
7420Sstevel@tonic-gate MIB2_SCTP_INACTIVE;
7430Sstevel@tonic-gate }
744*13009SChandrasekar.Marimuthu@Sun.COM scre.sctpAssocRemAddrRTO = TICK_TO_MSEC(fp->sf_rto);
745*13009SChandrasekar.Marimuthu@Sun.COM scre.sctpAssocRemAddrMaxPathRtx = fp->sf_max_retr;
746*13009SChandrasekar.Marimuthu@Sun.COM scre.sctpAssocRemAddrRtx = fp->sf_T3expire;
7470Sstevel@tonic-gate (void) snmp_append_data2(mp_rem_data, &mp_rem_tail,
7480Sstevel@tonic-gate (char *)&scre, sizeof (scre));
7490Sstevel@tonic-gate }
7501676Sjpk connp = sctp->sctp_connp;
7511676Sjpk needattr = B_FALSE;
7521676Sjpk bzero(&mlp, sizeof (mlp));
7531676Sjpk if (connp->conn_mlp_type != mlptSingle) {
7541676Sjpk if (connp->conn_mlp_type == mlptShared ||
7551676Sjpk connp->conn_mlp_type == mlptBoth)
7561676Sjpk mlp.tme_flags |= MIB2_TMEF_SHARED;
7571676Sjpk if (connp->conn_mlp_type == mlptPrivate ||
7581676Sjpk connp->conn_mlp_type == mlptBoth)
7591676Sjpk mlp.tme_flags |= MIB2_TMEF_PRIVATE;
7601676Sjpk needattr = B_TRUE;
7611676Sjpk }
7629710SKen.Powell@Sun.COM if (connp->conn_anon_mlp) {
7639710SKen.Powell@Sun.COM mlp.tme_flags |= MIB2_TMEF_ANONMLP;
7649710SKen.Powell@Sun.COM needattr = B_TRUE;
7659710SKen.Powell@Sun.COM }
76610934Ssommerfeld@sun.com switch (connp->conn_mac_mode) {
76710934Ssommerfeld@sun.com case CONN_MAC_DEFAULT:
76810934Ssommerfeld@sun.com break;
76910934Ssommerfeld@sun.com case CONN_MAC_AWARE:
7709710SKen.Powell@Sun.COM mlp.tme_flags |= MIB2_TMEF_MACEXEMPT;
7719710SKen.Powell@Sun.COM needattr = B_TRUE;
77210934Ssommerfeld@sun.com break;
77310934Ssommerfeld@sun.com case CONN_MAC_IMPLICIT:
77410934Ssommerfeld@sun.com mlp.tme_flags |= MIB2_TMEF_MACIMPLICIT;
77510934Ssommerfeld@sun.com needattr = B_TRUE;
77610934Ssommerfeld@sun.com break;
7779710SKen.Powell@Sun.COM }
77811042SErik.Nordmark@Sun.COM if (sctp->sctp_connp->conn_ixa->ixa_tsl != NULL) {
7791676Sjpk ts_label_t *tsl;
7801676Sjpk
78111042SErik.Nordmark@Sun.COM tsl = sctp->sctp_connp->conn_ixa->ixa_tsl;
7829710SKen.Powell@Sun.COM mlp.tme_flags |= MIB2_TMEF_IS_LABELED;
7831676Sjpk mlp.tme_doi = label2doi(tsl);
7841676Sjpk mlp.tme_label = *label2bslabel(tsl);
7851676Sjpk needattr = B_TRUE;
7861676Sjpk }
7870Sstevel@tonic-gate WAKE_SCTP(sctp);
7880Sstevel@tonic-gate sce.sctpAssocState = sctp_snmp_state(sctp);
7890Sstevel@tonic-gate sce.sctpAssocInStreams = sctp->sctp_num_istr;
7900Sstevel@tonic-gate sce.sctpAssocOutStreams = sctp->sctp_num_ostr;
7910Sstevel@tonic-gate sce.sctpAssocMaxRetr = sctp->sctp_pa_max_rxt;
7920Sstevel@tonic-gate /* A 0 here indicates that no primary process is known */
7930Sstevel@tonic-gate sce.sctpAssocPrimProcess = 0;
7940Sstevel@tonic-gate sce.sctpAssocT1expired = sctp->sctp_T1expire;
7950Sstevel@tonic-gate sce.sctpAssocT2expired = sctp->sctp_T2expire;
7960Sstevel@tonic-gate sce.sctpAssocRtxChunks = sctp->sctp_T3expire;
7970Sstevel@tonic-gate sce.sctpAssocStartTime = sctp->sctp_assoc_start_time;
7980Sstevel@tonic-gate sce.sctpConnEntryInfo.ce_sendq = sctp->sctp_unacked +
7990Sstevel@tonic-gate sctp->sctp_unsent;
8000Sstevel@tonic-gate sce.sctpConnEntryInfo.ce_recvq = sctp->sctp_rxqueued;
8010Sstevel@tonic-gate sce.sctpConnEntryInfo.ce_swnd = sctp->sctp_frwnd;
8020Sstevel@tonic-gate sce.sctpConnEntryInfo.ce_rwnd = sctp->sctp_rwnd;
8030Sstevel@tonic-gate sce.sctpConnEntryInfo.ce_mss = sctp->sctp_mss;
8040Sstevel@tonic-gate (void) snmp_append_data2(mp_conn_data, &mp_conn_tail,
8050Sstevel@tonic-gate (char *)&sce, sizeof (sce));
8061676Sjpk mlp.tme_connidx = idx++;
8071676Sjpk if (needattr)
8081676Sjpk (void) snmp_append_data2(mp_attr_ctl->b_cont,
8091676Sjpk &mp_attr_tail, (char *)&mlp, sizeof (mlp));
8100Sstevel@tonic-gate next_sctp:
8110Sstevel@tonic-gate sctp_prev = sctp;
8123448Sdh155122 mutex_enter(&sctps->sctps_g_lock);
8133448Sdh155122 sctp = list_next(&sctps->sctps_g_list, sctp);
8140Sstevel@tonic-gate }
8153448Sdh155122 mutex_exit(&sctps->sctps_g_lock);
8160Sstevel@tonic-gate if (sctp_prev != NULL)
8170Sstevel@tonic-gate SCTP_REFRELE(sctp_prev);
8180Sstevel@tonic-gate
81912869SKacheong.Poon@Sun.COM sctp_sum_mib(sctps, &sctp_mib);
82012869SKacheong.Poon@Sun.COM
8210Sstevel@tonic-gate optp = (struct opthdr *)&mpctl->b_rptr[sizeof (struct T_optmgmt_ack)];
8220Sstevel@tonic-gate optp->level = MIB2_SCTP;
8230Sstevel@tonic-gate optp->name = 0;
82412869SKacheong.Poon@Sun.COM (void) snmp_append_data(mpdata, (char *)&sctp_mib, sizeof (sctp_mib));
8250Sstevel@tonic-gate optp->len = msgdsize(mpdata);
8260Sstevel@tonic-gate qreply(q, mpctl);
8270Sstevel@tonic-gate
8280Sstevel@tonic-gate /* table of connections... */
8290Sstevel@tonic-gate optp = (struct opthdr *)&mp_conn_ctl->b_rptr[
8300Sstevel@tonic-gate sizeof (struct T_optmgmt_ack)];
8310Sstevel@tonic-gate optp->level = MIB2_SCTP;
8320Sstevel@tonic-gate optp->name = MIB2_SCTP_CONN;
8330Sstevel@tonic-gate optp->len = msgdsize(mp_conn_data);
8340Sstevel@tonic-gate qreply(q, mp_conn_ctl);
8350Sstevel@tonic-gate
8360Sstevel@tonic-gate /* assoc local address table */
8370Sstevel@tonic-gate optp = (struct opthdr *)&mp_local_ctl->b_rptr[
8380Sstevel@tonic-gate sizeof (struct T_optmgmt_ack)];
8390Sstevel@tonic-gate optp->level = MIB2_SCTP;
8400Sstevel@tonic-gate optp->name = MIB2_SCTP_CONN_LOCAL;
8410Sstevel@tonic-gate optp->len = msgdsize(mp_local_data);
8420Sstevel@tonic-gate qreply(q, mp_local_ctl);
8430Sstevel@tonic-gate
8440Sstevel@tonic-gate /* assoc remote address table */
8450Sstevel@tonic-gate optp = (struct opthdr *)&mp_rem_ctl->b_rptr[
8460Sstevel@tonic-gate sizeof (struct T_optmgmt_ack)];
8470Sstevel@tonic-gate optp->level = MIB2_SCTP;
8480Sstevel@tonic-gate optp->name = MIB2_SCTP_CONN_REMOTE;
8490Sstevel@tonic-gate optp->len = msgdsize(mp_rem_data);
8500Sstevel@tonic-gate qreply(q, mp_rem_ctl);
8510Sstevel@tonic-gate
8521676Sjpk /* table of MLP attributes */
8531676Sjpk optp = (struct opthdr *)&mp_attr_ctl->b_rptr[
8541676Sjpk sizeof (struct T_optmgmt_ack)];
8551676Sjpk optp->level = MIB2_SCTP;
8561676Sjpk optp->name = EXPER_XPORT_MLP;
8571676Sjpk optp->len = msgdsize(mp_attr_data);
8581676Sjpk if (optp->len == 0)
8591676Sjpk freemsg(mp_attr_ctl);
8601676Sjpk else
8611676Sjpk qreply(q, mp_attr_ctl);
8621676Sjpk
8630Sstevel@tonic-gate return (mp_ret);
8640Sstevel@tonic-gate }
8650Sstevel@tonic-gate
8660Sstevel@tonic-gate /* Translate SCTP state to MIB2 SCTP state. */
8670Sstevel@tonic-gate static int
sctp_snmp_state(sctp_t * sctp)8680Sstevel@tonic-gate sctp_snmp_state(sctp_t *sctp)
8690Sstevel@tonic-gate {
8700Sstevel@tonic-gate if (sctp == NULL)
8710Sstevel@tonic-gate return (0);
8720Sstevel@tonic-gate
8730Sstevel@tonic-gate switch (sctp->sctp_state) {
8740Sstevel@tonic-gate case SCTPS_IDLE:
8750Sstevel@tonic-gate case SCTPS_BOUND:
8760Sstevel@tonic-gate return (MIB2_SCTP_closed);
8770Sstevel@tonic-gate case SCTPS_LISTEN:
8780Sstevel@tonic-gate return (MIB2_SCTP_listen);
8790Sstevel@tonic-gate case SCTPS_COOKIE_WAIT:
8800Sstevel@tonic-gate return (MIB2_SCTP_cookieWait);
8810Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED:
8820Sstevel@tonic-gate return (MIB2_SCTP_cookieEchoed);
8830Sstevel@tonic-gate case SCTPS_ESTABLISHED:
8840Sstevel@tonic-gate return (MIB2_SCTP_established);
8850Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING:
8860Sstevel@tonic-gate return (MIB2_SCTP_shutdownPending);
8870Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT:
8880Sstevel@tonic-gate return (MIB2_SCTP_shutdownSent);
8890Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED:
8900Sstevel@tonic-gate return (MIB2_SCTP_shutdownReceived);
8910Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT:
8920Sstevel@tonic-gate return (MIB2_SCTP_shutdownAckSent);
8930Sstevel@tonic-gate default:
8940Sstevel@tonic-gate return (0);
8950Sstevel@tonic-gate }
8960Sstevel@tonic-gate }
89712869SKacheong.Poon@Sun.COM
89812869SKacheong.Poon@Sun.COM /*
89912869SKacheong.Poon@Sun.COM * To sum up all MIB2 stats for a sctp_stack_t from all per CPU stats. The
90012869SKacheong.Poon@Sun.COM * caller should initialize the target mib2_sctp_t properly as this function
90112869SKacheong.Poon@Sun.COM * just adds up all the per CPU stats.
90212869SKacheong.Poon@Sun.COM */
90312869SKacheong.Poon@Sun.COM static void
sctp_sum_mib(sctp_stack_t * sctps,mib2_sctp_t * sctp_mib)90412869SKacheong.Poon@Sun.COM sctp_sum_mib(sctp_stack_t *sctps, mib2_sctp_t *sctp_mib)
90512869SKacheong.Poon@Sun.COM {
90612869SKacheong.Poon@Sun.COM int i;
90712869SKacheong.Poon@Sun.COM int cnt;
90812869SKacheong.Poon@Sun.COM
90912869SKacheong.Poon@Sun.COM /* Static componets of mib2_sctp_t. */
91012869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpRtoAlgorithm, MIB2_SCTP_RTOALGO_VANJ);
91112869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpRtoMin, sctps->sctps_rto_ming);
91212869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpRtoMax, sctps->sctps_rto_maxg);
91312869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpRtoInitial, sctps->sctps_rto_initialg);
91412869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpMaxAssocs, -1);
91512869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpValCookieLife, sctps->sctps_cookie_life);
91612869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpMaxInitRetr, sctps->sctps_max_init_retr);
91712869SKacheong.Poon@Sun.COM
91812869SKacheong.Poon@Sun.COM /* fixed length structure for IPv4 and IPv6 counters */
91912869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpEntrySize, sizeof (mib2_sctpConnEntry_t));
92012869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpLocalEntrySize,
92112869SKacheong.Poon@Sun.COM sizeof (mib2_sctpConnLocalEntry_t));
92212869SKacheong.Poon@Sun.COM SET_MIB(sctp_mib->sctpRemoteEntrySize,
92312869SKacheong.Poon@Sun.COM sizeof (mib2_sctpConnRemoteEntry_t));
92412869SKacheong.Poon@Sun.COM
92512869SKacheong.Poon@Sun.COM /*
92612869SKacheong.Poon@Sun.COM * sctps_sc_cnt may change in the middle of the loop. It is better
92712869SKacheong.Poon@Sun.COM * to get its value first.
92812869SKacheong.Poon@Sun.COM */
92912869SKacheong.Poon@Sun.COM cnt = sctps->sctps_sc_cnt;
93012869SKacheong.Poon@Sun.COM for (i = 0; i < cnt; i++)
93112869SKacheong.Poon@Sun.COM sctp_add_mib(&sctps->sctps_sc[i]->sctp_sc_mib, sctp_mib);
93212869SKacheong.Poon@Sun.COM }
93312869SKacheong.Poon@Sun.COM
93412869SKacheong.Poon@Sun.COM static void
sctp_add_mib(mib2_sctp_t * from,mib2_sctp_t * to)93512869SKacheong.Poon@Sun.COM sctp_add_mib(mib2_sctp_t *from, mib2_sctp_t *to)
93612869SKacheong.Poon@Sun.COM {
93712869SKacheong.Poon@Sun.COM to->sctpActiveEstab += from->sctpActiveEstab;
93812869SKacheong.Poon@Sun.COM to->sctpPassiveEstab += from->sctpPassiveEstab;
93912869SKacheong.Poon@Sun.COM to->sctpAborted += from->sctpAborted;
94012869SKacheong.Poon@Sun.COM to->sctpShutdowns += from->sctpShutdowns;
94112869SKacheong.Poon@Sun.COM to->sctpOutOfBlue += from->sctpOutOfBlue;
94212869SKacheong.Poon@Sun.COM to->sctpChecksumError += from->sctpChecksumError;
94312869SKacheong.Poon@Sun.COM to->sctpOutCtrlChunks += from->sctpOutCtrlChunks;
94412869SKacheong.Poon@Sun.COM to->sctpOutOrderChunks += from->sctpOutOrderChunks;
94512869SKacheong.Poon@Sun.COM to->sctpOutUnorderChunks += from->sctpOutUnorderChunks;
94612869SKacheong.Poon@Sun.COM to->sctpRetransChunks += from->sctpRetransChunks;
94712869SKacheong.Poon@Sun.COM to->sctpOutAck += from->sctpOutAck;
94812869SKacheong.Poon@Sun.COM to->sctpOutAckDelayed += from->sctpOutAckDelayed;
94912869SKacheong.Poon@Sun.COM to->sctpOutWinUpdate += from->sctpOutWinUpdate;
95012869SKacheong.Poon@Sun.COM to->sctpOutFastRetrans += from->sctpOutFastRetrans;
95112869SKacheong.Poon@Sun.COM to->sctpOutWinProbe += from->sctpOutWinProbe;
95212869SKacheong.Poon@Sun.COM to->sctpInCtrlChunks += from->sctpInCtrlChunks;
95312869SKacheong.Poon@Sun.COM to->sctpInOrderChunks += from->sctpInOrderChunks;
95412869SKacheong.Poon@Sun.COM to->sctpInUnorderChunks += from->sctpInUnorderChunks;
95512869SKacheong.Poon@Sun.COM to->sctpInAck += from->sctpInAck;
95612869SKacheong.Poon@Sun.COM to->sctpInDupAck += from->sctpInDupAck;
95712869SKacheong.Poon@Sun.COM to->sctpInAckUnsent += from->sctpInAckUnsent;
95812869SKacheong.Poon@Sun.COM to->sctpFragUsrMsgs += from->sctpFragUsrMsgs;
95912869SKacheong.Poon@Sun.COM to->sctpReasmUsrMsgs += from->sctpReasmUsrMsgs;
96012869SKacheong.Poon@Sun.COM to->sctpOutSCTPPkts += from->sctpOutSCTPPkts;
96112869SKacheong.Poon@Sun.COM to->sctpInSCTPPkts += from->sctpInSCTPPkts;
96212869SKacheong.Poon@Sun.COM to->sctpInInvalidCookie += from->sctpInInvalidCookie;
96312869SKacheong.Poon@Sun.COM to->sctpTimRetrans += from->sctpTimRetrans;
96412869SKacheong.Poon@Sun.COM to->sctpTimRetransDrop += from->sctpTimRetransDrop;
96512869SKacheong.Poon@Sun.COM to->sctpTimHeartBeatProbe += from->sctpTimHeartBeatProbe;
96612869SKacheong.Poon@Sun.COM to->sctpTimHeartBeatDrop += from->sctpTimHeartBeatDrop;
96712869SKacheong.Poon@Sun.COM to->sctpListenDrop += from->sctpListenDrop;
96812869SKacheong.Poon@Sun.COM to->sctpInClosed += from->sctpInClosed;
96912869SKacheong.Poon@Sun.COM }
970