10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51735Skcpoon * Common Development and Distribution License (the "License"). 61735Skcpoon * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211735Skcpoon 220Sstevel@tonic-gate /* 23*3448Sdh155122 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/stream.h> 310Sstevel@tonic-gate #include <sys/mdb_modapi.h> 320Sstevel@tonic-gate #include <sys/socket.h> 330Sstevel@tonic-gate #include <sys/list.h> 340Sstevel@tonic-gate #include <sys/strsun.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <mdb/mdb_stdlib.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <netinet/in.h> 390Sstevel@tonic-gate #include <netinet/ip6.h> 400Sstevel@tonic-gate #include <netinet/sctp.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include <inet/common.h> 430Sstevel@tonic-gate #include <inet/ip.h> 440Sstevel@tonic-gate #include <inet/ip6.h> 450Sstevel@tonic-gate #include <inet/ipclassifier.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate #include <sctp/sctp_impl.h> 480Sstevel@tonic-gate #include <sctp/sctp_addr.h> 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define MDB_SCTP_SHOW_FLAGS 0x1 510Sstevel@tonic-gate #define MDB_SCTP_DUMP_ADDRS 0x2 520Sstevel@tonic-gate #define MDB_SCTP_SHOW_HASH 0x4 530Sstevel@tonic-gate #define MDB_SCTP_SHOW_OUT 0x8 540Sstevel@tonic-gate #define MDB_SCTP_SHOW_IN 0x10 550Sstevel@tonic-gate #define MDB_SCTP_SHOW_MISC 0x20 560Sstevel@tonic-gate #define MDB_SCTP_SHOW_RTT 0x40 570Sstevel@tonic-gate #define MDB_SCTP_SHOW_STATS 0x80 580Sstevel@tonic-gate #define MDB_SCTP_SHOW_FLOW 0x100 590Sstevel@tonic-gate #define MDB_SCTP_SHOW_HDR 0x200 600Sstevel@tonic-gate #define MDB_SCTP_SHOW_PMTUD 0x400 610Sstevel@tonic-gate #define MDB_SCTP_SHOW_RXT 0x800 620Sstevel@tonic-gate #define MDB_SCTP_SHOW_CONN 0x1000 630Sstevel@tonic-gate #define MDB_SCTP_SHOW_CLOSE 0x2000 640Sstevel@tonic-gate #define MDB_SCTP_SHOW_EXT 0x4000 650Sstevel@tonic-gate 660Sstevel@tonic-gate #define MDB_SCTP_SHOW_ALL 0xffffffff 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * Copy from usr/src/uts/common/os/list.c. Should we have a generic 700Sstevel@tonic-gate * mdb list walker? 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate #define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset)) 730Sstevel@tonic-gate 74*3448Sdh155122 static int 75*3448Sdh155122 ns_to_stackid(uintptr_t kaddr) 76*3448Sdh155122 { 77*3448Sdh155122 netstack_t nss; 78*3448Sdh155122 79*3448Sdh155122 if (mdb_vread(&nss, sizeof (nss), kaddr) == -1) { 80*3448Sdh155122 mdb_warn("failed to read netdstack info %p", kaddr); 81*3448Sdh155122 return (0); 82*3448Sdh155122 } 83*3448Sdh155122 return (nss.netstack_stackid); 84*3448Sdh155122 } 85*3448Sdh155122 86*3448Sdh155122 int 87*3448Sdh155122 sctp_stacks_walk_init(mdb_walk_state_t *wsp) 88*3448Sdh155122 { 89*3448Sdh155122 if (mdb_layered_walk("netstack", wsp) == -1) { 90*3448Sdh155122 mdb_warn("can't walk 'netstack'"); 91*3448Sdh155122 return (WALK_ERR); 92*3448Sdh155122 } 93*3448Sdh155122 return (WALK_NEXT); 94*3448Sdh155122 } 95*3448Sdh155122 96*3448Sdh155122 int 97*3448Sdh155122 sctp_stacks_walk_step(mdb_walk_state_t *wsp) 98*3448Sdh155122 { 99*3448Sdh155122 uintptr_t kaddr; 100*3448Sdh155122 netstack_t nss; 101*3448Sdh155122 102*3448Sdh155122 if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) { 103*3448Sdh155122 mdb_warn("can't read netstack at %p", wsp->walk_addr); 104*3448Sdh155122 return (WALK_ERR); 105*3448Sdh155122 } 106*3448Sdh155122 kaddr = (uintptr_t)nss.netstack_modules[NS_SCTP]; 107*3448Sdh155122 return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata)); 108*3448Sdh155122 } 109*3448Sdh155122 110432Svi117747 static char * 111432Svi117747 sctp_faddr_state(int state) 112432Svi117747 { 113432Svi117747 char *statestr; 114432Svi117747 115432Svi117747 switch (state) { 116432Svi117747 case SCTP_FADDRS_UNREACH: 117432Svi117747 statestr = "Unreachable"; 118432Svi117747 break; 119432Svi117747 case SCTP_FADDRS_DOWN: 120432Svi117747 statestr = "Down"; 121432Svi117747 break; 122432Svi117747 case SCTP_FADDRS_ALIVE: 123432Svi117747 statestr = "Alive"; 124432Svi117747 break; 125432Svi117747 case SCTP_FADDRS_UNCONFIRMED: 126432Svi117747 statestr = "Unconfirmed"; 127432Svi117747 break; 128432Svi117747 default: 129432Svi117747 statestr = "Unknown"; 130432Svi117747 break; 131432Svi117747 } 132432Svi117747 return (statestr); 133432Svi117747 } 134432Svi117747 1350Sstevel@tonic-gate /* ARGSUSED */ 1360Sstevel@tonic-gate static int 1370Sstevel@tonic-gate sctp_faddr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1380Sstevel@tonic-gate { 1390Sstevel@tonic-gate sctp_faddr_t fa[1]; 1400Sstevel@tonic-gate char *statestr; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1430Sstevel@tonic-gate return (DCMD_USAGE); 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate if (mdb_vread(fa, sizeof (*fa), addr) == -1) { 1460Sstevel@tonic-gate mdb_warn("cannot read fadder at %p", addr); 1470Sstevel@tonic-gate return (DCMD_ERR); 1480Sstevel@tonic-gate } 1490Sstevel@tonic-gate 150432Svi117747 statestr = sctp_faddr_state(fa->state); 1510Sstevel@tonic-gate mdb_printf("%<u>%p\t%<b>%N%</b>\t%s%</u>\n", addr, &fa->faddr, 1520Sstevel@tonic-gate statestr); 1530Sstevel@tonic-gate mdb_printf("next\t\t%?p\tsaddr\t%N\n", fa->next, &fa->saddr); 1540Sstevel@tonic-gate mdb_printf("rto\t\t%?d\tsrtt\t\t%?d\n", fa->rto, fa->srtt); 1550Sstevel@tonic-gate mdb_printf("rttvar\t\t%?d\trtt_updates\t%?u\n", fa->rttvar, 1560Sstevel@tonic-gate fa->rtt_updates); 1570Sstevel@tonic-gate mdb_printf("strikes\t\t%?d\tmax_retr\t%?d\n", fa->strikes, 1580Sstevel@tonic-gate fa->max_retr); 1590Sstevel@tonic-gate mdb_printf("hb_expiry\t%?ld\thb_interval\t%?u\n", fa->hb_expiry, 1600Sstevel@tonic-gate fa->hb_interval); 1610Sstevel@tonic-gate mdb_printf("pmss\t\t%?u\tcwnd\t\t%?u\n", fa->sfa_pmss, fa->cwnd); 1620Sstevel@tonic-gate mdb_printf("ssthresh\t%?u\tsuna\t\t%?u\n", fa->ssthresh, fa->suna); 1630Sstevel@tonic-gate mdb_printf("pba\t\t%?u\tacked\t\t%?u\n", fa->pba, fa->acked); 1640Sstevel@tonic-gate mdb_printf("lastactive\t%?ld\thb_secret\t%?#lx\n", fa->lastactive, 1650Sstevel@tonic-gate fa->hb_secret); 1660Sstevel@tonic-gate mdb_printf("timer_mp\t%?p\tire\t\t%?p\n", fa->timer_mp, fa->ire); 1670Sstevel@tonic-gate mdb_printf("hb_pending\t%?d\ttimer_running\t%?d\n" 1680Sstevel@tonic-gate "df\t\t%?d\tpmtu_discovered\t%?d\n" 1690Sstevel@tonic-gate "isv4\t\t%?d\tretransmissions\t%?u\n", 1700Sstevel@tonic-gate fa->hb_pending, fa->timer_running, fa->df, fa->pmtu_discovered, 1710Sstevel@tonic-gate fa->isv4, fa->T3expire); 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate return (DCMD_OK); 1740Sstevel@tonic-gate } 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate static void 1770Sstevel@tonic-gate print_set(sctp_set_t *sp) 1780Sstevel@tonic-gate { 1790Sstevel@tonic-gate mdb_printf("\tbegin\t%<b>%?x%</b>\t\tend\t%<b>%?x%</b>\n", 1800Sstevel@tonic-gate sp->begin, sp->end); 1810Sstevel@tonic-gate mdb_printf("\tnext\t%?p\tprev\t%?p\n", sp->next, sp->prev); 1820Sstevel@tonic-gate } 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /* ARGSUSED */ 1850Sstevel@tonic-gate static int 1860Sstevel@tonic-gate sctp_set(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1870Sstevel@tonic-gate { 1880Sstevel@tonic-gate sctp_set_t sp[1]; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1910Sstevel@tonic-gate return (DCMD_USAGE); 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) 1940Sstevel@tonic-gate return (DCMD_ERR); 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate print_set(sp); 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate return (DCMD_OK); 1990Sstevel@tonic-gate } 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate static void 2020Sstevel@tonic-gate dump_sack_info(uintptr_t addr) 2030Sstevel@tonic-gate { 2040Sstevel@tonic-gate sctp_set_t sp[1]; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate while (addr != 0) { 2070Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) { 2080Sstevel@tonic-gate mdb_warn("failed to read sctp_set at %p", addr); 2090Sstevel@tonic-gate return; 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate addr = (uintptr_t)sp->next; 2130Sstevel@tonic-gate print_set(sp); 2140Sstevel@tonic-gate } 2150Sstevel@tonic-gate } 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate static int 2180Sstevel@tonic-gate dump_msghdr(mblk_t *meta) 2190Sstevel@tonic-gate { 2200Sstevel@tonic-gate sctp_msg_hdr_t smh; 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate if (mdb_vread(&smh, sizeof (smh), (uintptr_t)meta->b_rptr) == -1) 2230Sstevel@tonic-gate return (-1); 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate mdb_printf("%<u>msg_hdr_t at \t%?p\tsentto\t%?p%</u>\n", 2260Sstevel@tonic-gate meta->b_rptr, SCTP_CHUNK_DEST(meta)); 2270Sstevel@tonic-gate mdb_printf("\tttl\t%?ld\ttob\t%?ld\n", smh.smh_ttl, smh.smh_tob); 2280Sstevel@tonic-gate mdb_printf("\tsid\t%?u\tssn\t%?u\n", smh.smh_sid, smh.smh_ssn); 2290Sstevel@tonic-gate mdb_printf("\tppid\t%?u\tflags\t%?s\n", smh.smh_ppid, 2300Sstevel@tonic-gate smh.smh_flags & MSG_UNORDERED ? "unordered" : " "); 2310Sstevel@tonic-gate mdb_printf("\tcontext\t%?u\tmsglen\t%?d\n", smh.smh_context, 2320Sstevel@tonic-gate smh.smh_msglen); 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate return (0); 2350Sstevel@tonic-gate } 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate static int 2380Sstevel@tonic-gate dump_datahdr(mblk_t *mp) 2390Sstevel@tonic-gate { 2400Sstevel@tonic-gate sctp_data_hdr_t sdc; 2410Sstevel@tonic-gate uint16_t sdh_int16; 2420Sstevel@tonic-gate uint32_t sdh_int32; 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate if (mdb_vread(&sdc, sizeof (sdc), (uintptr_t)mp->b_rptr) == -1) 2450Sstevel@tonic-gate return (-1); 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate mdb_printf("%<u>data_chunk_t \t%?p\tsentto\t%?p%</u>\n", 2480Sstevel@tonic-gate mp->b_rptr, SCTP_CHUNK_DEST(mp)); 2490Sstevel@tonic-gate mdb_printf("\tsent\t%?d\t", SCTP_CHUNK_ISSENT(mp)?1:0); 2500Sstevel@tonic-gate mdb_printf("retrans\t%?d\n", SCTP_CHUNK_WANT_REXMIT(mp)?1:0); 2510Sstevel@tonic-gate mdb_printf("\tacked\t%?d\t", SCTP_CHUNK_ISACKED(mp)?1:0); 2520Sstevel@tonic-gate mdb_printf("sackcnt\t%?u\n", SCTP_CHUNK_SACKCNT(mp)); 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_len, sizeof (sdc.sdh_len)); 2550Sstevel@tonic-gate mdb_printf("\tlen\t%?d\t", sdh_int16); 2560Sstevel@tonic-gate mdb_printf("BBIT=%d", SCTP_DATA_GET_BBIT(&sdc) == 0 ? 0 : 1); 2570Sstevel@tonic-gate mdb_printf("EBIT=%d", SCTP_DATA_GET_EBIT(&sdc) == 0 ? 0 : 1); 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_tsn, sizeof (sdc.sdh_tsn)); 2600Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_sid, sizeof (sdc.sdh_sid)); 2610Sstevel@tonic-gate mdb_printf("\ttsn\t%?x\tsid\t%?hu\n", sdh_int32, sdh_int16); 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_ssn, sizeof (sdc.sdh_ssn)); 2640Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_payload_id, 2650Sstevel@tonic-gate sizeof (sdc.sdh_payload_id)); 2660Sstevel@tonic-gate mdb_printf("\tssn\t%?hu\tppid\t%?d\n", sdh_int16, sdh_int32); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate return (0); 2690Sstevel@tonic-gate } 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate static int 2720Sstevel@tonic-gate sctp_sent_list(mblk_t *addr) 2730Sstevel@tonic-gate { 2740Sstevel@tonic-gate mblk_t meta, mp; 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate if (!addr) 2770Sstevel@tonic-gate return (0); 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 2800Sstevel@tonic-gate return (-1); 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate for (;;) { 2830Sstevel@tonic-gate dump_msghdr(&meta); 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate if (meta.b_cont == NULL) { 2860Sstevel@tonic-gate mdb_printf("No data chunks with message header!\n"); 2870Sstevel@tonic-gate return (-1); 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2900Sstevel@tonic-gate (uintptr_t)meta.b_cont) == -1) { 2910Sstevel@tonic-gate return (-1); 2920Sstevel@tonic-gate } 2930Sstevel@tonic-gate for (;;) { 2940Sstevel@tonic-gate dump_datahdr(&mp); 2950Sstevel@tonic-gate if (!mp.b_next) 2960Sstevel@tonic-gate break; 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2990Sstevel@tonic-gate (uintptr_t)(mp.b_next)) == -1) 3000Sstevel@tonic-gate return (-1); 3010Sstevel@tonic-gate } 3020Sstevel@tonic-gate if (meta.b_next == NULL) 3030Sstevel@tonic-gate break; 3040Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3050Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3060Sstevel@tonic-gate return (-1); 3070Sstevel@tonic-gate } 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate return (0); 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate static int 3130Sstevel@tonic-gate sctp_unsent_list(mblk_t *addr) 3140Sstevel@tonic-gate { 3150Sstevel@tonic-gate mblk_t meta; 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate if (!addr) 3180Sstevel@tonic-gate return (0); 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 3210Sstevel@tonic-gate return (-1); 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate for (;;) { 3240Sstevel@tonic-gate dump_msghdr(&meta); 3250Sstevel@tonic-gate 3260Sstevel@tonic-gate if (meta.b_next == NULL) 3270Sstevel@tonic-gate break; 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3300Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3310Sstevel@tonic-gate return (-1); 3320Sstevel@tonic-gate } 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate return (0); 3350Sstevel@tonic-gate } 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* ARGSUSED */ 3380Sstevel@tonic-gate static int 3390Sstevel@tonic-gate sctp_xmit_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3400Sstevel@tonic-gate { 3410Sstevel@tonic-gate sctp_t sctp; 3420Sstevel@tonic-gate 3430Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3440Sstevel@tonic-gate return (DCMD_USAGE); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) 3470Sstevel@tonic-gate return (DCMD_ERR); 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate mdb_printf("%<b>Chunkified TX list%</b>\n"); 3500Sstevel@tonic-gate if (sctp_sent_list(sctp.sctp_xmit_head) < 0) 3510Sstevel@tonic-gate return (DCMD_ERR); 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate mdb_printf("%<b>Unchunkified TX list%</b>\n"); 3540Sstevel@tonic-gate if (sctp_unsent_list(sctp.sctp_xmit_unsent) < 0) 3550Sstevel@tonic-gate return (DCMD_ERR); 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate return (DCMD_OK); 3580Sstevel@tonic-gate } 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* ARGSUSED */ 3610Sstevel@tonic-gate static int 3620Sstevel@tonic-gate sctp_mdata_chunk(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3630Sstevel@tonic-gate { 3640Sstevel@tonic-gate sctp_data_hdr_t dc; 3650Sstevel@tonic-gate mblk_t mp; 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3680Sstevel@tonic-gate return (DCMD_USAGE); 3690Sstevel@tonic-gate 3700Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), addr) == -1) 3710Sstevel@tonic-gate return (DCMD_ERR); 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate if (mdb_vread(&dc, sizeof (dc), (uintptr_t)mp.b_rptr) == -1) 3740Sstevel@tonic-gate return (DCMD_ERR); 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>tsn\t%?x\tsid\t%?hu\n", addr, 3770Sstevel@tonic-gate dc.sdh_tsn, dc.sdh_sid); 3780Sstevel@tonic-gate mdb_printf("%-?sssn\t%?hu\tppid\t%?x\n", "", dc.sdh_ssn, 3790Sstevel@tonic-gate dc.sdh_payload_id); 3800Sstevel@tonic-gate 3810Sstevel@tonic-gate return (DCMD_OK); 3820Sstevel@tonic-gate } 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate /* ARGSUSED */ 3850Sstevel@tonic-gate static int 3860Sstevel@tonic-gate sctp_istr_msgs(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3870Sstevel@tonic-gate { 3880Sstevel@tonic-gate mblk_t istrmp; 3890Sstevel@tonic-gate mblk_t dmp; 3900Sstevel@tonic-gate sctp_data_hdr_t dp; 3910Sstevel@tonic-gate uintptr_t daddr; 3920Sstevel@tonic-gate uintptr_t chaddr; 3930Sstevel@tonic-gate boolean_t bbit; 3940Sstevel@tonic-gate boolean_t ebit; 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3970Sstevel@tonic-gate return (DCMD_USAGE); 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate do { 4000Sstevel@tonic-gate if (mdb_vread(&istrmp, sizeof (istrmp), addr) == -1) 4010Sstevel@tonic-gate return (DCMD_ERR); 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate mdb_printf("\tistr mblk at %p: next: %?p\n" 4040Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, istrmp.b_next, 4050Sstevel@tonic-gate istrmp.b_prev, istrmp.b_cont); 4060Sstevel@tonic-gate daddr = (uintptr_t)&istrmp; 4070Sstevel@tonic-gate do { 4080Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4090Sstevel@tonic-gate break; 4100Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4110Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4120Sstevel@tonic-gate break; 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4150Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4180Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4220Sstevel@tonic-gate } while (daddr != NULL); 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate addr = (uintptr_t)istrmp.b_next; 4250Sstevel@tonic-gate } while (addr != NULL); 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate return (DCMD_OK); 4280Sstevel@tonic-gate } 4290Sstevel@tonic-gate 4300Sstevel@tonic-gate /* ARGSUSED */ 4310Sstevel@tonic-gate static int 4320Sstevel@tonic-gate sctp_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4330Sstevel@tonic-gate { 4340Sstevel@tonic-gate sctp_reass_t srp; 4350Sstevel@tonic-gate mblk_t srpmp; 4360Sstevel@tonic-gate sctp_data_hdr_t dp; 4370Sstevel@tonic-gate mblk_t dmp; 4380Sstevel@tonic-gate uintptr_t daddr; 4390Sstevel@tonic-gate uintptr_t chaddr; 4400Sstevel@tonic-gate boolean_t bbit, ebit; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4430Sstevel@tonic-gate return (DCMD_USAGE); 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate do { 4460Sstevel@tonic-gate if (mdb_vread(&srpmp, sizeof (srpmp), addr) == -1) 4470Sstevel@tonic-gate return (DCMD_ERR); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate if (mdb_vread(&srp, sizeof (srp), 4500Sstevel@tonic-gate (uintptr_t)srpmp.b_datap->db_base) == -1) 4510Sstevel@tonic-gate return (DCMD_ERR); 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 4540Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, srpmp.b_next, 4550Sstevel@tonic-gate srpmp.b_prev, srpmp.b_cont); 4560Sstevel@tonic-gate mdb_printf("\t\tssn: %hu\tneeded: %hu\tgot: %hu\ttail: %?p\n" 4570Sstevel@tonic-gate "\t\tpartial_delivered: %s\n", srp.ssn, srp.needed, 4580Sstevel@tonic-gate srp.got, srp.tail, srp.partial_delivered ? "TRUE" : 4590Sstevel@tonic-gate "FALSE"); 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate /* display the contents of this ssn's reassemby list */ 4620Sstevel@tonic-gate daddr = DB_TYPE(&srpmp) == M_CTL ? (uintptr_t)srpmp.b_cont : 4630Sstevel@tonic-gate (uintptr_t)&srpmp; 4640Sstevel@tonic-gate do { 4650Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4660Sstevel@tonic-gate break; 4670Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4680Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4690Sstevel@tonic-gate break; 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4720Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4750Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4760Sstevel@tonic-gate 4770Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4780Sstevel@tonic-gate } while (daddr != NULL); 4790Sstevel@tonic-gate 4800Sstevel@tonic-gate addr = (uintptr_t)srpmp.b_next; 4810Sstevel@tonic-gate } while (addr != NULL); 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate return (DCMD_OK); 4840Sstevel@tonic-gate } 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate /* ARGSUSED */ 4870Sstevel@tonic-gate static int 4880Sstevel@tonic-gate sctp_uo_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4890Sstevel@tonic-gate { 4900Sstevel@tonic-gate sctp_data_hdr_t dp; 4910Sstevel@tonic-gate mblk_t dmp; 4920Sstevel@tonic-gate uintptr_t chaddr; 4930Sstevel@tonic-gate boolean_t bbit; 4940Sstevel@tonic-gate boolean_t ebit; 4950Sstevel@tonic-gate boolean_t ubit; 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4980Sstevel@tonic-gate return (DCMD_USAGE); 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate do { 5010Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), addr) == -1) 5020Sstevel@tonic-gate return (DCMD_ERR); 5030Sstevel@tonic-gate 5040Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 5050Sstevel@tonic-gate "\t\tprev: %?p\n", addr, dmp.b_next, dmp.b_prev); 5060Sstevel@tonic-gate 5070Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 5080Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 5090Sstevel@tonic-gate break; 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 5120Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 5130Sstevel@tonic-gate ubit = (SCTP_DATA_GET_UBIT(&dp) != 0); 5140Sstevel@tonic-gate 5150Sstevel@tonic-gate mdb_printf("\t\t\tsid: %hu ssn: %hu tsn: %x " 5160Sstevel@tonic-gate "flags: %x (U=%d B=%d E=%d)\n", dp.sdh_sid, dp.sdh_ssn, 5170Sstevel@tonic-gate dp.sdh_tsn, dp.sdh_flags, ubit, bbit, ebit); 5180Sstevel@tonic-gate 5190Sstevel@tonic-gate addr = (uintptr_t)dmp.b_next; 5200Sstevel@tonic-gate } while (addr != NULL); 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate return (DCMD_OK); 5230Sstevel@tonic-gate } 5240Sstevel@tonic-gate 5250Sstevel@tonic-gate static int 5260Sstevel@tonic-gate sctp_instr(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 5270Sstevel@tonic-gate { 5280Sstevel@tonic-gate sctp_instr_t sip; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 5310Sstevel@tonic-gate return (DCMD_USAGE); 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate if (mdb_vread(&sip, sizeof (sip), addr) == -1) 5340Sstevel@tonic-gate return (DCMD_ERR); 5350Sstevel@tonic-gate 5360Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>\n\tmsglist\t%?p\tnmsgs\t%?d\n" 5370Sstevel@tonic-gate "\tnextseq\t%?d\treass\t%?p\n", addr, sip.istr_msgs, 5380Sstevel@tonic-gate sip.istr_nmsgs, sip.nextseq, sip.istr_reass); 5390Sstevel@tonic-gate mdb_set_dot(addr + sizeof (sip)); 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate return (sctp_reass_list((uintptr_t)sip.istr_reass, flags, ac, av)); 5420Sstevel@tonic-gate } 5430Sstevel@tonic-gate 5440Sstevel@tonic-gate static const char * 5450Sstevel@tonic-gate state2str(sctp_t *sctp) 5460Sstevel@tonic-gate { 5470Sstevel@tonic-gate switch (sctp->sctp_state) { 5480Sstevel@tonic-gate case SCTPS_IDLE: return ("SCTPS_IDLE"); 5490Sstevel@tonic-gate case SCTPS_BOUND: return ("SCTPS_BOUND"); 5500Sstevel@tonic-gate case SCTPS_LISTEN: return ("SCTPS_LISTEN"); 5510Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: return ("SCTPS_COOKIE_WAIT"); 5520Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED: return ("SCTPS_COOKIE_ECHOED"); 5530Sstevel@tonic-gate case SCTPS_ESTABLISHED: return ("SCTPS_ESTABLISHED"); 5540Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: return ("SCTPS_SHUTDOWN_PENDING"); 5550Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: return ("SCTPS_SHUTDOWN_SENT"); 5560Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED: return ("SCTPS_SHUTDOWN_RECEIVED"); 5570Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: return ("SCTPS_SHUTDOWN_ACK_SENT"); 5580Sstevel@tonic-gate default: return ("UNKNOWN STATE"); 5590Sstevel@tonic-gate } 5600Sstevel@tonic-gate } 5610Sstevel@tonic-gate 5620Sstevel@tonic-gate static void 5630Sstevel@tonic-gate show_sctp_flags(sctp_t *sctp) 5640Sstevel@tonic-gate { 5650Sstevel@tonic-gate mdb_printf("\tunderstands_asconf\t%d\n", 5660Sstevel@tonic-gate sctp->sctp_understands_asconf); 5670Sstevel@tonic-gate mdb_printf("\tdebug\t\t\t%d\n", sctp->sctp_debug); 5680Sstevel@tonic-gate mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend); 5690Sstevel@tonic-gate mdb_printf("\tdgram_errind\t\t%d\n", sctp->sctp_dgram_errind); 5700Sstevel@tonic-gate 5710Sstevel@tonic-gate mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_linger); 5720Sstevel@tonic-gate if (sctp->sctp_lingering) 5730Sstevel@tonic-gate return; 5740Sstevel@tonic-gate mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering); 5750Sstevel@tonic-gate mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback); 5760Sstevel@tonic-gate mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack); 5770Sstevel@tonic-gate 5780Sstevel@tonic-gate mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running); 5790Sstevel@tonic-gate mdb_printf("\trecvdstaddr\t\t%d\n", sctp->sctp_recvdstaddr); 5800Sstevel@tonic-gate mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum); 5810Sstevel@tonic-gate mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip); 5820Sstevel@tonic-gate 5830Sstevel@tonic-gate mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all); 5840Sstevel@tonic-gate mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep); 5850Sstevel@tonic-gate mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached); 5860Sstevel@tonic-gate mdb_printf("\tsend_adaption\t\t%d\n", sctp->sctp_send_adaption); 5870Sstevel@tonic-gate 5880Sstevel@tonic-gate mdb_printf("\trecv_adaption\t\t%d\n", sctp->sctp_recv_adaption); 5890Sstevel@tonic-gate mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay); 5900Sstevel@tonic-gate mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned); 5910Sstevel@tonic-gate mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit); 5921735Skcpoon 5930Sstevel@tonic-gate mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware); 594432Svi117747 mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal); 5951735Skcpoon mdb_printf("\trexmitting\t\t%d\n", sctp->sctp_rexmitting); 5962263Ssommerfe mdb_printf("\tzero_win_probe\t\t%d\n", sctp->sctp_zero_win_probe); 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo); 5990Sstevel@tonic-gate mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt); 6000Sstevel@tonic-gate mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt); 6010Sstevel@tonic-gate mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt); 6020Sstevel@tonic-gate 6030Sstevel@tonic-gate mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr); 6040Sstevel@tonic-gate mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt); 6050Sstevel@tonic-gate mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt); 6060Sstevel@tonic-gate mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt); 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate /* 6100Sstevel@tonic-gate * Given a sctp_saddr_ipif_t, print out its address. This assumes 6110Sstevel@tonic-gate * that addr contains the sctp_addr_ipif_t structure already and this 6120Sstevel@tonic-gate * function does not need to read it in. 6130Sstevel@tonic-gate */ 6140Sstevel@tonic-gate /* ARGSUSED */ 6150Sstevel@tonic-gate static int 6160Sstevel@tonic-gate print_saddr(uintptr_t ptr, const void *addr, void *cbdata) 6170Sstevel@tonic-gate { 6180Sstevel@tonic-gate sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr; 6190Sstevel@tonic-gate sctp_ipif_t ipif; 6200Sstevel@tonic-gate char *statestr; 6210Sstevel@tonic-gate 6220Sstevel@tonic-gate /* Read in the sctp_ipif object */ 6230Sstevel@tonic-gate if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) == 6240Sstevel@tonic-gate -1) { 6250Sstevel@tonic-gate mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp); 6260Sstevel@tonic-gate return (WALK_ERR); 6270Sstevel@tonic-gate } 6280Sstevel@tonic-gate 6290Sstevel@tonic-gate switch (ipif.sctp_ipif_state) { 6300Sstevel@tonic-gate case SCTP_IPIFS_CONDEMNED: 631432Svi117747 statestr = "Condemned"; 6320Sstevel@tonic-gate break; 6330Sstevel@tonic-gate case SCTP_IPIFS_INVALID: 634432Svi117747 statestr = "Invalid"; 6350Sstevel@tonic-gate break; 6360Sstevel@tonic-gate case SCTP_IPIFS_DOWN: 637432Svi117747 statestr = "Down"; 6380Sstevel@tonic-gate break; 6390Sstevel@tonic-gate case SCTP_IPIFS_UP: 640432Svi117747 statestr = "Up"; 6410Sstevel@tonic-gate break; 6420Sstevel@tonic-gate default: 643432Svi117747 statestr = "Unknown"; 6440Sstevel@tonic-gate break; 6450Sstevel@tonic-gate } 646432Svi117747 mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr, 647432Svi117747 statestr); 648432Svi117747 if (saddr->saddr_ipif_dontsrc == 1) 649432Svi117747 mdb_printf("/Dontsrc"); 650432Svi117747 if (saddr->saddr_ipif_unconfirmed == 1) 651432Svi117747 mdb_printf("/Unconfirmed"); 652432Svi117747 if (saddr->saddr_ipif_delete_pending == 1) 653432Svi117747 mdb_printf("/DeletePending"); 654432Svi117747 mdb_printf(")\n"); 655432Svi117747 mdb_printf("\t\t\tMTU %d id %d zoneid %d IPIF flags %x\n", 6560Sstevel@tonic-gate ipif.sctp_ipif_mtu, ipif.sctp_ipif_id, 657432Svi117747 ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags); 6580Sstevel@tonic-gate return (WALK_NEXT); 6590Sstevel@tonic-gate } 6600Sstevel@tonic-gate 6610Sstevel@tonic-gate /* 6620Sstevel@tonic-gate * Given a sctp_faddr_t, print out its address. This assumes that 6630Sstevel@tonic-gate * addr contains the sctp_faddr_t structure already and this function 6640Sstevel@tonic-gate * does not need to read it in. 6650Sstevel@tonic-gate */ 6660Sstevel@tonic-gate static int 6670Sstevel@tonic-gate print_faddr(uintptr_t ptr, const void *addr, void *cbdata) 6680Sstevel@tonic-gate { 669432Svi117747 char *statestr; 6700Sstevel@tonic-gate sctp_faddr_t *faddr = (sctp_faddr_t *)addr; 6710Sstevel@tonic-gate int *i = cbdata; 6720Sstevel@tonic-gate 673432Svi117747 statestr = sctp_faddr_state(faddr->state); 674432Svi117747 675432Svi117747 mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->faddr, ptr, 676432Svi117747 statestr); 6770Sstevel@tonic-gate return (WALK_NEXT); 6780Sstevel@tonic-gate } 6790Sstevel@tonic-gate 6800Sstevel@tonic-gate int 6810Sstevel@tonic-gate sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 6820Sstevel@tonic-gate { 6830Sstevel@tonic-gate sctp_t sctp; 6840Sstevel@tonic-gate conn_t connp; 6850Sstevel@tonic-gate int i; 6860Sstevel@tonic-gate uint_t opts = 0; 6870Sstevel@tonic-gate uint_t paddr = 0; 6880Sstevel@tonic-gate in_port_t lport, fport; 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 6910Sstevel@tonic-gate return (DCMD_USAGE); 6920Sstevel@tonic-gate 6930Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 6940Sstevel@tonic-gate mdb_warn("failed to read sctp_t at: %p\n", addr); 6950Sstevel@tonic-gate return (DCMD_ERR); 6960Sstevel@tonic-gate } 6970Sstevel@tonic-gate if (mdb_vread(&connp, sizeof (connp), 6980Sstevel@tonic-gate (uintptr_t)sctp.sctp_connp) == -1) { 6990Sstevel@tonic-gate mdb_warn("failed to read conn_t at: %p\n", sctp.sctp_connp); 7000Sstevel@tonic-gate return (DCMD_ERR); 7010Sstevel@tonic-gate } 7020Sstevel@tonic-gate 7030Sstevel@tonic-gate if (mdb_getopts(argc, argv, 7040Sstevel@tonic-gate 'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts, 7050Sstevel@tonic-gate 'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts, 7060Sstevel@tonic-gate 'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts, 7070Sstevel@tonic-gate 'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts, 7080Sstevel@tonic-gate 'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts, 7090Sstevel@tonic-gate 'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts, 7100Sstevel@tonic-gate 'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts, 7110Sstevel@tonic-gate 'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts, 7120Sstevel@tonic-gate 'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts, 7130Sstevel@tonic-gate 'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts, 7140Sstevel@tonic-gate 'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts, 7150Sstevel@tonic-gate 'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts, 7160Sstevel@tonic-gate 'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts, 7170Sstevel@tonic-gate 'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts, 7180Sstevel@tonic-gate 'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts, 7190Sstevel@tonic-gate 'P', MDB_OPT_SETBITS, 1, &paddr, 7200Sstevel@tonic-gate 'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) { 7210Sstevel@tonic-gate return (DCMD_USAGE); 7220Sstevel@tonic-gate } 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate /* non-verbose faddrs, suitable for pipelines to sctp_faddr */ 7250Sstevel@tonic-gate if (paddr != 0) { 7260Sstevel@tonic-gate sctp_faddr_t faddr, *fp; 7270Sstevel@tonic-gate for (fp = sctp.sctp_faddrs; fp != NULL; fp = faddr.next) { 7280Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp) 7290Sstevel@tonic-gate == -1) { 7300Sstevel@tonic-gate mdb_warn("failed to read faddr at %p", 7310Sstevel@tonic-gate fp); 7320Sstevel@tonic-gate return (DCMD_ERR); 7330Sstevel@tonic-gate } 7340Sstevel@tonic-gate mdb_printf("%p\n", fp); 7350Sstevel@tonic-gate } 7360Sstevel@tonic-gate return (DCMD_OK); 7370Sstevel@tonic-gate } 7380Sstevel@tonic-gate 7390Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 7400Sstevel@tonic-gate mdb_nhconvert(&fport, &sctp.sctp_fport, sizeof (fport)); 741*3448Sdh155122 mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% STACK=%d ZONE=%d%</u>", addr, 742*3448Sdh155122 state2str(&sctp), lport, fport, 743*3448Sdh155122 ns_to_stackid((uintptr_t)connp.conn_netstack), connp.conn_zoneid); 7440Sstevel@tonic-gate 7450Sstevel@tonic-gate if (sctp.sctp_faddrs) { 7460Sstevel@tonic-gate sctp_faddr_t faddr; 7470Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), 7480Sstevel@tonic-gate (uintptr_t)sctp.sctp_faddrs) != -1) 7490Sstevel@tonic-gate mdb_printf("%<u> %N%</u>", &faddr.faddr); 7500Sstevel@tonic-gate } 7510Sstevel@tonic-gate mdb_printf("\n"); 7520Sstevel@tonic-gate 7530Sstevel@tonic-gate if (opts & MDB_SCTP_DUMP_ADDRS) { 7540Sstevel@tonic-gate mdb_printf("%<b>Local and Peer Addresses%</b>\n"); 7550Sstevel@tonic-gate 7560Sstevel@tonic-gate /* Display source addresses */ 7570Sstevel@tonic-gate mdb_printf("nsaddrs\t\t%?d\n", sctp.sctp_nsaddrs); 7580Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr); 7590Sstevel@tonic-gate 7600Sstevel@tonic-gate /* Display peer addresses */ 761852Svi117747 mdb_printf("nfaddrs\t\t%?d\n", sctp.sctp_nfaddrs); 7620Sstevel@tonic-gate i = 1; 7630Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr); 7640Sstevel@tonic-gate 7650Sstevel@tonic-gate mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n", 7660Sstevel@tonic-gate sctp.sctp_lastfaddr, sctp.sctp_primary); 7670Sstevel@tonic-gate mdb_printf("current\t\t%?p\tlastdata\t%?p\n", 7680Sstevel@tonic-gate sctp.sctp_current, sctp.sctp_lastdata); 7690Sstevel@tonic-gate } 7700Sstevel@tonic-gate 7710Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_OUT) { 7720Sstevel@tonic-gate mdb_printf("%<b>Outbound Data%</b>\n"); 7730Sstevel@tonic-gate mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n", 7740Sstevel@tonic-gate sctp.sctp_xmit_head, sctp.sctp_xmit_tail); 7750Sstevel@tonic-gate mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n", 7760Sstevel@tonic-gate sctp.sctp_xmit_unsent, sctp.sctp_xmit_unsent_tail); 7770Sstevel@tonic-gate mdb_printf("xmit_unacked\t%?p\n", sctp.sctp_xmit_unacked); 7780Sstevel@tonic-gate mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n", 7790Sstevel@tonic-gate sctp.sctp_unacked, sctp.sctp_unsent); 7800Sstevel@tonic-gate mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n", 7810Sstevel@tonic-gate sctp.sctp_ltsn, sctp.sctp_lastack_rxd); 7820Sstevel@tonic-gate mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n", 7830Sstevel@tonic-gate sctp.sctp_recovery_tsn, sctp.sctp_adv_pap); 7840Sstevel@tonic-gate mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n", 7850Sstevel@tonic-gate sctp.sctp_num_ostr, sctp.sctp_ostrcntrs); 7860Sstevel@tonic-gate 7870Sstevel@tonic-gate mdb_printf("%<b>Default Send Parameters%</b>\n"); 7880Sstevel@tonic-gate mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n", 7890Sstevel@tonic-gate sctp.sctp_def_stream, sctp.sctp_def_flags); 7900Sstevel@tonic-gate mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n", 7910Sstevel@tonic-gate sctp.sctp_def_ppid, sctp.sctp_def_context); 7920Sstevel@tonic-gate mdb_printf("def_timetolive\t%?u\n", 7930Sstevel@tonic-gate sctp.sctp_def_timetolive); 7940Sstevel@tonic-gate } 7950Sstevel@tonic-gate 7960Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_IN) { 7970Sstevel@tonic-gate mdb_printf("%<b>Inbound Data%</b>\n"); 7980Sstevel@tonic-gate mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n", 7990Sstevel@tonic-gate sctp.sctp_sack_info, sctp.sctp_sack_gaps); 8000Sstevel@tonic-gate dump_sack_info((uintptr_t)sctp.sctp_sack_info); 8010Sstevel@tonic-gate mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n", 8020Sstevel@tonic-gate sctp.sctp_ftsn, sctp.sctp_lastacked); 8030Sstevel@tonic-gate mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n", 8040Sstevel@tonic-gate sctp.sctp_istr_nmsgs, sctp.sctp_sack_toggle); 8050Sstevel@tonic-gate mdb_printf("ack_mp\t\t%?p\n", sctp.sctp_ack_mp); 8060Sstevel@tonic-gate mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n", 8070Sstevel@tonic-gate sctp.sctp_num_istr, sctp.sctp_instr); 8080Sstevel@tonic-gate mdb_printf("unord_reass\t%?p\n", sctp.sctp_uo_frags); 8090Sstevel@tonic-gate } 8100Sstevel@tonic-gate 8110Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RTT) { 8120Sstevel@tonic-gate mdb_printf("%<b>RTT Tracking%</b>\n"); 8130Sstevel@tonic-gate mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n", 8140Sstevel@tonic-gate sctp.sctp_rtt_tsn, sctp.sctp_out_time); 8150Sstevel@tonic-gate } 8160Sstevel@tonic-gate 8170Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLOW) { 8180Sstevel@tonic-gate mdb_printf("%<b>Flow Control%</b>\n"); 8190Sstevel@tonic-gate mdb_printf("txmit_hiwater\t%?d\n" 8200Sstevel@tonic-gate "xmit_lowater\t%?d\tfrwnd\t\t%?u\n" 821852Svi117747 "rwnd\t\t%?u\tinitial rwnd\t%?u\n" 822852Svi117747 "rxqueued\t%?u\tcwnd_max\t%?u\n", sctp.sctp_xmit_hiwater, 8230Sstevel@tonic-gate sctp.sctp_xmit_lowater, sctp.sctp_frwnd, 824852Svi117747 sctp.sctp_rwnd, sctp.sctp_irwnd, sctp.sctp_rxqueued, 825852Svi117747 sctp.sctp_cwnd_max); 8260Sstevel@tonic-gate } 8270Sstevel@tonic-gate 8280Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HDR) { 8290Sstevel@tonic-gate mdb_printf("%<b>Composite Headers%</b>\n"); 8300Sstevel@tonic-gate mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n" 8310Sstevel@tonic-gate "iphc_len\t%?d\tiphc6_len\t%?d\n" 8320Sstevel@tonic-gate "hdr_len\t\t%?d\thdr6_len\t%?d\n" 8330Sstevel@tonic-gate "ipha\t\t%?p\tip6h\t\t%?p\n" 8340Sstevel@tonic-gate "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n" 8350Sstevel@tonic-gate "sctph\t\t%?p\tsctph6\t\t%?p\n" 8360Sstevel@tonic-gate "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp.sctp_iphc, 8370Sstevel@tonic-gate sctp.sctp_iphc6, sctp.sctp_iphc_len, 8380Sstevel@tonic-gate sctp.sctp_iphc6_len, sctp.sctp_hdr_len, 8390Sstevel@tonic-gate sctp.sctp_hdr6_len, sctp.sctp_ipha, sctp.sctp_ip6h, 8400Sstevel@tonic-gate sctp.sctp_ip_hdr_len, sctp.sctp_ip_hdr6_len, 8410Sstevel@tonic-gate sctp.sctp_sctph, sctp.sctp_sctph6, sctp.sctp_lvtag, 8420Sstevel@tonic-gate sctp.sctp_fvtag); 8430Sstevel@tonic-gate } 8440Sstevel@tonic-gate 8450Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_PMTUD) { 8460Sstevel@tonic-gate mdb_printf("%<b>PMTUd%</b>\n"); 8470Sstevel@tonic-gate mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n" 8480Sstevel@tonic-gate "mss\t\t%?u\n", 8490Sstevel@tonic-gate sctp.sctp_last_mtu_probe, sctp.sctp_mtu_probe_intvl, 8500Sstevel@tonic-gate sctp.sctp_mss); 8510Sstevel@tonic-gate } 8520Sstevel@tonic-gate 8530Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RXT) { 8540Sstevel@tonic-gate mdb_printf("%<b>Retransmit Info%</b>\n"); 8550Sstevel@tonic-gate mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n" 8560Sstevel@tonic-gate "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n" 8570Sstevel@tonic-gate "pp_max_rxt\t%?d\trto_max\t\t%?u\n" 8580Sstevel@tonic-gate "rto_min\t\t%?u\trto_initial\t%?u\n" 8591735Skcpoon "init_rto_max\t%?u\n" 8601735Skcpoon "rxt_nxttsn\t%?u\trxt_maxtsn\t%?u\n", sctp.sctp_cookie_mp, 8610Sstevel@tonic-gate sctp.sctp_strikes, sctp.sctp_max_init_rxt, 8620Sstevel@tonic-gate sctp.sctp_pa_max_rxt, sctp.sctp_pp_max_rxt, 8630Sstevel@tonic-gate sctp.sctp_rto_max, sctp.sctp_rto_min, 8641735Skcpoon sctp.sctp_rto_initial, sctp.sctp_init_rto_max, 8651735Skcpoon sctp.sctp_rxt_nxttsn, sctp.sctp_rxt_maxtsn); 8660Sstevel@tonic-gate } 8670Sstevel@tonic-gate 8680Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CONN) { 8690Sstevel@tonic-gate mdb_printf("%<b>Connection State%</b>\n"); 8700Sstevel@tonic-gate mdb_printf("last_secret_update%?ld\n", 8710Sstevel@tonic-gate sctp.sctp_last_secret_update); 8720Sstevel@tonic-gate 8730Sstevel@tonic-gate mdb_printf("secret\t\t"); 8740Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8750Sstevel@tonic-gate if (i % 2 == 0) 8760Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_secret[i]); 8770Sstevel@tonic-gate else 8780Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_secret[i]); 8790Sstevel@tonic-gate } 8800Sstevel@tonic-gate mdb_printf("\n"); 8810Sstevel@tonic-gate mdb_printf("old_secret\t"); 8820Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8830Sstevel@tonic-gate if (i % 2 == 0) 8840Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_old_secret[i]); 8850Sstevel@tonic-gate else 8860Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_old_secret[i]); 8870Sstevel@tonic-gate } 8880Sstevel@tonic-gate mdb_printf("\n"); 8890Sstevel@tonic-gate } 8900Sstevel@tonic-gate 8910Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_STATS) { 8920Sstevel@tonic-gate mdb_printf("%<b>Stats Counters%</b>\n"); 8930Sstevel@tonic-gate mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n" 8940Sstevel@tonic-gate "odchunks\t%?llu\toudchunks\t%?llu\n" 8950Sstevel@tonic-gate "rxtchunks\t%?llu\tT1expire\t%?lu\n" 8960Sstevel@tonic-gate "T2expire\t%?lu\tT3expire\t%?lu\n" 8970Sstevel@tonic-gate "msgcount\t%?llu\tprsctpdrop\t%?llu\n" 8980Sstevel@tonic-gate "AssocStartTime\t%?lu\n", 8990Sstevel@tonic-gate sctp.sctp_opkts, sctp.sctp_obchunks, 9000Sstevel@tonic-gate sctp.sctp_odchunks, sctp.sctp_oudchunks, 9010Sstevel@tonic-gate sctp.sctp_rxtchunks, sctp.sctp_T1expire, 9020Sstevel@tonic-gate sctp.sctp_T2expire, sctp.sctp_T3expire, 9030Sstevel@tonic-gate sctp.sctp_msgcount, sctp.sctp_prsctpdrop, 9040Sstevel@tonic-gate sctp.sctp_assoc_start_time); 9050Sstevel@tonic-gate mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n" 9060Sstevel@tonic-gate "idchunks\t%?llu\tiudchunks\t%?llu\n" 9070Sstevel@tonic-gate "fragdmsgs\t%?llu\treassmsgs\t%?llu\n", 9080Sstevel@tonic-gate sctp.sctp_ipkts, sctp.sctp_ibchunks, 9090Sstevel@tonic-gate sctp.sctp_idchunks, sctp.sctp_iudchunks, 9100Sstevel@tonic-gate sctp.sctp_fragdmsgs, sctp.sctp_reassmsgs); 9110Sstevel@tonic-gate } 9120Sstevel@tonic-gate 9130Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HASH) { 9140Sstevel@tonic-gate mdb_printf("%<b>Hash Tables%</b>\n"); 9150Sstevel@tonic-gate mdb_printf("conn_hash_next\t%?p\t", sctp.sctp_conn_hash_next); 9160Sstevel@tonic-gate mdb_printf("conn_hash_prev\t%?p\n", sctp.sctp_conn_hash_prev); 9170Sstevel@tonic-gate 9180Sstevel@tonic-gate mdb_printf("listen_hash_next%?p\t", 9190Sstevel@tonic-gate sctp.sctp_listen_hash_next); 9200Sstevel@tonic-gate mdb_printf("listen_hash_prev%?p\n", 9210Sstevel@tonic-gate sctp.sctp_listen_hash_prev); 9220Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 9230Sstevel@tonic-gate mdb_printf("[ listen_hash bucket\t%?d ]\n", 9240Sstevel@tonic-gate SCTP_LISTEN_HASH(lport)); 9250Sstevel@tonic-gate 9260Sstevel@tonic-gate mdb_printf("conn_tfp\t%?p\t", sctp.sctp_conn_tfp); 9270Sstevel@tonic-gate mdb_printf("listen_tfp\t%?p\n", sctp.sctp_listen_tfp); 9280Sstevel@tonic-gate 9290Sstevel@tonic-gate mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n", 9300Sstevel@tonic-gate sctp.sctp_bind_hash, sctp.sctp_ptpbhn); 9310Sstevel@tonic-gate mdb_printf("bind_lockp\t%?p\n", 9320Sstevel@tonic-gate sctp.sctp_bind_lockp); 9330Sstevel@tonic-gate mdb_printf("[ bind_hash bucket\t%?d ]\n", 9340Sstevel@tonic-gate SCTP_BIND_HASH(lport)); 9350Sstevel@tonic-gate } 9360Sstevel@tonic-gate 9370Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CLOSE) { 9380Sstevel@tonic-gate mdb_printf("%<b>Cleanup / Close%</b>\n"); 9390Sstevel@tonic-gate mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n" 9400Sstevel@tonic-gate "lingertime\t%?d\trefcnt\t\t%?hu\n", 9410Sstevel@tonic-gate sctp.sctp_shutdown_faddr, sctp.sctp_client_errno, 9420Sstevel@tonic-gate sctp.sctp_lingertime, sctp.sctp_refcnt); 9430Sstevel@tonic-gate } 9440Sstevel@tonic-gate 9450Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_MISC) { 9460Sstevel@tonic-gate mdb_printf("%<b>Miscellaneous%</b>\n"); 9470Sstevel@tonic-gate mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n" 9480Sstevel@tonic-gate "family\t\t%?u\tipversion\t%?hu\n" 9490Sstevel@tonic-gate "hb_interval\t%?u\tautoclose\t%?d\n" 9500Sstevel@tonic-gate "active\t\t%?ld\ttx_adaption_code%?x\n" 9510Sstevel@tonic-gate "rx_adaption_code%?x\ttimer_mp\t%?p\n", 9520Sstevel@tonic-gate sctp.sctp_bound_if, sctp.sctp_heartbeat_mp, 9530Sstevel@tonic-gate sctp.sctp_family, sctp.sctp_ipversion, 9540Sstevel@tonic-gate sctp.sctp_hb_interval, sctp.sctp_autoclose, 9550Sstevel@tonic-gate sctp.sctp_active, sctp.sctp_tx_adaption_code, 9560Sstevel@tonic-gate sctp.sctp_rx_adaption_code, sctp.sctp_timer_mp); 9570Sstevel@tonic-gate } 9580Sstevel@tonic-gate 9590Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_EXT) { 9600Sstevel@tonic-gate mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n"); 9610Sstevel@tonic-gate mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n" 9620Sstevel@tonic-gate "fcsn\t\t%?x\n", sctp.sctp_cxmit_list, sctp.sctp_lcsn, 9630Sstevel@tonic-gate sctp.sctp_fcsn); 9640Sstevel@tonic-gate } 9650Sstevel@tonic-gate 9660Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLAGS) { 9670Sstevel@tonic-gate mdb_printf("%<b>Flags%</b>\n"); 9680Sstevel@tonic-gate show_sctp_flags(&sctp); 9690Sstevel@tonic-gate } 9700Sstevel@tonic-gate 9710Sstevel@tonic-gate return (DCMD_OK); 9720Sstevel@tonic-gate } 9730Sstevel@tonic-gate 9740Sstevel@tonic-gate typedef struct fanout_walk_data { 9750Sstevel@tonic-gate int index; 9760Sstevel@tonic-gate int size; 9770Sstevel@tonic-gate uintptr_t sctp; 9780Sstevel@tonic-gate sctp_tf_t *fanout; 9790Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9800Sstevel@tonic-gate } fanout_walk_data_t; 9810Sstevel@tonic-gate 9820Sstevel@tonic-gate typedef struct fanout_init { 983*3448Sdh155122 const char *nested_walker_name; 984*3448Sdh155122 size_t offset; /* for what used to be a symbol */ 985*3448Sdh155122 int (*getsize)(sctp_stack_t *); 9860Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9870Sstevel@tonic-gate } fanout_init_t; 9880Sstevel@tonic-gate 9890Sstevel@tonic-gate static uintptr_t 9900Sstevel@tonic-gate listen_next(sctp_t *sctp) 9910Sstevel@tonic-gate { 9920Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_listen_hash_next); 9930Sstevel@tonic-gate } 9940Sstevel@tonic-gate 995*3448Sdh155122 /* ARGSUSED */ 9960Sstevel@tonic-gate static int 997*3448Sdh155122 listen_size(sctp_stack_t *sctps) 9980Sstevel@tonic-gate { 9990Sstevel@tonic-gate return (SCTP_LISTEN_FANOUT_SIZE); 10000Sstevel@tonic-gate } 10010Sstevel@tonic-gate 10020Sstevel@tonic-gate static uintptr_t 10030Sstevel@tonic-gate conn_next(sctp_t *sctp) 10040Sstevel@tonic-gate { 10050Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_conn_hash_next); 10060Sstevel@tonic-gate } 10070Sstevel@tonic-gate 10080Sstevel@tonic-gate static int 1009*3448Sdh155122 conn_size(sctp_stack_t *sctps) 10100Sstevel@tonic-gate { 10110Sstevel@tonic-gate int size; 1012*3448Sdh155122 uintptr_t kaddr; 10130Sstevel@tonic-gate 1014*3448Sdh155122 kaddr = (uintptr_t)&sctps->sctps_conn_hash_size; 1015*3448Sdh155122 1016*3448Sdh155122 if (mdb_vread(&size, sizeof (size), kaddr) == -1) { 1017*3448Sdh155122 mdb_warn("can't read 'sctps_conn_hash_size' at %p", kaddr); 10180Sstevel@tonic-gate return (1); 10190Sstevel@tonic-gate } 10200Sstevel@tonic-gate return (size); 10210Sstevel@tonic-gate } 10220Sstevel@tonic-gate 10230Sstevel@tonic-gate static uintptr_t 10240Sstevel@tonic-gate bind_next(sctp_t *sctp) 10250Sstevel@tonic-gate { 10260Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_bind_hash); 10270Sstevel@tonic-gate } 10280Sstevel@tonic-gate 1029*3448Sdh155122 /* ARGSUSED */ 10300Sstevel@tonic-gate static int 1031*3448Sdh155122 bind_size(sctp_stack_t *sctps) 10320Sstevel@tonic-gate { 10330Sstevel@tonic-gate return (SCTP_BIND_FANOUT_SIZE); 10340Sstevel@tonic-gate } 10350Sstevel@tonic-gate 10360Sstevel@tonic-gate static intptr_t 10370Sstevel@tonic-gate find_next_hash_item(fanout_walk_data_t *fw) 10380Sstevel@tonic-gate { 10390Sstevel@tonic-gate sctp_tf_t tf; 10400Sstevel@tonic-gate sctp_t sctp; 10410Sstevel@tonic-gate 10420Sstevel@tonic-gate /* first try to continue down the hash chain */ 10430Sstevel@tonic-gate if (fw->sctp != NULL) { 10440Sstevel@tonic-gate /* try to get next in hash chain */ 10450Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) { 10460Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", fw->sctp); 10470Sstevel@tonic-gate return (NULL); 10480Sstevel@tonic-gate } 10490Sstevel@tonic-gate fw->sctp = fw->getnext(&sctp); 10500Sstevel@tonic-gate if (fw->sctp != NULL) 10510Sstevel@tonic-gate return (fw->sctp); 10520Sstevel@tonic-gate else 10530Sstevel@tonic-gate /* end of chain; go to next bucket */ 10540Sstevel@tonic-gate fw->index++; 10550Sstevel@tonic-gate } 10560Sstevel@tonic-gate 10570Sstevel@tonic-gate /* find a new hash chain, traversing the buckets */ 10580Sstevel@tonic-gate for (; fw->index < fw->size; fw->index++) { 10590Sstevel@tonic-gate /* read the current hash line for an sctp */ 10600Sstevel@tonic-gate if (mdb_vread(&tf, sizeof (tf), 10610Sstevel@tonic-gate (uintptr_t)(fw->fanout + fw->index)) == -1) { 10620Sstevel@tonic-gate mdb_warn("failed to read tf at %p", 10630Sstevel@tonic-gate fw->fanout + fw->index); 10640Sstevel@tonic-gate return (NULL); 10650Sstevel@tonic-gate } 10660Sstevel@tonic-gate if (tf.tf_sctp != NULL) { 10670Sstevel@tonic-gate /* start of a new chain */ 10680Sstevel@tonic-gate fw->sctp = (uintptr_t)tf.tf_sctp; 10690Sstevel@tonic-gate return (fw->sctp); 10700Sstevel@tonic-gate } 10710Sstevel@tonic-gate } 10720Sstevel@tonic-gate return (NULL); 10730Sstevel@tonic-gate } 10740Sstevel@tonic-gate 10750Sstevel@tonic-gate static int 1076*3448Sdh155122 fanout_stack_walk_init(mdb_walk_state_t *wsp) 10770Sstevel@tonic-gate { 10780Sstevel@tonic-gate fanout_walk_data_t *lw; 10790Sstevel@tonic-gate fanout_init_t *fi = wsp->walk_arg; 1080*3448Sdh155122 sctp_stack_t *sctps = (sctp_stack_t *)wsp->walk_addr; 1081*3448Sdh155122 uintptr_t kaddr; 10820Sstevel@tonic-gate 1083*3448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), 1084*3448Sdh155122 wsp->walk_addr + fi->offset) == -1) { 1085*3448Sdh155122 mdb_warn("can't read sctp fanout at %p", 1086*3448Sdh155122 wsp->walk_addr + fi->offset); 10870Sstevel@tonic-gate return (WALK_ERR); 10880Sstevel@tonic-gate } 10890Sstevel@tonic-gate 10900Sstevel@tonic-gate lw = mdb_alloc(sizeof (*lw), UM_SLEEP); 10910Sstevel@tonic-gate lw->index = 0; 1092*3448Sdh155122 lw->size = fi->getsize(sctps); 10930Sstevel@tonic-gate lw->sctp = NULL; 1094*3448Sdh155122 lw->fanout = (sctp_tf_t *)kaddr; 10950Sstevel@tonic-gate lw->getnext = fi->getnext; 10960Sstevel@tonic-gate 10970Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(lw)) == NULL) { 10980Sstevel@tonic-gate return (WALK_DONE); 10990Sstevel@tonic-gate } 11000Sstevel@tonic-gate wsp->walk_data = lw; 11010Sstevel@tonic-gate return (WALK_NEXT); 11020Sstevel@tonic-gate } 11030Sstevel@tonic-gate 11040Sstevel@tonic-gate static int 1105*3448Sdh155122 fanout_stack_walk_step(mdb_walk_state_t *wsp) 11060Sstevel@tonic-gate { 11070Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11080Sstevel@tonic-gate uintptr_t addr = wsp->walk_addr; 11090Sstevel@tonic-gate sctp_t sctp; 11100Sstevel@tonic-gate int status; 11110Sstevel@tonic-gate 11120Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 11130Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", addr); 11140Sstevel@tonic-gate return (WALK_DONE); 11150Sstevel@tonic-gate } 11160Sstevel@tonic-gate 11170Sstevel@tonic-gate status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata); 11180Sstevel@tonic-gate if (status != WALK_NEXT) 11190Sstevel@tonic-gate return (status); 11200Sstevel@tonic-gate 11210Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(fw)) == NULL) 11220Sstevel@tonic-gate return (WALK_DONE); 11230Sstevel@tonic-gate 11240Sstevel@tonic-gate return (WALK_NEXT); 11250Sstevel@tonic-gate } 11260Sstevel@tonic-gate 11270Sstevel@tonic-gate static void 1128*3448Sdh155122 fanout_stack_walk_fini(mdb_walk_state_t *wsp) 11290Sstevel@tonic-gate { 11300Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11310Sstevel@tonic-gate 11320Sstevel@tonic-gate mdb_free(fw, sizeof (*fw)); 11330Sstevel@tonic-gate } 11340Sstevel@tonic-gate 1135*3448Sdh155122 int 1136*3448Sdh155122 fanout_walk_init(mdb_walk_state_t *wsp) 11370Sstevel@tonic-gate { 1138*3448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 1139*3448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 1140*3448Sdh155122 return (WALK_ERR); 1141*3448Sdh155122 } 1142*3448Sdh155122 1143*3448Sdh155122 return (WALK_NEXT); 1144*3448Sdh155122 } 1145*3448Sdh155122 1146*3448Sdh155122 int 1147*3448Sdh155122 fanout_walk_step(mdb_walk_state_t *wsp) 1148*3448Sdh155122 { 1149*3448Sdh155122 fanout_init_t *fi = wsp->walk_arg; 1150*3448Sdh155122 1151*3448Sdh155122 if (mdb_pwalk(fi->nested_walker_name, wsp->walk_callback, 1152*3448Sdh155122 wsp->walk_cbdata, wsp->walk_addr) == -1) { 1153*3448Sdh155122 mdb_warn("couldn't walk '%s'for address %p", 1154*3448Sdh155122 fi->nested_walker_name, wsp->walk_addr); 1155*3448Sdh155122 return (WALK_ERR); 1156*3448Sdh155122 } 11570Sstevel@tonic-gate return (WALK_NEXT); 11580Sstevel@tonic-gate } 11590Sstevel@tonic-gate 1160*3448Sdh155122 int 1161*3448Sdh155122 sctps_walk_init(mdb_walk_state_t *wsp) 11620Sstevel@tonic-gate { 11630Sstevel@tonic-gate 1164*3448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 1165*3448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 11660Sstevel@tonic-gate return (WALK_ERR); 11670Sstevel@tonic-gate } 1168*3448Sdh155122 1169*3448Sdh155122 return (WALK_NEXT); 1170*3448Sdh155122 } 11710Sstevel@tonic-gate 1172*3448Sdh155122 int 1173*3448Sdh155122 sctps_walk_step(mdb_walk_state_t *wsp) 1174*3448Sdh155122 { 1175*3448Sdh155122 uintptr_t kaddr; 1176*3448Sdh155122 1177*3448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_list); 1178*3448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 1179*3448Sdh155122 wsp->walk_cbdata, kaddr) == -1) { 1180*3448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", kaddr); 1181*3448Sdh155122 return (WALK_ERR); 11820Sstevel@tonic-gate } 1183*3448Sdh155122 return (WALK_NEXT); 11840Sstevel@tonic-gate } 11850Sstevel@tonic-gate 11860Sstevel@tonic-gate static int 11870Sstevel@tonic-gate sctp_walk_faddr_init(mdb_walk_state_t *wsp) 11880Sstevel@tonic-gate { 11890Sstevel@tonic-gate sctp_t sctp; 11900Sstevel@tonic-gate 11910Sstevel@tonic-gate if (wsp->walk_addr == NULL) 11920Sstevel@tonic-gate return (WALK_ERR); 11930Sstevel@tonic-gate 11940Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) { 11950Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 11960Sstevel@tonic-gate return (WALK_ERR); 11970Sstevel@tonic-gate } 11980Sstevel@tonic-gate if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != NULL) 11990Sstevel@tonic-gate return (WALK_NEXT); 12000Sstevel@tonic-gate else 12010Sstevel@tonic-gate return (WALK_DONE); 12020Sstevel@tonic-gate } 12030Sstevel@tonic-gate 12040Sstevel@tonic-gate static int 12050Sstevel@tonic-gate sctp_walk_faddr_step(mdb_walk_state_t *wsp) 12060Sstevel@tonic-gate { 12070Sstevel@tonic-gate uintptr_t faddr_ptr = wsp->walk_addr; 12080Sstevel@tonic-gate sctp_faddr_t sctp_faddr; 12090Sstevel@tonic-gate int status; 12100Sstevel@tonic-gate 12110Sstevel@tonic-gate if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) { 12120Sstevel@tonic-gate mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr); 12130Sstevel@tonic-gate return (WALK_ERR); 12140Sstevel@tonic-gate } 12150Sstevel@tonic-gate status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata); 12160Sstevel@tonic-gate if (status != WALK_NEXT) 12170Sstevel@tonic-gate return (status); 12180Sstevel@tonic-gate if ((faddr_ptr = (uintptr_t)sctp_faddr.next) == NULL) { 12190Sstevel@tonic-gate return (WALK_DONE); 12200Sstevel@tonic-gate } else { 12210Sstevel@tonic-gate wsp->walk_addr = faddr_ptr; 12220Sstevel@tonic-gate return (WALK_NEXT); 12230Sstevel@tonic-gate } 12240Sstevel@tonic-gate } 12250Sstevel@tonic-gate 12260Sstevel@tonic-gate /* 12270Sstevel@tonic-gate * Helper structure for sctp_walk_saddr. It stores the sctp_t being walked, 12280Sstevel@tonic-gate * the current index to the sctp_saddrs[], and the current count of the 12290Sstevel@tonic-gate * sctp_saddr_ipif_t list. 12300Sstevel@tonic-gate */ 12310Sstevel@tonic-gate typedef struct { 12320Sstevel@tonic-gate sctp_t sctp; 12330Sstevel@tonic-gate int hash_index; 12340Sstevel@tonic-gate int cur_cnt; 12350Sstevel@tonic-gate } saddr_walk_t; 12360Sstevel@tonic-gate 12370Sstevel@tonic-gate static int 12380Sstevel@tonic-gate sctp_walk_saddr_init(mdb_walk_state_t *wsp) 12390Sstevel@tonic-gate { 12400Sstevel@tonic-gate sctp_t *sctp; 12410Sstevel@tonic-gate int i; 12420Sstevel@tonic-gate saddr_walk_t *swalker; 12430Sstevel@tonic-gate 12440Sstevel@tonic-gate if (wsp->walk_addr == NULL) 12450Sstevel@tonic-gate return (WALK_ERR); 12460Sstevel@tonic-gate 12470Sstevel@tonic-gate swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP); 12480Sstevel@tonic-gate sctp = &swalker->sctp; 12490Sstevel@tonic-gate if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) { 12500Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12510Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 12520Sstevel@tonic-gate return (WALK_ERR); 12530Sstevel@tonic-gate } 12540Sstevel@tonic-gate 12550Sstevel@tonic-gate /* Find the first source address. */ 12560Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 12570Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 12580Sstevel@tonic-gate list_t *addr_list; 12590Sstevel@tonic-gate 12600Sstevel@tonic-gate addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list; 12610Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(addr_list, 12620Sstevel@tonic-gate addr_list->list_head.list_next); 12630Sstevel@tonic-gate 12640Sstevel@tonic-gate /* Recode the current info */ 12650Sstevel@tonic-gate swalker->hash_index = i; 12660Sstevel@tonic-gate swalker->cur_cnt = 1; 12670Sstevel@tonic-gate wsp->walk_data = swalker; 12680Sstevel@tonic-gate 12690Sstevel@tonic-gate return (WALK_NEXT); 12700Sstevel@tonic-gate } 12710Sstevel@tonic-gate } 12720Sstevel@tonic-gate return (WALK_DONE); 12730Sstevel@tonic-gate } 12740Sstevel@tonic-gate 12750Sstevel@tonic-gate static int 12760Sstevel@tonic-gate sctp_walk_saddr_step(mdb_walk_state_t *wsp) 12770Sstevel@tonic-gate { 12780Sstevel@tonic-gate uintptr_t saddr_ptr = wsp->walk_addr; 12790Sstevel@tonic-gate sctp_saddr_ipif_t saddr; 12800Sstevel@tonic-gate saddr_walk_t *swalker; 12810Sstevel@tonic-gate sctp_t *sctp; 12820Sstevel@tonic-gate int status; 12830Sstevel@tonic-gate int i, j; 12840Sstevel@tonic-gate 12850Sstevel@tonic-gate if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) { 12860Sstevel@tonic-gate mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr); 12870Sstevel@tonic-gate return (WALK_ERR); 12880Sstevel@tonic-gate } 12890Sstevel@tonic-gate status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata); 12900Sstevel@tonic-gate if (status != WALK_NEXT) 12910Sstevel@tonic-gate return (status); 12920Sstevel@tonic-gate 12930Sstevel@tonic-gate swalker = (saddr_walk_t *)wsp->walk_data; 12940Sstevel@tonic-gate sctp = &swalker->sctp; 12950Sstevel@tonic-gate i = swalker->hash_index; 12960Sstevel@tonic-gate j = swalker->cur_cnt; 12970Sstevel@tonic-gate 12980Sstevel@tonic-gate /* 12990Sstevel@tonic-gate * If there is still a source address in the current list, return it. 13000Sstevel@tonic-gate * Otherwise, go to the next list in the sctp_saddrs[]. 13010Sstevel@tonic-gate */ 13020Sstevel@tonic-gate if (j++ < sctp->sctp_saddrs[i].ipif_count) { 13030Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next; 13040Sstevel@tonic-gate swalker->cur_cnt = j; 13050Sstevel@tonic-gate return (WALK_NEXT); 13060Sstevel@tonic-gate } else { 13070Sstevel@tonic-gate list_t *lst; 13080Sstevel@tonic-gate 13090Sstevel@tonic-gate for (i = i + 1; i < SCTP_IPIF_HASH; i++) { 13100Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 13110Sstevel@tonic-gate lst = &sctp->sctp_saddrs[i].sctp_ipif_list; 13120Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 13130Sstevel@tonic-gate lst, lst->list_head.list_next); 13140Sstevel@tonic-gate swalker->hash_index = i; 13150Sstevel@tonic-gate swalker->cur_cnt = 1; 13160Sstevel@tonic-gate return (WALK_NEXT); 13170Sstevel@tonic-gate } 13180Sstevel@tonic-gate } 13190Sstevel@tonic-gate } 13200Sstevel@tonic-gate return (WALK_DONE); 13210Sstevel@tonic-gate } 13220Sstevel@tonic-gate 13230Sstevel@tonic-gate static void 13240Sstevel@tonic-gate sctp_walk_saddr_fini(mdb_walk_state_t *wsp) 13250Sstevel@tonic-gate { 13260Sstevel@tonic-gate saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data; 13270Sstevel@tonic-gate 13280Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 13290Sstevel@tonic-gate } 13300Sstevel@tonic-gate 1331*3448Sdh155122 1332*3448Sdh155122 typedef struct ill_walk_data { 1333*3448Sdh155122 sctp_ill_hash_t ills[SCTP_ILL_HASH]; 1334*3448Sdh155122 uint32_t count; 1335*3448Sdh155122 } ill_walk_data_t; 1336*3448Sdh155122 1337*3448Sdh155122 typedef struct ipuf_walk_data { 1338*3448Sdh155122 sctp_ipif_hash_t ipifs[SCTP_IPIF_HASH]; 1339*3448Sdh155122 uint32_t count; 1340*3448Sdh155122 } ipif_walk_data_t; 1341*3448Sdh155122 1342*3448Sdh155122 1343*3448Sdh155122 int 1344*3448Sdh155122 sctp_ill_walk_init(mdb_walk_state_t *wsp) 1345*3448Sdh155122 { 1346*3448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 1347*3448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 1348*3448Sdh155122 return (WALK_ERR); 1349*3448Sdh155122 } 1350*3448Sdh155122 1351*3448Sdh155122 return (WALK_NEXT); 1352*3448Sdh155122 } 1353*3448Sdh155122 1354*3448Sdh155122 int 1355*3448Sdh155122 sctp_ill_walk_step(mdb_walk_state_t *wsp) 1356*3448Sdh155122 { 1357*3448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ill", wsp->walk_callback, 1358*3448Sdh155122 wsp->walk_cbdata, wsp->walk_addr) == -1) { 1359*3448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ill' for addr %p", 1360*3448Sdh155122 wsp->walk_addr); 1361*3448Sdh155122 return (WALK_ERR); 1362*3448Sdh155122 } 1363*3448Sdh155122 return (WALK_NEXT); 1364*3448Sdh155122 } 1365*3448Sdh155122 1366*3448Sdh155122 /* 1367*3448Sdh155122 * wsp->walk_addr is the address of sctps_ill_list 1368*3448Sdh155122 */ 13690Sstevel@tonic-gate static int 1370*3448Sdh155122 sctp_stack_ill_walk_init(mdb_walk_state_t *wsp) 13710Sstevel@tonic-gate { 1372*3448Sdh155122 ill_walk_data_t iw; 13730Sstevel@tonic-gate intptr_t i; 1374*3448Sdh155122 uintptr_t kaddr, uaddr; 1375*3448Sdh155122 size_t offset; 1376*3448Sdh155122 1377*3448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_ills_count); 1378*3448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 1379*3448Sdh155122 mdb_warn("can't read sctps_ills_count at %p", kaddr); 1380*3448Sdh155122 return (WALK_ERR); 1381*3448Sdh155122 } 1382*3448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ills); 1383*3448Sdh155122 1384*3448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 1385*3448Sdh155122 mdb_warn("can't read scpts_g_ills %p", kaddr); 1386*3448Sdh155122 return (WALK_ERR); 1387*3448Sdh155122 } 1388*3448Sdh155122 if (mdb_vread(&iw.ills, sizeof (iw.ills), kaddr) == -1) { 1389*3448Sdh155122 mdb_warn("failed to read 'sctps_g_ills'"); 1390*3448Sdh155122 return (NULL); 1391*3448Sdh155122 } 13920Sstevel@tonic-gate 13930Sstevel@tonic-gate /* Find the first ill. */ 13940Sstevel@tonic-gate for (i = 0; i < SCTP_ILL_HASH; i++) { 1395*3448Sdh155122 if (iw.ills[i].ill_count > 0) { 1396*3448Sdh155122 uaddr = (uintptr_t)&iw.ills[i].sctp_ill_list; 1397*3448Sdh155122 offset = uaddr - (uintptr_t)&iw.ills; 1398*3448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 1399*3448Sdh155122 wsp->walk_cbdata, kaddr+offset) == -1) { 1400*3448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 1401*3448Sdh155122 kaddr); 1402*3448Sdh155122 return (WALK_ERR); 14030Sstevel@tonic-gate } 14040Sstevel@tonic-gate } 14050Sstevel@tonic-gate } 14060Sstevel@tonic-gate return (WALK_DONE); 14070Sstevel@tonic-gate } 14080Sstevel@tonic-gate 14090Sstevel@tonic-gate static int 1410*3448Sdh155122 sctp_stack_ill_walk_step(mdb_walk_state_t *wsp) 1411*3448Sdh155122 { 1412*3448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 1413*3448Sdh155122 wsp->walk_cbdata)); 1414*3448Sdh155122 } 1415*3448Sdh155122 1416*3448Sdh155122 int 1417*3448Sdh155122 sctp_ipif_walk_init(mdb_walk_state_t *wsp) 14180Sstevel@tonic-gate { 1419*3448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 1420*3448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 1421*3448Sdh155122 return (WALK_ERR); 1422*3448Sdh155122 } 1423*3448Sdh155122 return (WALK_NEXT); 1424*3448Sdh155122 } 1425*3448Sdh155122 1426*3448Sdh155122 int 1427*3448Sdh155122 sctp_ipif_walk_step(mdb_walk_state_t *wsp) 1428*3448Sdh155122 { 1429*3448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ipif", wsp->walk_callback, 1430*3448Sdh155122 wsp->walk_cbdata, wsp->walk_addr) == -1) { 1431*3448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ipif' for addr %p", 1432*3448Sdh155122 wsp->walk_addr); 1433*3448Sdh155122 return (WALK_ERR); 1434*3448Sdh155122 } 1435*3448Sdh155122 return (WALK_NEXT); 1436*3448Sdh155122 } 1437*3448Sdh155122 1438*3448Sdh155122 /* 1439*3448Sdh155122 * wsp->walk_addr is the address of sctps_ipif_list 1440*3448Sdh155122 */ 1441*3448Sdh155122 static int 1442*3448Sdh155122 sctp_stack_ipif_walk_init(mdb_walk_state_t *wsp) 1443*3448Sdh155122 { 1444*3448Sdh155122 ipif_walk_data_t iw; 14450Sstevel@tonic-gate intptr_t i; 1446*3448Sdh155122 uintptr_t kaddr, uaddr; 1447*3448Sdh155122 size_t offset; 1448*3448Sdh155122 1449*3448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs_count); 1450*3448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 1451*3448Sdh155122 mdb_warn("can't read sctps_g_ipifs_count at %p", kaddr); 1452*3448Sdh155122 return (WALK_ERR); 1453*3448Sdh155122 } 1454*3448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs); 14550Sstevel@tonic-gate 1456*3448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 1457*3448Sdh155122 mdb_warn("can't read scpts_g_ipifs %p", kaddr); 1458*3448Sdh155122 return (WALK_ERR); 1459*3448Sdh155122 } 1460*3448Sdh155122 if (mdb_vread(&iw.ipifs, sizeof (iw.ipifs), kaddr) == -1) { 1461*3448Sdh155122 mdb_warn("failed to read 'sctps_g_ipifs'"); 1462*3448Sdh155122 return (NULL); 1463*3448Sdh155122 } 1464*3448Sdh155122 1465*3448Sdh155122 /* Find the first ipif. */ 14660Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 1467*3448Sdh155122 if (iw.ipifs[i].ipif_count > 0) { 1468*3448Sdh155122 uaddr = (uintptr_t)&iw.ipifs[i].sctp_ipif_list; 1469*3448Sdh155122 offset = uaddr - (uintptr_t)&iw.ipifs; 1470*3448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 1471*3448Sdh155122 wsp->walk_cbdata, kaddr+offset) == -1) { 1472*3448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 1473*3448Sdh155122 kaddr); 1474*3448Sdh155122 return (WALK_ERR); 1475*3448Sdh155122 } 14760Sstevel@tonic-gate } 14770Sstevel@tonic-gate } 14780Sstevel@tonic-gate return (WALK_DONE); 14790Sstevel@tonic-gate } 14800Sstevel@tonic-gate 14810Sstevel@tonic-gate static int 1482*3448Sdh155122 sctp_stack_ipif_walk_step(mdb_walk_state_t *wsp) 14830Sstevel@tonic-gate { 1484*3448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 1485*3448Sdh155122 wsp->walk_cbdata)); 14860Sstevel@tonic-gate } 14870Sstevel@tonic-gate 14880Sstevel@tonic-gate static void 14890Sstevel@tonic-gate sctp_help(void) 14900Sstevel@tonic-gate { 14910Sstevel@tonic-gate mdb_printf("Print information for a given SCTP sctp_t\n\n"); 14920Sstevel@tonic-gate mdb_printf("Options:\n"); 14930Sstevel@tonic-gate mdb_printf("\t-a\t All the information\n"); 14940Sstevel@tonic-gate mdb_printf("\t-f\t Flags\n"); 14950Sstevel@tonic-gate mdb_printf("\t-h\t Hash Tables\n"); 14960Sstevel@tonic-gate mdb_printf("\t-o\t Outbound Data\n"); 14970Sstevel@tonic-gate mdb_printf("\t-i\t Inbound Data\n"); 14980Sstevel@tonic-gate mdb_printf("\t-m\t Miscellaneous Information\n"); 14990Sstevel@tonic-gate mdb_printf("\t-r\t RTT Tracking\n"); 15000Sstevel@tonic-gate mdb_printf("\t-S\t Stats Counters\n"); 15010Sstevel@tonic-gate mdb_printf("\t-F\t Flow Control\n"); 15020Sstevel@tonic-gate mdb_printf("\t-H\t Composite Headers\n"); 15030Sstevel@tonic-gate mdb_printf("\t-p\t PMTUD\n"); 15040Sstevel@tonic-gate mdb_printf("\t-R\t Retransmit Information\n"); 15050Sstevel@tonic-gate mdb_printf("\t-C\t Connection State\n"); 15060Sstevel@tonic-gate mdb_printf("\t-c\t Cleanup / Close\n"); 15070Sstevel@tonic-gate mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n"); 15080Sstevel@tonic-gate mdb_printf("\t-d\t Local and Peer addresses\n"); 15090Sstevel@tonic-gate mdb_printf("\t-P\t Peer addresses\n"); 15100Sstevel@tonic-gate } 15110Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = { 15120Sstevel@tonic-gate { "sctp", ":[-afhoimrSFHpRCcedP]", 15130Sstevel@tonic-gate "display sctp control structure", sctp, sctp_help }, 15140Sstevel@tonic-gate { "sctp_set", ":", "display a SCTP set", sctp_set }, 15150Sstevel@tonic-gate { "sctp_faddr", ":", "display a faddr", sctp_faddr }, 15160Sstevel@tonic-gate { "sctp_istr_msgs", ":", "display msg list on an instream", 15170Sstevel@tonic-gate sctp_istr_msgs }, 15180Sstevel@tonic-gate { "sctp_mdata_chunk", ":", "display a data chunk in an mblk", 15190Sstevel@tonic-gate sctp_mdata_chunk }, 15200Sstevel@tonic-gate { "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list }, 15210Sstevel@tonic-gate { "sctp_instr", ":", "display instr", sctp_instr }, 15220Sstevel@tonic-gate { "sctp_reass_list", ":", "display reass list", sctp_reass_list }, 15230Sstevel@tonic-gate { "sctp_uo_reass_list", ":", "display un-ordered reass list", 15240Sstevel@tonic-gate sctp_uo_reass_list }, 15250Sstevel@tonic-gate { NULL } 15260Sstevel@tonic-gate }; 15270Sstevel@tonic-gate 15280Sstevel@tonic-gate static const fanout_init_t listen_fanout_init = { 1529*3448Sdh155122 "sctp_stack_listen_fanout", OFFSETOF(sctp_stack_t, sctps_listen_fanout), 1530*3448Sdh155122 listen_size, listen_next 15310Sstevel@tonic-gate }; 15320Sstevel@tonic-gate 15330Sstevel@tonic-gate static const fanout_init_t conn_fanout_init = { 1534*3448Sdh155122 "sctp_stack_conn_fanout", OFFSETOF(sctp_stack_t, sctps_conn_fanout), 1535*3448Sdh155122 conn_size, conn_next 15360Sstevel@tonic-gate }; 15370Sstevel@tonic-gate 15380Sstevel@tonic-gate static const fanout_init_t bind_fanout_init = { 1539*3448Sdh155122 "sctp_stack_bind_fanout", OFFSETOF(sctp_stack_t, sctps_bind_fanout), 1540*3448Sdh155122 bind_size, bind_next 15410Sstevel@tonic-gate }; 15420Sstevel@tonic-gate 15430Sstevel@tonic-gate static const mdb_walker_t walkers[] = { 1544*3448Sdh155122 { "sctps", "walk the full chain of sctps for all stacks", 1545*3448Sdh155122 sctps_walk_init, sctps_walk_step, NULL }, 1546*3448Sdh155122 { "sctp_listen_fanout", "walk the sctp listen fanout for all stacks", 1547*3448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 15480Sstevel@tonic-gate (void *)&listen_fanout_init }, 1549*3448Sdh155122 { "sctp_conn_fanout", "walk the sctp conn fanout for all stacks", 1550*3448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 15510Sstevel@tonic-gate (void *)&conn_fanout_init }, 1552*3448Sdh155122 { "sctp_bind_fanout", "walk the sctp bind fanout for all stacks", 1553*3448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 1554*3448Sdh155122 (void *)&bind_fanout_init }, 1555*3448Sdh155122 { "sctp_stack_listen_fanout", 1556*3448Sdh155122 "walk the sctp listen fanout for one stack", 1557*3448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 1558*3448Sdh155122 fanout_stack_walk_fini, 1559*3448Sdh155122 (void *)&listen_fanout_init }, 1560*3448Sdh155122 { "sctp_stack_conn_fanout", "walk the sctp conn fanout for one stack", 1561*3448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 1562*3448Sdh155122 fanout_stack_walk_fini, 1563*3448Sdh155122 (void *)&conn_fanout_init }, 1564*3448Sdh155122 { "sctp_stack_bind_fanout", "walk the sctp bind fanoutfor one stack", 1565*3448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 1566*3448Sdh155122 fanout_stack_walk_fini, 15670Sstevel@tonic-gate (void *)&bind_fanout_init }, 15680Sstevel@tonic-gate { "sctp_walk_faddr", "walk the peer address list of a given sctp_t", 15690Sstevel@tonic-gate sctp_walk_faddr_init, sctp_walk_faddr_step, NULL }, 15700Sstevel@tonic-gate { "sctp_walk_saddr", "walk the local address list of a given sctp_t", 15710Sstevel@tonic-gate sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini }, 1572*3448Sdh155122 { "sctp_walk_ill", "walk the sctp_g_ills list for all stacks", 1573*3448Sdh155122 sctp_ill_walk_init, sctp_ill_walk_step, NULL }, 1574*3448Sdh155122 { "sctp_walk_ipif", "walk the sctp_g_ipif list for all stacks", 1575*3448Sdh155122 sctp_ipif_walk_init, sctp_ipif_walk_step, NULL }, 1576*3448Sdh155122 { "sctp_stack_walk_ill", "walk the sctp_g_ills list for one stack", 1577*3448Sdh155122 sctp_stack_ill_walk_init, sctp_stack_ill_walk_step, NULL }, 1578*3448Sdh155122 { "sctp_stack_walk_ipif", "walk the sctp_g_ipif list for one stack", 1579*3448Sdh155122 sctp_stack_ipif_walk_init, sctp_stack_ipif_walk_step, NULL }, 1580*3448Sdh155122 { "sctp_stacks", "walk all the sctp_stack_t", 1581*3448Sdh155122 sctp_stacks_walk_init, sctp_stacks_walk_step, NULL }, 15820Sstevel@tonic-gate { NULL } 15830Sstevel@tonic-gate }; 15840Sstevel@tonic-gate 15850Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers }; 15860Sstevel@tonic-gate 15870Sstevel@tonic-gate const mdb_modinfo_t * 15880Sstevel@tonic-gate _mdb_init(void) 15890Sstevel@tonic-gate { 15900Sstevel@tonic-gate return (&modinfo); 15910Sstevel@tonic-gate } 1592