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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 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 uint_t sctp_conn_hash_size; 690Sstevel@tonic-gate static GElf_Sym sctp_list_sym; 700Sstevel@tonic-gate static list_t sctp_list; 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * Both the ill and ipif global arrays are small, so we just read 740Sstevel@tonic-gate * in the whole arrays. 750Sstevel@tonic-gate */ 760Sstevel@tonic-gate static sctp_ill_hash_t local_g_ills[SCTP_ILL_HASH]; 770Sstevel@tonic-gate static sctp_ipif_hash_t local_g_ipifs[SCTP_IPIF_HASH]; 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * Copy from usr/src/uts/common/os/list.c. Should we have a generic 810Sstevel@tonic-gate * mdb list walker? 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate #define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset)) 840Sstevel@tonic-gate 85432Svi117747 static char * 86432Svi117747 sctp_faddr_state(int state) 87432Svi117747 { 88432Svi117747 char *statestr; 89432Svi117747 90432Svi117747 switch (state) { 91432Svi117747 case SCTP_FADDRS_UNREACH: 92432Svi117747 statestr = "Unreachable"; 93432Svi117747 break; 94432Svi117747 case SCTP_FADDRS_DOWN: 95432Svi117747 statestr = "Down"; 96432Svi117747 break; 97432Svi117747 case SCTP_FADDRS_ALIVE: 98432Svi117747 statestr = "Alive"; 99432Svi117747 break; 100432Svi117747 case SCTP_FADDRS_UNCONFIRMED: 101432Svi117747 statestr = "Unconfirmed"; 102432Svi117747 break; 103432Svi117747 default: 104432Svi117747 statestr = "Unknown"; 105432Svi117747 break; 106432Svi117747 } 107432Svi117747 return (statestr); 108432Svi117747 } 109432Svi117747 1100Sstevel@tonic-gate /* ARGSUSED */ 1110Sstevel@tonic-gate static int 1120Sstevel@tonic-gate sctp_faddr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1130Sstevel@tonic-gate { 1140Sstevel@tonic-gate sctp_faddr_t fa[1]; 1150Sstevel@tonic-gate char *statestr; 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1180Sstevel@tonic-gate return (DCMD_USAGE); 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate if (mdb_vread(fa, sizeof (*fa), addr) == -1) { 1210Sstevel@tonic-gate mdb_warn("cannot read fadder at %p", addr); 1220Sstevel@tonic-gate return (DCMD_ERR); 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate 125432Svi117747 statestr = sctp_faddr_state(fa->state); 1260Sstevel@tonic-gate mdb_printf("%<u>%p\t%<b>%N%</b>\t%s%</u>\n", addr, &fa->faddr, 1270Sstevel@tonic-gate statestr); 1280Sstevel@tonic-gate mdb_printf("next\t\t%?p\tsaddr\t%N\n", fa->next, &fa->saddr); 1290Sstevel@tonic-gate mdb_printf("rto\t\t%?d\tsrtt\t\t%?d\n", fa->rto, fa->srtt); 1300Sstevel@tonic-gate mdb_printf("rttvar\t\t%?d\trtt_updates\t%?u\n", fa->rttvar, 1310Sstevel@tonic-gate fa->rtt_updates); 1320Sstevel@tonic-gate mdb_printf("strikes\t\t%?d\tmax_retr\t%?d\n", fa->strikes, 1330Sstevel@tonic-gate fa->max_retr); 1340Sstevel@tonic-gate mdb_printf("hb_expiry\t%?ld\thb_interval\t%?u\n", fa->hb_expiry, 1350Sstevel@tonic-gate fa->hb_interval); 1360Sstevel@tonic-gate mdb_printf("pmss\t\t%?u\tcwnd\t\t%?u\n", fa->sfa_pmss, fa->cwnd); 1370Sstevel@tonic-gate mdb_printf("ssthresh\t%?u\tsuna\t\t%?u\n", fa->ssthresh, fa->suna); 1380Sstevel@tonic-gate mdb_printf("pba\t\t%?u\tacked\t\t%?u\n", fa->pba, fa->acked); 1390Sstevel@tonic-gate mdb_printf("lastactive\t%?ld\thb_secret\t%?#lx\n", fa->lastactive, 1400Sstevel@tonic-gate fa->hb_secret); 1410Sstevel@tonic-gate mdb_printf("timer_mp\t%?p\tire\t\t%?p\n", fa->timer_mp, fa->ire); 1420Sstevel@tonic-gate mdb_printf("hb_pending\t%?d\ttimer_running\t%?d\n" 1430Sstevel@tonic-gate "df\t\t%?d\tpmtu_discovered\t%?d\n" 1440Sstevel@tonic-gate "isv4\t\t%?d\tretransmissions\t%?u\n", 1450Sstevel@tonic-gate fa->hb_pending, fa->timer_running, fa->df, fa->pmtu_discovered, 1460Sstevel@tonic-gate fa->isv4, fa->T3expire); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate return (DCMD_OK); 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate static void 1520Sstevel@tonic-gate print_set(sctp_set_t *sp) 1530Sstevel@tonic-gate { 1540Sstevel@tonic-gate mdb_printf("\tbegin\t%<b>%?x%</b>\t\tend\t%<b>%?x%</b>\n", 1550Sstevel@tonic-gate sp->begin, sp->end); 1560Sstevel@tonic-gate mdb_printf("\tnext\t%?p\tprev\t%?p\n", sp->next, sp->prev); 1570Sstevel@tonic-gate } 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* ARGSUSED */ 1600Sstevel@tonic-gate static int 1610Sstevel@tonic-gate sctp_set(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1620Sstevel@tonic-gate { 1630Sstevel@tonic-gate sctp_set_t sp[1]; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1660Sstevel@tonic-gate return (DCMD_USAGE); 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) 1690Sstevel@tonic-gate return (DCMD_ERR); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate print_set(sp); 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate return (DCMD_OK); 1740Sstevel@tonic-gate } 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate static void 1770Sstevel@tonic-gate dump_sack_info(uintptr_t addr) 1780Sstevel@tonic-gate { 1790Sstevel@tonic-gate sctp_set_t sp[1]; 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate while (addr != 0) { 1820Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) { 1830Sstevel@tonic-gate mdb_warn("failed to read sctp_set at %p", addr); 1840Sstevel@tonic-gate return; 1850Sstevel@tonic-gate } 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate addr = (uintptr_t)sp->next; 1880Sstevel@tonic-gate print_set(sp); 1890Sstevel@tonic-gate } 1900Sstevel@tonic-gate } 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate static int 1930Sstevel@tonic-gate dump_msghdr(mblk_t *meta) 1940Sstevel@tonic-gate { 1950Sstevel@tonic-gate sctp_msg_hdr_t smh; 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate if (mdb_vread(&smh, sizeof (smh), (uintptr_t)meta->b_rptr) == -1) 1980Sstevel@tonic-gate return (-1); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate mdb_printf("%<u>msg_hdr_t at \t%?p\tsentto\t%?p%</u>\n", 2010Sstevel@tonic-gate meta->b_rptr, SCTP_CHUNK_DEST(meta)); 2020Sstevel@tonic-gate mdb_printf("\tttl\t%?ld\ttob\t%?ld\n", smh.smh_ttl, smh.smh_tob); 2030Sstevel@tonic-gate mdb_printf("\tsid\t%?u\tssn\t%?u\n", smh.smh_sid, smh.smh_ssn); 2040Sstevel@tonic-gate mdb_printf("\tppid\t%?u\tflags\t%?s\n", smh.smh_ppid, 2050Sstevel@tonic-gate smh.smh_flags & MSG_UNORDERED ? "unordered" : " "); 2060Sstevel@tonic-gate mdb_printf("\tcontext\t%?u\tmsglen\t%?d\n", smh.smh_context, 2070Sstevel@tonic-gate smh.smh_msglen); 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate return (0); 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate static int 2130Sstevel@tonic-gate dump_datahdr(mblk_t *mp) 2140Sstevel@tonic-gate { 2150Sstevel@tonic-gate sctp_data_hdr_t sdc; 2160Sstevel@tonic-gate uint16_t sdh_int16; 2170Sstevel@tonic-gate uint32_t sdh_int32; 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate if (mdb_vread(&sdc, sizeof (sdc), (uintptr_t)mp->b_rptr) == -1) 2200Sstevel@tonic-gate return (-1); 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate mdb_printf("%<u>data_chunk_t \t%?p\tsentto\t%?p%</u>\n", 2230Sstevel@tonic-gate mp->b_rptr, SCTP_CHUNK_DEST(mp)); 2240Sstevel@tonic-gate mdb_printf("\tsent\t%?d\t", SCTP_CHUNK_ISSENT(mp)?1:0); 2250Sstevel@tonic-gate mdb_printf("retrans\t%?d\n", SCTP_CHUNK_WANT_REXMIT(mp)?1:0); 2260Sstevel@tonic-gate mdb_printf("\tacked\t%?d\t", SCTP_CHUNK_ISACKED(mp)?1:0); 2270Sstevel@tonic-gate mdb_printf("sackcnt\t%?u\n", SCTP_CHUNK_SACKCNT(mp)); 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_len, sizeof (sdc.sdh_len)); 2300Sstevel@tonic-gate mdb_printf("\tlen\t%?d\t", sdh_int16); 2310Sstevel@tonic-gate mdb_printf("BBIT=%d", SCTP_DATA_GET_BBIT(&sdc) == 0 ? 0 : 1); 2320Sstevel@tonic-gate mdb_printf("EBIT=%d", SCTP_DATA_GET_EBIT(&sdc) == 0 ? 0 : 1); 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_tsn, sizeof (sdc.sdh_tsn)); 2350Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_sid, sizeof (sdc.sdh_sid)); 2360Sstevel@tonic-gate mdb_printf("\ttsn\t%?x\tsid\t%?hu\n", sdh_int32, sdh_int16); 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_ssn, sizeof (sdc.sdh_ssn)); 2390Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_payload_id, 2400Sstevel@tonic-gate sizeof (sdc.sdh_payload_id)); 2410Sstevel@tonic-gate mdb_printf("\tssn\t%?hu\tppid\t%?d\n", sdh_int16, sdh_int32); 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate return (0); 2440Sstevel@tonic-gate } 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate static int 2470Sstevel@tonic-gate sctp_sent_list(mblk_t *addr) 2480Sstevel@tonic-gate { 2490Sstevel@tonic-gate mblk_t meta, mp; 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate if (!addr) 2520Sstevel@tonic-gate return (0); 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 2550Sstevel@tonic-gate return (-1); 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate for (;;) { 2580Sstevel@tonic-gate dump_msghdr(&meta); 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate if (meta.b_cont == NULL) { 2610Sstevel@tonic-gate mdb_printf("No data chunks with message header!\n"); 2620Sstevel@tonic-gate return (-1); 2630Sstevel@tonic-gate } 2640Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2650Sstevel@tonic-gate (uintptr_t)meta.b_cont) == -1) { 2660Sstevel@tonic-gate return (-1); 2670Sstevel@tonic-gate } 2680Sstevel@tonic-gate for (;;) { 2690Sstevel@tonic-gate dump_datahdr(&mp); 2700Sstevel@tonic-gate if (!mp.b_next) 2710Sstevel@tonic-gate break; 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2740Sstevel@tonic-gate (uintptr_t)(mp.b_next)) == -1) 2750Sstevel@tonic-gate return (-1); 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate if (meta.b_next == NULL) 2780Sstevel@tonic-gate break; 2790Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 2800Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 2810Sstevel@tonic-gate return (-1); 2820Sstevel@tonic-gate } 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate return (0); 2850Sstevel@tonic-gate } 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate static int 2880Sstevel@tonic-gate sctp_unsent_list(mblk_t *addr) 2890Sstevel@tonic-gate { 2900Sstevel@tonic-gate mblk_t meta; 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate if (!addr) 2930Sstevel@tonic-gate return (0); 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 2960Sstevel@tonic-gate return (-1); 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate for (;;) { 2990Sstevel@tonic-gate dump_msghdr(&meta); 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate if (meta.b_next == NULL) 3020Sstevel@tonic-gate break; 3030Sstevel@tonic-gate 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 /* ARGSUSED */ 3130Sstevel@tonic-gate static int 3140Sstevel@tonic-gate sctp_xmit_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3150Sstevel@tonic-gate { 3160Sstevel@tonic-gate sctp_t sctp; 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3190Sstevel@tonic-gate return (DCMD_USAGE); 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) 3220Sstevel@tonic-gate return (DCMD_ERR); 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate mdb_printf("%<b>Chunkified TX list%</b>\n"); 3250Sstevel@tonic-gate if (sctp_sent_list(sctp.sctp_xmit_head) < 0) 3260Sstevel@tonic-gate return (DCMD_ERR); 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate mdb_printf("%<b>Unchunkified TX list%</b>\n"); 3290Sstevel@tonic-gate if (sctp_unsent_list(sctp.sctp_xmit_unsent) < 0) 3300Sstevel@tonic-gate return (DCMD_ERR); 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate return (DCMD_OK); 3330Sstevel@tonic-gate } 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate /* ARGSUSED */ 3360Sstevel@tonic-gate static int 3370Sstevel@tonic-gate sctp_mdata_chunk(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3380Sstevel@tonic-gate { 3390Sstevel@tonic-gate sctp_data_hdr_t dc; 3400Sstevel@tonic-gate mblk_t mp; 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3430Sstevel@tonic-gate return (DCMD_USAGE); 3440Sstevel@tonic-gate 3450Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), addr) == -1) 3460Sstevel@tonic-gate return (DCMD_ERR); 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate if (mdb_vread(&dc, sizeof (dc), (uintptr_t)mp.b_rptr) == -1) 3490Sstevel@tonic-gate return (DCMD_ERR); 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>tsn\t%?x\tsid\t%?hu\n", addr, 3520Sstevel@tonic-gate dc.sdh_tsn, dc.sdh_sid); 3530Sstevel@tonic-gate mdb_printf("%-?sssn\t%?hu\tppid\t%?x\n", "", dc.sdh_ssn, 3540Sstevel@tonic-gate dc.sdh_payload_id); 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate return (DCMD_OK); 3570Sstevel@tonic-gate } 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate /* ARGSUSED */ 3600Sstevel@tonic-gate static int 3610Sstevel@tonic-gate sctp_istr_msgs(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3620Sstevel@tonic-gate { 3630Sstevel@tonic-gate mblk_t istrmp; 3640Sstevel@tonic-gate mblk_t dmp; 3650Sstevel@tonic-gate sctp_data_hdr_t dp; 3660Sstevel@tonic-gate uintptr_t daddr; 3670Sstevel@tonic-gate uintptr_t chaddr; 3680Sstevel@tonic-gate boolean_t bbit; 3690Sstevel@tonic-gate boolean_t ebit; 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3720Sstevel@tonic-gate return (DCMD_USAGE); 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate do { 3750Sstevel@tonic-gate if (mdb_vread(&istrmp, sizeof (istrmp), addr) == -1) 3760Sstevel@tonic-gate return (DCMD_ERR); 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate mdb_printf("\tistr mblk at %p: next: %?p\n" 3790Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, istrmp.b_next, 3800Sstevel@tonic-gate istrmp.b_prev, istrmp.b_cont); 3810Sstevel@tonic-gate daddr = (uintptr_t)&istrmp; 3820Sstevel@tonic-gate do { 3830Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 3840Sstevel@tonic-gate break; 3850Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 3860Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 3870Sstevel@tonic-gate break; 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 3900Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 3910Sstevel@tonic-gate 3920Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 3930Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 3970Sstevel@tonic-gate } while (daddr != NULL); 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate addr = (uintptr_t)istrmp.b_next; 4000Sstevel@tonic-gate } while (addr != NULL); 4010Sstevel@tonic-gate 4020Sstevel@tonic-gate return (DCMD_OK); 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate /* ARGSUSED */ 4060Sstevel@tonic-gate static int 4070Sstevel@tonic-gate sctp_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4080Sstevel@tonic-gate { 4090Sstevel@tonic-gate sctp_reass_t srp; 4100Sstevel@tonic-gate mblk_t srpmp; 4110Sstevel@tonic-gate sctp_data_hdr_t dp; 4120Sstevel@tonic-gate mblk_t dmp; 4130Sstevel@tonic-gate uintptr_t daddr; 4140Sstevel@tonic-gate uintptr_t chaddr; 4150Sstevel@tonic-gate boolean_t bbit, ebit; 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4180Sstevel@tonic-gate return (DCMD_USAGE); 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate do { 4210Sstevel@tonic-gate if (mdb_vread(&srpmp, sizeof (srpmp), addr) == -1) 4220Sstevel@tonic-gate return (DCMD_ERR); 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate if (mdb_vread(&srp, sizeof (srp), 4250Sstevel@tonic-gate (uintptr_t)srpmp.b_datap->db_base) == -1) 4260Sstevel@tonic-gate return (DCMD_ERR); 4270Sstevel@tonic-gate 4280Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 4290Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, srpmp.b_next, 4300Sstevel@tonic-gate srpmp.b_prev, srpmp.b_cont); 4310Sstevel@tonic-gate mdb_printf("\t\tssn: %hu\tneeded: %hu\tgot: %hu\ttail: %?p\n" 4320Sstevel@tonic-gate "\t\tpartial_delivered: %s\n", srp.ssn, srp.needed, 4330Sstevel@tonic-gate srp.got, srp.tail, srp.partial_delivered ? "TRUE" : 4340Sstevel@tonic-gate "FALSE"); 4350Sstevel@tonic-gate 4360Sstevel@tonic-gate /* display the contents of this ssn's reassemby list */ 4370Sstevel@tonic-gate daddr = DB_TYPE(&srpmp) == M_CTL ? (uintptr_t)srpmp.b_cont : 4380Sstevel@tonic-gate (uintptr_t)&srpmp; 4390Sstevel@tonic-gate do { 4400Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4410Sstevel@tonic-gate break; 4420Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4430Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4440Sstevel@tonic-gate break; 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4470Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4500Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4530Sstevel@tonic-gate } while (daddr != NULL); 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate addr = (uintptr_t)srpmp.b_next; 4560Sstevel@tonic-gate } while (addr != NULL); 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate return (DCMD_OK); 4590Sstevel@tonic-gate } 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate /* ARGSUSED */ 4620Sstevel@tonic-gate static int 4630Sstevel@tonic-gate sctp_uo_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4640Sstevel@tonic-gate { 4650Sstevel@tonic-gate sctp_data_hdr_t dp; 4660Sstevel@tonic-gate mblk_t dmp; 4670Sstevel@tonic-gate uintptr_t chaddr; 4680Sstevel@tonic-gate boolean_t bbit; 4690Sstevel@tonic-gate boolean_t ebit; 4700Sstevel@tonic-gate boolean_t ubit; 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4730Sstevel@tonic-gate return (DCMD_USAGE); 4740Sstevel@tonic-gate 4750Sstevel@tonic-gate do { 4760Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), addr) == -1) 4770Sstevel@tonic-gate return (DCMD_ERR); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 4800Sstevel@tonic-gate "\t\tprev: %?p\n", addr, dmp.b_next, dmp.b_prev); 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4830Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4840Sstevel@tonic-gate break; 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4870Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4880Sstevel@tonic-gate ubit = (SCTP_DATA_GET_UBIT(&dp) != 0); 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate mdb_printf("\t\t\tsid: %hu ssn: %hu tsn: %x " 4910Sstevel@tonic-gate "flags: %x (U=%d B=%d E=%d)\n", dp.sdh_sid, dp.sdh_ssn, 4920Sstevel@tonic-gate dp.sdh_tsn, dp.sdh_flags, ubit, bbit, ebit); 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate addr = (uintptr_t)dmp.b_next; 4950Sstevel@tonic-gate } while (addr != NULL); 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate return (DCMD_OK); 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate static int 5010Sstevel@tonic-gate sctp_instr(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 5020Sstevel@tonic-gate { 5030Sstevel@tonic-gate sctp_instr_t sip; 5040Sstevel@tonic-gate 5050Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 5060Sstevel@tonic-gate return (DCMD_USAGE); 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate if (mdb_vread(&sip, sizeof (sip), addr) == -1) 5090Sstevel@tonic-gate return (DCMD_ERR); 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>\n\tmsglist\t%?p\tnmsgs\t%?d\n" 5120Sstevel@tonic-gate "\tnextseq\t%?d\treass\t%?p\n", addr, sip.istr_msgs, 5130Sstevel@tonic-gate sip.istr_nmsgs, sip.nextseq, sip.istr_reass); 5140Sstevel@tonic-gate mdb_set_dot(addr + sizeof (sip)); 5150Sstevel@tonic-gate 5160Sstevel@tonic-gate return (sctp_reass_list((uintptr_t)sip.istr_reass, flags, ac, av)); 5170Sstevel@tonic-gate } 5180Sstevel@tonic-gate 5190Sstevel@tonic-gate static const char * 5200Sstevel@tonic-gate state2str(sctp_t *sctp) 5210Sstevel@tonic-gate { 5220Sstevel@tonic-gate switch (sctp->sctp_state) { 5230Sstevel@tonic-gate case SCTPS_IDLE: return ("SCTPS_IDLE"); 5240Sstevel@tonic-gate case SCTPS_BOUND: return ("SCTPS_BOUND"); 5250Sstevel@tonic-gate case SCTPS_LISTEN: return ("SCTPS_LISTEN"); 5260Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: return ("SCTPS_COOKIE_WAIT"); 5270Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED: return ("SCTPS_COOKIE_ECHOED"); 5280Sstevel@tonic-gate case SCTPS_ESTABLISHED: return ("SCTPS_ESTABLISHED"); 5290Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: return ("SCTPS_SHUTDOWN_PENDING"); 5300Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: return ("SCTPS_SHUTDOWN_SENT"); 5310Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED: return ("SCTPS_SHUTDOWN_RECEIVED"); 5320Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: return ("SCTPS_SHUTDOWN_ACK_SENT"); 5330Sstevel@tonic-gate default: return ("UNKNOWN STATE"); 5340Sstevel@tonic-gate } 5350Sstevel@tonic-gate } 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate static void 5380Sstevel@tonic-gate show_sctp_flags(sctp_t *sctp) 5390Sstevel@tonic-gate { 5400Sstevel@tonic-gate mdb_printf("\tunderstands_asconf\t%d\n", 5410Sstevel@tonic-gate sctp->sctp_understands_asconf); 5420Sstevel@tonic-gate mdb_printf("\tdebug\t\t\t%d\n", sctp->sctp_debug); 5430Sstevel@tonic-gate mdb_printf("\tdontroute\t\t%d\n", sctp->sctp_dontroute); 5440Sstevel@tonic-gate mdb_printf("\tbroadcast\t\t%d\n", sctp->sctp_broadcast); 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate mdb_printf("\tuseloopback\t\t%d\n", sctp->sctp_useloopback); 5470Sstevel@tonic-gate mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend); 5480Sstevel@tonic-gate mdb_printf("\tdgram_errind\t\t%d\n", sctp->sctp_dgram_errind); 5490Sstevel@tonic-gate mdb_printf("\treuseaddr\t\t%d\n", sctp->sctp_reuseaddr); 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_linger); 5520Sstevel@tonic-gate if (sctp->sctp_lingering) 5530Sstevel@tonic-gate return; 5540Sstevel@tonic-gate mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering); 5550Sstevel@tonic-gate mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback); 5560Sstevel@tonic-gate mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack); 5570Sstevel@tonic-gate 5580Sstevel@tonic-gate mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running); 5590Sstevel@tonic-gate mdb_printf("\trecvdstaddr\t\t%d\n", sctp->sctp_recvdstaddr); 5600Sstevel@tonic-gate mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum); 5610Sstevel@tonic-gate mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip); 5620Sstevel@tonic-gate 5630Sstevel@tonic-gate mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all); 5640Sstevel@tonic-gate mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep); 5650Sstevel@tonic-gate mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached); 5660Sstevel@tonic-gate mdb_printf("\tsend_adaption\t\t%d\n", sctp->sctp_send_adaption); 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate mdb_printf("\trecv_adaption\t\t%d\n", sctp->sctp_recv_adaption); 5690Sstevel@tonic-gate mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay); 5700Sstevel@tonic-gate mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned); 5710Sstevel@tonic-gate mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit); 5720Sstevel@tonic-gate mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware); 573432Svi117747 mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal); 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo); 5760Sstevel@tonic-gate mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt); 5770Sstevel@tonic-gate mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt); 5780Sstevel@tonic-gate mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt); 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr); 5810Sstevel@tonic-gate mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt); 5820Sstevel@tonic-gate mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt); 5830Sstevel@tonic-gate mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt); 5840Sstevel@tonic-gate } 5850Sstevel@tonic-gate 5860Sstevel@tonic-gate /* 5870Sstevel@tonic-gate * Given a sctp_saddr_ipif_t, print out its address. This assumes 5880Sstevel@tonic-gate * that addr contains the sctp_addr_ipif_t structure already and this 5890Sstevel@tonic-gate * function does not need to read it in. 5900Sstevel@tonic-gate */ 5910Sstevel@tonic-gate /* ARGSUSED */ 5920Sstevel@tonic-gate static int 5930Sstevel@tonic-gate print_saddr(uintptr_t ptr, const void *addr, void *cbdata) 5940Sstevel@tonic-gate { 5950Sstevel@tonic-gate sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr; 5960Sstevel@tonic-gate sctp_ipif_t ipif; 5970Sstevel@tonic-gate char *statestr; 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate /* Read in the sctp_ipif object */ 6000Sstevel@tonic-gate if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) == 6010Sstevel@tonic-gate -1) { 6020Sstevel@tonic-gate mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp); 6030Sstevel@tonic-gate return (WALK_ERR); 6040Sstevel@tonic-gate } 6050Sstevel@tonic-gate 6060Sstevel@tonic-gate switch (ipif.sctp_ipif_state) { 6070Sstevel@tonic-gate case SCTP_IPIFS_CONDEMNED: 608432Svi117747 statestr = "Condemned"; 6090Sstevel@tonic-gate break; 6100Sstevel@tonic-gate case SCTP_IPIFS_INVALID: 611432Svi117747 statestr = "Invalid"; 6120Sstevel@tonic-gate break; 6130Sstevel@tonic-gate case SCTP_IPIFS_DOWN: 614432Svi117747 statestr = "Down"; 6150Sstevel@tonic-gate break; 6160Sstevel@tonic-gate case SCTP_IPIFS_UP: 617432Svi117747 statestr = "Up"; 6180Sstevel@tonic-gate break; 6190Sstevel@tonic-gate default: 620432Svi117747 statestr = "Unknown"; 6210Sstevel@tonic-gate break; 6220Sstevel@tonic-gate } 623432Svi117747 mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr, 624432Svi117747 statestr); 625432Svi117747 if (saddr->saddr_ipif_dontsrc == 1) 626432Svi117747 mdb_printf("/Dontsrc"); 627432Svi117747 if (saddr->saddr_ipif_unconfirmed == 1) 628432Svi117747 mdb_printf("/Unconfirmed"); 629432Svi117747 if (saddr->saddr_ipif_delete_pending == 1) 630432Svi117747 mdb_printf("/DeletePending"); 631432Svi117747 mdb_printf(")\n"); 632432Svi117747 mdb_printf("\t\t\tMTU %d id %d zoneid %d IPIF flags %x\n", 6330Sstevel@tonic-gate ipif.sctp_ipif_mtu, ipif.sctp_ipif_id, 634432Svi117747 ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags); 6350Sstevel@tonic-gate return (WALK_NEXT); 6360Sstevel@tonic-gate } 6370Sstevel@tonic-gate 6380Sstevel@tonic-gate /* 6390Sstevel@tonic-gate * Given a sctp_faddr_t, print out its address. This assumes that 6400Sstevel@tonic-gate * addr contains the sctp_faddr_t structure already and this function 6410Sstevel@tonic-gate * does not need to read it in. 6420Sstevel@tonic-gate */ 6430Sstevel@tonic-gate static int 6440Sstevel@tonic-gate print_faddr(uintptr_t ptr, const void *addr, void *cbdata) 6450Sstevel@tonic-gate { 646432Svi117747 char *statestr; 6470Sstevel@tonic-gate sctp_faddr_t *faddr = (sctp_faddr_t *)addr; 6480Sstevel@tonic-gate int *i = cbdata; 6490Sstevel@tonic-gate 650432Svi117747 statestr = sctp_faddr_state(faddr->state); 651432Svi117747 652432Svi117747 mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->faddr, ptr, 653432Svi117747 statestr); 6540Sstevel@tonic-gate return (WALK_NEXT); 6550Sstevel@tonic-gate } 6560Sstevel@tonic-gate 6570Sstevel@tonic-gate int 6580Sstevel@tonic-gate sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 6590Sstevel@tonic-gate { 6600Sstevel@tonic-gate sctp_t sctp; 6610Sstevel@tonic-gate conn_t connp; 6620Sstevel@tonic-gate int i; 6630Sstevel@tonic-gate uint_t opts = 0; 6640Sstevel@tonic-gate uint_t paddr = 0; 6650Sstevel@tonic-gate in_port_t lport, fport; 6660Sstevel@tonic-gate 6670Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 6680Sstevel@tonic-gate return (DCMD_USAGE); 6690Sstevel@tonic-gate 6700Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 6710Sstevel@tonic-gate mdb_warn("failed to read sctp_t at: %p\n", addr); 6720Sstevel@tonic-gate return (DCMD_ERR); 6730Sstevel@tonic-gate } 6740Sstevel@tonic-gate if (mdb_vread(&connp, sizeof (connp), 6750Sstevel@tonic-gate (uintptr_t)sctp.sctp_connp) == -1) { 6760Sstevel@tonic-gate mdb_warn("failed to read conn_t at: %p\n", sctp.sctp_connp); 6770Sstevel@tonic-gate return (DCMD_ERR); 6780Sstevel@tonic-gate } 6790Sstevel@tonic-gate 6800Sstevel@tonic-gate if (mdb_getopts(argc, argv, 6810Sstevel@tonic-gate 'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts, 6820Sstevel@tonic-gate 'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts, 6830Sstevel@tonic-gate 'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts, 6840Sstevel@tonic-gate 'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts, 6850Sstevel@tonic-gate 'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts, 6860Sstevel@tonic-gate 'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts, 6870Sstevel@tonic-gate 'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts, 6880Sstevel@tonic-gate 'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts, 6890Sstevel@tonic-gate 'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts, 6900Sstevel@tonic-gate 'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts, 6910Sstevel@tonic-gate 'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts, 6920Sstevel@tonic-gate 'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts, 6930Sstevel@tonic-gate 'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts, 6940Sstevel@tonic-gate 'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts, 6950Sstevel@tonic-gate 'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts, 6960Sstevel@tonic-gate 'P', MDB_OPT_SETBITS, 1, &paddr, 6970Sstevel@tonic-gate 'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) { 6980Sstevel@tonic-gate return (DCMD_USAGE); 6990Sstevel@tonic-gate } 7000Sstevel@tonic-gate 7010Sstevel@tonic-gate /* non-verbose faddrs, suitable for pipelines to sctp_faddr */ 7020Sstevel@tonic-gate if (paddr != 0) { 7030Sstevel@tonic-gate sctp_faddr_t faddr, *fp; 7040Sstevel@tonic-gate for (fp = sctp.sctp_faddrs; fp != NULL; fp = faddr.next) { 7050Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp) 7060Sstevel@tonic-gate == -1) { 7070Sstevel@tonic-gate mdb_warn("failed to read faddr at %p", 7080Sstevel@tonic-gate fp); 7090Sstevel@tonic-gate return (DCMD_ERR); 7100Sstevel@tonic-gate } 7110Sstevel@tonic-gate mdb_printf("%p\n", fp); 7120Sstevel@tonic-gate } 7130Sstevel@tonic-gate return (DCMD_OK); 7140Sstevel@tonic-gate } 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 7170Sstevel@tonic-gate mdb_nhconvert(&fport, &sctp.sctp_fport, sizeof (fport)); 7180Sstevel@tonic-gate mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% ZONE=%d%</u>", addr, 7190Sstevel@tonic-gate state2str(&sctp), lport, fport, connp.conn_zoneid); 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate if (sctp.sctp_faddrs) { 7220Sstevel@tonic-gate sctp_faddr_t faddr; 7230Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), 7240Sstevel@tonic-gate (uintptr_t)sctp.sctp_faddrs) != -1) 7250Sstevel@tonic-gate mdb_printf("%<u> %N%</u>", &faddr.faddr); 7260Sstevel@tonic-gate } 7270Sstevel@tonic-gate mdb_printf("\n"); 7280Sstevel@tonic-gate 7290Sstevel@tonic-gate if (opts & MDB_SCTP_DUMP_ADDRS) { 7300Sstevel@tonic-gate mdb_printf("%<b>Local and Peer Addresses%</b>\n"); 7310Sstevel@tonic-gate 7320Sstevel@tonic-gate /* Display source addresses */ 7330Sstevel@tonic-gate mdb_printf("nsaddrs\t\t%?d\n", sctp.sctp_nsaddrs); 7340Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr); 7350Sstevel@tonic-gate 7360Sstevel@tonic-gate /* Display peer addresses */ 7370Sstevel@tonic-gate mdb_printf("faddrs\t\t%?p\n", sctp.sctp_faddrs); 7380Sstevel@tonic-gate i = 1; 7390Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr); 7400Sstevel@tonic-gate 7410Sstevel@tonic-gate mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n", 7420Sstevel@tonic-gate sctp.sctp_lastfaddr, sctp.sctp_primary); 7430Sstevel@tonic-gate mdb_printf("current\t\t%?p\tlastdata\t%?p\n", 7440Sstevel@tonic-gate sctp.sctp_current, sctp.sctp_lastdata); 7450Sstevel@tonic-gate } 7460Sstevel@tonic-gate 7470Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_OUT) { 7480Sstevel@tonic-gate mdb_printf("%<b>Outbound Data%</b>\n"); 7490Sstevel@tonic-gate mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n", 7500Sstevel@tonic-gate sctp.sctp_xmit_head, sctp.sctp_xmit_tail); 7510Sstevel@tonic-gate mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n", 7520Sstevel@tonic-gate sctp.sctp_xmit_unsent, sctp.sctp_xmit_unsent_tail); 7530Sstevel@tonic-gate mdb_printf("xmit_unacked\t%?p\n", sctp.sctp_xmit_unacked); 7540Sstevel@tonic-gate mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n", 7550Sstevel@tonic-gate sctp.sctp_unacked, sctp.sctp_unsent); 7560Sstevel@tonic-gate mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n", 7570Sstevel@tonic-gate sctp.sctp_ltsn, sctp.sctp_lastack_rxd); 7580Sstevel@tonic-gate mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n", 7590Sstevel@tonic-gate sctp.sctp_recovery_tsn, sctp.sctp_adv_pap); 7600Sstevel@tonic-gate mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n", 7610Sstevel@tonic-gate sctp.sctp_num_ostr, sctp.sctp_ostrcntrs); 7620Sstevel@tonic-gate 7630Sstevel@tonic-gate mdb_printf("%<b>Default Send Parameters%</b>\n"); 7640Sstevel@tonic-gate mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n", 7650Sstevel@tonic-gate sctp.sctp_def_stream, sctp.sctp_def_flags); 7660Sstevel@tonic-gate mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n", 7670Sstevel@tonic-gate sctp.sctp_def_ppid, sctp.sctp_def_context); 7680Sstevel@tonic-gate mdb_printf("def_timetolive\t%?u\n", 7690Sstevel@tonic-gate sctp.sctp_def_timetolive); 7700Sstevel@tonic-gate } 7710Sstevel@tonic-gate 7720Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_IN) { 7730Sstevel@tonic-gate mdb_printf("%<b>Inbound Data%</b>\n"); 7740Sstevel@tonic-gate mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n", 7750Sstevel@tonic-gate sctp.sctp_sack_info, sctp.sctp_sack_gaps); 7760Sstevel@tonic-gate dump_sack_info((uintptr_t)sctp.sctp_sack_info); 7770Sstevel@tonic-gate mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n", 7780Sstevel@tonic-gate sctp.sctp_ftsn, sctp.sctp_lastacked); 7790Sstevel@tonic-gate mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n", 7800Sstevel@tonic-gate sctp.sctp_istr_nmsgs, sctp.sctp_sack_toggle); 7810Sstevel@tonic-gate mdb_printf("ack_mp\t\t%?p\n", sctp.sctp_ack_mp); 7820Sstevel@tonic-gate mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n", 7830Sstevel@tonic-gate sctp.sctp_num_istr, sctp.sctp_instr); 7840Sstevel@tonic-gate mdb_printf("unord_reass\t%?p\n", sctp.sctp_uo_frags); 7850Sstevel@tonic-gate } 7860Sstevel@tonic-gate 7870Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RTT) { 7880Sstevel@tonic-gate mdb_printf("%<b>RTT Tracking%</b>\n"); 7890Sstevel@tonic-gate mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n", 7900Sstevel@tonic-gate sctp.sctp_rtt_tsn, sctp.sctp_out_time); 7910Sstevel@tonic-gate } 7920Sstevel@tonic-gate 7930Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLOW) { 7940Sstevel@tonic-gate mdb_printf("%<b>Flow Control%</b>\n"); 7950Sstevel@tonic-gate mdb_printf("txmit_hiwater\t%?d\n" 7960Sstevel@tonic-gate "xmit_lowater\t%?d\tfrwnd\t\t%?u\n" 7970Sstevel@tonic-gate "rwnd\t\t%?u\trxqueued\t%?u\n" 7980Sstevel@tonic-gate "cwnd_max\t%?u\n", sctp.sctp_xmit_hiwater, 7990Sstevel@tonic-gate sctp.sctp_xmit_lowater, sctp.sctp_frwnd, 8000Sstevel@tonic-gate sctp.sctp_rwnd, sctp.sctp_rxqueued, sctp.sctp_cwnd_max); 8010Sstevel@tonic-gate } 8020Sstevel@tonic-gate 8030Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HDR) { 8040Sstevel@tonic-gate mdb_printf("%<b>Composite Headers%</b>\n"); 8050Sstevel@tonic-gate mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n" 8060Sstevel@tonic-gate "iphc_len\t%?d\tiphc6_len\t%?d\n" 8070Sstevel@tonic-gate "hdr_len\t\t%?d\thdr6_len\t%?d\n" 8080Sstevel@tonic-gate "ipha\t\t%?p\tip6h\t\t%?p\n" 8090Sstevel@tonic-gate "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n" 8100Sstevel@tonic-gate "sctph\t\t%?p\tsctph6\t\t%?p\n" 8110Sstevel@tonic-gate "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp.sctp_iphc, 8120Sstevel@tonic-gate sctp.sctp_iphc6, sctp.sctp_iphc_len, 8130Sstevel@tonic-gate sctp.sctp_iphc6_len, sctp.sctp_hdr_len, 8140Sstevel@tonic-gate sctp.sctp_hdr6_len, sctp.sctp_ipha, sctp.sctp_ip6h, 8150Sstevel@tonic-gate sctp.sctp_ip_hdr_len, sctp.sctp_ip_hdr6_len, 8160Sstevel@tonic-gate sctp.sctp_sctph, sctp.sctp_sctph6, sctp.sctp_lvtag, 8170Sstevel@tonic-gate sctp.sctp_fvtag); 8180Sstevel@tonic-gate } 8190Sstevel@tonic-gate 8200Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_PMTUD) { 8210Sstevel@tonic-gate mdb_printf("%<b>PMTUd%</b>\n"); 8220Sstevel@tonic-gate mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n" 8230Sstevel@tonic-gate "mss\t\t%?u\n", 8240Sstevel@tonic-gate sctp.sctp_last_mtu_probe, sctp.sctp_mtu_probe_intvl, 8250Sstevel@tonic-gate sctp.sctp_mss); 8260Sstevel@tonic-gate } 8270Sstevel@tonic-gate 8280Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RXT) { 8290Sstevel@tonic-gate mdb_printf("%<b>Retransmit Info%</b>\n"); 8300Sstevel@tonic-gate mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n" 8310Sstevel@tonic-gate "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n" 8320Sstevel@tonic-gate "pp_max_rxt\t%?d\trto_max\t\t%?u\n" 8330Sstevel@tonic-gate "rto_min\t\t%?u\trto_initial\t%?u\n" 8340Sstevel@tonic-gate "init_rto_max\t%?u\n", sctp.sctp_cookie_mp, 8350Sstevel@tonic-gate sctp.sctp_strikes, sctp.sctp_max_init_rxt, 8360Sstevel@tonic-gate sctp.sctp_pa_max_rxt, sctp.sctp_pp_max_rxt, 8370Sstevel@tonic-gate sctp.sctp_rto_max, sctp.sctp_rto_min, 8380Sstevel@tonic-gate sctp.sctp_rto_initial, sctp.sctp_init_rto_max); 8390Sstevel@tonic-gate } 8400Sstevel@tonic-gate 8410Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CONN) { 8420Sstevel@tonic-gate mdb_printf("%<b>Connection State%</b>\n"); 8430Sstevel@tonic-gate mdb_printf("last_secret_update%?ld\n", 8440Sstevel@tonic-gate sctp.sctp_last_secret_update); 8450Sstevel@tonic-gate 8460Sstevel@tonic-gate mdb_printf("secret\t\t"); 8470Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8480Sstevel@tonic-gate if (i % 2 == 0) 8490Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_secret[i]); 8500Sstevel@tonic-gate else 8510Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_secret[i]); 8520Sstevel@tonic-gate } 8530Sstevel@tonic-gate mdb_printf("\n"); 8540Sstevel@tonic-gate mdb_printf("old_secret\t"); 8550Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8560Sstevel@tonic-gate if (i % 2 == 0) 8570Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_old_secret[i]); 8580Sstevel@tonic-gate else 8590Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_old_secret[i]); 8600Sstevel@tonic-gate } 8610Sstevel@tonic-gate mdb_printf("\n"); 8620Sstevel@tonic-gate } 8630Sstevel@tonic-gate 8640Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_STATS) { 8650Sstevel@tonic-gate mdb_printf("%<b>Stats Counters%</b>\n"); 8660Sstevel@tonic-gate mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n" 8670Sstevel@tonic-gate "odchunks\t%?llu\toudchunks\t%?llu\n" 8680Sstevel@tonic-gate "rxtchunks\t%?llu\tT1expire\t%?lu\n" 8690Sstevel@tonic-gate "T2expire\t%?lu\tT3expire\t%?lu\n" 8700Sstevel@tonic-gate "msgcount\t%?llu\tprsctpdrop\t%?llu\n" 8710Sstevel@tonic-gate "AssocStartTime\t%?lu\n", 8720Sstevel@tonic-gate sctp.sctp_opkts, sctp.sctp_obchunks, 8730Sstevel@tonic-gate sctp.sctp_odchunks, sctp.sctp_oudchunks, 8740Sstevel@tonic-gate sctp.sctp_rxtchunks, sctp.sctp_T1expire, 8750Sstevel@tonic-gate sctp.sctp_T2expire, sctp.sctp_T3expire, 8760Sstevel@tonic-gate sctp.sctp_msgcount, sctp.sctp_prsctpdrop, 8770Sstevel@tonic-gate sctp.sctp_assoc_start_time); 8780Sstevel@tonic-gate mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n" 8790Sstevel@tonic-gate "idchunks\t%?llu\tiudchunks\t%?llu\n" 8800Sstevel@tonic-gate "fragdmsgs\t%?llu\treassmsgs\t%?llu\n", 8810Sstevel@tonic-gate sctp.sctp_ipkts, sctp.sctp_ibchunks, 8820Sstevel@tonic-gate sctp.sctp_idchunks, sctp.sctp_iudchunks, 8830Sstevel@tonic-gate sctp.sctp_fragdmsgs, sctp.sctp_reassmsgs); 8840Sstevel@tonic-gate } 8850Sstevel@tonic-gate 8860Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HASH) { 8870Sstevel@tonic-gate mdb_printf("%<b>Hash Tables%</b>\n"); 8880Sstevel@tonic-gate mdb_printf("conn_hash_next\t%?p\t", sctp.sctp_conn_hash_next); 8890Sstevel@tonic-gate mdb_printf("conn_hash_prev\t%?p\n", sctp.sctp_conn_hash_prev); 8900Sstevel@tonic-gate mdb_printf("[ conn_hash bucket\t%?d ]\n", 8910Sstevel@tonic-gate SCTP_CONN_HASH(sctp.sctp_ports)); 8920Sstevel@tonic-gate 8930Sstevel@tonic-gate mdb_printf("listen_hash_next%?p\t", 8940Sstevel@tonic-gate sctp.sctp_listen_hash_next); 8950Sstevel@tonic-gate mdb_printf("listen_hash_prev%?p\n", 8960Sstevel@tonic-gate sctp.sctp_listen_hash_prev); 8970Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 8980Sstevel@tonic-gate mdb_printf("[ listen_hash bucket\t%?d ]\n", 8990Sstevel@tonic-gate SCTP_LISTEN_HASH(lport)); 9000Sstevel@tonic-gate 9010Sstevel@tonic-gate mdb_printf("conn_tfp\t%?p\t", sctp.sctp_conn_tfp); 9020Sstevel@tonic-gate mdb_printf("listen_tfp\t%?p\n", sctp.sctp_listen_tfp); 9030Sstevel@tonic-gate 9040Sstevel@tonic-gate mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n", 9050Sstevel@tonic-gate sctp.sctp_bind_hash, sctp.sctp_ptpbhn); 9060Sstevel@tonic-gate mdb_printf("bind_lockp\t%?p\n", 9070Sstevel@tonic-gate sctp.sctp_bind_lockp); 9080Sstevel@tonic-gate mdb_printf("[ bind_hash bucket\t%?d ]\n", 9090Sstevel@tonic-gate SCTP_BIND_HASH(lport)); 9100Sstevel@tonic-gate } 9110Sstevel@tonic-gate 9120Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CLOSE) { 9130Sstevel@tonic-gate mdb_printf("%<b>Cleanup / Close%</b>\n"); 9140Sstevel@tonic-gate mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n" 9150Sstevel@tonic-gate "lingertime\t%?d\trefcnt\t\t%?hu\n", 9160Sstevel@tonic-gate sctp.sctp_shutdown_faddr, sctp.sctp_client_errno, 9170Sstevel@tonic-gate sctp.sctp_lingertime, sctp.sctp_refcnt); 9180Sstevel@tonic-gate } 9190Sstevel@tonic-gate 9200Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_MISC) { 9210Sstevel@tonic-gate mdb_printf("%<b>Miscellaneous%</b>\n"); 9220Sstevel@tonic-gate mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n" 9230Sstevel@tonic-gate "family\t\t%?u\tipversion\t%?hu\n" 9240Sstevel@tonic-gate "hb_interval\t%?u\tautoclose\t%?d\n" 9250Sstevel@tonic-gate "active\t\t%?ld\ttx_adaption_code%?x\n" 9260Sstevel@tonic-gate "rx_adaption_code%?x\ttimer_mp\t%?p\n", 9270Sstevel@tonic-gate sctp.sctp_bound_if, sctp.sctp_heartbeat_mp, 9280Sstevel@tonic-gate sctp.sctp_family, sctp.sctp_ipversion, 9290Sstevel@tonic-gate sctp.sctp_hb_interval, sctp.sctp_autoclose, 9300Sstevel@tonic-gate sctp.sctp_active, sctp.sctp_tx_adaption_code, 9310Sstevel@tonic-gate sctp.sctp_rx_adaption_code, sctp.sctp_timer_mp); 9320Sstevel@tonic-gate } 9330Sstevel@tonic-gate 9340Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_EXT) { 9350Sstevel@tonic-gate mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n"); 9360Sstevel@tonic-gate mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n" 9370Sstevel@tonic-gate "fcsn\t\t%?x\n", sctp.sctp_cxmit_list, sctp.sctp_lcsn, 9380Sstevel@tonic-gate sctp.sctp_fcsn); 9390Sstevel@tonic-gate } 9400Sstevel@tonic-gate 9410Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLAGS) { 9420Sstevel@tonic-gate mdb_printf("%<b>Flags%</b>\n"); 9430Sstevel@tonic-gate show_sctp_flags(&sctp); 9440Sstevel@tonic-gate } 9450Sstevel@tonic-gate 9460Sstevel@tonic-gate return (DCMD_OK); 9470Sstevel@tonic-gate } 9480Sstevel@tonic-gate 9490Sstevel@tonic-gate typedef struct fanout_walk_data { 9500Sstevel@tonic-gate int index; 9510Sstevel@tonic-gate int size; 9520Sstevel@tonic-gate uintptr_t sctp; 9530Sstevel@tonic-gate sctp_tf_t *fanout; 9540Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9550Sstevel@tonic-gate } fanout_walk_data_t; 9560Sstevel@tonic-gate 9570Sstevel@tonic-gate typedef struct fanout_init { 9580Sstevel@tonic-gate const char *symname; 9590Sstevel@tonic-gate int (*getsize)(); 9600Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9610Sstevel@tonic-gate } fanout_init_t; 9620Sstevel@tonic-gate 9630Sstevel@tonic-gate static uintptr_t 9640Sstevel@tonic-gate listen_next(sctp_t *sctp) 9650Sstevel@tonic-gate { 9660Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_listen_hash_next); 9670Sstevel@tonic-gate } 9680Sstevel@tonic-gate 9690Sstevel@tonic-gate static int 9700Sstevel@tonic-gate listen_size(void) 9710Sstevel@tonic-gate { 9720Sstevel@tonic-gate return (SCTP_LISTEN_FANOUT_SIZE); 9730Sstevel@tonic-gate } 9740Sstevel@tonic-gate 9750Sstevel@tonic-gate static uintptr_t 9760Sstevel@tonic-gate conn_next(sctp_t *sctp) 9770Sstevel@tonic-gate { 9780Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_conn_hash_next); 9790Sstevel@tonic-gate } 9800Sstevel@tonic-gate 9810Sstevel@tonic-gate static int 9820Sstevel@tonic-gate conn_size(void) 9830Sstevel@tonic-gate { 9840Sstevel@tonic-gate GElf_Sym sym; 9850Sstevel@tonic-gate int size; 9860Sstevel@tonic-gate 9870Sstevel@tonic-gate if (mdb_lookup_by_name("sctp_conn_hash_size", &sym) == -1) { 9880Sstevel@tonic-gate mdb_warn("can't read 'sctp_conn_hash_size'"); 9890Sstevel@tonic-gate return (1); 9900Sstevel@tonic-gate } 9910Sstevel@tonic-gate if (mdb_vread(&size, sizeof (size), sym.st_value) == -1) { 9920Sstevel@tonic-gate mdb_warn("can't dereference 'sctp_conn_hash_size'"); 9930Sstevel@tonic-gate return (1); 9940Sstevel@tonic-gate } 9950Sstevel@tonic-gate return (size); 9960Sstevel@tonic-gate } 9970Sstevel@tonic-gate 9980Sstevel@tonic-gate static uintptr_t 9990Sstevel@tonic-gate bind_next(sctp_t *sctp) 10000Sstevel@tonic-gate { 10010Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_bind_hash); 10020Sstevel@tonic-gate } 10030Sstevel@tonic-gate 10040Sstevel@tonic-gate static int 10050Sstevel@tonic-gate bind_size(void) 10060Sstevel@tonic-gate { 10070Sstevel@tonic-gate return (SCTP_BIND_FANOUT_SIZE); 10080Sstevel@tonic-gate } 10090Sstevel@tonic-gate 10100Sstevel@tonic-gate static intptr_t 10110Sstevel@tonic-gate find_next_hash_item(fanout_walk_data_t *fw) 10120Sstevel@tonic-gate { 10130Sstevel@tonic-gate sctp_tf_t tf; 10140Sstevel@tonic-gate sctp_t sctp; 10150Sstevel@tonic-gate 10160Sstevel@tonic-gate /* first try to continue down the hash chain */ 10170Sstevel@tonic-gate if (fw->sctp != NULL) { 10180Sstevel@tonic-gate /* try to get next in hash chain */ 10190Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) { 10200Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", fw->sctp); 10210Sstevel@tonic-gate return (NULL); 10220Sstevel@tonic-gate } 10230Sstevel@tonic-gate fw->sctp = fw->getnext(&sctp); 10240Sstevel@tonic-gate if (fw->sctp != NULL) 10250Sstevel@tonic-gate return (fw->sctp); 10260Sstevel@tonic-gate else 10270Sstevel@tonic-gate /* end of chain; go to next bucket */ 10280Sstevel@tonic-gate fw->index++; 10290Sstevel@tonic-gate } 10300Sstevel@tonic-gate 10310Sstevel@tonic-gate /* find a new hash chain, traversing the buckets */ 10320Sstevel@tonic-gate for (; fw->index < fw->size; fw->index++) { 10330Sstevel@tonic-gate /* read the current hash line for an sctp */ 10340Sstevel@tonic-gate if (mdb_vread(&tf, sizeof (tf), 10350Sstevel@tonic-gate (uintptr_t)(fw->fanout + fw->index)) == -1) { 10360Sstevel@tonic-gate mdb_warn("failed to read tf at %p", 10370Sstevel@tonic-gate fw->fanout + fw->index); 10380Sstevel@tonic-gate return (NULL); 10390Sstevel@tonic-gate } 10400Sstevel@tonic-gate if (tf.tf_sctp != NULL) { 10410Sstevel@tonic-gate /* start of a new chain */ 10420Sstevel@tonic-gate fw->sctp = (uintptr_t)tf.tf_sctp; 10430Sstevel@tonic-gate return (fw->sctp); 10440Sstevel@tonic-gate } 10450Sstevel@tonic-gate } 10460Sstevel@tonic-gate return (NULL); 10470Sstevel@tonic-gate } 10480Sstevel@tonic-gate 10490Sstevel@tonic-gate static int 10500Sstevel@tonic-gate fanout_walk_init(mdb_walk_state_t *wsp) 10510Sstevel@tonic-gate { 10520Sstevel@tonic-gate GElf_Sym sym; 10530Sstevel@tonic-gate fanout_walk_data_t *lw; 10540Sstevel@tonic-gate fanout_init_t *fi = wsp->walk_arg; 10550Sstevel@tonic-gate 10560Sstevel@tonic-gate if (mdb_lookup_by_name(fi->symname, &sym) == -1) { 10570Sstevel@tonic-gate mdb_warn("failed to read '%s'", fi->symname); 10580Sstevel@tonic-gate return (WALK_ERR); 10590Sstevel@tonic-gate } 10600Sstevel@tonic-gate 10610Sstevel@tonic-gate lw = mdb_alloc(sizeof (*lw), UM_SLEEP); 10620Sstevel@tonic-gate lw->index = 0; 10630Sstevel@tonic-gate lw->size = fi->getsize(); 10640Sstevel@tonic-gate lw->sctp = NULL; 1065*436Sdmick lw->fanout = (sctp_tf_t *)(uintptr_t)sym.st_value; 10660Sstevel@tonic-gate lw->getnext = fi->getnext; 10670Sstevel@tonic-gate 10680Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(lw)) == NULL) { 10690Sstevel@tonic-gate return (WALK_DONE); 10700Sstevel@tonic-gate } 10710Sstevel@tonic-gate wsp->walk_data = lw; 10720Sstevel@tonic-gate return (WALK_NEXT); 10730Sstevel@tonic-gate } 10740Sstevel@tonic-gate 10750Sstevel@tonic-gate static int 10760Sstevel@tonic-gate fanout_walk_step(mdb_walk_state_t *wsp) 10770Sstevel@tonic-gate { 10780Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 10790Sstevel@tonic-gate uintptr_t addr = wsp->walk_addr; 10800Sstevel@tonic-gate sctp_t sctp; 10810Sstevel@tonic-gate int status; 10820Sstevel@tonic-gate 10830Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 10840Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", addr); 10850Sstevel@tonic-gate return (WALK_DONE); 10860Sstevel@tonic-gate } 10870Sstevel@tonic-gate 10880Sstevel@tonic-gate status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata); 10890Sstevel@tonic-gate if (status != WALK_NEXT) 10900Sstevel@tonic-gate return (status); 10910Sstevel@tonic-gate 10920Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(fw)) == NULL) 10930Sstevel@tonic-gate return (WALK_DONE); 10940Sstevel@tonic-gate 10950Sstevel@tonic-gate return (WALK_NEXT); 10960Sstevel@tonic-gate } 10970Sstevel@tonic-gate 10980Sstevel@tonic-gate static void 10990Sstevel@tonic-gate fanout_walk_fini(mdb_walk_state_t *wsp) 11000Sstevel@tonic-gate { 11010Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11020Sstevel@tonic-gate 11030Sstevel@tonic-gate mdb_free(fw, sizeof (*fw)); 11040Sstevel@tonic-gate } 11050Sstevel@tonic-gate 11060Sstevel@tonic-gate static int 11070Sstevel@tonic-gate sctp_walk_init(mdb_walk_state_t *wsp) 11080Sstevel@tonic-gate { 11090Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(&sctp_list, 11100Sstevel@tonic-gate sctp_list.list_head.list_next); 11110Sstevel@tonic-gate return (WALK_NEXT); 11120Sstevel@tonic-gate } 11130Sstevel@tonic-gate 11140Sstevel@tonic-gate static int 11150Sstevel@tonic-gate sctp_walk_step(mdb_walk_state_t *wsp) 11160Sstevel@tonic-gate { 11170Sstevel@tonic-gate uintptr_t psctp = wsp->walk_addr; 11180Sstevel@tonic-gate sctp_t sctp; 11190Sstevel@tonic-gate int status; 11200Sstevel@tonic-gate 11210Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), psctp) == -1) { 11220Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", psctp); 11230Sstevel@tonic-gate return (WALK_ERR); 11240Sstevel@tonic-gate } 11250Sstevel@tonic-gate status = wsp->walk_callback(psctp, &sctp, wsp->walk_cbdata); 11260Sstevel@tonic-gate if (status != WALK_NEXT) 11270Sstevel@tonic-gate return (status); 11280Sstevel@tonic-gate 11290Sstevel@tonic-gate if ((psctp = (uintptr_t)sctp.sctp_list.list_next) == 11300Sstevel@tonic-gate sctp_list_sym.st_value + OFFSETOF(list_t, list_head)) { 11310Sstevel@tonic-gate return (WALK_DONE); 11320Sstevel@tonic-gate } else { 11330Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(&sctp_list, psctp); 11340Sstevel@tonic-gate return (WALK_NEXT); 11350Sstevel@tonic-gate } 11360Sstevel@tonic-gate } 11370Sstevel@tonic-gate 11380Sstevel@tonic-gate static int 11390Sstevel@tonic-gate sctp_walk_faddr_init(mdb_walk_state_t *wsp) 11400Sstevel@tonic-gate { 11410Sstevel@tonic-gate sctp_t sctp; 11420Sstevel@tonic-gate 11430Sstevel@tonic-gate if (wsp->walk_addr == NULL) 11440Sstevel@tonic-gate return (WALK_ERR); 11450Sstevel@tonic-gate 11460Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) { 11470Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 11480Sstevel@tonic-gate return (WALK_ERR); 11490Sstevel@tonic-gate } 11500Sstevel@tonic-gate if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != NULL) 11510Sstevel@tonic-gate return (WALK_NEXT); 11520Sstevel@tonic-gate else 11530Sstevel@tonic-gate return (WALK_DONE); 11540Sstevel@tonic-gate } 11550Sstevel@tonic-gate 11560Sstevel@tonic-gate static int 11570Sstevel@tonic-gate sctp_walk_faddr_step(mdb_walk_state_t *wsp) 11580Sstevel@tonic-gate { 11590Sstevel@tonic-gate uintptr_t faddr_ptr = wsp->walk_addr; 11600Sstevel@tonic-gate sctp_faddr_t sctp_faddr; 11610Sstevel@tonic-gate int status; 11620Sstevel@tonic-gate 11630Sstevel@tonic-gate if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) { 11640Sstevel@tonic-gate mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr); 11650Sstevel@tonic-gate return (WALK_ERR); 11660Sstevel@tonic-gate } 11670Sstevel@tonic-gate status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata); 11680Sstevel@tonic-gate if (status != WALK_NEXT) 11690Sstevel@tonic-gate return (status); 11700Sstevel@tonic-gate if ((faddr_ptr = (uintptr_t)sctp_faddr.next) == NULL) { 11710Sstevel@tonic-gate return (WALK_DONE); 11720Sstevel@tonic-gate } else { 11730Sstevel@tonic-gate wsp->walk_addr = faddr_ptr; 11740Sstevel@tonic-gate return (WALK_NEXT); 11750Sstevel@tonic-gate } 11760Sstevel@tonic-gate } 11770Sstevel@tonic-gate 11780Sstevel@tonic-gate /* 11790Sstevel@tonic-gate * Helper structure for sctp_walk_saddr. It stores the sctp_t being walked, 11800Sstevel@tonic-gate * the current index to the sctp_saddrs[], and the current count of the 11810Sstevel@tonic-gate * sctp_saddr_ipif_t list. 11820Sstevel@tonic-gate */ 11830Sstevel@tonic-gate typedef struct { 11840Sstevel@tonic-gate sctp_t sctp; 11850Sstevel@tonic-gate int hash_index; 11860Sstevel@tonic-gate int cur_cnt; 11870Sstevel@tonic-gate } saddr_walk_t; 11880Sstevel@tonic-gate 11890Sstevel@tonic-gate static int 11900Sstevel@tonic-gate sctp_walk_saddr_init(mdb_walk_state_t *wsp) 11910Sstevel@tonic-gate { 11920Sstevel@tonic-gate sctp_t *sctp; 11930Sstevel@tonic-gate int i; 11940Sstevel@tonic-gate saddr_walk_t *swalker; 11950Sstevel@tonic-gate 11960Sstevel@tonic-gate if (wsp->walk_addr == NULL) 11970Sstevel@tonic-gate return (WALK_ERR); 11980Sstevel@tonic-gate 11990Sstevel@tonic-gate swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP); 12000Sstevel@tonic-gate sctp = &swalker->sctp; 12010Sstevel@tonic-gate if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) { 12020Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12030Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 12040Sstevel@tonic-gate return (WALK_ERR); 12050Sstevel@tonic-gate } 12060Sstevel@tonic-gate 12070Sstevel@tonic-gate /* Find the first source address. */ 12080Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 12090Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 12100Sstevel@tonic-gate list_t *addr_list; 12110Sstevel@tonic-gate 12120Sstevel@tonic-gate addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list; 12130Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(addr_list, 12140Sstevel@tonic-gate addr_list->list_head.list_next); 12150Sstevel@tonic-gate 12160Sstevel@tonic-gate /* Recode the current info */ 12170Sstevel@tonic-gate swalker->hash_index = i; 12180Sstevel@tonic-gate swalker->cur_cnt = 1; 12190Sstevel@tonic-gate wsp->walk_data = swalker; 12200Sstevel@tonic-gate 12210Sstevel@tonic-gate return (WALK_NEXT); 12220Sstevel@tonic-gate } 12230Sstevel@tonic-gate } 12240Sstevel@tonic-gate return (WALK_DONE); 12250Sstevel@tonic-gate } 12260Sstevel@tonic-gate 12270Sstevel@tonic-gate static int 12280Sstevel@tonic-gate sctp_walk_saddr_step(mdb_walk_state_t *wsp) 12290Sstevel@tonic-gate { 12300Sstevel@tonic-gate uintptr_t saddr_ptr = wsp->walk_addr; 12310Sstevel@tonic-gate sctp_saddr_ipif_t saddr; 12320Sstevel@tonic-gate saddr_walk_t *swalker; 12330Sstevel@tonic-gate sctp_t *sctp; 12340Sstevel@tonic-gate int status; 12350Sstevel@tonic-gate int i, j; 12360Sstevel@tonic-gate 12370Sstevel@tonic-gate if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) { 12380Sstevel@tonic-gate mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr); 12390Sstevel@tonic-gate return (WALK_ERR); 12400Sstevel@tonic-gate } 12410Sstevel@tonic-gate status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata); 12420Sstevel@tonic-gate if (status != WALK_NEXT) 12430Sstevel@tonic-gate return (status); 12440Sstevel@tonic-gate 12450Sstevel@tonic-gate swalker = (saddr_walk_t *)wsp->walk_data; 12460Sstevel@tonic-gate sctp = &swalker->sctp; 12470Sstevel@tonic-gate i = swalker->hash_index; 12480Sstevel@tonic-gate j = swalker->cur_cnt; 12490Sstevel@tonic-gate 12500Sstevel@tonic-gate /* 12510Sstevel@tonic-gate * If there is still a source address in the current list, return it. 12520Sstevel@tonic-gate * Otherwise, go to the next list in the sctp_saddrs[]. 12530Sstevel@tonic-gate */ 12540Sstevel@tonic-gate if (j++ < sctp->sctp_saddrs[i].ipif_count) { 12550Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next; 12560Sstevel@tonic-gate swalker->cur_cnt = j; 12570Sstevel@tonic-gate return (WALK_NEXT); 12580Sstevel@tonic-gate } else { 12590Sstevel@tonic-gate list_t *lst; 12600Sstevel@tonic-gate 12610Sstevel@tonic-gate for (i = i + 1; i < SCTP_IPIF_HASH; i++) { 12620Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 12630Sstevel@tonic-gate lst = &sctp->sctp_saddrs[i].sctp_ipif_list; 12640Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 12650Sstevel@tonic-gate lst, lst->list_head.list_next); 12660Sstevel@tonic-gate swalker->hash_index = i; 12670Sstevel@tonic-gate swalker->cur_cnt = 1; 12680Sstevel@tonic-gate return (WALK_NEXT); 12690Sstevel@tonic-gate } 12700Sstevel@tonic-gate } 12710Sstevel@tonic-gate } 12720Sstevel@tonic-gate return (WALK_DONE); 12730Sstevel@tonic-gate } 12740Sstevel@tonic-gate 12750Sstevel@tonic-gate static void 12760Sstevel@tonic-gate sctp_walk_saddr_fini(mdb_walk_state_t *wsp) 12770Sstevel@tonic-gate { 12780Sstevel@tonic-gate saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data; 12790Sstevel@tonic-gate 12800Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 12810Sstevel@tonic-gate } 12820Sstevel@tonic-gate 12830Sstevel@tonic-gate static int 12840Sstevel@tonic-gate sctp_walk_ill_init(mdb_walk_state_t *wsp) 12850Sstevel@tonic-gate { 12860Sstevel@tonic-gate intptr_t i; 12870Sstevel@tonic-gate 12880Sstevel@tonic-gate /* Find the first ill. */ 12890Sstevel@tonic-gate for (i = 0; i < SCTP_ILL_HASH; i++) { 12900Sstevel@tonic-gate if (local_g_ills[i].ill_count > 0) { 12910Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 12920Sstevel@tonic-gate &local_g_ills[i].sctp_ill_list, 12930Sstevel@tonic-gate local_g_ills[i].sctp_ill_list.list_head.list_next); 12940Sstevel@tonic-gate wsp->walk_data = (void *)i; 12950Sstevel@tonic-gate wsp->walk_arg = (void *)1; 12960Sstevel@tonic-gate return (WALK_NEXT); 12970Sstevel@tonic-gate } 12980Sstevel@tonic-gate } 12990Sstevel@tonic-gate return (WALK_DONE); 13000Sstevel@tonic-gate } 13010Sstevel@tonic-gate 13020Sstevel@tonic-gate static int 13030Sstevel@tonic-gate sctp_walk_ill_step(mdb_walk_state_t *wsp) 13040Sstevel@tonic-gate { 13050Sstevel@tonic-gate uintptr_t ill_ptr = wsp->walk_addr; 13060Sstevel@tonic-gate sctp_ill_t ill; 13070Sstevel@tonic-gate int status; 13080Sstevel@tonic-gate intptr_t i, j; 13090Sstevel@tonic-gate 13100Sstevel@tonic-gate if (mdb_vread(&ill, sizeof (sctp_ill_t), ill_ptr) == -1) { 13110Sstevel@tonic-gate mdb_warn("failed to read sctp_ill_t at %p", ill_ptr); 13120Sstevel@tonic-gate return (WALK_ERR); 13130Sstevel@tonic-gate } 13140Sstevel@tonic-gate status = wsp->walk_callback(ill_ptr, &ill, wsp->walk_cbdata); 13150Sstevel@tonic-gate if (status != WALK_NEXT) 13160Sstevel@tonic-gate return (status); 13170Sstevel@tonic-gate 13180Sstevel@tonic-gate i = (intptr_t)wsp->walk_data; 13190Sstevel@tonic-gate j = (intptr_t)wsp->walk_arg; 13200Sstevel@tonic-gate 13210Sstevel@tonic-gate /* 13220Sstevel@tonic-gate * If there is still an ill in the current list, return it. 13230Sstevel@tonic-gate * Otherwise, go to the next list and find another one. 13240Sstevel@tonic-gate */ 13250Sstevel@tonic-gate if (j++ < local_g_ills[i].ill_count) { 13260Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)ill.sctp_ills.list_next; 13270Sstevel@tonic-gate wsp->walk_data = (void *)i; 13280Sstevel@tonic-gate wsp->walk_arg = (void *)j; 13290Sstevel@tonic-gate return (WALK_NEXT); 13300Sstevel@tonic-gate } else { 13310Sstevel@tonic-gate list_t *ill_list; 13320Sstevel@tonic-gate 13330Sstevel@tonic-gate for (i = i + 1; i < SCTP_ILL_HASH; i++) { 13340Sstevel@tonic-gate if (local_g_ills[i].ill_count > 0) { 13350Sstevel@tonic-gate ill_list = &local_g_ills[i].sctp_ill_list; 13360Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 13370Sstevel@tonic-gate ill_list, ill_list->list_head.list_next); 13380Sstevel@tonic-gate 13390Sstevel@tonic-gate /* Record the current position. */ 13400Sstevel@tonic-gate wsp->walk_data = (void *)i; 13410Sstevel@tonic-gate wsp->walk_arg = (void *)1; 13420Sstevel@tonic-gate return (WALK_NEXT); 13430Sstevel@tonic-gate } 13440Sstevel@tonic-gate } 13450Sstevel@tonic-gate } 13460Sstevel@tonic-gate return (WALK_DONE); 13470Sstevel@tonic-gate } 13480Sstevel@tonic-gate 13490Sstevel@tonic-gate static int 13500Sstevel@tonic-gate sctp_walk_ipif_init(mdb_walk_state_t *wsp) 13510Sstevel@tonic-gate { 13520Sstevel@tonic-gate intptr_t i; 13530Sstevel@tonic-gate list_t *ipif_list; 13540Sstevel@tonic-gate 13550Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 13560Sstevel@tonic-gate if (local_g_ipifs[i].ipif_count > 0) { 13570Sstevel@tonic-gate ipif_list = &local_g_ipifs[i].sctp_ipif_list; 13580Sstevel@tonic-gate 13590Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(ipif_list, 13600Sstevel@tonic-gate ipif_list->list_head.list_next); 13610Sstevel@tonic-gate wsp->walk_data = (void *)i; 13620Sstevel@tonic-gate wsp->walk_arg = (void *)1; 13630Sstevel@tonic-gate return (WALK_NEXT); 13640Sstevel@tonic-gate } 13650Sstevel@tonic-gate } 13660Sstevel@tonic-gate return (WALK_DONE); 13670Sstevel@tonic-gate } 13680Sstevel@tonic-gate 13690Sstevel@tonic-gate static int 13700Sstevel@tonic-gate sctp_walk_ipif_step(mdb_walk_state_t *wsp) 13710Sstevel@tonic-gate { 13720Sstevel@tonic-gate uintptr_t ipif_ptr = wsp->walk_addr; 13730Sstevel@tonic-gate sctp_ipif_t ipif; 13740Sstevel@tonic-gate int status; 13750Sstevel@tonic-gate intptr_t i, j; 13760Sstevel@tonic-gate 13770Sstevel@tonic-gate if (mdb_vread(&ipif, sizeof (sctp_ipif_t), ipif_ptr) == -1) { 13780Sstevel@tonic-gate mdb_warn("failed to read sctp_ipif_t at %p", ipif_ptr); 13790Sstevel@tonic-gate return (WALK_ERR); 13800Sstevel@tonic-gate } 13810Sstevel@tonic-gate status = wsp->walk_callback(ipif_ptr, &ipif, wsp->walk_cbdata); 13820Sstevel@tonic-gate if (status != WALK_NEXT) 13830Sstevel@tonic-gate return (status); 13840Sstevel@tonic-gate 13850Sstevel@tonic-gate i = (intptr_t)wsp->walk_data; 13860Sstevel@tonic-gate j = (intptr_t)wsp->walk_arg; 13870Sstevel@tonic-gate 13880Sstevel@tonic-gate /* 13890Sstevel@tonic-gate * If there is still an ipif in the current list, return it. 13900Sstevel@tonic-gate * Otherwise, go to the next list and find another one. 13910Sstevel@tonic-gate */ 13920Sstevel@tonic-gate if (j++ < local_g_ipifs[i].ipif_count) { 13930Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)ipif.sctp_ipifs.list_next; 13940Sstevel@tonic-gate wsp->walk_data = (void *)i; 13950Sstevel@tonic-gate wsp->walk_arg = (void *)j; 13960Sstevel@tonic-gate return (WALK_NEXT); 13970Sstevel@tonic-gate } else { 13980Sstevel@tonic-gate list_t *ipif_list; 13990Sstevel@tonic-gate 14000Sstevel@tonic-gate for (i = i + 1; i < SCTP_IPIF_HASH; i++) { 14010Sstevel@tonic-gate if (local_g_ipifs[i].ipif_count > 0) { 14020Sstevel@tonic-gate ipif_list = &local_g_ipifs[i].sctp_ipif_list; 14030Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 14040Sstevel@tonic-gate ipif_list, ipif_list->list_head.list_next); 14050Sstevel@tonic-gate 14060Sstevel@tonic-gate /* Record the current position */ 14070Sstevel@tonic-gate wsp->walk_data = (void *)i; 14080Sstevel@tonic-gate wsp->walk_arg = (void *)1; 14090Sstevel@tonic-gate return (WALK_NEXT); 14100Sstevel@tonic-gate } 14110Sstevel@tonic-gate } 14120Sstevel@tonic-gate } 14130Sstevel@tonic-gate return (WALK_DONE); 14140Sstevel@tonic-gate } 14150Sstevel@tonic-gate 14160Sstevel@tonic-gate static void 14170Sstevel@tonic-gate sctp_help(void) 14180Sstevel@tonic-gate { 14190Sstevel@tonic-gate mdb_printf("Print information for a given SCTP sctp_t\n\n"); 14200Sstevel@tonic-gate mdb_printf("Options:\n"); 14210Sstevel@tonic-gate mdb_printf("\t-a\t All the information\n"); 14220Sstevel@tonic-gate mdb_printf("\t-f\t Flags\n"); 14230Sstevel@tonic-gate mdb_printf("\t-h\t Hash Tables\n"); 14240Sstevel@tonic-gate mdb_printf("\t-o\t Outbound Data\n"); 14250Sstevel@tonic-gate mdb_printf("\t-i\t Inbound Data\n"); 14260Sstevel@tonic-gate mdb_printf("\t-m\t Miscellaneous Information\n"); 14270Sstevel@tonic-gate mdb_printf("\t-r\t RTT Tracking\n"); 14280Sstevel@tonic-gate mdb_printf("\t-S\t Stats Counters\n"); 14290Sstevel@tonic-gate mdb_printf("\t-F\t Flow Control\n"); 14300Sstevel@tonic-gate mdb_printf("\t-H\t Composite Headers\n"); 14310Sstevel@tonic-gate mdb_printf("\t-p\t PMTUD\n"); 14320Sstevel@tonic-gate mdb_printf("\t-R\t Retransmit Information\n"); 14330Sstevel@tonic-gate mdb_printf("\t-C\t Connection State\n"); 14340Sstevel@tonic-gate mdb_printf("\t-c\t Cleanup / Close\n"); 14350Sstevel@tonic-gate mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n"); 14360Sstevel@tonic-gate mdb_printf("\t-d\t Local and Peer addresses\n"); 14370Sstevel@tonic-gate mdb_printf("\t-P\t Peer addresses\n"); 14380Sstevel@tonic-gate } 14390Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = { 14400Sstevel@tonic-gate { "sctp", ":[-afhoimrSFHpRCcedP]", 14410Sstevel@tonic-gate "display sctp control structure", sctp, sctp_help }, 14420Sstevel@tonic-gate { "sctp_set", ":", "display a SCTP set", sctp_set }, 14430Sstevel@tonic-gate { "sctp_faddr", ":", "display a faddr", sctp_faddr }, 14440Sstevel@tonic-gate { "sctp_istr_msgs", ":", "display msg list on an instream", 14450Sstevel@tonic-gate sctp_istr_msgs }, 14460Sstevel@tonic-gate { "sctp_mdata_chunk", ":", "display a data chunk in an mblk", 14470Sstevel@tonic-gate sctp_mdata_chunk }, 14480Sstevel@tonic-gate { "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list }, 14490Sstevel@tonic-gate { "sctp_instr", ":", "display instr", sctp_instr }, 14500Sstevel@tonic-gate { "sctp_reass_list", ":", "display reass list", sctp_reass_list }, 14510Sstevel@tonic-gate { "sctp_uo_reass_list", ":", "display un-ordered reass list", 14520Sstevel@tonic-gate sctp_uo_reass_list }, 14530Sstevel@tonic-gate { NULL } 14540Sstevel@tonic-gate }; 14550Sstevel@tonic-gate 14560Sstevel@tonic-gate static const fanout_init_t listen_fanout_init = { 14570Sstevel@tonic-gate "sctp_listen_fanout", listen_size, listen_next 14580Sstevel@tonic-gate }; 14590Sstevel@tonic-gate 14600Sstevel@tonic-gate static const fanout_init_t conn_fanout_init = { 14610Sstevel@tonic-gate "sctp_conn_fanout", conn_size, conn_next 14620Sstevel@tonic-gate }; 14630Sstevel@tonic-gate 14640Sstevel@tonic-gate static const fanout_init_t bind_fanout_init = { 14650Sstevel@tonic-gate "sctp_bind_fanout", bind_size, bind_next 14660Sstevel@tonic-gate }; 14670Sstevel@tonic-gate 14680Sstevel@tonic-gate static const mdb_walker_t walkers[] = { 14690Sstevel@tonic-gate { "sctps", "walk the full chain of sctps", 14700Sstevel@tonic-gate sctp_walk_init, sctp_walk_step, NULL }, 14710Sstevel@tonic-gate { "sctp_listen_fanout", "walk the sctp listen fanout", 14720Sstevel@tonic-gate fanout_walk_init, fanout_walk_step, fanout_walk_fini, 14730Sstevel@tonic-gate (void *)&listen_fanout_init }, 14740Sstevel@tonic-gate { "sctp_conn_fanout", "walk the sctp conn fanout", 14750Sstevel@tonic-gate fanout_walk_init, fanout_walk_step, fanout_walk_fini, 14760Sstevel@tonic-gate (void *)&conn_fanout_init }, 14770Sstevel@tonic-gate { "sctp_bind_fanout", "walk the sctp bind fanout", 14780Sstevel@tonic-gate fanout_walk_init, fanout_walk_step, fanout_walk_fini, 14790Sstevel@tonic-gate (void *)&bind_fanout_init }, 14800Sstevel@tonic-gate { "sctp_walk_faddr", "walk the peer address list of a given sctp_t", 14810Sstevel@tonic-gate sctp_walk_faddr_init, sctp_walk_faddr_step, NULL }, 14820Sstevel@tonic-gate { "sctp_walk_saddr", "walk the local address list of a given sctp_t", 14830Sstevel@tonic-gate sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini }, 14840Sstevel@tonic-gate { "sctp_walk_ill", "walk the sctp_g_ills list", 14850Sstevel@tonic-gate sctp_walk_ill_init, sctp_walk_ill_step, NULL }, 14860Sstevel@tonic-gate { "sctp_walk_ipif", "walk the sctp_g_ipif list", 14870Sstevel@tonic-gate sctp_walk_ipif_init, sctp_walk_ipif_step, NULL }, 14880Sstevel@tonic-gate { NULL } 14890Sstevel@tonic-gate }; 14900Sstevel@tonic-gate 14910Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers }; 14920Sstevel@tonic-gate 14930Sstevel@tonic-gate const mdb_modinfo_t * 14940Sstevel@tonic-gate _mdb_init(void) 14950Sstevel@tonic-gate { 14960Sstevel@tonic-gate GElf_Sym sym; 14970Sstevel@tonic-gate GElf_Sym ills_sym; 14980Sstevel@tonic-gate GElf_Sym ipifs_sym; 14990Sstevel@tonic-gate 15000Sstevel@tonic-gate if (mdb_lookup_by_name("sctp_g_list", &sctp_list_sym) == -1) { 15010Sstevel@tonic-gate mdb_warn("failed to find 'sctp_g_list'"); 15020Sstevel@tonic-gate return (NULL); 15030Sstevel@tonic-gate } 15040Sstevel@tonic-gate if (mdb_vread(&sctp_list, sizeof (list_t), 15050Sstevel@tonic-gate (uintptr_t)sctp_list_sym.st_value) == -1) { 15060Sstevel@tonic-gate mdb_warn("failed to read 'sctp_g_list'"); 15070Sstevel@tonic-gate return (NULL); 15080Sstevel@tonic-gate } 15090Sstevel@tonic-gate if (mdb_lookup_by_name("sctp_conn_hash_size", &sym) != -1) { 15100Sstevel@tonic-gate if (mdb_vread(&sctp_conn_hash_size, 15110Sstevel@tonic-gate sizeof (sctp_conn_hash_size), sym.st_value) == -1) { 15120Sstevel@tonic-gate mdb_warn("failed to read 'sctp_conn_hash_size'"); 15130Sstevel@tonic-gate return (NULL); 15140Sstevel@tonic-gate } 15150Sstevel@tonic-gate } 15160Sstevel@tonic-gate if (mdb_lookup_by_name("sctp_g_ills", &ills_sym) == -1) { 15170Sstevel@tonic-gate mdb_warn("failed to find 'sctp_g_ills'"); 15180Sstevel@tonic-gate return (NULL); 15190Sstevel@tonic-gate } 15200Sstevel@tonic-gate if (mdb_vread(&local_g_ills, sizeof (local_g_ills), 15210Sstevel@tonic-gate (uintptr_t)ills_sym.st_value) == -1) { 15220Sstevel@tonic-gate mdb_warn("failed to read 'sctp_g_ills'"); 15230Sstevel@tonic-gate return (NULL); 15240Sstevel@tonic-gate } 15250Sstevel@tonic-gate if (mdb_lookup_by_name("sctp_g_ipifs", &ipifs_sym) == -1) { 15260Sstevel@tonic-gate mdb_warn("failed to find 'sctp_g_ipifs'"); 15270Sstevel@tonic-gate return (NULL); 15280Sstevel@tonic-gate } 15290Sstevel@tonic-gate if (mdb_vread(&local_g_ipifs, sizeof (local_g_ipifs), 15300Sstevel@tonic-gate (uintptr_t)ipifs_sym.st_value) == -1) { 15310Sstevel@tonic-gate mdb_warn("failed to read 'sctp_g_ipifs'"); 15320Sstevel@tonic-gate return (NULL); 15330Sstevel@tonic-gate } 15340Sstevel@tonic-gate 15350Sstevel@tonic-gate return (&modinfo); 15360Sstevel@tonic-gate } 1537