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