Print this page
10096 kstat update routines shouldn't check for NULL kstat
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/sctp/sctp_snmp.c
+++ new/usr/src/uts/common/inet/sctp/sctp_snmp.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 +/*
27 + * Copyright (c) 2018, Joyent, Inc.
28 + */
29 +
26 30 #include <sys/types.h>
27 31 #include <sys/stream.h>
28 32 #include <sys/cmn_err.h>
29 33 #define _SUN_TPI_VERSION 2
30 34 #include <sys/tihdr.h>
31 35 #include <sys/ddi.h>
32 36 #include <sys/sunddi.h>
33 37 #include <sys/tsol/tndb.h>
34 38
35 39 #include <netinet/in.h>
36 40
37 41 #include <inet/common.h>
38 42 #include <inet/ip.h>
39 43 #include <inet/mib2.h>
40 44 #include <inet/snmpcom.h>
41 45 #include <inet/kstatcom.h>
42 46 #include <inet/ipclassifier.h>
43 47 #include "sctp_impl.h"
44 48 #include "sctp_addr.h"
45 49
46 50 static void sctp_clr_kstats2(sctp_kstat_t *);
47 51 static void sctp_add_kstats2(sctp_kstat_counter_t *, sctp_kstat_t *);
48 52 static int sctp_snmp_state(sctp_t *);
49 53 static void sctp_sum_mib(sctp_stack_t *, mib2_sctp_t *);
50 54 static void sctp_add_mib(mib2_sctp_t *, mib2_sctp_t *);
51 55
52 56 static int
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
53 57 sctp_kstat_update(kstat_t *kp, int rw)
54 58 {
55 59 sctp_named_kstat_t *sctpkp;
56 60 sctp_t *sctp, *sctp_prev;
57 61 zoneid_t myzoneid;
58 62 netstackid_t stackid = (netstackid_t)(uintptr_t)kp->ks_private;
59 63 netstack_t *ns;
60 64 sctp_stack_t *sctps;
61 65 mib2_sctp_t sctp_mib;
62 66
63 - if (kp == NULL|| kp->ks_data == NULL)
67 + if (kp->ks_data == NULL)
64 68 return (EIO);
65 69
66 70 if (rw == KSTAT_WRITE)
67 71 return (EACCES);
68 72
69 73 ns = netstack_find_by_stackid(stackid);
70 74 if (ns == NULL)
71 75 return (-1);
72 76 sctps = ns->netstack_sctp;
73 77 if (sctps == NULL) {
74 78 netstack_rele(ns);
75 79 return (-1);
76 80 }
77 81
78 82 /*
79 83 * For all exclusive netstacks, the zone ID is always GLOBAL_ZONEID.
80 84 */
81 85 if (stackid != GLOBAL_NETSTACKID)
82 86 myzoneid = GLOBAL_ZONEID;
83 87 else
84 88 myzoneid = curproc->p_zone->zone_id;
85 89
86 90 bzero(&sctp_mib, sizeof (sctp_mib));
87 91
88 92 /*
89 93 * Get the number of current associations and gather their
90 94 * individual set of statistics.
91 95 */
92 96 sctp_prev = NULL;
93 97 mutex_enter(&sctps->sctps_g_lock);
94 98 sctp = list_head(&sctps->sctps_g_list);
95 99 while (sctp != NULL) {
96 100 mutex_enter(&sctp->sctp_reflock);
97 101 if (sctp->sctp_condemned) {
98 102 mutex_exit(&sctp->sctp_reflock);
99 103 sctp = list_next(&sctps->sctps_g_list, sctp);
100 104 continue;
101 105 }
102 106 sctp->sctp_refcnt++;
103 107 mutex_exit(&sctp->sctp_reflock);
104 108 mutex_exit(&sctps->sctps_g_lock);
105 109 if (sctp_prev != NULL)
106 110 SCTP_REFRELE(sctp_prev);
107 111 if (sctp->sctp_connp->conn_zoneid != myzoneid)
108 112 goto next_sctp;
109 113 if (sctp->sctp_state == SCTPS_ESTABLISHED ||
110 114 sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
111 115 sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
112 116 /*
113 117 * Just bump the local sctp_mib. The number of
114 118 * existing associations is not kept in kernel.
115 119 */
116 120 BUMP_MIB(&sctp_mib, sctpCurrEstab);
117 121 }
118 122
119 123 if (sctp->sctp_opkts) {
120 124 SCTPS_UPDATE_MIB(sctps, sctpOutSCTPPkts,
121 125 sctp->sctp_opkts);
122 126 sctp->sctp_opkts = 0;
123 127 }
124 128
125 129 if (sctp->sctp_obchunks) {
126 130 SCTPS_UPDATE_MIB(sctps, sctpOutCtrlChunks,
127 131 sctp->sctp_obchunks);
128 132 UPDATE_LOCAL(sctp->sctp_cum_obchunks,
129 133 sctp->sctp_obchunks);
130 134 sctp->sctp_obchunks = 0;
131 135 }
132 136
133 137 if (sctp->sctp_odchunks) {
134 138 SCTPS_UPDATE_MIB(sctps, sctpOutOrderChunks,
135 139 sctp->sctp_odchunks);
136 140 UPDATE_LOCAL(sctp->sctp_cum_odchunks,
137 141 sctp->sctp_odchunks);
138 142 sctp->sctp_odchunks = 0;
139 143 }
140 144
141 145 if (sctp->sctp_oudchunks) {
142 146 SCTPS_UPDATE_MIB(sctps, sctpOutUnorderChunks,
143 147 sctp->sctp_oudchunks);
144 148 UPDATE_LOCAL(sctp->sctp_cum_oudchunks,
145 149 sctp->sctp_oudchunks);
146 150 sctp->sctp_oudchunks = 0;
147 151 }
148 152
149 153 if (sctp->sctp_rxtchunks) {
150 154 SCTPS_UPDATE_MIB(sctps, sctpRetransChunks,
151 155 sctp->sctp_rxtchunks);
152 156 UPDATE_LOCAL(sctp->sctp_cum_rxtchunks,
153 157 sctp->sctp_rxtchunks);
154 158 sctp->sctp_rxtchunks = 0;
155 159 }
156 160
157 161 if (sctp->sctp_ipkts) {
158 162 SCTPS_UPDATE_MIB(sctps, sctpInSCTPPkts,
159 163 sctp->sctp_ipkts);
160 164 sctp->sctp_ipkts = 0;
161 165 }
162 166
163 167 if (sctp->sctp_ibchunks) {
164 168 SCTPS_UPDATE_MIB(sctps, sctpInCtrlChunks,
165 169 sctp->sctp_ibchunks);
166 170 UPDATE_LOCAL(sctp->sctp_cum_ibchunks,
167 171 sctp->sctp_ibchunks);
168 172 sctp->sctp_ibchunks = 0;
169 173 }
170 174
171 175 if (sctp->sctp_idchunks) {
172 176 SCTPS_UPDATE_MIB(sctps, sctpInOrderChunks,
173 177 sctp->sctp_idchunks);
174 178 UPDATE_LOCAL(sctp->sctp_cum_idchunks,
175 179 sctp->sctp_idchunks);
176 180 sctp->sctp_idchunks = 0;
177 181 }
178 182
179 183 if (sctp->sctp_iudchunks) {
180 184 SCTPS_UPDATE_MIB(sctps, sctpInUnorderChunks,
181 185 sctp->sctp_iudchunks);
182 186 UPDATE_LOCAL(sctp->sctp_cum_iudchunks,
183 187 sctp->sctp_iudchunks);
184 188 sctp->sctp_iudchunks = 0;
185 189 }
186 190
187 191 if (sctp->sctp_fragdmsgs) {
188 192 SCTPS_UPDATE_MIB(sctps, sctpFragUsrMsgs,
189 193 sctp->sctp_fragdmsgs);
190 194 sctp->sctp_fragdmsgs = 0;
191 195 }
192 196
193 197 if (sctp->sctp_reassmsgs) {
194 198 SCTPS_UPDATE_MIB(sctps, sctpReasmUsrMsgs,
195 199 sctp->sctp_reassmsgs);
196 200 sctp->sctp_reassmsgs = 0;
197 201 }
198 202
199 203 next_sctp:
200 204 sctp_prev = sctp;
201 205 mutex_enter(&sctps->sctps_g_lock);
202 206 sctp = list_next(&sctps->sctps_g_list, sctp);
203 207 }
204 208 mutex_exit(&sctps->sctps_g_lock);
205 209 if (sctp_prev != NULL)
206 210 SCTP_REFRELE(sctp_prev);
207 211
208 212 sctp_sum_mib(sctps, &sctp_mib);
209 213
210 214 /* Copy data from the SCTP MIB */
211 215 sctpkp = (sctp_named_kstat_t *)kp->ks_data;
212 216
213 217 /* These are from global ndd params. */
214 218 sctpkp->sctpRtoMin.value.ui32 = sctps->sctps_rto_ming;
215 219 sctpkp->sctpRtoMax.value.ui32 = sctps->sctps_rto_maxg;
216 220 sctpkp->sctpRtoInitial.value.ui32 = sctps->sctps_rto_initialg;
217 221 sctpkp->sctpValCookieLife.value.ui32 = sctps->sctps_cookie_life;
218 222 sctpkp->sctpMaxInitRetr.value.ui32 = sctps->sctps_max_init_retr;
219 223
220 224 /* Copy data from the local sctp_mib to the provided kstat. */
221 225 sctpkp->sctpCurrEstab.value.i32 = sctp_mib.sctpCurrEstab;
222 226 sctpkp->sctpActiveEstab.value.i32 = sctp_mib.sctpActiveEstab;
223 227 sctpkp->sctpPassiveEstab.value.i32 = sctp_mib.sctpPassiveEstab;
224 228 sctpkp->sctpAborted.value.i32 = sctp_mib.sctpAborted;
225 229 sctpkp->sctpShutdowns.value.i32 = sctp_mib.sctpShutdowns;
226 230 sctpkp->sctpOutOfBlue.value.i32 = sctp_mib.sctpOutOfBlue;
227 231 sctpkp->sctpChecksumError.value.i32 = sctp_mib.sctpChecksumError;
228 232 sctpkp->sctpOutCtrlChunks.value.i64 = sctp_mib.sctpOutCtrlChunks;
229 233 sctpkp->sctpOutOrderChunks.value.i64 = sctp_mib.sctpOutOrderChunks;
230 234 sctpkp->sctpOutUnorderChunks.value.i64 = sctp_mib.sctpOutUnorderChunks;
231 235 sctpkp->sctpRetransChunks.value.i64 = sctp_mib.sctpRetransChunks;
232 236 sctpkp->sctpOutAck.value.i32 = sctp_mib.sctpOutAck;
233 237 sctpkp->sctpOutAckDelayed.value.i32 = sctp_mib.sctpOutAckDelayed;
234 238 sctpkp->sctpOutWinUpdate.value.i32 = sctp_mib.sctpOutWinUpdate;
235 239 sctpkp->sctpOutFastRetrans.value.i32 = sctp_mib.sctpOutFastRetrans;
236 240 sctpkp->sctpOutWinProbe.value.i32 = sctp_mib.sctpOutWinProbe;
237 241 sctpkp->sctpInCtrlChunks.value.i64 = sctp_mib.sctpInCtrlChunks;
238 242 sctpkp->sctpInOrderChunks.value.i64 = sctp_mib.sctpInOrderChunks;
239 243 sctpkp->sctpInUnorderChunks.value.i64 = sctp_mib.sctpInUnorderChunks;
240 244 sctpkp->sctpInAck.value.i32 = sctp_mib.sctpInAck;
241 245 sctpkp->sctpInDupAck.value.i32 = sctp_mib.sctpInDupAck;
242 246 sctpkp->sctpInAckUnsent.value.i32 = sctp_mib.sctpInAckUnsent;
243 247 sctpkp->sctpFragUsrMsgs.value.i64 = sctp_mib.sctpFragUsrMsgs;
244 248 sctpkp->sctpReasmUsrMsgs.value.i64 = sctp_mib.sctpReasmUsrMsgs;
245 249 sctpkp->sctpOutSCTPPkts.value.i64 = sctp_mib.sctpOutSCTPPkts;
246 250 sctpkp->sctpInSCTPPkts.value.i64 = sctp_mib.sctpInSCTPPkts;
247 251 sctpkp->sctpInInvalidCookie.value.i32 = sctp_mib.sctpInInvalidCookie;
248 252 sctpkp->sctpTimRetrans.value.i32 = sctp_mib.sctpTimRetrans;
249 253 sctpkp->sctpTimRetransDrop.value.i32 = sctp_mib.sctpTimRetransDrop;
250 254 sctpkp->sctpTimHeartBeatProbe.value.i32 =
251 255 sctp_mib.sctpTimHeartBeatProbe;
252 256 sctpkp->sctpTimHeartBeatDrop.value.i32 = sctp_mib.sctpTimHeartBeatDrop;
253 257 sctpkp->sctpListenDrop.value.i32 = sctp_mib.sctpListenDrop;
254 258 sctpkp->sctpInClosed.value.i32 = sctp_mib.sctpInClosed;
255 259
256 260 netstack_rele(ns);
257 261 return (0);
258 262 }
259 263
260 264 void *
261 265 sctp_kstat_init(netstackid_t stackid)
262 266 {
263 267 kstat_t *ksp;
264 268
265 269 sctp_named_kstat_t template = {
266 270 { "sctpRtoAlgorithm", KSTAT_DATA_INT32, 0 },
267 271 { "sctpRtoMin", KSTAT_DATA_UINT32, 0 },
268 272 { "sctpRtoMax", KSTAT_DATA_UINT32, 0 },
269 273 { "sctpRtoInitial", KSTAT_DATA_UINT32, 0 },
270 274 { "sctpMaxAssocs", KSTAT_DATA_INT32, 0 },
271 275 { "sctpValCookieLife", KSTAT_DATA_UINT32, 0 },
272 276 { "sctpMaxInitRetr", KSTAT_DATA_UINT32, 0 },
273 277 { "sctpCurrEstab", KSTAT_DATA_INT32, 0 },
274 278 { "sctpActiveEstab", KSTAT_DATA_INT32, 0 },
275 279 { "sctpPassiveEstab", KSTAT_DATA_INT32, 0 },
276 280 { "sctpAborted", KSTAT_DATA_INT32, 0 },
277 281 { "sctpShutdowns", KSTAT_DATA_INT32, 0 },
278 282 { "sctpOutOfBlue", KSTAT_DATA_INT32, 0 },
279 283 { "sctpChecksumError", KSTAT_DATA_INT32, 0 },
280 284 { "sctpOutCtrlChunks", KSTAT_DATA_INT64, 0 },
281 285 { "sctpOutOrderChunks", KSTAT_DATA_INT64, 0 },
282 286 { "sctpOutUnorderChunks", KSTAT_DATA_INT64, 0 },
283 287 { "sctpRetransChunks", KSTAT_DATA_INT64, 0 },
284 288 { "sctpOutAck", KSTAT_DATA_INT32, 0 },
285 289 { "sctpOutAckDelayed", KSTAT_DATA_INT32, 0 },
286 290 { "sctpOutWinUpdate", KSTAT_DATA_INT32, 0 },
287 291 { "sctpOutFastRetrans", KSTAT_DATA_INT32, 0 },
288 292 { "sctpOutWinProbe", KSTAT_DATA_INT32, 0 },
289 293 { "sctpInCtrlChunks", KSTAT_DATA_INT64, 0 },
290 294 { "sctpInOrderChunks", KSTAT_DATA_INT64, 0 },
291 295 { "sctpInUnorderChunks", KSTAT_DATA_INT64, 0 },
292 296 { "sctpInAck", KSTAT_DATA_INT32, 0 },
293 297 { "sctpInDupAck", KSTAT_DATA_INT32, 0 },
294 298 { "sctpInAckUnsent", KSTAT_DATA_INT32, 0 },
295 299 { "sctpFragUsrMsgs", KSTAT_DATA_INT64, 0 },
296 300 { "sctpReasmUsrMsgs", KSTAT_DATA_INT64, 0 },
297 301 { "sctpOutSCTPPkts", KSTAT_DATA_INT64, 0 },
298 302 { "sctpInSCTPPkts", KSTAT_DATA_INT64, 0 },
299 303 { "sctpInInvalidCookie", KSTAT_DATA_INT32, 0 },
300 304 { "sctpTimRetrans", KSTAT_DATA_INT32, 0 },
301 305 { "sctpTimRetransDrop", KSTAT_DATA_INT32, 0 },
302 306 { "sctpTimHearBeatProbe", KSTAT_DATA_INT32, 0 },
303 307 { "sctpTimHearBeatDrop", KSTAT_DATA_INT32, 0 },
304 308 { "sctpListenDrop", KSTAT_DATA_INT32, 0 },
305 309 { "sctpInClosed", KSTAT_DATA_INT32, 0 }
306 310 };
307 311
308 312 ksp = kstat_create_netstack(SCTP_MOD_NAME, 0, "sctp", "mib2",
309 313 KSTAT_TYPE_NAMED, NUM_OF_FIELDS(sctp_named_kstat_t), 0, stackid);
310 314
311 315 if (ksp == NULL)
312 316 return (NULL);
313 317
314 318 /* These won't change. */
315 319 template.sctpRtoAlgorithm.value.i32 = MIB2_SCTP_RTOALGO_VANJ;
316 320 template.sctpMaxAssocs.value.i32 = -1;
317 321
318 322 bcopy(&template, ksp->ks_data, sizeof (template));
319 323 ksp->ks_update = sctp_kstat_update;
320 324 ksp->ks_private = (void *)(uintptr_t)stackid;
321 325
322 326 kstat_install(ksp);
323 327 return (ksp);
324 328 }
325 329
326 330 /*
327 331 * To set all sctp_stat_t counters to 0.
328 332 */
329 333 static void
330 334 sctp_clr_kstats2(sctp_kstat_t *stats)
331 335 {
332 336 stats->sctp_add_faddr.value.ui64 = 0;
333 337 stats->sctp_add_timer.value.ui64 = 0;
334 338 stats->sctp_conn_create.value.ui64 = 0;
335 339 stats->sctp_find_next_tq.value.ui64 = 0;
336 340 stats->sctp_fr_add_hdr.value.ui64 = 0;
337 341 stats->sctp_fr_not_found.value.ui64 = 0;
338 342 stats->sctp_output_failed.value.ui64 = 0;
339 343 stats->sctp_rexmit_failed.value.ui64 = 0;
340 344 stats->sctp_send_init_failed.value.ui64 = 0;
341 345 stats->sctp_send_cookie_failed.value.ui64 = 0;
342 346 stats->sctp_send_cookie_ack_failed.value.ui64 = 0;
343 347 stats->sctp_send_err_failed.value.ui64 = 0;
344 348 stats->sctp_send_sack_failed.value.ui64 = 0;
345 349 stats->sctp_send_shutdown_failed.value.ui64 = 0;
346 350 stats->sctp_send_shutdown_ack_failed.value.ui64 = 0;
347 351 stats->sctp_send_shutdown_comp_failed.value.ui64 = 0;
348 352 stats->sctp_send_user_abort_failed.value.ui64 = 0;
349 353 stats->sctp_send_asconf_failed.value.ui64 = 0;
350 354 stats->sctp_send_asconf_ack_failed.value.ui64 = 0;
351 355 stats->sctp_send_ftsn_failed.value.ui64 = 0;
352 356 stats->sctp_send_hb_failed.value.ui64 = 0;
353 357 stats->sctp_return_hb_failed.value.ui64 = 0;
354 358 stats->sctp_ss_rexmit_failed.value.ui64 = 0;
355 359 stats->sctp_cl_connect.value.ui64 = 0;
356 360 stats->sctp_cl_assoc_change.value.ui64 = 0;
357 361 stats->sctp_cl_check_addrs.value.ui64 = 0;
358 362 stats->sctp_reclaim_cnt.value.ui64 = 0;
359 363 stats->sctp_listen_cnt_drop.value.ui64 = 0;
360 364 }
361 365
362 366 /*
363 367 * To add counters from the per CPU sctp_kstat_counter_t to the stack
364 368 * sctp_kstat_t.
365 369 */
366 370 static void
367 371 sctp_add_kstats2(sctp_kstat_counter_t *from, sctp_kstat_t *to)
368 372 {
369 373 to->sctp_add_faddr.value.ui64 += from->sctp_add_faddr;
370 374 to->sctp_add_timer.value.ui64 += from->sctp_add_timer;
371 375 to->sctp_conn_create.value.ui64 += from->sctp_conn_create;
372 376 to->sctp_find_next_tq.value.ui64 += from->sctp_find_next_tq;
373 377 to->sctp_fr_add_hdr.value.ui64 += from->sctp_fr_add_hdr;
374 378 to->sctp_fr_not_found.value.ui64 += from->sctp_fr_not_found;
375 379 to->sctp_output_failed.value.ui64 += from->sctp_output_failed;
376 380 to->sctp_rexmit_failed.value.ui64 += from->sctp_rexmit_failed;
377 381 to->sctp_send_init_failed.value.ui64 += from->sctp_send_init_failed;
378 382 to->sctp_send_cookie_failed.value.ui64 += from->sctp_send_cookie_failed;
379 383 to->sctp_send_cookie_ack_failed.value.ui64 +=
380 384 from->sctp_send_cookie_ack_failed;
381 385 to->sctp_send_err_failed.value.ui64 += from->sctp_send_err_failed;
382 386 to->sctp_send_sack_failed.value.ui64 += from->sctp_send_sack_failed;
383 387 to->sctp_send_shutdown_failed.value.ui64 +=
384 388 from->sctp_send_shutdown_failed;
385 389 to->sctp_send_shutdown_ack_failed.value.ui64 +=
386 390 from->sctp_send_shutdown_ack_failed;
387 391 to->sctp_send_shutdown_comp_failed.value.ui64 +=
388 392 from->sctp_send_shutdown_comp_failed;
389 393 to->sctp_send_user_abort_failed.value.ui64 +=
390 394 from->sctp_send_user_abort_failed;
391 395 to->sctp_send_asconf_failed.value.ui64 += from->sctp_send_asconf_failed;
392 396 to->sctp_send_asconf_ack_failed.value.ui64 +=
393 397 from->sctp_send_asconf_ack_failed;
394 398 to->sctp_send_ftsn_failed.value.ui64 += from->sctp_send_ftsn_failed;
395 399 to->sctp_send_hb_failed.value.ui64 += from->sctp_send_hb_failed;
396 400 to->sctp_return_hb_failed.value.ui64 += from->sctp_return_hb_failed;
397 401 to->sctp_ss_rexmit_failed.value.ui64 += from->sctp_ss_rexmit_failed;
398 402 to->sctp_cl_connect.value.ui64 += from->sctp_cl_connect;
399 403 to->sctp_cl_assoc_change.value.ui64 += from->sctp_cl_assoc_change;
400 404 to->sctp_cl_check_addrs.value.ui64 += from->sctp_cl_check_addrs;
401 405 }
402 406
403 407 /*
404 408 * Sum up all per CPU tcp_stat_t kstat counters.
405 409 */
406 410 static int
407 411 sctp_kstat2_update(kstat_t *kp, int rw)
408 412 {
409 413 netstackid_t stackid = (netstackid_t)(uintptr_t)kp->ks_private;
410 414 netstack_t *ns;
411 415 sctp_stack_t *sctps;
412 416 sctp_kstat_t *stats;
413 417 int i;
414 418 int cnt;
415 419
416 420 if (rw == KSTAT_WRITE)
417 421 return (EACCES);
418 422
419 423 ns = netstack_find_by_stackid(stackid);
420 424 if (ns == NULL)
421 425 return (-1);
422 426 sctps = ns->netstack_sctp;
423 427 if (sctps == NULL) {
424 428 netstack_rele(ns);
425 429 return (-1);
426 430 }
427 431
428 432 stats = (sctp_kstat_t *)kp->ks_data;
429 433 sctp_clr_kstats2(stats);
430 434
431 435 /*
432 436 * sctps_sc_cnt may change in the middle of the loop. It is better
433 437 * to get its value first.
434 438 */
435 439 cnt = sctps->sctps_sc_cnt;
436 440 for (i = 0; i < cnt; i++)
437 441 sctp_add_kstats2(&sctps->sctps_sc[i]->sctp_sc_stats, stats);
438 442
439 443 netstack_rele(ns);
440 444 return (0);
441 445 }
442 446
443 447 /*
444 448 * The following kstats are for debugging purposes. They keep
445 449 * track of problems which should not happen normally. But in
446 450 * those cases which they do happen, these kstats would be handy
447 451 * for engineers to diagnose the problems. They are not intended
448 452 * to be consumed by customers.
449 453 */
450 454 void *
451 455 sctp_kstat2_init(netstackid_t stackid)
452 456 {
453 457 kstat_t *ksp;
454 458
455 459 sctp_kstat_t template = {
456 460 { "sctp_add_faddr", KSTAT_DATA_UINT64 },
457 461 { "sctp_add_timer", KSTAT_DATA_UINT64 },
458 462 { "sctp_conn_create", KSTAT_DATA_UINT64 },
459 463 { "sctp_find_next_tq", KSTAT_DATA_UINT64 },
460 464 { "sctp_fr_add_hdr", KSTAT_DATA_UINT64 },
461 465 { "sctp_fr_not_found", KSTAT_DATA_UINT64 },
462 466 { "sctp_output_failed", KSTAT_DATA_UINT64 },
463 467 { "sctp_rexmit_failed", KSTAT_DATA_UINT64 },
464 468 { "sctp_send_init_failed", KSTAT_DATA_UINT64 },
465 469 { "sctp_send_cookie_failed", KSTAT_DATA_UINT64 },
466 470 { "sctp_send_cookie_ack_failed", KSTAT_DATA_UINT64 },
467 471 { "sctp_send_err_failed", KSTAT_DATA_UINT64 },
468 472 { "sctp_send_sack_failed", KSTAT_DATA_UINT64 },
469 473 { "sctp_send_shutdown_failed", KSTAT_DATA_UINT64 },
470 474 { "sctp_send_shutdown_ack_failed", KSTAT_DATA_UINT64 },
471 475 { "sctp_send_shutdown_comp_failed", KSTAT_DATA_UINT64 },
472 476 { "sctp_send_user_abort_failed", KSTAT_DATA_UINT64 },
473 477 { "sctp_send_asconf_failed", KSTAT_DATA_UINT64 },
474 478 { "sctp_send_asconf_ack_failed", KSTAT_DATA_UINT64 },
475 479 { "sctp_send_ftsn_failed", KSTAT_DATA_UINT64 },
476 480 { "sctp_send_hb_failed", KSTAT_DATA_UINT64 },
477 481 { "sctp_return_hb_failed", KSTAT_DATA_UINT64 },
478 482 { "sctp_ss_rexmit_failed", KSTAT_DATA_UINT64 },
479 483 { "sctp_cl_connect", KSTAT_DATA_UINT64 },
480 484 { "sctp_cl_assoc_change", KSTAT_DATA_UINT64 },
481 485 { "sctp_cl_check_addrs", KSTAT_DATA_UINT64 },
482 486 { "sctp_reclaim_drop", KSTAT_DATA_UINT64 },
483 487 { "sctp_listen_cnt_drop", KSTAT_DATA_UINT64 },
484 488 };
485 489
486 490 ksp = kstat_create_netstack(SCTP_MOD_NAME, 0, "sctpstat", "net",
487 491 KSTAT_TYPE_NAMED, NUM_OF_FIELDS(template), 0, stackid);
488 492
489 493 if (ksp == NULL)
490 494 return (NULL);
491 495
492 496 bcopy(&template, ksp->ks_data, sizeof (template));
493 497 ksp->ks_private = (void *)(uintptr_t)stackid;
494 498 ksp->ks_update = sctp_kstat2_update;
495 499
496 500 kstat_install(ksp);
497 501 return (ksp);
498 502 }
499 503
500 504 void
501 505 sctp_kstat_fini(netstackid_t stackid, kstat_t *ksp)
502 506 {
503 507 if (ksp != NULL) {
504 508 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
505 509 kstat_delete_netstack(ksp, stackid);
506 510 }
507 511 }
508 512
509 513 void
510 514 sctp_kstat2_fini(netstackid_t stackid, kstat_t *ksp)
511 515 {
512 516 if (ksp != NULL) {
513 517 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
514 518 kstat_delete_netstack(ksp, stackid);
515 519 }
516 520 }
517 521
518 522 /*
519 523 * Return SNMP global stats in buffer in mpdata.
520 524 * Return associatiation table in mp_conn_data,
521 525 * local address table in mp_local_data, and
522 526 * remote address table in mp_rem_data.
523 527 */
524 528 mblk_t *
525 529 sctp_snmp_get_mib2(queue_t *q, mblk_t *mpctl, sctp_stack_t *sctps)
526 530 {
527 531 mblk_t *mpdata, *mp_ret;
528 532 mblk_t *mp_conn_ctl = NULL;
529 533 mblk_t *mp_conn_data;
530 534 mblk_t *mp_conn_tail = NULL;
531 535 mblk_t *mp_local_ctl = NULL;
532 536 mblk_t *mp_local_data;
533 537 mblk_t *mp_local_tail = NULL;
534 538 mblk_t *mp_rem_ctl = NULL;
535 539 mblk_t *mp_rem_data;
536 540 mblk_t *mp_rem_tail = NULL;
537 541 mblk_t *mp_attr_ctl = NULL;
538 542 mblk_t *mp_attr_data;
539 543 mblk_t *mp_attr_tail = NULL;
540 544 struct opthdr *optp;
541 545 sctp_t *sctp, *sctp_prev = NULL;
542 546 sctp_faddr_t *fp;
543 547 mib2_sctpConnEntry_t sce;
544 548 mib2_sctpConnLocalEntry_t scle;
545 549 mib2_sctpConnRemoteEntry_t scre;
546 550 mib2_transportMLPEntry_t mlp;
547 551 int i;
548 552 int l;
549 553 int scanned = 0;
550 554 zoneid_t zoneid = Q_TO_CONN(q)->conn_zoneid;
551 555 conn_t *connp;
552 556 boolean_t needattr;
553 557 int idx;
554 558 mib2_sctp_t sctp_mib;
555 559
556 560 /*
557 561 * Make copies of the original message.
558 562 * mpctl will hold SCTP counters,
559 563 * mp_conn_ctl will hold list of connections.
560 564 */
561 565 mp_ret = copymsg(mpctl);
562 566 mp_conn_ctl = copymsg(mpctl);
563 567 mp_local_ctl = copymsg(mpctl);
564 568 mp_rem_ctl = copymsg(mpctl);
565 569 mp_attr_ctl = copymsg(mpctl);
566 570
567 571 mpdata = mpctl->b_cont;
568 572
569 573 if (mp_conn_ctl == NULL || mp_local_ctl == NULL ||
570 574 mp_rem_ctl == NULL || mp_attr_ctl == NULL || mpdata == NULL) {
571 575 freemsg(mp_attr_ctl);
572 576 freemsg(mp_rem_ctl);
573 577 freemsg(mp_local_ctl);
574 578 freemsg(mp_conn_ctl);
575 579 freemsg(mp_ret);
576 580 freemsg(mpctl);
577 581 return (NULL);
578 582 }
579 583 mp_conn_data = mp_conn_ctl->b_cont;
580 584 mp_local_data = mp_local_ctl->b_cont;
581 585 mp_rem_data = mp_rem_ctl->b_cont;
582 586 mp_attr_data = mp_attr_ctl->b_cont;
583 587
584 588 bzero(&sctp_mib, sizeof (sctp_mib));
585 589
586 590 /* hostname address parameters are not supported in Solaris */
587 591 sce.sctpAssocRemHostName.o_length = 0;
588 592 sce.sctpAssocRemHostName.o_bytes[0] = 0;
589 593
590 594 /* build table of connections -- need count in fixed part */
591 595
592 596 idx = 0;
593 597 mutex_enter(&sctps->sctps_g_lock);
594 598 sctp = list_head(&sctps->sctps_g_list);
595 599 while (sctp != NULL) {
596 600 mutex_enter(&sctp->sctp_reflock);
597 601 if (sctp->sctp_condemned) {
598 602 mutex_exit(&sctp->sctp_reflock);
599 603 sctp = list_next(&sctps->sctps_g_list, sctp);
600 604 continue;
601 605 }
602 606 sctp->sctp_refcnt++;
603 607 mutex_exit(&sctp->sctp_reflock);
604 608 mutex_exit(&sctps->sctps_g_lock);
605 609 if (sctp_prev != NULL)
606 610 SCTP_REFRELE(sctp_prev);
607 611 if (sctp->sctp_connp->conn_zoneid != zoneid)
608 612 goto next_sctp;
609 613 if (sctp->sctp_state == SCTPS_ESTABLISHED ||
610 614 sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
611 615 sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
612 616 /*
613 617 * Just bump the local sctp_mib. The number of
614 618 * existing associations is not kept in kernel.
615 619 */
616 620 BUMP_MIB(&sctp_mib, sctpCurrEstab);
617 621 }
618 622 SCTPS_UPDATE_MIB(sctps, sctpOutSCTPPkts, sctp->sctp_opkts);
619 623 sctp->sctp_opkts = 0;
620 624 SCTPS_UPDATE_MIB(sctps, sctpOutCtrlChunks, sctp->sctp_obchunks);
621 625 UPDATE_LOCAL(sctp->sctp_cum_obchunks,
622 626 sctp->sctp_obchunks);
623 627 sctp->sctp_obchunks = 0;
624 628 SCTPS_UPDATE_MIB(sctps, sctpOutOrderChunks,
625 629 sctp->sctp_odchunks);
626 630 UPDATE_LOCAL(sctp->sctp_cum_odchunks,
627 631 sctp->sctp_odchunks);
628 632 sctp->sctp_odchunks = 0;
629 633 SCTPS_UPDATE_MIB(sctps, sctpOutUnorderChunks,
630 634 sctp->sctp_oudchunks);
631 635 UPDATE_LOCAL(sctp->sctp_cum_oudchunks,
632 636 sctp->sctp_oudchunks);
633 637 sctp->sctp_oudchunks = 0;
634 638 SCTPS_UPDATE_MIB(sctps, sctpRetransChunks,
635 639 sctp->sctp_rxtchunks);
636 640 UPDATE_LOCAL(sctp->sctp_cum_rxtchunks,
637 641 sctp->sctp_rxtchunks);
638 642 sctp->sctp_rxtchunks = 0;
639 643 SCTPS_UPDATE_MIB(sctps, sctpInSCTPPkts, sctp->sctp_ipkts);
640 644 sctp->sctp_ipkts = 0;
641 645 SCTPS_UPDATE_MIB(sctps, sctpInCtrlChunks, sctp->sctp_ibchunks);
642 646 UPDATE_LOCAL(sctp->sctp_cum_ibchunks,
643 647 sctp->sctp_ibchunks);
644 648 sctp->sctp_ibchunks = 0;
645 649 SCTPS_UPDATE_MIB(sctps, sctpInOrderChunks, sctp->sctp_idchunks);
646 650 UPDATE_LOCAL(sctp->sctp_cum_idchunks,
647 651 sctp->sctp_idchunks);
648 652 sctp->sctp_idchunks = 0;
649 653 SCTPS_UPDATE_MIB(sctps, sctpInUnorderChunks,
650 654 sctp->sctp_iudchunks);
651 655 UPDATE_LOCAL(sctp->sctp_cum_iudchunks,
652 656 sctp->sctp_iudchunks);
653 657 sctp->sctp_iudchunks = 0;
654 658 SCTPS_UPDATE_MIB(sctps, sctpFragUsrMsgs, sctp->sctp_fragdmsgs);
655 659 sctp->sctp_fragdmsgs = 0;
656 660 SCTPS_UPDATE_MIB(sctps, sctpReasmUsrMsgs, sctp->sctp_reassmsgs);
657 661 sctp->sctp_reassmsgs = 0;
658 662
659 663 sce.sctpAssocId = ntohl(sctp->sctp_lvtag);
660 664 sce.sctpAssocLocalPort = ntohs(sctp->sctp_connp->conn_lport);
661 665 sce.sctpAssocRemPort = ntohs(sctp->sctp_connp->conn_fport);
662 666
663 667 RUN_SCTP(sctp);
664 668 if (sctp->sctp_primary != NULL) {
665 669 fp = sctp->sctp_primary;
666 670
667 671 if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
668 672 sce.sctpAssocRemPrimAddrType =
669 673 MIB2_SCTP_ADDR_V4;
670 674 } else {
671 675 sce.sctpAssocRemPrimAddrType =
672 676 MIB2_SCTP_ADDR_V6;
673 677 }
674 678 sce.sctpAssocRemPrimAddr = fp->sf_faddr;
675 679 sce.sctpAssocLocPrimAddr = fp->sf_saddr;
676 680 sce.sctpAssocHeartBeatInterval = TICK_TO_MSEC(
677 681 fp->sf_hb_interval);
678 682 } else {
679 683 sce.sctpAssocRemPrimAddrType = MIB2_SCTP_ADDR_V4;
680 684 bzero(&sce.sctpAssocRemPrimAddr,
681 685 sizeof (sce.sctpAssocRemPrimAddr));
682 686 bzero(&sce.sctpAssocLocPrimAddr,
683 687 sizeof (sce.sctpAssocLocPrimAddr));
684 688 sce.sctpAssocHeartBeatInterval =
685 689 sctps->sctps_heartbeat_interval;
686 690 }
687 691
688 692 /*
689 693 * Table for local addresses
690 694 */
691 695 scanned = 0;
692 696 for (i = 0; i < SCTP_IPIF_HASH; i++) {
693 697 sctp_saddr_ipif_t *obj;
694 698
695 699 if (sctp->sctp_saddrs[i].ipif_count == 0)
696 700 continue;
697 701 obj = list_head(&sctp->sctp_saddrs[i].sctp_ipif_list);
698 702 for (l = 0; l < sctp->sctp_saddrs[i].ipif_count; l++) {
699 703 sctp_ipif_t *sctp_ipif;
700 704 in6_addr_t addr;
701 705
702 706 sctp_ipif = obj->saddr_ipifp;
703 707 addr = sctp_ipif->sctp_ipif_saddr;
704 708 scanned++;
705 709 scle.sctpAssocId = ntohl(sctp->sctp_lvtag);
706 710 if (IN6_IS_ADDR_V4MAPPED(&addr)) {
707 711 scle.sctpAssocLocalAddrType =
708 712 MIB2_SCTP_ADDR_V4;
709 713 } else {
710 714 scle.sctpAssocLocalAddrType =
711 715 MIB2_SCTP_ADDR_V6;
712 716 }
713 717 scle.sctpAssocLocalAddr = addr;
714 718 (void) snmp_append_data2(mp_local_data,
715 719 &mp_local_tail, (char *)&scle,
716 720 sizeof (scle));
717 721 if (scanned >= sctp->sctp_nsaddrs)
718 722 goto done;
719 723 obj = list_next(&sctp->
720 724 sctp_saddrs[i].sctp_ipif_list, obj);
721 725 }
722 726 }
723 727 done:
724 728 /*
725 729 * Table for remote addresses
726 730 */
727 731 for (fp = sctp->sctp_faddrs; fp; fp = fp->sf_next) {
728 732 scre.sctpAssocId = ntohl(sctp->sctp_lvtag);
729 733 if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
730 734 scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V4;
731 735 } else {
732 736 scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V6;
733 737 }
734 738 scre.sctpAssocRemAddr = fp->sf_faddr;
735 739 if (fp->sf_state == SCTP_FADDRS_ALIVE) {
736 740 scre.sctpAssocRemAddrActive =
737 741 scre.sctpAssocRemAddrHBActive =
738 742 MIB2_SCTP_ACTIVE;
739 743 } else {
740 744 scre.sctpAssocRemAddrActive =
741 745 scre.sctpAssocRemAddrHBActive =
742 746 MIB2_SCTP_INACTIVE;
743 747 }
744 748 scre.sctpAssocRemAddrRTO = TICK_TO_MSEC(fp->sf_rto);
745 749 scre.sctpAssocRemAddrMaxPathRtx = fp->sf_max_retr;
746 750 scre.sctpAssocRemAddrRtx = fp->sf_T3expire;
747 751 (void) snmp_append_data2(mp_rem_data, &mp_rem_tail,
748 752 (char *)&scre, sizeof (scre));
749 753 }
750 754 connp = sctp->sctp_connp;
751 755 needattr = B_FALSE;
752 756 bzero(&mlp, sizeof (mlp));
753 757 if (connp->conn_mlp_type != mlptSingle) {
754 758 if (connp->conn_mlp_type == mlptShared ||
755 759 connp->conn_mlp_type == mlptBoth)
756 760 mlp.tme_flags |= MIB2_TMEF_SHARED;
757 761 if (connp->conn_mlp_type == mlptPrivate ||
758 762 connp->conn_mlp_type == mlptBoth)
759 763 mlp.tme_flags |= MIB2_TMEF_PRIVATE;
760 764 needattr = B_TRUE;
761 765 }
762 766 if (connp->conn_anon_mlp) {
763 767 mlp.tme_flags |= MIB2_TMEF_ANONMLP;
764 768 needattr = B_TRUE;
765 769 }
766 770 switch (connp->conn_mac_mode) {
767 771 case CONN_MAC_DEFAULT:
768 772 break;
769 773 case CONN_MAC_AWARE:
770 774 mlp.tme_flags |= MIB2_TMEF_MACEXEMPT;
771 775 needattr = B_TRUE;
772 776 break;
773 777 case CONN_MAC_IMPLICIT:
774 778 mlp.tme_flags |= MIB2_TMEF_MACIMPLICIT;
775 779 needattr = B_TRUE;
776 780 break;
777 781 }
778 782 if (sctp->sctp_connp->conn_ixa->ixa_tsl != NULL) {
779 783 ts_label_t *tsl;
780 784
781 785 tsl = sctp->sctp_connp->conn_ixa->ixa_tsl;
782 786 mlp.tme_flags |= MIB2_TMEF_IS_LABELED;
783 787 mlp.tme_doi = label2doi(tsl);
784 788 mlp.tme_label = *label2bslabel(tsl);
785 789 needattr = B_TRUE;
786 790 }
787 791 WAKE_SCTP(sctp);
788 792 sce.sctpAssocState = sctp_snmp_state(sctp);
789 793 sce.sctpAssocInStreams = sctp->sctp_num_istr;
790 794 sce.sctpAssocOutStreams = sctp->sctp_num_ostr;
791 795 sce.sctpAssocMaxRetr = sctp->sctp_pa_max_rxt;
792 796 /* A 0 here indicates that no primary process is known */
793 797 sce.sctpAssocPrimProcess = 0;
794 798 sce.sctpAssocT1expired = sctp->sctp_T1expire;
795 799 sce.sctpAssocT2expired = sctp->sctp_T2expire;
796 800 sce.sctpAssocRtxChunks = sctp->sctp_T3expire;
797 801 sce.sctpAssocStartTime = sctp->sctp_assoc_start_time;
798 802 sce.sctpConnEntryInfo.ce_sendq = sctp->sctp_unacked +
799 803 sctp->sctp_unsent;
800 804 sce.sctpConnEntryInfo.ce_recvq = sctp->sctp_rxqueued;
801 805 sce.sctpConnEntryInfo.ce_swnd = sctp->sctp_frwnd;
802 806 sce.sctpConnEntryInfo.ce_rwnd = sctp->sctp_rwnd;
803 807 sce.sctpConnEntryInfo.ce_mss = sctp->sctp_mss;
804 808 (void) snmp_append_data2(mp_conn_data, &mp_conn_tail,
805 809 (char *)&sce, sizeof (sce));
806 810 mlp.tme_connidx = idx++;
807 811 if (needattr)
808 812 (void) snmp_append_data2(mp_attr_ctl->b_cont,
809 813 &mp_attr_tail, (char *)&mlp, sizeof (mlp));
810 814 next_sctp:
811 815 sctp_prev = sctp;
812 816 mutex_enter(&sctps->sctps_g_lock);
813 817 sctp = list_next(&sctps->sctps_g_list, sctp);
814 818 }
815 819 mutex_exit(&sctps->sctps_g_lock);
816 820 if (sctp_prev != NULL)
817 821 SCTP_REFRELE(sctp_prev);
818 822
819 823 sctp_sum_mib(sctps, &sctp_mib);
820 824
821 825 optp = (struct opthdr *)&mpctl->b_rptr[sizeof (struct T_optmgmt_ack)];
822 826 optp->level = MIB2_SCTP;
823 827 optp->name = 0;
824 828 (void) snmp_append_data(mpdata, (char *)&sctp_mib, sizeof (sctp_mib));
825 829 optp->len = msgdsize(mpdata);
826 830 qreply(q, mpctl);
827 831
828 832 /* table of connections... */
829 833 optp = (struct opthdr *)&mp_conn_ctl->b_rptr[
830 834 sizeof (struct T_optmgmt_ack)];
831 835 optp->level = MIB2_SCTP;
832 836 optp->name = MIB2_SCTP_CONN;
833 837 optp->len = msgdsize(mp_conn_data);
834 838 qreply(q, mp_conn_ctl);
835 839
836 840 /* assoc local address table */
837 841 optp = (struct opthdr *)&mp_local_ctl->b_rptr[
838 842 sizeof (struct T_optmgmt_ack)];
839 843 optp->level = MIB2_SCTP;
840 844 optp->name = MIB2_SCTP_CONN_LOCAL;
841 845 optp->len = msgdsize(mp_local_data);
842 846 qreply(q, mp_local_ctl);
843 847
844 848 /* assoc remote address table */
845 849 optp = (struct opthdr *)&mp_rem_ctl->b_rptr[
846 850 sizeof (struct T_optmgmt_ack)];
847 851 optp->level = MIB2_SCTP;
848 852 optp->name = MIB2_SCTP_CONN_REMOTE;
849 853 optp->len = msgdsize(mp_rem_data);
850 854 qreply(q, mp_rem_ctl);
851 855
852 856 /* table of MLP attributes */
853 857 optp = (struct opthdr *)&mp_attr_ctl->b_rptr[
854 858 sizeof (struct T_optmgmt_ack)];
855 859 optp->level = MIB2_SCTP;
856 860 optp->name = EXPER_XPORT_MLP;
857 861 optp->len = msgdsize(mp_attr_data);
858 862 if (optp->len == 0)
859 863 freemsg(mp_attr_ctl);
860 864 else
861 865 qreply(q, mp_attr_ctl);
862 866
863 867 return (mp_ret);
864 868 }
865 869
866 870 /* Translate SCTP state to MIB2 SCTP state. */
867 871 static int
868 872 sctp_snmp_state(sctp_t *sctp)
869 873 {
870 874 if (sctp == NULL)
871 875 return (0);
872 876
873 877 switch (sctp->sctp_state) {
874 878 case SCTPS_IDLE:
875 879 case SCTPS_BOUND:
876 880 return (MIB2_SCTP_closed);
877 881 case SCTPS_LISTEN:
878 882 return (MIB2_SCTP_listen);
879 883 case SCTPS_COOKIE_WAIT:
880 884 return (MIB2_SCTP_cookieWait);
881 885 case SCTPS_COOKIE_ECHOED:
882 886 return (MIB2_SCTP_cookieEchoed);
883 887 case SCTPS_ESTABLISHED:
884 888 return (MIB2_SCTP_established);
885 889 case SCTPS_SHUTDOWN_PENDING:
886 890 return (MIB2_SCTP_shutdownPending);
887 891 case SCTPS_SHUTDOWN_SENT:
888 892 return (MIB2_SCTP_shutdownSent);
889 893 case SCTPS_SHUTDOWN_RECEIVED:
890 894 return (MIB2_SCTP_shutdownReceived);
891 895 case SCTPS_SHUTDOWN_ACK_SENT:
892 896 return (MIB2_SCTP_shutdownAckSent);
893 897 default:
894 898 return (0);
895 899 }
896 900 }
897 901
898 902 /*
899 903 * To sum up all MIB2 stats for a sctp_stack_t from all per CPU stats. The
900 904 * caller should initialize the target mib2_sctp_t properly as this function
901 905 * just adds up all the per CPU stats.
902 906 */
903 907 static void
904 908 sctp_sum_mib(sctp_stack_t *sctps, mib2_sctp_t *sctp_mib)
905 909 {
906 910 int i;
907 911 int cnt;
908 912
909 913 /* Static componets of mib2_sctp_t. */
910 914 SET_MIB(sctp_mib->sctpRtoAlgorithm, MIB2_SCTP_RTOALGO_VANJ);
911 915 SET_MIB(sctp_mib->sctpRtoMin, sctps->sctps_rto_ming);
912 916 SET_MIB(sctp_mib->sctpRtoMax, sctps->sctps_rto_maxg);
913 917 SET_MIB(sctp_mib->sctpRtoInitial, sctps->sctps_rto_initialg);
914 918 SET_MIB(sctp_mib->sctpMaxAssocs, -1);
915 919 SET_MIB(sctp_mib->sctpValCookieLife, sctps->sctps_cookie_life);
916 920 SET_MIB(sctp_mib->sctpMaxInitRetr, sctps->sctps_max_init_retr);
917 921
918 922 /* fixed length structure for IPv4 and IPv6 counters */
919 923 SET_MIB(sctp_mib->sctpEntrySize, sizeof (mib2_sctpConnEntry_t));
920 924 SET_MIB(sctp_mib->sctpLocalEntrySize,
921 925 sizeof (mib2_sctpConnLocalEntry_t));
922 926 SET_MIB(sctp_mib->sctpRemoteEntrySize,
923 927 sizeof (mib2_sctpConnRemoteEntry_t));
924 928
925 929 /*
926 930 * sctps_sc_cnt may change in the middle of the loop. It is better
927 931 * to get its value first.
928 932 */
929 933 cnt = sctps->sctps_sc_cnt;
930 934 for (i = 0; i < cnt; i++)
931 935 sctp_add_mib(&sctps->sctps_sc[i]->sctp_sc_mib, sctp_mib);
932 936 }
933 937
934 938 static void
935 939 sctp_add_mib(mib2_sctp_t *from, mib2_sctp_t *to)
936 940 {
937 941 to->sctpActiveEstab += from->sctpActiveEstab;
938 942 to->sctpPassiveEstab += from->sctpPassiveEstab;
939 943 to->sctpAborted += from->sctpAborted;
940 944 to->sctpShutdowns += from->sctpShutdowns;
941 945 to->sctpOutOfBlue += from->sctpOutOfBlue;
942 946 to->sctpChecksumError += from->sctpChecksumError;
943 947 to->sctpOutCtrlChunks += from->sctpOutCtrlChunks;
944 948 to->sctpOutOrderChunks += from->sctpOutOrderChunks;
945 949 to->sctpOutUnorderChunks += from->sctpOutUnorderChunks;
946 950 to->sctpRetransChunks += from->sctpRetransChunks;
947 951 to->sctpOutAck += from->sctpOutAck;
948 952 to->sctpOutAckDelayed += from->sctpOutAckDelayed;
949 953 to->sctpOutWinUpdate += from->sctpOutWinUpdate;
950 954 to->sctpOutFastRetrans += from->sctpOutFastRetrans;
951 955 to->sctpOutWinProbe += from->sctpOutWinProbe;
952 956 to->sctpInCtrlChunks += from->sctpInCtrlChunks;
953 957 to->sctpInOrderChunks += from->sctpInOrderChunks;
954 958 to->sctpInUnorderChunks += from->sctpInUnorderChunks;
955 959 to->sctpInAck += from->sctpInAck;
956 960 to->sctpInDupAck += from->sctpInDupAck;
957 961 to->sctpInAckUnsent += from->sctpInAckUnsent;
958 962 to->sctpFragUsrMsgs += from->sctpFragUsrMsgs;
959 963 to->sctpReasmUsrMsgs += from->sctpReasmUsrMsgs;
960 964 to->sctpOutSCTPPkts += from->sctpOutSCTPPkts;
961 965 to->sctpInSCTPPkts += from->sctpInSCTPPkts;
962 966 to->sctpInInvalidCookie += from->sctpInInvalidCookie;
963 967 to->sctpTimRetrans += from->sctpTimRetrans;
964 968 to->sctpTimRetransDrop += from->sctpTimRetransDrop;
965 969 to->sctpTimHeartBeatProbe += from->sctpTimHeartBeatProbe;
966 970 to->sctpTimHeartBeatDrop += from->sctpTimHeartBeatDrop;
967 971 to->sctpListenDrop += from->sctpListenDrop;
968 972 to->sctpInClosed += from->sctpInClosed;
969 973 }
↓ open down ↓ |
896 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX