1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Joyent, Inc.
25 */
26
27 #include <sys/types.h>
28 #include <sys/stream.h>
29 #include <sys/mdb_modapi.h>
30 #include <sys/socket.h>
31 #include <sys/list.h>
32 #include <sys/strsun.h>
33
34 #include <mdb/mdb_stdlib.h>
35
36 #include <netinet/in.h>
37 #include <netinet/ip6.h>
38 #include <netinet/sctp.h>
39
40 #include <inet/common.h>
41 #include <inet/ip.h>
42 #include <inet/ip6.h>
43 #include <inet/ipclassifier.h>
44
45 #include <sctp/sctp_impl.h>
46 #include <sctp/sctp_addr.h>
47
48 #define MDB_SCTP_SHOW_FLAGS 0x1
49 #define MDB_SCTP_DUMP_ADDRS 0x2
50 #define MDB_SCTP_SHOW_HASH 0x4
51 #define MDB_SCTP_SHOW_OUT 0x8
52 #define MDB_SCTP_SHOW_IN 0x10
53 #define MDB_SCTP_SHOW_MISC 0x20
54 #define MDB_SCTP_SHOW_RTT 0x40
55 #define MDB_SCTP_SHOW_STATS 0x80
56 #define MDB_SCTP_SHOW_FLOW 0x100
57 #define MDB_SCTP_SHOW_HDR 0x200
58 #define MDB_SCTP_SHOW_PMTUD 0x400
59 #define MDB_SCTP_SHOW_RXT 0x800
60 #define MDB_SCTP_SHOW_CONN 0x1000
61 #define MDB_SCTP_SHOW_CLOSE 0x2000
62 #define MDB_SCTP_SHOW_EXT 0x4000
63
64 #define MDB_SCTP_SHOW_ALL 0xffffffff
65
66 /*
67 * Copy from usr/src/uts/common/os/list.c. Should we have a generic
68 * mdb list walker?
69 */
70 #define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
71
72 static int
ns_to_stackid(uintptr_t kaddr)73 ns_to_stackid(uintptr_t kaddr)
74 {
75 netstack_t nss;
76
77 if (mdb_vread(&nss, sizeof (nss), kaddr) == -1) {
78 mdb_warn("failed to read netdstack info %p", kaddr);
79 return (0);
80 }
81 return (nss.netstack_stackid);
82 }
83
84 int
sctp_stacks_walk_init(mdb_walk_state_t * wsp)85 sctp_stacks_walk_init(mdb_walk_state_t *wsp)
86 {
87 if (mdb_layered_walk("netstack", wsp) == -1) {
88 mdb_warn("can't walk 'netstack'");
89 return (WALK_ERR);
90 }
91 return (WALK_NEXT);
92 }
93
94 int
sctp_stacks_walk_step(mdb_walk_state_t * wsp)95 sctp_stacks_walk_step(mdb_walk_state_t *wsp)
96 {
97 uintptr_t kaddr;
98 netstack_t nss;
99
100 if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) {
101 mdb_warn("can't read netstack at %p", wsp->walk_addr);
102 return (WALK_ERR);
103 }
104 kaddr = (uintptr_t)nss.netstack_modules[NS_SCTP];
105 return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata));
106 }
107
108 static char *
sctp_faddr_state(int state)109 sctp_faddr_state(int state)
110 {
111 char *statestr;
112
113 switch (state) {
114 case SCTP_FADDRS_UNREACH:
115 statestr = "Unreachable";
116 break;
117 case SCTP_FADDRS_DOWN:
118 statestr = "Down";
119 break;
120 case SCTP_FADDRS_ALIVE:
121 statestr = "Alive";
122 break;
123 case SCTP_FADDRS_UNCONFIRMED:
124 statestr = "Unconfirmed";
125 break;
126 default:
127 statestr = "Unknown";
128 break;
129 }
130 return (statestr);
131 }
132
133 /* ARGSUSED */
134 static int
sctp_faddr(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)135 sctp_faddr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
136 {
137 sctp_faddr_t fa[1];
138 char *statestr;
139
140 if (!(flags & DCMD_ADDRSPEC))
141 return (DCMD_USAGE);
142
143 if (mdb_vread(fa, sizeof (*fa), addr) == -1) {
144 mdb_warn("cannot read fadder at %p", addr);
145 return (DCMD_ERR);
146 }
147
148 statestr = sctp_faddr_state(fa->sf_state);
149 mdb_printf("%<u>%p\t%<b>%N%</b>\t%s%</u>\n", addr, &fa->sf_faddr,
150 statestr);
151 mdb_printf("next\t\t%?p\tsaddr\t%N\n", fa->sf_next, &fa->sf_saddr);
152 mdb_printf("rto\t\t%?d\tsrtt\t\t%?d\n", fa->sf_rto, fa->sf_srtt);
153 mdb_printf("rttvar\t\t%?d\trtt_updates\t%?u\n", fa->sf_rttvar,
154 fa->sf_rtt_updates);
155 mdb_printf("strikes\t\t%?d\tmax_retr\t%?d\n", fa->sf_strikes,
156 fa->sf_max_retr);
157 mdb_printf("hb_expiry\t%?ld\thb_interval\t%?u\n", fa->sf_hb_expiry,
158 fa->sf_hb_interval);
159 mdb_printf("pmss\t\t%?u\tcwnd\t\t%?u\n", fa->sf_pmss, fa->sf_cwnd);
160 mdb_printf("ssthresh\t%?u\tsuna\t\t%?u\n", fa->sf_ssthresh,
161 fa->sf_suna);
162 mdb_printf("pba\t\t%?u\tacked\t\t%?u\n", fa->sf_pba, fa->sf_acked);
163 mdb_printf("lastactive\t%?ld\thb_secret\t%?#lx\n", fa->sf_lastactive,
164 fa->sf_hb_secret);
165 mdb_printf("rxt_unacked\t%?u\n", fa->sf_rxt_unacked);
166 mdb_printf("timer_mp\t%?p\tixa\t\t%?p\n", fa->sf_timer_mp, fa->sf_ixa);
167 mdb_printf("hb_enabled\t%?d\thb_pending\t%?d\n"
168 "timer_running\t%?d\tdf\t\t%?d\n"
169 "pmtu_discovered\t%?d\tisv4\t\t%?d\n"
170 "retransmissions\t%?u\n",
171 fa->sf_hb_enabled, fa->sf_hb_pending, fa->sf_timer_running,
172 fa->sf_df, fa->sf_pmtu_discovered, fa->sf_isv4, fa->sf_T3expire);
173
174 return (DCMD_OK);
175 }
176
177 static void
print_set(sctp_set_t * sp)178 print_set(sctp_set_t *sp)
179 {
180 mdb_printf("\tbegin\t%<b>%?x%</b>\t\tend\t%<b>%?x%</b>\n",
181 sp->begin, sp->end);
182 mdb_printf("\tnext\t%?p\tprev\t%?p\n", sp->next, sp->prev);
183 }
184
185 /* ARGSUSED */
186 static int
sctp_set(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)187 sctp_set(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
188 {
189 sctp_set_t sp[1];
190
191 if (!(flags & DCMD_ADDRSPEC))
192 return (DCMD_USAGE);
193
194 if (mdb_vread(sp, sizeof (*sp), addr) == -1)
195 return (DCMD_ERR);
196
197 print_set(sp);
198
199 return (DCMD_OK);
200 }
201
202 static void
dump_sack_info(uintptr_t addr)203 dump_sack_info(uintptr_t addr)
204 {
205 sctp_set_t sp[1];
206
207 while (addr != 0) {
208 if (mdb_vread(sp, sizeof (*sp), addr) == -1) {
209 mdb_warn("failed to read sctp_set at %p", addr);
210 return;
211 }
212
213 addr = (uintptr_t)sp->next;
214 print_set(sp);
215 }
216 }
217
218 static int
dump_msghdr(mblk_t * meta)219 dump_msghdr(mblk_t *meta)
220 {
221 sctp_msg_hdr_t smh;
222
223 if (mdb_vread(&smh, sizeof (smh), (uintptr_t)meta->b_rptr) == -1)
224 return (-1);
225
226 mdb_printf("%<u>msg_hdr_t at \t%?p\tsentto\t%?p%</u>\n",
227 meta->b_rptr, SCTP_CHUNK_DEST(meta));
228 mdb_printf("\tttl\t%?ld\ttob\t%?ld\n", smh.smh_ttl, smh.smh_tob);
229 mdb_printf("\tsid\t%?u\tssn\t%?u\n", smh.smh_sid, smh.smh_ssn);
230 mdb_printf("\tppid\t%?u\tflags\t%?s\n", smh.smh_ppid,
231 smh.smh_flags & MSG_UNORDERED ? "unordered" : " ");
232 mdb_printf("\tcontext\t%?u\tmsglen\t%?d\n", smh.smh_context,
233 smh.smh_msglen);
234
235 return (0);
236 }
237
238 static int
dump_datahdr(mblk_t * mp)239 dump_datahdr(mblk_t *mp)
240 {
241 sctp_data_hdr_t sdc;
242 uint16_t sdh_int16;
243 uint32_t sdh_int32;
244
245 if (mdb_vread(&sdc, sizeof (sdc), (uintptr_t)mp->b_rptr) == -1)
246 return (-1);
247
248 mdb_printf("%<u>data_chunk_t \t%?p\tsentto\t%?p%</u>\n",
249 mp->b_rptr, SCTP_CHUNK_DEST(mp));
250 mdb_printf("\tsent\t%?d\t", SCTP_CHUNK_ISSENT(mp)?1:0);
251 mdb_printf("retrans\t%?d\n", SCTP_CHUNK_WANT_REXMIT(mp)?1:0);
252 mdb_printf("\tacked\t%?d\t", SCTP_CHUNK_ISACKED(mp)?1:0);
253 mdb_printf("sackcnt\t%?u\n", SCTP_CHUNK_SACKCNT(mp));
254
255 mdb_nhconvert(&sdh_int16, &sdc.sdh_len, sizeof (sdc.sdh_len));
256 mdb_printf("\tlen\t%?d\t", sdh_int16);
257 mdb_printf("BBIT=%d", SCTP_DATA_GET_BBIT(&sdc) == 0 ? 0 : 1);
258 mdb_printf("EBIT=%d", SCTP_DATA_GET_EBIT(&sdc) == 0 ? 0 : 1);
259
260 mdb_nhconvert(&sdh_int32, &sdc.sdh_tsn, sizeof (sdc.sdh_tsn));
261 mdb_nhconvert(&sdh_int16, &sdc.sdh_sid, sizeof (sdc.sdh_sid));
262 mdb_printf("\ttsn\t%?x\tsid\t%?hu\n", sdh_int32, sdh_int16);
263
264 mdb_nhconvert(&sdh_int16, &sdc.sdh_ssn, sizeof (sdc.sdh_ssn));
265 mdb_nhconvert(&sdh_int32, &sdc.sdh_payload_id,
266 sizeof (sdc.sdh_payload_id));
267 mdb_printf("\tssn\t%?hu\tppid\t%?d\n", sdh_int16, sdh_int32);
268
269 return (0);
270 }
271
272 static int
sctp_sent_list(mblk_t * addr)273 sctp_sent_list(mblk_t *addr)
274 {
275 mblk_t meta, mp;
276
277 if (!addr)
278 return (0);
279
280 if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1)
281 return (-1);
282
283 for (;;) {
284 dump_msghdr(&meta);
285
286 if (meta.b_cont == NULL) {
287 mdb_printf("No data chunks with message header!\n");
288 return (-1);
289 }
290 if (mdb_vread(&mp, sizeof (mp),
291 (uintptr_t)meta.b_cont) == -1) {
292 return (-1);
293 }
294 for (;;) {
295 dump_datahdr(&mp);
296 if (!mp.b_next)
297 break;
298
299 if (mdb_vread(&mp, sizeof (mp),
300 (uintptr_t)(mp.b_next)) == -1)
301 return (-1);
302 }
303 if (meta.b_next == NULL)
304 break;
305 if (mdb_vread(&meta, sizeof (meta),
306 (uintptr_t)meta.b_next) == -1)
307 return (-1);
308 }
309
310 return (0);
311 }
312
313 static int
sctp_unsent_list(mblk_t * addr)314 sctp_unsent_list(mblk_t *addr)
315 {
316 mblk_t meta;
317
318 if (!addr)
319 return (0);
320
321 if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1)
322 return (-1);
323
324 for (;;) {
325 dump_msghdr(&meta);
326
327 if (meta.b_next == NULL)
328 break;
329
330 if (mdb_vread(&meta, sizeof (meta),
331 (uintptr_t)meta.b_next) == -1)
332 return (-1);
333 }
334
335 return (0);
336 }
337
338 /* ARGSUSED */
339 static int
sctp_xmit_list(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)340 sctp_xmit_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
341 {
342 sctp_t sctp;
343
344 if (!(flags & DCMD_ADDRSPEC))
345 return (DCMD_USAGE);
346
347 if (mdb_vread(&sctp, sizeof (sctp), addr) == -1)
348 return (DCMD_ERR);
349
350 mdb_printf("%<b>Chunkified TX list%</b>\n");
351 if (sctp_sent_list(sctp.sctp_xmit_head) < 0)
352 return (DCMD_ERR);
353
354 mdb_printf("%<b>Unchunkified TX list%</b>\n");
355 if (sctp_unsent_list(sctp.sctp_xmit_unsent) < 0)
356 return (DCMD_ERR);
357
358 return (DCMD_OK);
359 }
360
361 /* ARGSUSED */
362 static int
sctp_mdata_chunk(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)363 sctp_mdata_chunk(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
364 {
365 sctp_data_hdr_t dc;
366 mblk_t mp;
367
368 if (!(flags & DCMD_ADDRSPEC))
369 return (DCMD_USAGE);
370
371 if (mdb_vread(&mp, sizeof (mp), addr) == -1)
372 return (DCMD_ERR);
373
374 if (mdb_vread(&dc, sizeof (dc), (uintptr_t)mp.b_rptr) == -1)
375 return (DCMD_ERR);
376
377 mdb_printf("%<b>%-?p%</b>tsn\t%?x\tsid\t%?hu\n", addr,
378 dc.sdh_tsn, dc.sdh_sid);
379 mdb_printf("%-?sssn\t%?hu\tppid\t%?x\n", "", dc.sdh_ssn,
380 dc.sdh_payload_id);
381
382 return (DCMD_OK);
383 }
384
385 /* ARGSUSED */
386 static int
sctp_istr_msgs(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)387 sctp_istr_msgs(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
388 {
389 mblk_t istrmp;
390 mblk_t dmp;
391 sctp_data_hdr_t dp;
392 uintptr_t daddr;
393 uintptr_t chaddr;
394 boolean_t bbit;
395 boolean_t ebit;
396
397 if (!(flags & DCMD_ADDRSPEC))
398 return (DCMD_USAGE);
399
400 do {
401 if (mdb_vread(&istrmp, sizeof (istrmp), addr) == -1)
402 return (DCMD_ERR);
403
404 mdb_printf("\tistr mblk at %p: next: %?p\n"
405 "\t\tprev: %?p\tcont: %?p\n", addr, istrmp.b_next,
406 istrmp.b_prev, istrmp.b_cont);
407 daddr = (uintptr_t)&istrmp;
408 do {
409 if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1)
410 break;
411 chaddr = (uintptr_t)dmp.b_rptr;
412 if (mdb_vread(&dp, sizeof (dp), chaddr) == -1)
413 break;
414
415 bbit = (SCTP_DATA_GET_BBIT(&dp) != 0);
416 ebit = (SCTP_DATA_GET_EBIT(&dp) != 0);
417
418 mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n",
419 dp.sdh_tsn, bbit, ebit);
420
421
422 daddr = (uintptr_t)dmp.b_cont;
423 } while (daddr != 0);
424
425 addr = (uintptr_t)istrmp.b_next;
426 } while (addr != 0);
427
428 return (DCMD_OK);
429 }
430
431 /* ARGSUSED */
432 static int
sctp_reass_list(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)433 sctp_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
434 {
435 sctp_reass_t srp;
436 mblk_t srpmp;
437 sctp_data_hdr_t dp;
438 mblk_t dmp;
439 uintptr_t daddr;
440 uintptr_t chaddr;
441 boolean_t bbit, ebit;
442
443 if (!(flags & DCMD_ADDRSPEC))
444 return (DCMD_USAGE);
445
446 do {
447 if (mdb_vread(&srpmp, sizeof (srpmp), addr) == -1)
448 return (DCMD_ERR);
449
450 if (mdb_vread(&srp, sizeof (srp),
451 (uintptr_t)srpmp.b_datap->db_base) == -1)
452 return (DCMD_ERR);
453
454 mdb_printf("\treassembly mblk at %p: next: %?p\n"
455 "\t\tprev: %?p\tcont: %?p\n", addr, srpmp.b_next,
456 srpmp.b_prev, srpmp.b_cont);
457 mdb_printf("\t\tssn: %hu\tneeded: %hu\tgot: %hu\ttail: %?p\n"
458 "\t\tpartial_delivered: %s\n", srp.sr_ssn, srp.sr_needed,
459 srp.sr_got, srp.sr_tail, srp.sr_partial_delivered ? "TRUE" :
460 "FALSE");
461
462 /* display the contents of this ssn's reassemby list */
463 daddr = DB_TYPE(&srpmp) == M_CTL ? (uintptr_t)srpmp.b_cont :
464 (uintptr_t)&srpmp;
465 do {
466 if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1)
467 break;
468 chaddr = (uintptr_t)dmp.b_rptr;
469 if (mdb_vread(&dp, sizeof (dp), chaddr) == -1)
470 break;
471
472 bbit = (SCTP_DATA_GET_BBIT(&dp) != 0);
473 ebit = (SCTP_DATA_GET_EBIT(&dp) != 0);
474
475 mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n",
476 dp.sdh_tsn, bbit, ebit);
477
478 daddr = (uintptr_t)dmp.b_cont;
479 } while (daddr != 0);
480
481 addr = (uintptr_t)srpmp.b_next;
482 } while (addr != 0);
483
484 return (DCMD_OK);
485 }
486
487 /* ARGSUSED */
488 static int
sctp_uo_reass_list(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)489 sctp_uo_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
490 {
491 sctp_data_hdr_t dp;
492 mblk_t dmp;
493 uintptr_t chaddr;
494 boolean_t bbit;
495 boolean_t ebit;
496 boolean_t ubit;
497
498 if (!(flags & DCMD_ADDRSPEC))
499 return (DCMD_USAGE);
500
501 do {
502 if (mdb_vread(&dmp, sizeof (dmp), addr) == -1)
503 return (DCMD_ERR);
504
505 mdb_printf("\treassembly mblk at %p: next: %?p\n"
506 "\t\tprev: %?p\n", addr, dmp.b_next, dmp.b_prev);
507
508 chaddr = (uintptr_t)dmp.b_rptr;
509 if (mdb_vread(&dp, sizeof (dp), chaddr) == -1)
510 break;
511
512 bbit = (SCTP_DATA_GET_BBIT(&dp) != 0);
513 ebit = (SCTP_DATA_GET_EBIT(&dp) != 0);
514 ubit = (SCTP_DATA_GET_UBIT(&dp) != 0);
515
516 mdb_printf("\t\t\tsid: %hu ssn: %hu tsn: %x "
517 "flags: %x (U=%d B=%d E=%d)\n", dp.sdh_sid, dp.sdh_ssn,
518 dp.sdh_tsn, dp.sdh_flags, ubit, bbit, ebit);
519
520 addr = (uintptr_t)dmp.b_next;
521 } while (addr != 0);
522
523 return (DCMD_OK);
524 }
525
526 static int
sctp_instr(uintptr_t addr,uint_t flags,int ac,const mdb_arg_t * av)527 sctp_instr(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av)
528 {
529 sctp_instr_t sip;
530
531 if (!(flags & DCMD_ADDRSPEC))
532 return (DCMD_USAGE);
533
534 if (mdb_vread(&sip, sizeof (sip), addr) == -1)
535 return (DCMD_ERR);
536
537 mdb_printf("%<b>%-?p%</b>\n\tmsglist\t%?p\tnmsgs\t%?d\n"
538 "\tnextseq\t%?d\treass\t%?p\n", addr, sip.istr_msgs,
539 sip.istr_nmsgs, sip.nextseq, sip.istr_reass);
540 mdb_set_dot(addr + sizeof (sip));
541
542 return (sctp_reass_list((uintptr_t)sip.istr_reass, flags, ac, av));
543 }
544
545 static const char *
state2str(sctp_t * sctp)546 state2str(sctp_t *sctp)
547 {
548 switch (sctp->sctp_state) {
549 case SCTPS_IDLE: return ("SCTPS_IDLE");
550 case SCTPS_BOUND: return ("SCTPS_BOUND");
551 case SCTPS_LISTEN: return ("SCTPS_LISTEN");
552 case SCTPS_COOKIE_WAIT: return ("SCTPS_COOKIE_WAIT");
553 case SCTPS_COOKIE_ECHOED: return ("SCTPS_COOKIE_ECHOED");
554 case SCTPS_ESTABLISHED: return ("SCTPS_ESTABLISHED");
555 case SCTPS_SHUTDOWN_PENDING: return ("SCTPS_SHUTDOWN_PENDING");
556 case SCTPS_SHUTDOWN_SENT: return ("SCTPS_SHUTDOWN_SENT");
557 case SCTPS_SHUTDOWN_RECEIVED: return ("SCTPS_SHUTDOWN_RECEIVED");
558 case SCTPS_SHUTDOWN_ACK_SENT: return ("SCTPS_SHUTDOWN_ACK_SENT");
559 default: return ("UNKNOWN STATE");
560 }
561 }
562
563 static void
show_sctp_flags(sctp_t * sctp)564 show_sctp_flags(sctp_t *sctp)
565 {
566 mdb_printf("\tunderstands_asconf\t%d\n",
567 sctp->sctp_understands_asconf);
568 mdb_printf("\tdebug\t\t\t%d\n", sctp->sctp_connp->conn_debug);
569 mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend);
570 mdb_printf("\tdgram_errind\t\t%d\n",
571 sctp->sctp_connp->conn_dgram_errind);
572
573 mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_connp->conn_linger);
574 if (sctp->sctp_lingering)
575 return;
576 mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering);
577 mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback);
578 mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack);
579
580 mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running);
581 mdb_printf("\trecvdstaddr\t\t%d\n",
582 sctp->sctp_connp->conn_recv_ancillary.crb_recvdstaddr);
583 mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum);
584 mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip);
585
586 mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all);
587 mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep);
588 mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached);
589 mdb_printf("\tsend_adaptation\t\t%d\n", sctp->sctp_send_adaptation);
590
591 mdb_printf("\trecv_adaptation\t\t%d\n", sctp->sctp_recv_adaptation);
592 mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay);
593 mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned);
594 mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit);
595
596 mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware);
597 mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal);
598 mdb_printf("\trexmitting\t\t%d\n", sctp->sctp_rexmitting);
599 mdb_printf("\tzero_win_probe\t\t%d\n", sctp->sctp_zero_win_probe);
600
601 mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo);
602 mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt);
603 mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt);
604 mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt);
605
606 mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr);
607 mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt);
608 mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt);
609 mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt);
610 }
611
612 /*
613 * Given a sctp_saddr_ipif_t, print out its address. This assumes
614 * that addr contains the sctp_addr_ipif_t structure already and this
615 * function does not need to read it in.
616 */
617 /* ARGSUSED */
618 static int
print_saddr(uintptr_t ptr,const void * addr,void * cbdata)619 print_saddr(uintptr_t ptr, const void *addr, void *cbdata)
620 {
621 sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr;
622 sctp_ipif_t ipif;
623 char *statestr;
624
625 /* Read in the sctp_ipif object */
626 if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) ==
627 -1) {
628 mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp);
629 return (WALK_ERR);
630 }
631
632 switch (ipif.sctp_ipif_state) {
633 case SCTP_IPIFS_CONDEMNED:
634 statestr = "Condemned";
635 break;
636 case SCTP_IPIFS_INVALID:
637 statestr = "Invalid";
638 break;
639 case SCTP_IPIFS_DOWN:
640 statestr = "Down";
641 break;
642 case SCTP_IPIFS_UP:
643 statestr = "Up";
644 break;
645 default:
646 statestr = "Unknown";
647 break;
648 }
649 mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr,
650 statestr);
651 if (saddr->saddr_ipif_dontsrc == 1)
652 mdb_printf("/Dontsrc");
653 if (saddr->saddr_ipif_unconfirmed == 1)
654 mdb_printf("/Unconfirmed");
655 if (saddr->saddr_ipif_delete_pending == 1)
656 mdb_printf("/DeletePending");
657 mdb_printf(")\n");
658 mdb_printf("\t\t\tid %d zoneid %d IPIF flags %x\n",
659 ipif.sctp_ipif_id,
660 ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags);
661 return (WALK_NEXT);
662 }
663
664 /*
665 * Given a sctp_faddr_t, print out its address. This assumes that
666 * addr contains the sctp_faddr_t structure already and this function
667 * does not need to read it in.
668 */
669 static int
print_faddr(uintptr_t ptr,const void * addr,void * cbdata)670 print_faddr(uintptr_t ptr, const void *addr, void *cbdata)
671 {
672 char *statestr;
673 sctp_faddr_t *faddr = (sctp_faddr_t *)addr;
674 int *i = cbdata;
675
676 statestr = sctp_faddr_state(faddr->sf_state);
677
678 mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->sf_faddr, ptr,
679 statestr);
680 return (WALK_NEXT);
681 }
682
683 int
sctp(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)684 sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
685 {
686 sctp_t sctps, *sctp;
687 conn_t conns, *connp;
688 int i;
689 uint_t opts = 0;
690 uint_t paddr = 0;
691 in_port_t lport, fport;
692
693 if (!(flags & DCMD_ADDRSPEC))
694 return (DCMD_USAGE);
695
696 if (mdb_vread(&sctps, sizeof (sctps), addr) == -1) {
697 mdb_warn("failed to read sctp_t at: %p\n", addr);
698 return (DCMD_ERR);
699 }
700 sctp = &sctps;
701
702 if (mdb_vread(&conns, sizeof (conns),
703 (uintptr_t)sctp->sctp_connp) == -1) {
704 mdb_warn("failed to read conn_t at: %p\n", sctp->sctp_connp);
705 return (DCMD_ERR);
706 }
707
708 connp = &conns;
709
710 connp->conn_sctp = sctp;
711 sctp->sctp_connp = connp;
712
713 if (mdb_getopts(argc, argv,
714 'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts,
715 'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts,
716 'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts,
717 'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts,
718 'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts,
719 'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts,
720 'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts,
721 'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts,
722 'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts,
723 'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts,
724 'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts,
725 'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts,
726 'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts,
727 'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts,
728 'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts,
729 'P', MDB_OPT_SETBITS, 1, &paddr,
730 'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts,
731 NULL) != argc) {
732 return (DCMD_USAGE);
733 }
734
735 /* non-verbose faddrs, suitable for pipelines to sctp_faddr */
736 if (paddr != 0) {
737 sctp_faddr_t faddr, *fp;
738 for (fp = sctp->sctp_faddrs; fp != NULL; fp = faddr.sf_next) {
739 if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp)
740 == -1) {
741 mdb_warn("failed to read faddr at %p",
742 fp);
743 return (DCMD_ERR);
744 }
745 mdb_printf("%p\n", fp);
746 }
747 return (DCMD_OK);
748 }
749
750 mdb_nhconvert(&lport, &connp->conn_lport, sizeof (lport));
751 mdb_nhconvert(&fport, &connp->conn_fport, sizeof (fport));
752 mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% STACK=%d ZONE=%d%</u>", addr,
753 state2str(sctp), lport, fport,
754 ns_to_stackid((uintptr_t)connp->conn_netstack), connp->conn_zoneid);
755
756 if (sctp->sctp_faddrs) {
757 sctp_faddr_t faddr;
758 if (mdb_vread(&faddr, sizeof (faddr),
759 (uintptr_t)sctp->sctp_faddrs) != -1)
760 mdb_printf("%<u> %N%</u>", &faddr.sf_faddr);
761 }
762 mdb_printf("\n");
763
764 if (opts & MDB_SCTP_DUMP_ADDRS) {
765 mdb_printf("%<b>Local and Peer Addresses%</b>\n");
766
767 /* Display source addresses */
768 mdb_printf("nsaddrs\t\t%?d\n", sctp->sctp_nsaddrs);
769 (void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr);
770
771 /* Display peer addresses */
772 mdb_printf("nfaddrs\t\t%?d\n", sctp->sctp_nfaddrs);
773 i = 1;
774 (void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr);
775
776 mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n",
777 sctp->sctp_lastfaddr, sctp->sctp_primary);
778 mdb_printf("current\t\t%?p\tlastdata\t%?p\n",
779 sctp->sctp_current, sctp->sctp_lastdata);
780 }
781
782 if (opts & MDB_SCTP_SHOW_OUT) {
783 mdb_printf("%<b>Outbound Data%</b>\n");
784 mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n",
785 sctp->sctp_xmit_head, sctp->sctp_xmit_tail);
786 mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n",
787 sctp->sctp_xmit_unsent, sctp->sctp_xmit_unsent_tail);
788 mdb_printf("xmit_unacked\t%?p\n", sctp->sctp_xmit_unacked);
789 mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n",
790 sctp->sctp_unacked, sctp->sctp_unsent);
791 mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n",
792 sctp->sctp_ltsn, sctp->sctp_lastack_rxd);
793 mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n",
794 sctp->sctp_recovery_tsn, sctp->sctp_adv_pap);
795 mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n",
796 sctp->sctp_num_ostr, sctp->sctp_ostrcntrs);
797 mdb_printf("pad_mp\t\t%?p\terr_chunks\t%?p\n",
798 sctp->sctp_pad_mp, sctp->sctp_err_chunks);
799 mdb_printf("err_len\t\t%?u\n", sctp->sctp_err_len);
800
801 mdb_printf("%<b>Default Send Parameters%</b>\n");
802 mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n",
803 sctp->sctp_def_stream, sctp->sctp_def_flags);
804 mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n",
805 sctp->sctp_def_ppid, sctp->sctp_def_context);
806 mdb_printf("def_timetolive\t%?u\n",
807 sctp->sctp_def_timetolive);
808 }
809
810 if (opts & MDB_SCTP_SHOW_IN) {
811 mdb_printf("%<b>Inbound Data%</b>\n");
812 mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n",
813 sctp->sctp_sack_info, sctp->sctp_sack_gaps);
814 dump_sack_info((uintptr_t)sctp->sctp_sack_info);
815 mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n",
816 sctp->sctp_ftsn, sctp->sctp_lastacked);
817 mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n",
818 sctp->sctp_istr_nmsgs, sctp->sctp_sack_toggle);
819 mdb_printf("ack_mp\t\t%?p\n", sctp->sctp_ack_mp);
820 mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n",
821 sctp->sctp_num_istr, sctp->sctp_instr);
822 mdb_printf("unord_reass\t%?p\n", sctp->sctp_uo_frags);
823 }
824
825 if (opts & MDB_SCTP_SHOW_RTT) {
826 mdb_printf("%<b>RTT Tracking%</b>\n");
827 mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n",
828 sctp->sctp_rtt_tsn, sctp->sctp_out_time);
829 }
830
831 if (opts & MDB_SCTP_SHOW_FLOW) {
832 mdb_printf("%<b>Flow Control%</b>\n");
833 mdb_printf("tconn_sndbuf\t%?d\n"
834 "conn_sndlowat\t%?d\tfrwnd\t\t%?u\n"
835 "rwnd\t\t%?u\tlast advertised rwnd\t%?u\n"
836 "rxqueued\t%?u\tcwnd_max\t%?u\n", connp->conn_sndbuf,
837 connp->conn_sndlowat, sctp->sctp_frwnd,
838 sctp->sctp_rwnd, sctp->sctp_arwnd, sctp->sctp_rxqueued,
839 sctp->sctp_cwnd_max);
840 }
841
842 if (opts & MDB_SCTP_SHOW_HDR) {
843 mdb_printf("%<b>Composite Headers%</b>\n");
844 mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n"
845 "iphc_len\t%?d\tiphc6_len\t%?d\n"
846 "hdr_len\t\t%?d\thdr6_len\t%?d\n"
847 "ipha\t\t%?p\tip6h\t\t%?p\n"
848 "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n"
849 "sctph\t\t%?p\tsctph6\t\t%?p\n"
850 "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp->sctp_iphc,
851 sctp->sctp_iphc6, sctp->sctp_iphc_len,
852 sctp->sctp_iphc6_len, sctp->sctp_hdr_len,
853 sctp->sctp_hdr6_len, sctp->sctp_ipha, sctp->sctp_ip6h,
854 sctp->sctp_ip_hdr_len, sctp->sctp_ip_hdr6_len,
855 sctp->sctp_sctph, sctp->sctp_sctph6, sctp->sctp_lvtag,
856 sctp->sctp_fvtag);
857 }
858
859 if (opts & MDB_SCTP_SHOW_PMTUD) {
860 mdb_printf("%<b>PMTUd%</b>\n");
861 mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n"
862 "mss\t\t%?u\n",
863 sctp->sctp_last_mtu_probe, sctp->sctp_mtu_probe_intvl,
864 sctp->sctp_mss);
865 }
866
867 if (opts & MDB_SCTP_SHOW_RXT) {
868 mdb_printf("%<b>Retransmit Info%</b>\n");
869 mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n"
870 "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n"
871 "pp_max_rxt\t%?d\trto_max\t\t%?u\n"
872 "rto_min\t\t%?u\trto_initial\t%?u\n"
873 "init_rto_max\t%?u\n"
874 "rxt_nxttsn\t%?u\trxt_maxtsn\t%?u\n", sctp->sctp_cookie_mp,
875 sctp->sctp_strikes, sctp->sctp_max_init_rxt,
876 sctp->sctp_pa_max_rxt, sctp->sctp_pp_max_rxt,
877 sctp->sctp_rto_max, sctp->sctp_rto_min,
878 sctp->sctp_rto_initial, sctp->sctp_rto_max_init,
879 sctp->sctp_rxt_nxttsn, sctp->sctp_rxt_maxtsn);
880 }
881
882 if (opts & MDB_SCTP_SHOW_CONN) {
883 mdb_printf("%<b>Connection State%</b>\n");
884 mdb_printf("last_secret_update%?ld\n",
885 sctp->sctp_last_secret_update);
886
887 mdb_printf("secret\t\t");
888 for (i = 0; i < SCTP_SECRET_LEN; i++) {
889 if (i % 2 == 0)
890 mdb_printf("0x%02x", sctp->sctp_secret[i]);
891 else
892 mdb_printf("%02x ", sctp->sctp_secret[i]);
893 }
894 mdb_printf("\n");
895 mdb_printf("old_secret\t");
896 for (i = 0; i < SCTP_SECRET_LEN; i++) {
897 if (i % 2 == 0)
898 mdb_printf("0x%02x", sctp->sctp_old_secret[i]);
899 else
900 mdb_printf("%02x ", sctp->sctp_old_secret[i]);
901 }
902 mdb_printf("\n");
903 }
904
905 if (opts & MDB_SCTP_SHOW_STATS) {
906 mdb_printf("%<b>Stats Counters%</b>\n");
907 mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n"
908 "odchunks\t%?llu\toudchunks\t%?llu\n"
909 "rxtchunks\t%?llu\tT1expire\t%?lu\n"
910 "T2expire\t%?lu\tT3expire\t%?lu\n"
911 "msgcount\t%?llu\tprsctpdrop\t%?llu\n"
912 "AssocStartTime\t%?lu\n",
913 sctp->sctp_opkts, sctp->sctp_obchunks,
914 sctp->sctp_odchunks, sctp->sctp_oudchunks,
915 sctp->sctp_rxtchunks, sctp->sctp_T1expire,
916 sctp->sctp_T2expire, sctp->sctp_T3expire,
917 sctp->sctp_msgcount, sctp->sctp_prsctpdrop,
918 sctp->sctp_assoc_start_time);
919 mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n"
920 "idchunks\t%?llu\tiudchunks\t%?llu\n"
921 "fragdmsgs\t%?llu\treassmsgs\t%?llu\n",
922 sctp->sctp_ipkts, sctp->sctp_ibchunks,
923 sctp->sctp_idchunks, sctp->sctp_iudchunks,
924 sctp->sctp_fragdmsgs, sctp->sctp_reassmsgs);
925 }
926
927 if (opts & MDB_SCTP_SHOW_HASH) {
928 mdb_printf("%<b>Hash Tables%</b>\n");
929 mdb_printf("conn_hash_next\t%?p\t", sctp->sctp_conn_hash_next);
930 mdb_printf("conn_hash_prev\t%?p\n", sctp->sctp_conn_hash_prev);
931
932 mdb_printf("listen_hash_next%?p\t",
933 sctp->sctp_listen_hash_next);
934 mdb_printf("listen_hash_prev%?p\n",
935 sctp->sctp_listen_hash_prev);
936 mdb_nhconvert(&lport, &connp->conn_lport, sizeof (lport));
937 mdb_printf("[ listen_hash bucket\t%?d ]\n",
938 SCTP_LISTEN_HASH(lport));
939
940 mdb_printf("conn_tfp\t%?p\t", sctp->sctp_conn_tfp);
941 mdb_printf("listen_tfp\t%?p\n", sctp->sctp_listen_tfp);
942
943 mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n",
944 sctp->sctp_bind_hash, sctp->sctp_ptpbhn);
945 mdb_printf("bind_lockp\t%?p\n",
946 sctp->sctp_bind_lockp);
947 mdb_printf("[ bind_hash bucket\t%?d ]\n",
948 SCTP_BIND_HASH(lport));
949 }
950
951 if (opts & MDB_SCTP_SHOW_CLOSE) {
952 mdb_printf("%<b>Cleanup / Close%</b>\n");
953 mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n"
954 "lingertime\t%?d\trefcnt\t\t%?hu\n",
955 sctp->sctp_shutdown_faddr, sctp->sctp_client_errno,
956 connp->conn_lingertime, sctp->sctp_refcnt);
957 }
958
959 if (opts & MDB_SCTP_SHOW_MISC) {
960 mdb_printf("%<b>Miscellaneous%</b>\n");
961 mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n"
962 "family\t\t%?u\tipversion\t%?hu\n"
963 "hb_interval\t%?u\tautoclose\t%?d\n"
964 "active\t\t%?ld\ttx_adaptation_code%?x\n"
965 "rx_adaptation_code%?x\ttimer_mp\t%?p\n"
966 "partial_delivery_point\t%?d\n",
967 connp->conn_bound_if, sctp->sctp_heartbeat_mp,
968 connp->conn_family,
969 connp->conn_ipversion,
970 sctp->sctp_hb_interval, sctp->sctp_autoclose,
971 sctp->sctp_active, sctp->sctp_tx_adaptation_code,
972 sctp->sctp_rx_adaptation_code, sctp->sctp_timer_mp,
973 sctp->sctp_pd_point);
974 }
975
976 if (opts & MDB_SCTP_SHOW_EXT) {
977 mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n");
978 mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n"
979 "fcsn\t\t%?x\n", sctp->sctp_cxmit_list, sctp->sctp_lcsn,
980 sctp->sctp_fcsn);
981 }
982
983 if (opts & MDB_SCTP_SHOW_FLAGS) {
984 mdb_printf("%<b>Flags%</b>\n");
985 show_sctp_flags(sctp);
986 }
987
988 return (DCMD_OK);
989 }
990
991 typedef struct fanout_walk_data {
992 int index;
993 int size;
994 uintptr_t sctp;
995 sctp_tf_t *fanout;
996 uintptr_t (*getnext)(sctp_t *);
997 } fanout_walk_data_t;
998
999 typedef struct fanout_init {
1000 const char *nested_walker_name;
1001 size_t offset; /* for what used to be a symbol */
1002 int (*getsize)(sctp_stack_t *);
1003 uintptr_t (*getnext)(sctp_t *);
1004 } fanout_init_t;
1005
1006 static uintptr_t
listen_next(sctp_t * sctp)1007 listen_next(sctp_t *sctp)
1008 {
1009 return ((uintptr_t)sctp->sctp_listen_hash_next);
1010 }
1011
1012 /* ARGSUSED */
1013 static int
listen_size(sctp_stack_t * sctps)1014 listen_size(sctp_stack_t *sctps)
1015 {
1016 return (SCTP_LISTEN_FANOUT_SIZE);
1017 }
1018
1019 static uintptr_t
conn_next(sctp_t * sctp)1020 conn_next(sctp_t *sctp)
1021 {
1022 return ((uintptr_t)sctp->sctp_conn_hash_next);
1023 }
1024
1025 static int
conn_size(sctp_stack_t * sctps)1026 conn_size(sctp_stack_t *sctps)
1027 {
1028 int size;
1029 uintptr_t kaddr;
1030
1031 kaddr = (uintptr_t)&sctps->sctps_conn_hash_size;
1032
1033 if (mdb_vread(&size, sizeof (size), kaddr) == -1) {
1034 mdb_warn("can't read 'sctps_conn_hash_size' at %p", kaddr);
1035 return (1);
1036 }
1037 return (size);
1038 }
1039
1040 static uintptr_t
bind_next(sctp_t * sctp)1041 bind_next(sctp_t *sctp)
1042 {
1043 return ((uintptr_t)sctp->sctp_bind_hash);
1044 }
1045
1046 /* ARGSUSED */
1047 static int
bind_size(sctp_stack_t * sctps)1048 bind_size(sctp_stack_t *sctps)
1049 {
1050 return (SCTP_BIND_FANOUT_SIZE);
1051 }
1052
1053 static uintptr_t
find_next_hash_item(fanout_walk_data_t * fw)1054 find_next_hash_item(fanout_walk_data_t *fw)
1055 {
1056 sctp_tf_t tf;
1057 sctp_t sctp;
1058
1059 /* first try to continue down the hash chain */
1060 if (fw->sctp != 0) {
1061 /* try to get next in hash chain */
1062 if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) {
1063 mdb_warn("failed to read sctp at %p", fw->sctp);
1064 return (0);
1065 }
1066 fw->sctp = fw->getnext(&sctp);
1067 if (fw->sctp != 0)
1068 return (fw->sctp);
1069 else
1070 /* end of chain; go to next bucket */
1071 fw->index++;
1072 }
1073
1074 /* find a new hash chain, traversing the buckets */
1075 for (; fw->index < fw->size; fw->index++) {
1076 /* read the current hash line for an sctp */
1077 if (mdb_vread(&tf, sizeof (tf),
1078 (uintptr_t)(fw->fanout + fw->index)) == -1) {
1079 mdb_warn("failed to read tf at %p",
1080 fw->fanout + fw->index);
1081 return (0);
1082 }
1083 if (tf.tf_sctp != NULL) {
1084 /* start of a new chain */
1085 fw->sctp = (uintptr_t)tf.tf_sctp;
1086 return (fw->sctp);
1087 }
1088 }
1089 return (0);
1090 }
1091
1092 static int
fanout_stack_walk_init(mdb_walk_state_t * wsp)1093 fanout_stack_walk_init(mdb_walk_state_t *wsp)
1094 {
1095 fanout_walk_data_t *lw;
1096 fanout_init_t *fi = wsp->walk_arg;
1097 sctp_stack_t *sctps = (sctp_stack_t *)wsp->walk_addr;
1098 uintptr_t kaddr;
1099
1100 if (mdb_vread(&kaddr, sizeof (kaddr),
1101 wsp->walk_addr + fi->offset) == -1) {
1102 mdb_warn("can't read sctp fanout at %p",
1103 wsp->walk_addr + fi->offset);
1104 return (WALK_ERR);
1105 }
1106
1107 lw = mdb_alloc(sizeof (*lw), UM_SLEEP);
1108 lw->index = 0;
1109 lw->size = fi->getsize(sctps);
1110 lw->sctp = 0;
1111 lw->fanout = (sctp_tf_t *)kaddr;
1112 lw->getnext = fi->getnext;
1113
1114 if ((wsp->walk_addr = find_next_hash_item(lw)) == 0) {
1115 return (WALK_DONE);
1116 }
1117 wsp->walk_data = lw;
1118 return (WALK_NEXT);
1119 }
1120
1121 static int
fanout_stack_walk_step(mdb_walk_state_t * wsp)1122 fanout_stack_walk_step(mdb_walk_state_t *wsp)
1123 {
1124 fanout_walk_data_t *fw = wsp->walk_data;
1125 uintptr_t addr = wsp->walk_addr;
1126 sctp_t sctp;
1127 int status;
1128
1129 if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) {
1130 mdb_warn("failed to read sctp at %p", addr);
1131 return (WALK_DONE);
1132 }
1133
1134 status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata);
1135 if (status != WALK_NEXT)
1136 return (status);
1137
1138 if ((wsp->walk_addr = find_next_hash_item(fw)) == 0)
1139 return (WALK_DONE);
1140
1141 return (WALK_NEXT);
1142 }
1143
1144 static void
fanout_stack_walk_fini(mdb_walk_state_t * wsp)1145 fanout_stack_walk_fini(mdb_walk_state_t *wsp)
1146 {
1147 fanout_walk_data_t *fw = wsp->walk_data;
1148
1149 mdb_free(fw, sizeof (*fw));
1150 }
1151
1152 int
fanout_walk_init(mdb_walk_state_t * wsp)1153 fanout_walk_init(mdb_walk_state_t *wsp)
1154 {
1155 if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1156 mdb_warn("can't walk 'sctp_stacks'");
1157 return (WALK_ERR);
1158 }
1159
1160 return (WALK_NEXT);
1161 }
1162
1163 int
fanout_walk_step(mdb_walk_state_t * wsp)1164 fanout_walk_step(mdb_walk_state_t *wsp)
1165 {
1166 fanout_init_t *fi = wsp->walk_arg;
1167
1168 if (mdb_pwalk(fi->nested_walker_name, wsp->walk_callback,
1169 wsp->walk_cbdata, wsp->walk_addr) == -1) {
1170 mdb_warn("couldn't walk '%s'for address %p",
1171 fi->nested_walker_name, wsp->walk_addr);
1172 return (WALK_ERR);
1173 }
1174 return (WALK_NEXT);
1175 }
1176
1177 int
sctps_walk_init(mdb_walk_state_t * wsp)1178 sctps_walk_init(mdb_walk_state_t *wsp)
1179 {
1180
1181 if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1182 mdb_warn("can't walk 'sctp_stacks'");
1183 return (WALK_ERR);
1184 }
1185
1186 return (WALK_NEXT);
1187 }
1188
1189 int
sctps_walk_step(mdb_walk_state_t * wsp)1190 sctps_walk_step(mdb_walk_state_t *wsp)
1191 {
1192 uintptr_t kaddr;
1193
1194 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_list);
1195 if (mdb_pwalk("list", wsp->walk_callback,
1196 wsp->walk_cbdata, kaddr) == -1) {
1197 mdb_warn("couldn't walk 'list' for address %p", kaddr);
1198 return (WALK_ERR);
1199 }
1200 return (WALK_NEXT);
1201 }
1202
1203 static int
sctp_walk_faddr_init(mdb_walk_state_t * wsp)1204 sctp_walk_faddr_init(mdb_walk_state_t *wsp)
1205 {
1206 sctp_t sctp;
1207
1208 if (wsp->walk_addr == 0)
1209 return (WALK_ERR);
1210
1211 if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) {
1212 mdb_warn("failed to read sctp at %p", wsp->walk_addr);
1213 return (WALK_ERR);
1214 }
1215 if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != 0)
1216 return (WALK_NEXT);
1217 else
1218 return (WALK_DONE);
1219 }
1220
1221 static int
sctp_walk_faddr_step(mdb_walk_state_t * wsp)1222 sctp_walk_faddr_step(mdb_walk_state_t *wsp)
1223 {
1224 uintptr_t faddr_ptr = wsp->walk_addr;
1225 sctp_faddr_t sctp_faddr;
1226 int status;
1227
1228 if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) {
1229 mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr);
1230 return (WALK_ERR);
1231 }
1232 status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata);
1233 if (status != WALK_NEXT)
1234 return (status);
1235 if ((faddr_ptr = (uintptr_t)sctp_faddr.sf_next) == 0) {
1236 return (WALK_DONE);
1237 } else {
1238 wsp->walk_addr = faddr_ptr;
1239 return (WALK_NEXT);
1240 }
1241 }
1242
1243 /*
1244 * Helper structure for sctp_walk_saddr. It stores the sctp_t being walked,
1245 * the current index to the sctp_saddrs[], and the current count of the
1246 * sctp_saddr_ipif_t list.
1247 */
1248 typedef struct {
1249 sctp_t sctp;
1250 int hash_index;
1251 int cur_cnt;
1252 } saddr_walk_t;
1253
1254 static int
sctp_walk_saddr_init(mdb_walk_state_t * wsp)1255 sctp_walk_saddr_init(mdb_walk_state_t *wsp)
1256 {
1257 sctp_t *sctp;
1258 int i;
1259 saddr_walk_t *swalker;
1260
1261 if (wsp->walk_addr == 0)
1262 return (WALK_ERR);
1263
1264 swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP);
1265 sctp = &swalker->sctp;
1266 if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) {
1267 mdb_warn("failed to read sctp at %p", wsp->walk_addr);
1268 mdb_free(swalker, sizeof (saddr_walk_t));
1269 return (WALK_ERR);
1270 }
1271
1272 /* Find the first source address. */
1273 for (i = 0; i < SCTP_IPIF_HASH; i++) {
1274 if (sctp->sctp_saddrs[i].ipif_count > 0) {
1275 list_t *addr_list;
1276
1277 addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list;
1278 wsp->walk_addr = (uintptr_t)list_object(addr_list,
1279 addr_list->list_head.list_next);
1280
1281 /* Recode the current info */
1282 swalker->hash_index = i;
1283 swalker->cur_cnt = 1;
1284 wsp->walk_data = swalker;
1285
1286 return (WALK_NEXT);
1287 }
1288 }
1289 return (WALK_DONE);
1290 }
1291
1292 static int
sctp_walk_saddr_step(mdb_walk_state_t * wsp)1293 sctp_walk_saddr_step(mdb_walk_state_t *wsp)
1294 {
1295 uintptr_t saddr_ptr = wsp->walk_addr;
1296 sctp_saddr_ipif_t saddr;
1297 saddr_walk_t *swalker;
1298 sctp_t *sctp;
1299 int status;
1300 int i, j;
1301
1302 if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) {
1303 mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr);
1304 return (WALK_ERR);
1305 }
1306 status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata);
1307 if (status != WALK_NEXT)
1308 return (status);
1309
1310 swalker = (saddr_walk_t *)wsp->walk_data;
1311 sctp = &swalker->sctp;
1312 i = swalker->hash_index;
1313 j = swalker->cur_cnt;
1314
1315 /*
1316 * If there is still a source address in the current list, return it.
1317 * Otherwise, go to the next list in the sctp_saddrs[].
1318 */
1319 if (j++ < sctp->sctp_saddrs[i].ipif_count) {
1320 wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next;
1321 swalker->cur_cnt = j;
1322 return (WALK_NEXT);
1323 } else {
1324 list_t *lst;
1325
1326 for (i = i + 1; i < SCTP_IPIF_HASH; i++) {
1327 if (sctp->sctp_saddrs[i].ipif_count > 0) {
1328 lst = &sctp->sctp_saddrs[i].sctp_ipif_list;
1329 wsp->walk_addr = (uintptr_t)list_object(
1330 lst, lst->list_head.list_next);
1331 swalker->hash_index = i;
1332 swalker->cur_cnt = 1;
1333 return (WALK_NEXT);
1334 }
1335 }
1336 }
1337 return (WALK_DONE);
1338 }
1339
1340 static void
sctp_walk_saddr_fini(mdb_walk_state_t * wsp)1341 sctp_walk_saddr_fini(mdb_walk_state_t *wsp)
1342 {
1343 saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data;
1344
1345 mdb_free(swalker, sizeof (saddr_walk_t));
1346 }
1347
1348
1349 typedef struct ill_walk_data {
1350 sctp_ill_hash_t ills[SCTP_ILL_HASH];
1351 uint32_t count;
1352 } ill_walk_data_t;
1353
1354 typedef struct ipuf_walk_data {
1355 sctp_ipif_hash_t ipifs[SCTP_IPIF_HASH];
1356 uint32_t count;
1357 } ipif_walk_data_t;
1358
1359
1360 int
sctp_ill_walk_init(mdb_walk_state_t * wsp)1361 sctp_ill_walk_init(mdb_walk_state_t *wsp)
1362 {
1363 if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1364 mdb_warn("can't walk 'sctp_stacks'");
1365 return (WALK_ERR);
1366 }
1367
1368 return (WALK_NEXT);
1369 }
1370
1371 int
sctp_ill_walk_step(mdb_walk_state_t * wsp)1372 sctp_ill_walk_step(mdb_walk_state_t *wsp)
1373 {
1374 if (mdb_pwalk("sctp_stack_walk_ill", wsp->walk_callback,
1375 wsp->walk_cbdata, wsp->walk_addr) == -1) {
1376 mdb_warn("couldn't walk 'sctp_stack_walk_ill' for addr %p",
1377 wsp->walk_addr);
1378 return (WALK_ERR);
1379 }
1380 return (WALK_NEXT);
1381 }
1382
1383 /*
1384 * wsp->walk_addr is the address of sctps_ill_list
1385 */
1386 static int
sctp_stack_ill_walk_init(mdb_walk_state_t * wsp)1387 sctp_stack_ill_walk_init(mdb_walk_state_t *wsp)
1388 {
1389 ill_walk_data_t iw;
1390 intptr_t i;
1391 uintptr_t kaddr, uaddr;
1392 size_t offset;
1393
1394 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_ills_count);
1395 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) {
1396 mdb_warn("can't read sctps_ills_count at %p", kaddr);
1397 return (WALK_ERR);
1398 }
1399 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ills);
1400
1401 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) {
1402 mdb_warn("can't read scpts_g_ills %p", kaddr);
1403 return (WALK_ERR);
1404 }
1405 if (mdb_vread(&iw.ills, sizeof (iw.ills), kaddr) == -1) {
1406 mdb_warn("failed to read 'sctps_g_ills'");
1407 return (0);
1408 }
1409
1410 /* Find the first ill. */
1411 for (i = 0; i < SCTP_ILL_HASH; i++) {
1412 if (iw.ills[i].ill_count > 0) {
1413 uaddr = (uintptr_t)&iw.ills[i].sctp_ill_list;
1414 offset = uaddr - (uintptr_t)&iw.ills;
1415 if (mdb_pwalk("list", wsp->walk_callback,
1416 wsp->walk_cbdata, kaddr+offset) == -1) {
1417 mdb_warn("couldn't walk 'list' for address %p",
1418 kaddr);
1419 return (WALK_ERR);
1420 }
1421 }
1422 }
1423 return (WALK_DONE);
1424 }
1425
1426 static int
sctp_stack_ill_walk_step(mdb_walk_state_t * wsp)1427 sctp_stack_ill_walk_step(mdb_walk_state_t *wsp)
1428 {
1429 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
1430 wsp->walk_cbdata));
1431 }
1432
1433 int
sctp_ipif_walk_init(mdb_walk_state_t * wsp)1434 sctp_ipif_walk_init(mdb_walk_state_t *wsp)
1435 {
1436 if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1437 mdb_warn("can't walk 'sctp_stacks'");
1438 return (WALK_ERR);
1439 }
1440 return (WALK_NEXT);
1441 }
1442
1443 int
sctp_ipif_walk_step(mdb_walk_state_t * wsp)1444 sctp_ipif_walk_step(mdb_walk_state_t *wsp)
1445 {
1446 if (mdb_pwalk("sctp_stack_walk_ipif", wsp->walk_callback,
1447 wsp->walk_cbdata, wsp->walk_addr) == -1) {
1448 mdb_warn("couldn't walk 'sctp_stack_walk_ipif' for addr %p",
1449 wsp->walk_addr);
1450 return (WALK_ERR);
1451 }
1452 return (WALK_NEXT);
1453 }
1454
1455 /*
1456 * wsp->walk_addr is the address of sctps_ipif_list
1457 */
1458 static int
sctp_stack_ipif_walk_init(mdb_walk_state_t * wsp)1459 sctp_stack_ipif_walk_init(mdb_walk_state_t *wsp)
1460 {
1461 ipif_walk_data_t iw;
1462 intptr_t i;
1463 uintptr_t kaddr, uaddr;
1464 size_t offset;
1465
1466 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs_count);
1467 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) {
1468 mdb_warn("can't read sctps_g_ipifs_count at %p", kaddr);
1469 return (WALK_ERR);
1470 }
1471 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs);
1472
1473 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) {
1474 mdb_warn("can't read scpts_g_ipifs %p", kaddr);
1475 return (WALK_ERR);
1476 }
1477 if (mdb_vread(&iw.ipifs, sizeof (iw.ipifs), kaddr) == -1) {
1478 mdb_warn("failed to read 'sctps_g_ipifs'");
1479 return (0);
1480 }
1481
1482 /* Find the first ipif. */
1483 for (i = 0; i < SCTP_IPIF_HASH; i++) {
1484 if (iw.ipifs[i].ipif_count > 0) {
1485 uaddr = (uintptr_t)&iw.ipifs[i].sctp_ipif_list;
1486 offset = uaddr - (uintptr_t)&iw.ipifs;
1487 if (mdb_pwalk("list", wsp->walk_callback,
1488 wsp->walk_cbdata, kaddr+offset) == -1) {
1489 mdb_warn("couldn't walk 'list' for address %p",
1490 kaddr);
1491 return (WALK_ERR);
1492 }
1493 }
1494 }
1495 return (WALK_DONE);
1496 }
1497
1498 static int
sctp_stack_ipif_walk_step(mdb_walk_state_t * wsp)1499 sctp_stack_ipif_walk_step(mdb_walk_state_t *wsp)
1500 {
1501 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
1502 wsp->walk_cbdata));
1503 }
1504
1505 /*
1506 * Initialization function for the per CPU SCTP stats counter walker of a given
1507 * SCTP stack.
1508 */
1509 int
sctps_sc_walk_init(mdb_walk_state_t * wsp)1510 sctps_sc_walk_init(mdb_walk_state_t *wsp)
1511 {
1512 sctp_stack_t sctps;
1513
1514 if (wsp->walk_addr == 0)
1515 return (WALK_ERR);
1516
1517 if (mdb_vread(&sctps, sizeof (sctps), wsp->walk_addr) == -1) {
1518 mdb_warn("failed to read sctp_stack_t at %p", wsp->walk_addr);
1519 return (WALK_ERR);
1520 }
1521 if (sctps.sctps_sc_cnt == 0)
1522 return (WALK_DONE);
1523
1524 /*
1525 * Store the sctp_stack_t pointer in walk_data. The stepping function
1526 * used it to calculate if the end of the counter has reached.
1527 */
1528 wsp->walk_data = (void *)wsp->walk_addr;
1529 wsp->walk_addr = (uintptr_t)sctps.sctps_sc;
1530 return (WALK_NEXT);
1531 }
1532
1533 /*
1534 * Stepping function for the per CPU SCTP stats counterwalker.
1535 */
1536 int
sctps_sc_walk_step(mdb_walk_state_t * wsp)1537 sctps_sc_walk_step(mdb_walk_state_t *wsp)
1538 {
1539 int status;
1540 sctp_stack_t sctps;
1541 sctp_stats_cpu_t *stats;
1542 char *next, *end;
1543
1544 if (mdb_vread(&sctps, sizeof (sctps), (uintptr_t)wsp->walk_data) ==
1545 -1) {
1546 mdb_warn("failed to read sctp_stack_t at %p", wsp->walk_addr);
1547 return (WALK_ERR);
1548 }
1549 if (mdb_vread(&stats, sizeof (stats), wsp->walk_addr) == -1) {
1550 mdb_warn("failed ot read sctp_stats_cpu_t at %p",
1551 wsp->walk_addr);
1552 return (WALK_ERR);
1553 }
1554 status = wsp->walk_callback((uintptr_t)stats, &stats, wsp->walk_cbdata);
1555 if (status != WALK_NEXT)
1556 return (status);
1557
1558 next = (char *)wsp->walk_addr + sizeof (sctp_stats_cpu_t *);
1559 end = (char *)sctps.sctps_sc + sctps.sctps_sc_cnt *
1560 sizeof (sctp_stats_cpu_t *);
1561 if (next >= end)
1562 return (WALK_DONE);
1563 wsp->walk_addr = (uintptr_t)next;
1564 return (WALK_NEXT);
1565 }
1566
1567 static void
sctp_help(void)1568 sctp_help(void)
1569 {
1570 mdb_printf("Print information for a given SCTP sctp_t\n\n");
1571 mdb_printf("Options:\n");
1572 mdb_printf("\t-a\t All the information\n");
1573 mdb_printf("\t-f\t Flags\n");
1574 mdb_printf("\t-h\t Hash Tables\n");
1575 mdb_printf("\t-o\t Outbound Data\n");
1576 mdb_printf("\t-i\t Inbound Data\n");
1577 mdb_printf("\t-m\t Miscellaneous Information\n");
1578 mdb_printf("\t-r\t RTT Tracking\n");
1579 mdb_printf("\t-S\t Stats Counters\n");
1580 mdb_printf("\t-F\t Flow Control\n");
1581 mdb_printf("\t-H\t Composite Headers\n");
1582 mdb_printf("\t-p\t PMTUD\n");
1583 mdb_printf("\t-R\t Retransmit Information\n");
1584 mdb_printf("\t-C\t Connection State\n");
1585 mdb_printf("\t-c\t Cleanup / Close\n");
1586 mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n");
1587 mdb_printf("\t-d\t Local and Peer addresses\n");
1588 mdb_printf("\t-P\t Peer addresses\n");
1589 }
1590
1591 static const mdb_dcmd_t dcmds[] = {
1592 { "sctp", ":[-afhoimrSFHpRCcedP]",
1593 "display sctp control structure", sctp, sctp_help },
1594 { "sctp_set", ":", "display a SCTP set", sctp_set },
1595 { "sctp_faddr", ":", "display a faddr", sctp_faddr },
1596 { "sctp_istr_msgs", ":", "display msg list on an instream",
1597 sctp_istr_msgs },
1598 { "sctp_mdata_chunk", ":", "display a data chunk in an mblk",
1599 sctp_mdata_chunk },
1600 { "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list },
1601 { "sctp_instr", ":", "display instr", sctp_instr },
1602 { "sctp_reass_list", ":", "display reass list", sctp_reass_list },
1603 { "sctp_uo_reass_list", ":", "display un-ordered reass list",
1604 sctp_uo_reass_list },
1605 { NULL }
1606 };
1607
1608 static const fanout_init_t listen_fanout_init = {
1609 "sctp_stack_listen_fanout", OFFSETOF(sctp_stack_t, sctps_listen_fanout),
1610 listen_size, listen_next
1611 };
1612
1613 static const fanout_init_t conn_fanout_init = {
1614 "sctp_stack_conn_fanout", OFFSETOF(sctp_stack_t, sctps_conn_fanout),
1615 conn_size, conn_next
1616 };
1617
1618 static const fanout_init_t bind_fanout_init = {
1619 "sctp_stack_bind_fanout", OFFSETOF(sctp_stack_t, sctps_bind_fanout),
1620 bind_size, bind_next
1621 };
1622
1623 static const mdb_walker_t walkers[] = {
1624 { "sctps", "walk the full chain of sctps for all stacks",
1625 sctps_walk_init, sctps_walk_step, NULL },
1626 { "sctp_listen_fanout", "walk the sctp listen fanout for all stacks",
1627 fanout_walk_init, fanout_walk_step, NULL,
1628 (void *)&listen_fanout_init },
1629 { "sctp_conn_fanout", "walk the sctp conn fanout for all stacks",
1630 fanout_walk_init, fanout_walk_step, NULL,
1631 (void *)&conn_fanout_init },
1632 { "sctp_bind_fanout", "walk the sctp bind fanout for all stacks",
1633 fanout_walk_init, fanout_walk_step, NULL,
1634 (void *)&bind_fanout_init },
1635 { "sctp_stack_listen_fanout",
1636 "walk the sctp listen fanout for one stack",
1637 fanout_stack_walk_init, fanout_stack_walk_step,
1638 fanout_stack_walk_fini,
1639 (void *)&listen_fanout_init },
1640 { "sctp_stack_conn_fanout", "walk the sctp conn fanout for one stack",
1641 fanout_stack_walk_init, fanout_stack_walk_step,
1642 fanout_stack_walk_fini,
1643 (void *)&conn_fanout_init },
1644 { "sctp_stack_bind_fanout", "walk the sctp bind fanoutfor one stack",
1645 fanout_stack_walk_init, fanout_stack_walk_step,
1646 fanout_stack_walk_fini,
1647 (void *)&bind_fanout_init },
1648 { "sctp_walk_faddr", "walk the peer address list of a given sctp_t",
1649 sctp_walk_faddr_init, sctp_walk_faddr_step, NULL },
1650 { "sctp_walk_saddr", "walk the local address list of a given sctp_t",
1651 sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini },
1652 { "sctp_walk_ill", "walk the sctp_g_ills list for all stacks",
1653 sctp_ill_walk_init, sctp_ill_walk_step, NULL },
1654 { "sctp_walk_ipif", "walk the sctp_g_ipif list for all stacks",
1655 sctp_ipif_walk_init, sctp_ipif_walk_step, NULL },
1656 { "sctp_stack_walk_ill", "walk the sctp_g_ills list for one stack",
1657 sctp_stack_ill_walk_init, sctp_stack_ill_walk_step, NULL },
1658 { "sctp_stack_walk_ipif", "walk the sctp_g_ipif list for one stack",
1659 sctp_stack_ipif_walk_init, sctp_stack_ipif_walk_step, NULL },
1660 { "sctps_sc", "walk all the per CPU stats counters of a sctp_stack_t",
1661 sctps_sc_walk_init, sctps_sc_walk_step, NULL },
1662 { NULL }
1663 };
1664
1665 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
1666
1667 const mdb_modinfo_t *
_mdb_init(void)1668 _mdb_init(void)
1669 {
1670 return (&modinfo);
1671 }
1672