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