xref: /titanic_50/usr/src/cmd/mdb/common/modules/sctp/sctp.c (revision e07d9cb85217949d497b02d7211de8a197d2f2eb)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/stream.h>
31 #include <sys/mdb_modapi.h>
32 #include <sys/socket.h>
33 #include <sys/list.h>
34 #include <sys/strsun.h>
35 
36 #include <mdb/mdb_stdlib.h>
37 
38 #include <netinet/in.h>
39 #include <netinet/ip6.h>
40 #include <netinet/sctp.h>
41 
42 #include <inet/common.h>
43 #include <inet/ip.h>
44 #include <inet/ip6.h>
45 #include <inet/ipclassifier.h>
46 
47 #include <sctp/sctp_impl.h>
48 #include <sctp/sctp_addr.h>
49 
50 #define	MDB_SCTP_SHOW_FLAGS	0x1
51 #define	MDB_SCTP_DUMP_ADDRS	0x2
52 #define	MDB_SCTP_SHOW_HASH	0x4
53 #define	MDB_SCTP_SHOW_OUT	0x8
54 #define	MDB_SCTP_SHOW_IN	0x10
55 #define	MDB_SCTP_SHOW_MISC	0x20
56 #define	MDB_SCTP_SHOW_RTT	0x40
57 #define	MDB_SCTP_SHOW_STATS	0x80
58 #define	MDB_SCTP_SHOW_FLOW	0x100
59 #define	MDB_SCTP_SHOW_HDR	0x200
60 #define	MDB_SCTP_SHOW_PMTUD	0x400
61 #define	MDB_SCTP_SHOW_RXT	0x800
62 #define	MDB_SCTP_SHOW_CONN	0x1000
63 #define	MDB_SCTP_SHOW_CLOSE	0x2000
64 #define	MDB_SCTP_SHOW_EXT	0x4000
65 
66 #define	MDB_SCTP_SHOW_ALL	0xffffffff
67 
68 /*
69  * Copy from usr/src/uts/common/os/list.c.  Should we have a generic
70  * mdb list walker?
71  */
72 #define	list_object(a, node) ((void *)(((char *)node) - (a)->list_offset))
73 
74 static int
75 ns_to_stackid(uintptr_t kaddr)
76 {
77 	netstack_t nss;
78 
79 	if (mdb_vread(&nss, sizeof (nss), kaddr) == -1) {
80 		mdb_warn("failed to read netdstack info %p", kaddr);
81 		return (0);
82 	}
83 	return (nss.netstack_stackid);
84 }
85 
86 int
87 sctp_stacks_walk_init(mdb_walk_state_t *wsp)
88 {
89 	if (mdb_layered_walk("netstack", wsp) == -1) {
90 		mdb_warn("can't walk 'netstack'");
91 		return (WALK_ERR);
92 	}
93 	return (WALK_NEXT);
94 }
95 
96 int
97 sctp_stacks_walk_step(mdb_walk_state_t *wsp)
98 {
99 	uintptr_t kaddr;
100 	netstack_t nss;
101 
102 	if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) {
103 		mdb_warn("can't read netstack at %p", wsp->walk_addr);
104 		return (WALK_ERR);
105 	}
106 	kaddr = (uintptr_t)nss.netstack_modules[NS_SCTP];
107 	return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata));
108 }
109 
110 static char *
111 sctp_faddr_state(int state)
112 {
113 	char *statestr;
114 
115 	switch (state) {
116 	case SCTP_FADDRS_UNREACH:
117 		statestr = "Unreachable";
118 		break;
119 	case SCTP_FADDRS_DOWN:
120 		statestr = "Down";
121 		break;
122 	case SCTP_FADDRS_ALIVE:
123 		statestr = "Alive";
124 		break;
125 	case SCTP_FADDRS_UNCONFIRMED:
126 		statestr = "Unconfirmed";
127 		break;
128 	default:
129 		statestr = "Unknown";
130 		break;
131 	}
132 	return (statestr);
133 }
134 
135 /* ARGSUSED */
136 static int
137 sctp_faddr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
138 {
139 	sctp_faddr_t fa[1];
140 	char *statestr;
141 
142 	if (!(flags & DCMD_ADDRSPEC))
143 		return (DCMD_USAGE);
144 
145 	if (mdb_vread(fa, sizeof (*fa), addr) == -1) {
146 		mdb_warn("cannot read fadder at %p", addr);
147 		return (DCMD_ERR);
148 	}
149 
150 	statestr = sctp_faddr_state(fa->state);
151 	mdb_printf("%<u>%p\t%<b>%N%</b>\t%s%</u>\n", addr, &fa->faddr,
152 	    statestr);
153 	mdb_printf("next\t\t%?p\tsaddr\t%N\n", fa->next, &fa->saddr);
154 	mdb_printf("rto\t\t%?d\tsrtt\t\t%?d\n", fa->rto, fa->srtt);
155 	mdb_printf("rttvar\t\t%?d\trtt_updates\t%?u\n", fa->rttvar,
156 	    fa->rtt_updates);
157 	mdb_printf("strikes\t\t%?d\tmax_retr\t%?d\n", fa->strikes,
158 	    fa->max_retr);
159 	mdb_printf("hb_expiry\t%?ld\thb_interval\t%?u\n", fa->hb_expiry,
160 	    fa->hb_interval);
161 	mdb_printf("pmss\t\t%?u\tcwnd\t\t%?u\n", fa->sfa_pmss, fa->cwnd);
162 	mdb_printf("ssthresh\t%?u\tsuna\t\t%?u\n", fa->ssthresh, fa->suna);
163 	mdb_printf("pba\t\t%?u\tacked\t\t%?u\n", fa->pba, fa->acked);
164 	mdb_printf("lastactive\t%?ld\thb_secret\t%?#lx\n", fa->lastactive,
165 	    fa->hb_secret);
166 	mdb_printf("rxt_unacked\t\t%?u\n", fa->rxt_unacked);
167 	mdb_printf("timer_mp\t%?p\tire\t\t%?p\n", fa->timer_mp, fa->ire);
168 	mdb_printf("hb_pending\t%?d\ttimer_running\t%?d\n"
169 	    "df\t\t%?d\tpmtu_discovered\t%?d\n"
170 	    "isv4\t\t%?d\tretransmissions\t%?u\n",
171 	    fa->hb_pending, fa->timer_running, fa->df, fa->pmtu_discovered,
172 	    fa->isv4, fa->T3expire);
173 
174 	return (DCMD_OK);
175 }
176 
177 static void
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
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
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
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
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
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
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
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
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
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 != NULL);
424 
425 		addr = (uintptr_t)istrmp.b_next;
426 	} while (addr != NULL);
427 
428 	return (DCMD_OK);
429 }
430 
431 /* ARGSUSED */
432 static int
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.ssn, srp.needed,
459 		    srp.got, srp.tail, srp.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 != NULL);
480 
481 		addr = (uintptr_t)srpmp.b_next;
482 	} while (addr != NULL);
483 
484 	return (DCMD_OK);
485 }
486 
487 /* ARGSUSED */
488 static int
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 != NULL);
522 
523 	return (DCMD_OK);
524 }
525 
526 static int
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 *
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
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_debug);
569 	mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend);
570 	mdb_printf("\tdgram_errind\t\t%d\n", sctp->sctp_dgram_errind);
571 
572 	mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_linger);
573 	if (sctp->sctp_lingering)
574 		return;
575 	mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering);
576 	mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback);
577 	mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack);
578 
579 	mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running);
580 	mdb_printf("\trecvdstaddr\t\t%d\n", sctp->sctp_recvdstaddr);
581 	mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum);
582 	mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip);
583 
584 	mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all);
585 	mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep);
586 	mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached);
587 	mdb_printf("\tsend_adaption\t\t%d\n", sctp->sctp_send_adaption);
588 
589 	mdb_printf("\trecv_adaption\t\t%d\n", sctp->sctp_recv_adaption);
590 	mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay);
591 	mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned);
592 	mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit);
593 
594 	mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware);
595 	mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal);
596 	mdb_printf("\trexmitting\t\t%d\n", sctp->sctp_rexmitting);
597 	mdb_printf("\tzero_win_probe\t\t%d\n", sctp->sctp_zero_win_probe);
598 
599 	mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo);
600 	mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt);
601 	mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt);
602 	mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt);
603 
604 	mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr);
605 	mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt);
606 	mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt);
607 	mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt);
608 }
609 
610 /*
611  * Given a sctp_saddr_ipif_t, print out its address.  This assumes
612  * that addr contains the sctp_addr_ipif_t structure already and this
613  * function does not need to read it in.
614  */
615 /* ARGSUSED */
616 static int
617 print_saddr(uintptr_t ptr, const void *addr, void *cbdata)
618 {
619 	sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr;
620 	sctp_ipif_t ipif;
621 	char *statestr;
622 
623 	/* Read in the sctp_ipif object */
624 	if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) ==
625 	    -1) {
626 		mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp);
627 		return (WALK_ERR);
628 	}
629 
630 	switch (ipif.sctp_ipif_state) {
631 	case SCTP_IPIFS_CONDEMNED:
632 		statestr = "Condemned";
633 		break;
634 	case SCTP_IPIFS_INVALID:
635 		statestr = "Invalid";
636 		break;
637 	case SCTP_IPIFS_DOWN:
638 		statestr = "Down";
639 		break;
640 	case SCTP_IPIFS_UP:
641 		statestr = "Up";
642 		break;
643 	default:
644 		statestr = "Unknown";
645 		break;
646 	}
647 	mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr,
648 	    statestr);
649 	if (saddr->saddr_ipif_dontsrc == 1)
650 		mdb_printf("/Dontsrc");
651 	if (saddr->saddr_ipif_unconfirmed == 1)
652 		mdb_printf("/Unconfirmed");
653 	if (saddr->saddr_ipif_delete_pending == 1)
654 		mdb_printf("/DeletePending");
655 	mdb_printf(")\n");
656 	mdb_printf("\t\t\tMTU %d id %d zoneid %d IPIF flags %x\n",
657 	    ipif.sctp_ipif_mtu, ipif.sctp_ipif_id,
658 	    ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags);
659 	return (WALK_NEXT);
660 }
661 
662 /*
663  * Given a sctp_faddr_t, print out its address.  This assumes that
664  * addr contains the sctp_faddr_t structure already and this function
665  * does not need to read it in.
666  */
667 static int
668 print_faddr(uintptr_t ptr, const void *addr, void *cbdata)
669 {
670 	char	*statestr;
671 	sctp_faddr_t *faddr = (sctp_faddr_t *)addr;
672 	int *i = cbdata;
673 
674 	statestr = sctp_faddr_state(faddr->state);
675 
676 	mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->faddr, ptr,
677 	    statestr);
678 	return (WALK_NEXT);
679 }
680 
681 int
682 sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
683 {
684 	sctp_t sctp;
685 	conn_t connp;
686 	int i;
687 	uint_t opts = 0;
688 	uint_t paddr = 0;
689 	in_port_t lport, fport;
690 
691 	if (!(flags & DCMD_ADDRSPEC))
692 		return (DCMD_USAGE);
693 
694 	if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) {
695 		mdb_warn("failed to read sctp_t at: %p\n", addr);
696 		return (DCMD_ERR);
697 	}
698 	if (mdb_vread(&connp, sizeof (connp),
699 	    (uintptr_t)sctp.sctp_connp) == -1) {
700 		mdb_warn("failed to read conn_t at: %p\n", sctp.sctp_connp);
701 		return (DCMD_ERR);
702 	}
703 
704 	if (mdb_getopts(argc, argv,
705 		'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts,
706 		'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts,
707 		'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts,
708 		'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts,
709 		'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts,
710 		'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts,
711 		'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts,
712 		'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts,
713 		'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts,
714 		'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts,
715 		'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts,
716 		'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts,
717 		'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts,
718 		'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts,
719 		'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts,
720 		'P', MDB_OPT_SETBITS, 1, &paddr,
721 		'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) {
722 		return (DCMD_USAGE);
723 	}
724 
725 	/* non-verbose faddrs, suitable for pipelines to sctp_faddr */
726 	if (paddr != 0) {
727 		sctp_faddr_t faddr, *fp;
728 		for (fp = sctp.sctp_faddrs; fp != NULL; fp = faddr.next) {
729 			if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp)
730 			    == -1) {
731 				mdb_warn("failed to read faddr at %p",
732 				    fp);
733 				return (DCMD_ERR);
734 			}
735 			mdb_printf("%p\n", fp);
736 		}
737 		return (DCMD_OK);
738 	}
739 
740 	mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport));
741 	mdb_nhconvert(&fport, &sctp.sctp_fport, sizeof (fport));
742 	mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% STACK=%d ZONE=%d%</u>", addr,
743 	    state2str(&sctp), lport, fport,
744 	    ns_to_stackid((uintptr_t)connp.conn_netstack), connp.conn_zoneid);
745 
746 	if (sctp.sctp_faddrs) {
747 		sctp_faddr_t faddr;
748 		if (mdb_vread(&faddr, sizeof (faddr),
749 		    (uintptr_t)sctp.sctp_faddrs) != -1)
750 			mdb_printf("%<u> %N%</u>", &faddr.faddr);
751 	}
752 	mdb_printf("\n");
753 
754 	if (opts & MDB_SCTP_DUMP_ADDRS) {
755 		mdb_printf("%<b>Local and Peer Addresses%</b>\n");
756 
757 		/* Display source addresses */
758 		mdb_printf("nsaddrs\t\t%?d\n", sctp.sctp_nsaddrs);
759 		(void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr);
760 
761 		/* Display peer addresses */
762 		mdb_printf("nfaddrs\t\t%?d\n", sctp.sctp_nfaddrs);
763 		i = 1;
764 		(void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr);
765 
766 		mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n",
767 		    sctp.sctp_lastfaddr, sctp.sctp_primary);
768 		mdb_printf("current\t\t%?p\tlastdata\t%?p\n",
769 		    sctp.sctp_current, sctp.sctp_lastdata);
770 	}
771 
772 	if (opts & MDB_SCTP_SHOW_OUT) {
773 		mdb_printf("%<b>Outbound Data%</b>\n");
774 		mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n",
775 		    sctp.sctp_xmit_head, sctp.sctp_xmit_tail);
776 		mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n",
777 		    sctp.sctp_xmit_unsent, sctp.sctp_xmit_unsent_tail);
778 		mdb_printf("xmit_unacked\t%?p\n", sctp.sctp_xmit_unacked);
779 		mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n",
780 		    sctp.sctp_unacked, sctp.sctp_unsent);
781 		mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n",
782 		    sctp.sctp_ltsn, sctp.sctp_lastack_rxd);
783 		mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n",
784 		    sctp.sctp_recovery_tsn, sctp.sctp_adv_pap);
785 		mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n",
786 		    sctp.sctp_num_ostr, sctp.sctp_ostrcntrs);
787 
788 		mdb_printf("%<b>Default Send Parameters%</b>\n");
789 		mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n",
790 		    sctp.sctp_def_stream, sctp.sctp_def_flags);
791 		mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n",
792 		    sctp.sctp_def_ppid, sctp.sctp_def_context);
793 		mdb_printf("def_timetolive\t%?u\n",
794 		    sctp.sctp_def_timetolive);
795 	}
796 
797 	if (opts & MDB_SCTP_SHOW_IN) {
798 		mdb_printf("%<b>Inbound Data%</b>\n");
799 		mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n",
800 		    sctp.sctp_sack_info, sctp.sctp_sack_gaps);
801 		dump_sack_info((uintptr_t)sctp.sctp_sack_info);
802 		mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n",
803 		    sctp.sctp_ftsn, sctp.sctp_lastacked);
804 		mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n",
805 		    sctp.sctp_istr_nmsgs, sctp.sctp_sack_toggle);
806 		mdb_printf("ack_mp\t\t%?p\n", sctp.sctp_ack_mp);
807 		mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n",
808 		    sctp.sctp_num_istr, sctp.sctp_instr);
809 		mdb_printf("unord_reass\t%?p\n", sctp.sctp_uo_frags);
810 	}
811 
812 	if (opts & MDB_SCTP_SHOW_RTT) {
813 		mdb_printf("%<b>RTT Tracking%</b>\n");
814 		mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n",
815 		    sctp.sctp_rtt_tsn, sctp.sctp_out_time);
816 	}
817 
818 	if (opts & MDB_SCTP_SHOW_FLOW) {
819 		mdb_printf("%<b>Flow Control%</b>\n");
820 		mdb_printf("txmit_hiwater\t%?d\n"
821 		    "xmit_lowater\t%?d\tfrwnd\t\t%?u\n"
822 		    "rwnd\t\t%?u\tinitial rwnd\t%?u\n"
823 		    "rxqueued\t%?u\tcwnd_max\t%?u\n", sctp.sctp_xmit_hiwater,
824 		    sctp.sctp_xmit_lowater, sctp.sctp_frwnd,
825 		    sctp.sctp_rwnd, sctp.sctp_irwnd, sctp.sctp_rxqueued,
826 		    sctp.sctp_cwnd_max);
827 	}
828 
829 	if (opts & MDB_SCTP_SHOW_HDR) {
830 		mdb_printf("%<b>Composite Headers%</b>\n");
831 		mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n"
832 		    "iphc_len\t%?d\tiphc6_len\t%?d\n"
833 		    "hdr_len\t\t%?d\thdr6_len\t%?d\n"
834 		    "ipha\t\t%?p\tip6h\t\t%?p\n"
835 		    "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n"
836 		    "sctph\t\t%?p\tsctph6\t\t%?p\n"
837 		    "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp.sctp_iphc,
838 		    sctp.sctp_iphc6, sctp.sctp_iphc_len,
839 		    sctp.sctp_iphc6_len, sctp.sctp_hdr_len,
840 		    sctp.sctp_hdr6_len, sctp.sctp_ipha, sctp.sctp_ip6h,
841 		    sctp.sctp_ip_hdr_len, sctp.sctp_ip_hdr6_len,
842 		    sctp.sctp_sctph, sctp.sctp_sctph6, sctp.sctp_lvtag,
843 		    sctp.sctp_fvtag);
844 	}
845 
846 	if (opts & MDB_SCTP_SHOW_PMTUD) {
847 		mdb_printf("%<b>PMTUd%</b>\n");
848 		mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n"
849 		    "mss\t\t%?u\n",
850 		    sctp.sctp_last_mtu_probe, sctp.sctp_mtu_probe_intvl,
851 		    sctp.sctp_mss);
852 	}
853 
854 	if (opts & MDB_SCTP_SHOW_RXT) {
855 		mdb_printf("%<b>Retransmit Info%</b>\n");
856 		mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n"
857 		    "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n"
858 		    "pp_max_rxt\t%?d\trto_max\t\t%?u\n"
859 		    "rto_min\t\t%?u\trto_initial\t%?u\n"
860 		    "init_rto_max\t%?u\n"
861 		    "rxt_nxttsn\t%?u\trxt_maxtsn\t%?u\n", sctp.sctp_cookie_mp,
862 		    sctp.sctp_strikes, sctp.sctp_max_init_rxt,
863 		    sctp.sctp_pa_max_rxt, sctp.sctp_pp_max_rxt,
864 		    sctp.sctp_rto_max, sctp.sctp_rto_min,
865 		    sctp.sctp_rto_initial, sctp.sctp_init_rto_max,
866 		    sctp.sctp_rxt_nxttsn, sctp.sctp_rxt_maxtsn);
867 	}
868 
869 	if (opts & MDB_SCTP_SHOW_CONN) {
870 		mdb_printf("%<b>Connection State%</b>\n");
871 		mdb_printf("last_secret_update%?ld\n",
872 		    sctp.sctp_last_secret_update);
873 
874 		mdb_printf("secret\t\t");
875 		for (i = 0; i < SCTP_SECRET_LEN; i++) {
876 			if (i % 2 == 0)
877 				mdb_printf("0x%02x", sctp.sctp_secret[i]);
878 			else
879 				mdb_printf("%02x ", sctp.sctp_secret[i]);
880 		}
881 		mdb_printf("\n");
882 		mdb_printf("old_secret\t");
883 		for (i = 0; i < SCTP_SECRET_LEN; i++) {
884 			if (i % 2 == 0)
885 				mdb_printf("0x%02x", sctp.sctp_old_secret[i]);
886 			else
887 				mdb_printf("%02x ", sctp.sctp_old_secret[i]);
888 		}
889 		mdb_printf("\n");
890 	}
891 
892 	if (opts & MDB_SCTP_SHOW_STATS) {
893 		mdb_printf("%<b>Stats Counters%</b>\n");
894 		mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n"
895 		    "odchunks\t%?llu\toudchunks\t%?llu\n"
896 		    "rxtchunks\t%?llu\tT1expire\t%?lu\n"
897 		    "T2expire\t%?lu\tT3expire\t%?lu\n"
898 		    "msgcount\t%?llu\tprsctpdrop\t%?llu\n"
899 		    "AssocStartTime\t%?lu\n",
900 		    sctp.sctp_opkts, sctp.sctp_obchunks,
901 		    sctp.sctp_odchunks, sctp.sctp_oudchunks,
902 		    sctp.sctp_rxtchunks, sctp.sctp_T1expire,
903 		    sctp.sctp_T2expire, sctp.sctp_T3expire,
904 		    sctp.sctp_msgcount, sctp.sctp_prsctpdrop,
905 		    sctp.sctp_assoc_start_time);
906 		mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n"
907 		    "idchunks\t%?llu\tiudchunks\t%?llu\n"
908 		    "fragdmsgs\t%?llu\treassmsgs\t%?llu\n",
909 		    sctp.sctp_ipkts, sctp.sctp_ibchunks,
910 		    sctp.sctp_idchunks, sctp.sctp_iudchunks,
911 		    sctp.sctp_fragdmsgs, sctp.sctp_reassmsgs);
912 	}
913 
914 	if (opts & MDB_SCTP_SHOW_HASH) {
915 		mdb_printf("%<b>Hash Tables%</b>\n");
916 		mdb_printf("conn_hash_next\t%?p\t", sctp.sctp_conn_hash_next);
917 		mdb_printf("conn_hash_prev\t%?p\n", sctp.sctp_conn_hash_prev);
918 
919 		mdb_printf("listen_hash_next%?p\t",
920 		    sctp.sctp_listen_hash_next);
921 		mdb_printf("listen_hash_prev%?p\n",
922 		    sctp.sctp_listen_hash_prev);
923 		mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport));
924 		mdb_printf("[ listen_hash bucket\t%?d ]\n",
925 		    SCTP_LISTEN_HASH(lport));
926 
927 		mdb_printf("conn_tfp\t%?p\t", sctp.sctp_conn_tfp);
928 		mdb_printf("listen_tfp\t%?p\n", sctp.sctp_listen_tfp);
929 
930 		mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n",
931 		    sctp.sctp_bind_hash, sctp.sctp_ptpbhn);
932 		mdb_printf("bind_lockp\t%?p\n",
933 		    sctp.sctp_bind_lockp);
934 		mdb_printf("[ bind_hash bucket\t%?d ]\n",
935 		    SCTP_BIND_HASH(lport));
936 	}
937 
938 	if (opts & MDB_SCTP_SHOW_CLOSE) {
939 		mdb_printf("%<b>Cleanup / Close%</b>\n");
940 		mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n"
941 		    "lingertime\t%?d\trefcnt\t\t%?hu\n",
942 		    sctp.sctp_shutdown_faddr, sctp.sctp_client_errno,
943 		    sctp.sctp_lingertime, sctp.sctp_refcnt);
944 	}
945 
946 	if (opts & MDB_SCTP_SHOW_MISC) {
947 		mdb_printf("%<b>Miscellaneous%</b>\n");
948 		mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n"
949 		    "family\t\t%?u\tipversion\t%?hu\n"
950 		    "hb_interval\t%?u\tautoclose\t%?d\n"
951 		    "active\t\t%?ld\ttx_adaption_code%?x\n"
952 		    "rx_adaption_code%?x\ttimer_mp\t%?p\n"
953 		    "partial_delivery_point\t%?d\n",
954 		    sctp.sctp_bound_if, sctp.sctp_heartbeat_mp,
955 		    sctp.sctp_family, sctp.sctp_ipversion,
956 		    sctp.sctp_hb_interval, sctp.sctp_autoclose,
957 		    sctp.sctp_active, sctp.sctp_tx_adaption_code,
958 		    sctp.sctp_rx_adaption_code, sctp.sctp_timer_mp,
959 		    sctp.sctp_pd_point);
960 	}
961 
962 	if (opts & MDB_SCTP_SHOW_EXT) {
963 		mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n");
964 		mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n"
965 		    "fcsn\t\t%?x\n", sctp.sctp_cxmit_list, sctp.sctp_lcsn,
966 		    sctp.sctp_fcsn);
967 	}
968 
969 	if (opts & MDB_SCTP_SHOW_FLAGS) {
970 		mdb_printf("%<b>Flags%</b>\n");
971 		show_sctp_flags(&sctp);
972 	}
973 
974 	return (DCMD_OK);
975 }
976 
977 typedef struct fanout_walk_data {
978 	int index;
979 	int size;
980 	uintptr_t sctp;
981 	sctp_tf_t *fanout;
982 	uintptr_t (*getnext)(sctp_t *);
983 } fanout_walk_data_t;
984 
985 typedef struct fanout_init {
986 	const char *nested_walker_name;
987 	size_t offset;	/* for what used to be a symbol */
988 	int (*getsize)(sctp_stack_t *);
989 	uintptr_t (*getnext)(sctp_t *);
990 } fanout_init_t;
991 
992 static uintptr_t
993 listen_next(sctp_t *sctp)
994 {
995 	return ((uintptr_t)sctp->sctp_listen_hash_next);
996 }
997 
998 /* ARGSUSED */
999 static int
1000 listen_size(sctp_stack_t *sctps)
1001 {
1002 	return (SCTP_LISTEN_FANOUT_SIZE);
1003 }
1004 
1005 static uintptr_t
1006 conn_next(sctp_t *sctp)
1007 {
1008 	return ((uintptr_t)sctp->sctp_conn_hash_next);
1009 }
1010 
1011 static int
1012 conn_size(sctp_stack_t *sctps)
1013 {
1014 	int size;
1015 	uintptr_t kaddr;
1016 
1017 	kaddr = (uintptr_t)&sctps->sctps_conn_hash_size;
1018 
1019 	if (mdb_vread(&size, sizeof (size), kaddr) == -1) {
1020 		mdb_warn("can't read 'sctps_conn_hash_size' at %p", kaddr);
1021 		return (1);
1022 	}
1023 	return (size);
1024 }
1025 
1026 static uintptr_t
1027 bind_next(sctp_t *sctp)
1028 {
1029 	return ((uintptr_t)sctp->sctp_bind_hash);
1030 }
1031 
1032 /* ARGSUSED */
1033 static int
1034 bind_size(sctp_stack_t *sctps)
1035 {
1036 	return (SCTP_BIND_FANOUT_SIZE);
1037 }
1038 
1039 static intptr_t
1040 find_next_hash_item(fanout_walk_data_t *fw)
1041 {
1042 	sctp_tf_t tf;
1043 	sctp_t sctp;
1044 
1045 	/* first try to continue down the hash chain */
1046 	if (fw->sctp != NULL) {
1047 		/* try to get next in hash chain */
1048 		if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) {
1049 			mdb_warn("failed to read sctp at %p", fw->sctp);
1050 			return (NULL);
1051 		}
1052 		fw->sctp = fw->getnext(&sctp);
1053 		if (fw->sctp != NULL)
1054 			return (fw->sctp);
1055 		else
1056 			/* end of chain; go to next bucket */
1057 			fw->index++;
1058 	}
1059 
1060 	/* find a new hash chain, traversing the buckets */
1061 	for (; fw->index < fw->size; fw->index++) {
1062 		/* read the current hash line for an sctp */
1063 		if (mdb_vread(&tf, sizeof (tf),
1064 			(uintptr_t)(fw->fanout + fw->index)) == -1) {
1065 			mdb_warn("failed to read tf at %p",
1066 			    fw->fanout + fw->index);
1067 			return (NULL);
1068 		}
1069 		if (tf.tf_sctp != NULL) {
1070 			/* start of a new chain */
1071 			fw->sctp = (uintptr_t)tf.tf_sctp;
1072 			return (fw->sctp);
1073 		}
1074 	}
1075 	return (NULL);
1076 }
1077 
1078 static int
1079 fanout_stack_walk_init(mdb_walk_state_t *wsp)
1080 {
1081 	fanout_walk_data_t *lw;
1082 	fanout_init_t *fi = wsp->walk_arg;
1083 	sctp_stack_t *sctps = (sctp_stack_t *)wsp->walk_addr;
1084 	uintptr_t kaddr;
1085 
1086 	if (mdb_vread(&kaddr, sizeof (kaddr),
1087 	    wsp->walk_addr + fi->offset) == -1) {
1088 		mdb_warn("can't read sctp fanout at %p",
1089 		    wsp->walk_addr + fi->offset);
1090 		return (WALK_ERR);
1091 	}
1092 
1093 	lw = mdb_alloc(sizeof (*lw), UM_SLEEP);
1094 	lw->index = 0;
1095 	lw->size = fi->getsize(sctps);
1096 	lw->sctp = NULL;
1097 	lw->fanout = (sctp_tf_t *)kaddr;
1098 	lw->getnext = fi->getnext;
1099 
1100 	if ((wsp->walk_addr = find_next_hash_item(lw)) == NULL) {
1101 		return (WALK_DONE);
1102 	}
1103 	wsp->walk_data = lw;
1104 	return (WALK_NEXT);
1105 }
1106 
1107 static int
1108 fanout_stack_walk_step(mdb_walk_state_t *wsp)
1109 {
1110 	fanout_walk_data_t *fw = wsp->walk_data;
1111 	uintptr_t addr = wsp->walk_addr;
1112 	sctp_t sctp;
1113 	int status;
1114 
1115 	if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) {
1116 		mdb_warn("failed to read sctp at %p", addr);
1117 		return (WALK_DONE);
1118 	}
1119 
1120 	status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata);
1121 	if (status != WALK_NEXT)
1122 		return (status);
1123 
1124 	if ((wsp->walk_addr = find_next_hash_item(fw)) == NULL)
1125 		return (WALK_DONE);
1126 
1127 	return (WALK_NEXT);
1128 }
1129 
1130 static void
1131 fanout_stack_walk_fini(mdb_walk_state_t *wsp)
1132 {
1133 	fanout_walk_data_t *fw = wsp->walk_data;
1134 
1135 	mdb_free(fw, sizeof (*fw));
1136 }
1137 
1138 int
1139 fanout_walk_init(mdb_walk_state_t *wsp)
1140 {
1141 	if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1142 		mdb_warn("can't walk 'sctp_stacks'");
1143 		return (WALK_ERR);
1144 	}
1145 
1146 	return (WALK_NEXT);
1147 }
1148 
1149 int
1150 fanout_walk_step(mdb_walk_state_t *wsp)
1151 {
1152 	fanout_init_t *fi = wsp->walk_arg;
1153 
1154 	if (mdb_pwalk(fi->nested_walker_name, wsp->walk_callback,
1155 		wsp->walk_cbdata, wsp->walk_addr) == -1) {
1156 		mdb_warn("couldn't walk '%s'for address %p",
1157 		    fi->nested_walker_name, wsp->walk_addr);
1158 		return (WALK_ERR);
1159 	}
1160 	return (WALK_NEXT);
1161 }
1162 
1163 int
1164 sctps_walk_init(mdb_walk_state_t *wsp)
1165 {
1166 
1167 	if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1168 		mdb_warn("can't walk 'sctp_stacks'");
1169 		return (WALK_ERR);
1170 	}
1171 
1172 	return (WALK_NEXT);
1173 }
1174 
1175 int
1176 sctps_walk_step(mdb_walk_state_t *wsp)
1177 {
1178 	uintptr_t kaddr;
1179 
1180 	kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_list);
1181 	if (mdb_pwalk("list", wsp->walk_callback,
1182 		wsp->walk_cbdata, kaddr) == -1) {
1183 		mdb_warn("couldn't walk 'list' for address %p", kaddr);
1184 		return (WALK_ERR);
1185 	}
1186 	return (WALK_NEXT);
1187 }
1188 
1189 static int
1190 sctp_walk_faddr_init(mdb_walk_state_t *wsp)
1191 {
1192 	sctp_t sctp;
1193 
1194 	if (wsp->walk_addr == NULL)
1195 		return (WALK_ERR);
1196 
1197 	if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) {
1198 		mdb_warn("failed to read sctp at %p", wsp->walk_addr);
1199 		return (WALK_ERR);
1200 	}
1201 	if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != NULL)
1202 		return (WALK_NEXT);
1203 	else
1204 		return (WALK_DONE);
1205 }
1206 
1207 static int
1208 sctp_walk_faddr_step(mdb_walk_state_t *wsp)
1209 {
1210 	uintptr_t faddr_ptr = wsp->walk_addr;
1211 	sctp_faddr_t sctp_faddr;
1212 	int status;
1213 
1214 	if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) {
1215 		mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr);
1216 		return (WALK_ERR);
1217 	}
1218 	status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata);
1219 	if (status != WALK_NEXT)
1220 		return (status);
1221 	if ((faddr_ptr = (uintptr_t)sctp_faddr.next) == NULL) {
1222 		return (WALK_DONE);
1223 	} else {
1224 		wsp->walk_addr = faddr_ptr;
1225 		return (WALK_NEXT);
1226 	}
1227 }
1228 
1229 /*
1230  * Helper structure for sctp_walk_saddr.  It stores the sctp_t being walked,
1231  * the current index to the sctp_saddrs[], and the current count of the
1232  * sctp_saddr_ipif_t list.
1233  */
1234 typedef struct {
1235 	sctp_t	sctp;
1236 	int	hash_index;
1237 	int	cur_cnt;
1238 } saddr_walk_t;
1239 
1240 static int
1241 sctp_walk_saddr_init(mdb_walk_state_t *wsp)
1242 {
1243 	sctp_t *sctp;
1244 	int i;
1245 	saddr_walk_t *swalker;
1246 
1247 	if (wsp->walk_addr == NULL)
1248 		return (WALK_ERR);
1249 
1250 	swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP);
1251 	sctp = &swalker->sctp;
1252 	if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) {
1253 		mdb_warn("failed to read sctp at %p", wsp->walk_addr);
1254 		mdb_free(swalker, sizeof (saddr_walk_t));
1255 		return (WALK_ERR);
1256 	}
1257 
1258 	/* Find the first source address. */
1259 	for (i = 0; i < SCTP_IPIF_HASH; i++) {
1260 		if (sctp->sctp_saddrs[i].ipif_count > 0) {
1261 			list_t *addr_list;
1262 
1263 			addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list;
1264 			wsp->walk_addr = (uintptr_t)list_object(addr_list,
1265 			    addr_list->list_head.list_next);
1266 
1267 			/* Recode the current info */
1268 			swalker->hash_index = i;
1269 			swalker->cur_cnt = 1;
1270 			wsp->walk_data = swalker;
1271 
1272 			return (WALK_NEXT);
1273 		}
1274 	}
1275 	return (WALK_DONE);
1276 }
1277 
1278 static int
1279 sctp_walk_saddr_step(mdb_walk_state_t *wsp)
1280 {
1281 	uintptr_t saddr_ptr = wsp->walk_addr;
1282 	sctp_saddr_ipif_t saddr;
1283 	saddr_walk_t *swalker;
1284 	sctp_t *sctp;
1285 	int status;
1286 	int i, j;
1287 
1288 	if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) {
1289 		mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr);
1290 		return (WALK_ERR);
1291 	}
1292 	status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata);
1293 	if (status != WALK_NEXT)
1294 		return (status);
1295 
1296 	swalker = (saddr_walk_t *)wsp->walk_data;
1297 	sctp = &swalker->sctp;
1298 	i = swalker->hash_index;
1299 	j = swalker->cur_cnt;
1300 
1301 	/*
1302 	 * If there is still a source address in the current list, return it.
1303 	 * Otherwise, go to the next list in the sctp_saddrs[].
1304 	 */
1305 	if (j++ < sctp->sctp_saddrs[i].ipif_count) {
1306 		wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next;
1307 		swalker->cur_cnt = j;
1308 		return (WALK_NEXT);
1309 	} else {
1310 		list_t *lst;
1311 
1312 		for (i = i + 1; i < SCTP_IPIF_HASH; i++) {
1313 			if (sctp->sctp_saddrs[i].ipif_count > 0) {
1314 				lst = &sctp->sctp_saddrs[i].sctp_ipif_list;
1315 				wsp->walk_addr = (uintptr_t)list_object(
1316 				    lst, lst->list_head.list_next);
1317 				swalker->hash_index = i;
1318 				swalker->cur_cnt = 1;
1319 				return (WALK_NEXT);
1320 			}
1321 		}
1322 	}
1323 	return (WALK_DONE);
1324 }
1325 
1326 static void
1327 sctp_walk_saddr_fini(mdb_walk_state_t *wsp)
1328 {
1329 	saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data;
1330 
1331 	mdb_free(swalker, sizeof (saddr_walk_t));
1332 }
1333 
1334 
1335 typedef struct ill_walk_data {
1336 	sctp_ill_hash_t ills[SCTP_ILL_HASH];
1337 	uint32_t	count;
1338 } ill_walk_data_t;
1339 
1340 typedef struct ipuf_walk_data {
1341 	sctp_ipif_hash_t ipifs[SCTP_IPIF_HASH];
1342 	uint32_t	count;
1343 } ipif_walk_data_t;
1344 
1345 
1346 int
1347 sctp_ill_walk_init(mdb_walk_state_t *wsp)
1348 {
1349 	if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1350 		mdb_warn("can't walk 'sctp_stacks'");
1351 		return (WALK_ERR);
1352 	}
1353 
1354 	return (WALK_NEXT);
1355 }
1356 
1357 int
1358 sctp_ill_walk_step(mdb_walk_state_t *wsp)
1359 {
1360 	if (mdb_pwalk("sctp_stack_walk_ill", wsp->walk_callback,
1361 		wsp->walk_cbdata, wsp->walk_addr) == -1) {
1362 		mdb_warn("couldn't walk 'sctp_stack_walk_ill' for addr %p",
1363 		    wsp->walk_addr);
1364 		return (WALK_ERR);
1365 	}
1366 	return (WALK_NEXT);
1367 }
1368 
1369 /*
1370  * wsp->walk_addr is the address of sctps_ill_list
1371  */
1372 static int
1373 sctp_stack_ill_walk_init(mdb_walk_state_t *wsp)
1374 {
1375 	ill_walk_data_t iw;
1376 	intptr_t i;
1377 	uintptr_t kaddr, uaddr;
1378 	size_t offset;
1379 
1380 	kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_ills_count);
1381 	if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) {
1382 		mdb_warn("can't read sctps_ills_count at %p", kaddr);
1383 		return (WALK_ERR);
1384 	}
1385 	kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ills);
1386 
1387 	if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) {
1388 		mdb_warn("can't read scpts_g_ills %p", kaddr);
1389 		return (WALK_ERR);
1390 	}
1391 	if (mdb_vread(&iw.ills, sizeof (iw.ills), kaddr) == -1) {
1392 		mdb_warn("failed to read 'sctps_g_ills'");
1393 		return (NULL);
1394 	}
1395 
1396 	/* Find the first ill. */
1397 	for (i = 0; i < SCTP_ILL_HASH; i++) {
1398 		if (iw.ills[i].ill_count > 0) {
1399 			uaddr = (uintptr_t)&iw.ills[i].sctp_ill_list;
1400 			offset = uaddr - (uintptr_t)&iw.ills;
1401 			if (mdb_pwalk("list", wsp->walk_callback,
1402 				wsp->walk_cbdata, kaddr+offset) == -1) {
1403 				mdb_warn("couldn't walk 'list' for address %p",
1404 				    kaddr);
1405 				return (WALK_ERR);
1406 			}
1407 		}
1408 	}
1409 	return (WALK_DONE);
1410 }
1411 
1412 static int
1413 sctp_stack_ill_walk_step(mdb_walk_state_t *wsp)
1414 {
1415 	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
1416 		    wsp->walk_cbdata));
1417 }
1418 
1419 int
1420 sctp_ipif_walk_init(mdb_walk_state_t *wsp)
1421 {
1422 	if (mdb_layered_walk("sctp_stacks", wsp) == -1) {
1423 		mdb_warn("can't walk 'sctp_stacks'");
1424 		return (WALK_ERR);
1425 	}
1426 	return (WALK_NEXT);
1427 }
1428 
1429 int
1430 sctp_ipif_walk_step(mdb_walk_state_t *wsp)
1431 {
1432 	if (mdb_pwalk("sctp_stack_walk_ipif", wsp->walk_callback,
1433 		wsp->walk_cbdata, wsp->walk_addr) == -1) {
1434 		mdb_warn("couldn't walk 'sctp_stack_walk_ipif' for addr %p",
1435 		    wsp->walk_addr);
1436 		return (WALK_ERR);
1437 	}
1438 	return (WALK_NEXT);
1439 }
1440 
1441 /*
1442  * wsp->walk_addr is the address of sctps_ipif_list
1443  */
1444 static int
1445 sctp_stack_ipif_walk_init(mdb_walk_state_t *wsp)
1446 {
1447 	ipif_walk_data_t iw;
1448 	intptr_t i;
1449 	uintptr_t kaddr, uaddr;
1450 	size_t offset;
1451 
1452 	kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs_count);
1453 	if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) {
1454 		mdb_warn("can't read sctps_g_ipifs_count at %p", kaddr);
1455 		return (WALK_ERR);
1456 	}
1457 	kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs);
1458 
1459 	if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) {
1460 		mdb_warn("can't read scpts_g_ipifs %p", kaddr);
1461 		return (WALK_ERR);
1462 	}
1463 	if (mdb_vread(&iw.ipifs, sizeof (iw.ipifs), kaddr) == -1) {
1464 		mdb_warn("failed to read 'sctps_g_ipifs'");
1465 		return (NULL);
1466 	}
1467 
1468 	/* Find the first ipif. */
1469 	for (i = 0; i < SCTP_IPIF_HASH; i++) {
1470 		if (iw.ipifs[i].ipif_count > 0) {
1471 			uaddr = (uintptr_t)&iw.ipifs[i].sctp_ipif_list;
1472 			offset = uaddr - (uintptr_t)&iw.ipifs;
1473 			if (mdb_pwalk("list", wsp->walk_callback,
1474 				wsp->walk_cbdata, kaddr+offset) == -1) {
1475 				mdb_warn("couldn't walk 'list' for address %p",
1476 				    kaddr);
1477 				return (WALK_ERR);
1478 			}
1479 		}
1480 	}
1481 	return (WALK_DONE);
1482 }
1483 
1484 static int
1485 sctp_stack_ipif_walk_step(mdb_walk_state_t *wsp)
1486 {
1487 	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
1488 		    wsp->walk_cbdata));
1489 }
1490 
1491 static void
1492 sctp_help(void)
1493 {
1494 	mdb_printf("Print information for a given SCTP sctp_t\n\n");
1495 	mdb_printf("Options:\n");
1496 	mdb_printf("\t-a\t All the information\n");
1497 	mdb_printf("\t-f\t Flags\n");
1498 	mdb_printf("\t-h\t Hash Tables\n");
1499 	mdb_printf("\t-o\t Outbound Data\n");
1500 	mdb_printf("\t-i\t Inbound Data\n");
1501 	mdb_printf("\t-m\t Miscellaneous Information\n");
1502 	mdb_printf("\t-r\t RTT Tracking\n");
1503 	mdb_printf("\t-S\t Stats Counters\n");
1504 	mdb_printf("\t-F\t Flow Control\n");
1505 	mdb_printf("\t-H\t Composite Headers\n");
1506 	mdb_printf("\t-p\t PMTUD\n");
1507 	mdb_printf("\t-R\t Retransmit Information\n");
1508 	mdb_printf("\t-C\t Connection State\n");
1509 	mdb_printf("\t-c\t Cleanup / Close\n");
1510 	mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n");
1511 	mdb_printf("\t-d\t Local and Peer addresses\n");
1512 	mdb_printf("\t-P\t Peer addresses\n");
1513 }
1514 static const mdb_dcmd_t dcmds[] = {
1515 	{ "sctp", ":[-afhoimrSFHpRCcedP]",
1516 	    "display sctp control structure", sctp, sctp_help },
1517 	{ "sctp_set", ":", "display a SCTP set", sctp_set },
1518 	{ "sctp_faddr", ":", "display a faddr", sctp_faddr },
1519 	{ "sctp_istr_msgs", ":", "display msg list on an instream",
1520 	    sctp_istr_msgs },
1521 	{ "sctp_mdata_chunk", ":", "display a data chunk in an mblk",
1522 	    sctp_mdata_chunk },
1523 	{ "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list },
1524 	{ "sctp_instr", ":", "display instr", sctp_instr },
1525 	{ "sctp_reass_list", ":", "display reass list", sctp_reass_list },
1526 	{ "sctp_uo_reass_list", ":", "display un-ordered reass list",
1527 	    sctp_uo_reass_list },
1528 	{ NULL }
1529 };
1530 
1531 static const fanout_init_t listen_fanout_init = {
1532 	"sctp_stack_listen_fanout", OFFSETOF(sctp_stack_t, sctps_listen_fanout),
1533 	listen_size, listen_next
1534 };
1535 
1536 static const fanout_init_t conn_fanout_init = {
1537 	"sctp_stack_conn_fanout",  OFFSETOF(sctp_stack_t, sctps_conn_fanout),
1538 	conn_size, conn_next
1539 };
1540 
1541 static const fanout_init_t bind_fanout_init = {
1542 	"sctp_stack_bind_fanout", OFFSETOF(sctp_stack_t, sctps_bind_fanout),
1543 	bind_size, bind_next
1544 };
1545 
1546 static const mdb_walker_t walkers[] = {
1547 	{ "sctps", "walk the full chain of sctps for all stacks",
1548 	    sctps_walk_init, sctps_walk_step, NULL },
1549 	{ "sctp_listen_fanout", "walk the sctp listen fanout for all stacks",
1550 	    fanout_walk_init, fanout_walk_step, NULL,
1551 	    (void *)&listen_fanout_init },
1552 	{ "sctp_conn_fanout", "walk the sctp conn fanout for all stacks",
1553 	    fanout_walk_init, fanout_walk_step, NULL,
1554 	    (void *)&conn_fanout_init },
1555 	{ "sctp_bind_fanout", "walk the sctp bind fanout for all stacks",
1556 	    fanout_walk_init, fanout_walk_step, NULL,
1557 	    (void *)&bind_fanout_init },
1558 	{ "sctp_stack_listen_fanout",
1559 	    "walk the sctp listen fanout for one stack",
1560 	    fanout_stack_walk_init, fanout_stack_walk_step,
1561 	    fanout_stack_walk_fini,
1562 	    (void *)&listen_fanout_init },
1563 	{ "sctp_stack_conn_fanout", "walk the sctp conn fanout for one stack",
1564 	    fanout_stack_walk_init, fanout_stack_walk_step,
1565 	    fanout_stack_walk_fini,
1566 	    (void *)&conn_fanout_init },
1567 	{ "sctp_stack_bind_fanout", "walk the sctp bind fanoutfor one stack",
1568 	    fanout_stack_walk_init, fanout_stack_walk_step,
1569 	    fanout_stack_walk_fini,
1570 	    (void *)&bind_fanout_init },
1571 	{ "sctp_walk_faddr", "walk the peer address list of a given sctp_t",
1572 	    sctp_walk_faddr_init, sctp_walk_faddr_step, NULL },
1573 	{ "sctp_walk_saddr", "walk the local address list of a given sctp_t",
1574 	    sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini },
1575 	{ "sctp_walk_ill", "walk the sctp_g_ills list for all stacks",
1576 	    sctp_ill_walk_init, sctp_ill_walk_step, NULL },
1577 	{ "sctp_walk_ipif", "walk the sctp_g_ipif list for all stacks",
1578 		sctp_ipif_walk_init, sctp_ipif_walk_step, NULL },
1579 	{ "sctp_stack_walk_ill", "walk the sctp_g_ills list for one stack",
1580 		sctp_stack_ill_walk_init, sctp_stack_ill_walk_step, NULL },
1581 	{ "sctp_stack_walk_ipif", "walk the sctp_g_ipif list for one stack",
1582 		sctp_stack_ipif_walk_init, sctp_stack_ipif_walk_step, NULL },
1583 	{ "sctp_stacks", "walk all the sctp_stack_t",
1584 		sctp_stacks_walk_init, sctp_stacks_walk_step, NULL },
1585 	{ NULL }
1586 };
1587 
1588 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
1589 
1590 const mdb_modinfo_t *
1591 _mdb_init(void)
1592 {
1593 	return (&modinfo);
1594 }
1595