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;
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
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;
553 556 int idx;
554 557 mib2_sctp_t sctp_mib;
555 558
559 +
560 + conn_pid_node_list_hdr_t *cph;
561 +
556 562 /*
557 563 * Make copies of the original message.
558 564 * mpctl will hold SCTP counters,
559 565 * mp_conn_ctl will hold list of connections.
560 566 */
561 567 mp_ret = copymsg(mpctl);
562 568 mp_conn_ctl = copymsg(mpctl);
569 + mp_pidnode_ctl = copymsg(mpctl);
563 570 mp_local_ctl = copymsg(mpctl);
564 571 mp_rem_ctl = copymsg(mpctl);
565 572 mp_attr_ctl = copymsg(mpctl);
566 573
567 574 mpdata = mpctl->b_cont;
568 575
569 - if (mp_conn_ctl == NULL || mp_local_ctl == NULL ||
570 - mp_rem_ctl == NULL || mp_attr_ctl == NULL || mpdata == NULL) {
576 + if (mp_conn_ctl == NULL || mp_pidnode_ctl == NULL ||
577 + mp_local_ctl == NULL || mp_rem_ctl == NULL || mp_attr_ctl == NULL ||
578 + mpdata == NULL) {
571 579 freemsg(mp_attr_ctl);
572 580 freemsg(mp_rem_ctl);
573 581 freemsg(mp_local_ctl);
582 + freemsg(mp_pidnode_ctl);
574 583 freemsg(mp_conn_ctl);
575 584 freemsg(mp_ret);
576 585 freemsg(mpctl);
577 586 return (NULL);
578 587 }
579 588 mp_conn_data = mp_conn_ctl->b_cont;
589 + mp_pidnode_data = mp_pidnode_ctl->b_cont;
580 590 mp_local_data = mp_local_ctl->b_cont;
581 591 mp_rem_data = mp_rem_ctl->b_cont;
582 592 mp_attr_data = mp_attr_ctl->b_cont;
583 593
584 594 bzero(&sctp_mib, sizeof (sctp_mib));
585 595
586 596 /* hostname address parameters are not supported in Solaris */
587 597 sce.sctpAssocRemHostName.o_length = 0;
588 598 sce.sctpAssocRemHostName.o_bytes[0] = 0;
589 599
590 600 /* build table of connections -- need count in fixed part */
591 601
592 602 idx = 0;
593 603 mutex_enter(&sctps->sctps_g_lock);
594 604 sctp = list_head(&sctps->sctps_g_list);
595 605 while (sctp != NULL) {
596 606 mutex_enter(&sctp->sctp_reflock);
597 607 if (sctp->sctp_condemned) {
598 608 mutex_exit(&sctp->sctp_reflock);
599 609 sctp = list_next(&sctps->sctps_g_list, sctp);
600 610 continue;
601 611 }
602 612 sctp->sctp_refcnt++;
603 613 mutex_exit(&sctp->sctp_reflock);
604 614 mutex_exit(&sctps->sctps_g_lock);
605 615 if (sctp_prev != NULL)
606 616 SCTP_REFRELE(sctp_prev);
607 617 if (sctp->sctp_connp->conn_zoneid != zoneid)
608 618 goto next_sctp;
609 619 if (sctp->sctp_state == SCTPS_ESTABLISHED ||
610 620 sctp->sctp_state == SCTPS_SHUTDOWN_PENDING ||
611 621 sctp->sctp_state == SCTPS_SHUTDOWN_RECEIVED) {
612 622 /*
613 623 * Just bump the local sctp_mib. The number of
614 624 * existing associations is not kept in kernel.
615 625 */
616 626 BUMP_MIB(&sctp_mib, sctpCurrEstab);
617 627 }
618 628 SCTPS_UPDATE_MIB(sctps, sctpOutSCTPPkts, sctp->sctp_opkts);
619 629 sctp->sctp_opkts = 0;
620 630 SCTPS_UPDATE_MIB(sctps, sctpOutCtrlChunks, sctp->sctp_obchunks);
621 631 UPDATE_LOCAL(sctp->sctp_cum_obchunks,
622 632 sctp->sctp_obchunks);
623 633 sctp->sctp_obchunks = 0;
624 634 SCTPS_UPDATE_MIB(sctps, sctpOutOrderChunks,
625 635 sctp->sctp_odchunks);
626 636 UPDATE_LOCAL(sctp->sctp_cum_odchunks,
627 637 sctp->sctp_odchunks);
628 638 sctp->sctp_odchunks = 0;
629 639 SCTPS_UPDATE_MIB(sctps, sctpOutUnorderChunks,
630 640 sctp->sctp_oudchunks);
631 641 UPDATE_LOCAL(sctp->sctp_cum_oudchunks,
632 642 sctp->sctp_oudchunks);
633 643 sctp->sctp_oudchunks = 0;
634 644 SCTPS_UPDATE_MIB(sctps, sctpRetransChunks,
635 645 sctp->sctp_rxtchunks);
636 646 UPDATE_LOCAL(sctp->sctp_cum_rxtchunks,
637 647 sctp->sctp_rxtchunks);
638 648 sctp->sctp_rxtchunks = 0;
639 649 SCTPS_UPDATE_MIB(sctps, sctpInSCTPPkts, sctp->sctp_ipkts);
640 650 sctp->sctp_ipkts = 0;
641 651 SCTPS_UPDATE_MIB(sctps, sctpInCtrlChunks, sctp->sctp_ibchunks);
642 652 UPDATE_LOCAL(sctp->sctp_cum_ibchunks,
643 653 sctp->sctp_ibchunks);
644 654 sctp->sctp_ibchunks = 0;
645 655 SCTPS_UPDATE_MIB(sctps, sctpInOrderChunks, sctp->sctp_idchunks);
646 656 UPDATE_LOCAL(sctp->sctp_cum_idchunks,
647 657 sctp->sctp_idchunks);
648 658 sctp->sctp_idchunks = 0;
649 659 SCTPS_UPDATE_MIB(sctps, sctpInUnorderChunks,
650 660 sctp->sctp_iudchunks);
651 661 UPDATE_LOCAL(sctp->sctp_cum_iudchunks,
652 662 sctp->sctp_iudchunks);
653 663 sctp->sctp_iudchunks = 0;
654 664 SCTPS_UPDATE_MIB(sctps, sctpFragUsrMsgs, sctp->sctp_fragdmsgs);
655 665 sctp->sctp_fragdmsgs = 0;
656 666 SCTPS_UPDATE_MIB(sctps, sctpReasmUsrMsgs, sctp->sctp_reassmsgs);
657 667 sctp->sctp_reassmsgs = 0;
658 668
659 669 sce.sctpAssocId = ntohl(sctp->sctp_lvtag);
660 670 sce.sctpAssocLocalPort = ntohs(sctp->sctp_connp->conn_lport);
661 671 sce.sctpAssocRemPort = ntohs(sctp->sctp_connp->conn_fport);
662 672
663 673 RUN_SCTP(sctp);
664 674 if (sctp->sctp_primary != NULL) {
665 675 fp = sctp->sctp_primary;
666 676
667 677 if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
668 678 sce.sctpAssocRemPrimAddrType =
669 679 MIB2_SCTP_ADDR_V4;
670 680 } else {
671 681 sce.sctpAssocRemPrimAddrType =
672 682 MIB2_SCTP_ADDR_V6;
673 683 }
674 684 sce.sctpAssocRemPrimAddr = fp->sf_faddr;
675 685 sce.sctpAssocLocPrimAddr = fp->sf_saddr;
676 686 sce.sctpAssocHeartBeatInterval = TICK_TO_MSEC(
677 687 fp->sf_hb_interval);
678 688 } else {
679 689 sce.sctpAssocRemPrimAddrType = MIB2_SCTP_ADDR_V4;
680 690 bzero(&sce.sctpAssocRemPrimAddr,
681 691 sizeof (sce.sctpAssocRemPrimAddr));
682 692 bzero(&sce.sctpAssocLocPrimAddr,
683 693 sizeof (sce.sctpAssocLocPrimAddr));
684 694 sce.sctpAssocHeartBeatInterval =
685 695 sctps->sctps_heartbeat_interval;
686 696 }
687 697
688 698 /*
689 699 * Table for local addresses
690 700 */
691 701 scanned = 0;
692 702 for (i = 0; i < SCTP_IPIF_HASH; i++) {
693 703 sctp_saddr_ipif_t *obj;
694 704
695 705 if (sctp->sctp_saddrs[i].ipif_count == 0)
696 706 continue;
697 707 obj = list_head(&sctp->sctp_saddrs[i].sctp_ipif_list);
698 708 for (l = 0; l < sctp->sctp_saddrs[i].ipif_count; l++) {
699 709 sctp_ipif_t *sctp_ipif;
700 710 in6_addr_t addr;
701 711
702 712 sctp_ipif = obj->saddr_ipifp;
703 713 addr = sctp_ipif->sctp_ipif_saddr;
704 714 scanned++;
705 715 scle.sctpAssocId = ntohl(sctp->sctp_lvtag);
706 716 if (IN6_IS_ADDR_V4MAPPED(&addr)) {
707 717 scle.sctpAssocLocalAddrType =
708 718 MIB2_SCTP_ADDR_V4;
709 719 } else {
710 720 scle.sctpAssocLocalAddrType =
711 721 MIB2_SCTP_ADDR_V6;
712 722 }
713 723 scle.sctpAssocLocalAddr = addr;
714 724 (void) snmp_append_data2(mp_local_data,
715 725 &mp_local_tail, (char *)&scle,
716 726 sizeof (scle));
717 727 if (scanned >= sctp->sctp_nsaddrs)
718 728 goto done;
719 729 obj = list_next(&sctp->
720 730 sctp_saddrs[i].sctp_ipif_list, obj);
721 731 }
722 732 }
723 733 done:
724 734 /*
725 735 * Table for remote addresses
726 736 */
727 737 for (fp = sctp->sctp_faddrs; fp; fp = fp->sf_next) {
728 738 scre.sctpAssocId = ntohl(sctp->sctp_lvtag);
729 739 if (IN6_IS_ADDR_V4MAPPED(&fp->sf_faddr)) {
730 740 scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V4;
731 741 } else {
732 742 scre.sctpAssocRemAddrType = MIB2_SCTP_ADDR_V6;
733 743 }
734 744 scre.sctpAssocRemAddr = fp->sf_faddr;
735 745 if (fp->sf_state == SCTP_FADDRS_ALIVE) {
736 746 scre.sctpAssocRemAddrActive =
737 747 scre.sctpAssocRemAddrHBActive =
738 748 MIB2_SCTP_ACTIVE;
739 749 } else {
740 750 scre.sctpAssocRemAddrActive =
741 751 scre.sctpAssocRemAddrHBActive =
742 752 MIB2_SCTP_INACTIVE;
743 753 }
744 754 scre.sctpAssocRemAddrRTO = TICK_TO_MSEC(fp->sf_rto);
745 755 scre.sctpAssocRemAddrMaxPathRtx = fp->sf_max_retr;
746 756 scre.sctpAssocRemAddrRtx = fp->sf_T3expire;
747 757 (void) snmp_append_data2(mp_rem_data, &mp_rem_tail,
748 758 (char *)&scre, sizeof (scre));
749 759 }
750 760 connp = sctp->sctp_connp;
751 761 needattr = B_FALSE;
752 762 bzero(&mlp, sizeof (mlp));
753 763 if (connp->conn_mlp_type != mlptSingle) {
754 764 if (connp->conn_mlp_type == mlptShared ||
755 765 connp->conn_mlp_type == mlptBoth)
756 766 mlp.tme_flags |= MIB2_TMEF_SHARED;
757 767 if (connp->conn_mlp_type == mlptPrivate ||
758 768 connp->conn_mlp_type == mlptBoth)
759 769 mlp.tme_flags |= MIB2_TMEF_PRIVATE;
760 770 needattr = B_TRUE;
761 771 }
762 772 if (connp->conn_anon_mlp) {
763 773 mlp.tme_flags |= MIB2_TMEF_ANONMLP;
764 774 needattr = B_TRUE;
765 775 }
766 776 switch (connp->conn_mac_mode) {
767 777 case CONN_MAC_DEFAULT:
768 778 break;
769 779 case CONN_MAC_AWARE:
770 780 mlp.tme_flags |= MIB2_TMEF_MACEXEMPT;
771 781 needattr = B_TRUE;
772 782 break;
773 783 case CONN_MAC_IMPLICIT:
774 784 mlp.tme_flags |= MIB2_TMEF_MACIMPLICIT;
775 785 needattr = B_TRUE;
776 786 break;
777 787 }
778 788 if (sctp->sctp_connp->conn_ixa->ixa_tsl != NULL) {
779 789 ts_label_t *tsl;
780 790
781 791 tsl = sctp->sctp_connp->conn_ixa->ixa_tsl;
782 792 mlp.tme_flags |= MIB2_TMEF_IS_LABELED;
783 793 mlp.tme_doi = label2doi(tsl);
784 794 mlp.tme_label = *label2bslabel(tsl);
785 795 needattr = B_TRUE;
786 796 }
787 797 WAKE_SCTP(sctp);
788 798 sce.sctpAssocState = sctp_snmp_state(sctp);
789 799 sce.sctpAssocInStreams = sctp->sctp_num_istr;
790 800 sce.sctpAssocOutStreams = sctp->sctp_num_ostr;
791 801 sce.sctpAssocMaxRetr = sctp->sctp_pa_max_rxt;
792 802 /* A 0 here indicates that no primary process is known */
793 803 sce.sctpAssocPrimProcess = 0;
794 804 sce.sctpAssocT1expired = sctp->sctp_T1expire;
795 805 sce.sctpAssocT2expired = sctp->sctp_T2expire;
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
796 806 sce.sctpAssocRtxChunks = sctp->sctp_T3expire;
797 807 sce.sctpAssocStartTime = sctp->sctp_assoc_start_time;
798 808 sce.sctpConnEntryInfo.ce_sendq = sctp->sctp_unacked +
799 809 sctp->sctp_unsent;
800 810 sce.sctpConnEntryInfo.ce_recvq = sctp->sctp_rxqueued;
801 811 sce.sctpConnEntryInfo.ce_swnd = sctp->sctp_frwnd;
802 812 sce.sctpConnEntryInfo.ce_rwnd = sctp->sctp_rwnd;
803 813 sce.sctpConnEntryInfo.ce_mss = sctp->sctp_mss;
804 814 (void) snmp_append_data2(mp_conn_data, &mp_conn_tail,
805 815 (char *)&sce, sizeof (sce));
816 + /* my data */
817 + (void) snmp_append_data2(mp_pidnode_data, &mp_pidnode_tail,
818 + (char *)&sce, sizeof (sce));
819 +
820 + cph = conn_get_pid_list(connp);
821 +
822 + (void) snmp_append_data2(mp_pidnode_data, &mp_pidnode_tail,
823 + (char *)cph, cph->cph_tot_size);
824 +
825 + kmem_free(cph, cph->cph_tot_size);
826 + /* end of my data */
806 827 mlp.tme_connidx = idx++;
807 828 if (needattr)
808 829 (void) snmp_append_data2(mp_attr_ctl->b_cont,
809 830 &mp_attr_tail, (char *)&mlp, sizeof (mlp));
810 831 next_sctp:
811 832 sctp_prev = sctp;
812 833 mutex_enter(&sctps->sctps_g_lock);
813 834 sctp = list_next(&sctps->sctps_g_list, sctp);
814 835 }
815 836 mutex_exit(&sctps->sctps_g_lock);
816 837 if (sctp_prev != NULL)
817 838 SCTP_REFRELE(sctp_prev);
818 839
819 840 sctp_sum_mib(sctps, &sctp_mib);
820 841
821 842 optp = (struct opthdr *)&mpctl->b_rptr[sizeof (struct T_optmgmt_ack)];
822 843 optp->level = MIB2_SCTP;
823 844 optp->name = 0;
824 845 (void) snmp_append_data(mpdata, (char *)&sctp_mib, sizeof (sctp_mib));
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
825 846 optp->len = msgdsize(mpdata);
826 847 qreply(q, mpctl);
827 848
828 849 /* table of connections... */
829 850 optp = (struct opthdr *)&mp_conn_ctl->b_rptr[
830 851 sizeof (struct T_optmgmt_ack)];
831 852 optp->level = MIB2_SCTP;
832 853 optp->name = MIB2_SCTP_CONN;
833 854 optp->len = msgdsize(mp_conn_data);
834 855 qreply(q, mp_conn_ctl);
856 +
857 + /* table of EXPER_XPORT_PROC_INFO */
858 + optp = (struct opthdr *)&mp_pidnode_ctl->b_rptr[
859 + sizeof (struct T_optmgmt_ack)];
860 + optp->level = MIB2_SCTP;
861 + optp->name = EXPER_XPORT_PROC_INFO;
862 + optp->len = msgdsize(mp_pidnode_data);
863 + qreply(q, mp_pidnode_ctl);
835 864
836 865 /* assoc local address table */
837 866 optp = (struct opthdr *)&mp_local_ctl->b_rptr[
838 867 sizeof (struct T_optmgmt_ack)];
839 868 optp->level = MIB2_SCTP;
840 869 optp->name = MIB2_SCTP_CONN_LOCAL;
841 870 optp->len = msgdsize(mp_local_data);
842 871 qreply(q, mp_local_ctl);
843 872
844 873 /* assoc remote address table */
845 874 optp = (struct opthdr *)&mp_rem_ctl->b_rptr[
846 875 sizeof (struct T_optmgmt_ack)];
847 876 optp->level = MIB2_SCTP;
848 877 optp->name = MIB2_SCTP_CONN_REMOTE;
849 878 optp->len = msgdsize(mp_rem_data);
850 879 qreply(q, mp_rem_ctl);
851 880
852 881 /* table of MLP attributes */
853 882 optp = (struct opthdr *)&mp_attr_ctl->b_rptr[
854 883 sizeof (struct T_optmgmt_ack)];
855 884 optp->level = MIB2_SCTP;
856 885 optp->name = EXPER_XPORT_MLP;
857 886 optp->len = msgdsize(mp_attr_data);
858 887 if (optp->len == 0)
859 888 freemsg(mp_attr_ctl);
860 889 else
861 890 qreply(q, mp_attr_ctl);
862 891
863 892 return (mp_ret);
864 893 }
865 894
866 895 /* Translate SCTP state to MIB2 SCTP state. */
867 896 static int
868 897 sctp_snmp_state(sctp_t *sctp)
869 898 {
870 899 if (sctp == NULL)
871 900 return (0);
872 901
873 902 switch (sctp->sctp_state) {
874 903 case SCTPS_IDLE:
875 904 case SCTPS_BOUND:
876 905 return (MIB2_SCTP_closed);
877 906 case SCTPS_LISTEN:
878 907 return (MIB2_SCTP_listen);
879 908 case SCTPS_COOKIE_WAIT:
880 909 return (MIB2_SCTP_cookieWait);
881 910 case SCTPS_COOKIE_ECHOED:
882 911 return (MIB2_SCTP_cookieEchoed);
883 912 case SCTPS_ESTABLISHED:
884 913 return (MIB2_SCTP_established);
885 914 case SCTPS_SHUTDOWN_PENDING:
886 915 return (MIB2_SCTP_shutdownPending);
887 916 case SCTPS_SHUTDOWN_SENT:
888 917 return (MIB2_SCTP_shutdownSent);
889 918 case SCTPS_SHUTDOWN_RECEIVED:
890 919 return (MIB2_SCTP_shutdownReceived);
891 920 case SCTPS_SHUTDOWN_ACK_SENT:
892 921 return (MIB2_SCTP_shutdownAckSent);
893 922 default:
894 923 return (0);
895 924 }
896 925 }
897 926
898 927 /*
899 928 * To sum up all MIB2 stats for a sctp_stack_t from all per CPU stats. The
900 929 * caller should initialize the target mib2_sctp_t properly as this function
901 930 * just adds up all the per CPU stats.
902 931 */
903 932 static void
904 933 sctp_sum_mib(sctp_stack_t *sctps, mib2_sctp_t *sctp_mib)
905 934 {
906 935 int i;
907 936 int cnt;
908 937
909 938 /* Static componets of mib2_sctp_t. */
910 939 SET_MIB(sctp_mib->sctpRtoAlgorithm, MIB2_SCTP_RTOALGO_VANJ);
911 940 SET_MIB(sctp_mib->sctpRtoMin, sctps->sctps_rto_ming);
912 941 SET_MIB(sctp_mib->sctpRtoMax, sctps->sctps_rto_maxg);
913 942 SET_MIB(sctp_mib->sctpRtoInitial, sctps->sctps_rto_initialg);
914 943 SET_MIB(sctp_mib->sctpMaxAssocs, -1);
915 944 SET_MIB(sctp_mib->sctpValCookieLife, sctps->sctps_cookie_life);
916 945 SET_MIB(sctp_mib->sctpMaxInitRetr, sctps->sctps_max_init_retr);
917 946
918 947 /* fixed length structure for IPv4 and IPv6 counters */
919 948 SET_MIB(sctp_mib->sctpEntrySize, sizeof (mib2_sctpConnEntry_t));
920 949 SET_MIB(sctp_mib->sctpLocalEntrySize,
921 950 sizeof (mib2_sctpConnLocalEntry_t));
922 951 SET_MIB(sctp_mib->sctpRemoteEntrySize,
923 952 sizeof (mib2_sctpConnRemoteEntry_t));
924 953
925 954 /*
926 955 * sctps_sc_cnt may change in the middle of the loop. It is better
927 956 * to get its value first.
928 957 */
929 958 cnt = sctps->sctps_sc_cnt;
930 959 for (i = 0; i < cnt; i++)
931 960 sctp_add_mib(&sctps->sctps_sc[i]->sctp_sc_mib, sctp_mib);
932 961 }
933 962
934 963 static void
935 964 sctp_add_mib(mib2_sctp_t *from, mib2_sctp_t *to)
936 965 {
937 966 to->sctpActiveEstab += from->sctpActiveEstab;
938 967 to->sctpPassiveEstab += from->sctpPassiveEstab;
939 968 to->sctpAborted += from->sctpAborted;
940 969 to->sctpShutdowns += from->sctpShutdowns;
941 970 to->sctpOutOfBlue += from->sctpOutOfBlue;
942 971 to->sctpChecksumError += from->sctpChecksumError;
943 972 to->sctpOutCtrlChunks += from->sctpOutCtrlChunks;
944 973 to->sctpOutOrderChunks += from->sctpOutOrderChunks;
945 974 to->sctpOutUnorderChunks += from->sctpOutUnorderChunks;
946 975 to->sctpRetransChunks += from->sctpRetransChunks;
947 976 to->sctpOutAck += from->sctpOutAck;
948 977 to->sctpOutAckDelayed += from->sctpOutAckDelayed;
949 978 to->sctpOutWinUpdate += from->sctpOutWinUpdate;
950 979 to->sctpOutFastRetrans += from->sctpOutFastRetrans;
951 980 to->sctpOutWinProbe += from->sctpOutWinProbe;
952 981 to->sctpInCtrlChunks += from->sctpInCtrlChunks;
953 982 to->sctpInOrderChunks += from->sctpInOrderChunks;
954 983 to->sctpInUnorderChunks += from->sctpInUnorderChunks;
955 984 to->sctpInAck += from->sctpInAck;
956 985 to->sctpInDupAck += from->sctpInDupAck;
957 986 to->sctpInAckUnsent += from->sctpInAckUnsent;
958 987 to->sctpFragUsrMsgs += from->sctpFragUsrMsgs;
959 988 to->sctpReasmUsrMsgs += from->sctpReasmUsrMsgs;
960 989 to->sctpOutSCTPPkts += from->sctpOutSCTPPkts;
961 990 to->sctpInSCTPPkts += from->sctpInSCTPPkts;
962 991 to->sctpInInvalidCookie += from->sctpInInvalidCookie;
963 992 to->sctpTimRetrans += from->sctpTimRetrans;
964 993 to->sctpTimRetransDrop += from->sctpTimRetransDrop;
965 994 to->sctpTimHeartBeatProbe += from->sctpTimHeartBeatProbe;
966 995 to->sctpTimHeartBeatDrop += from->sctpTimHeartBeatDrop;
967 996 to->sctpListenDrop += from->sctpListenDrop;
968 997 to->sctpInClosed += from->sctpInClosed;
969 998 }
↓ open down ↓ |
125 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX