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 /* 233448Sdh155122 * 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 743448Sdh155122 static int 753448Sdh155122 ns_to_stackid(uintptr_t kaddr) 763448Sdh155122 { 773448Sdh155122 netstack_t nss; 783448Sdh155122 793448Sdh155122 if (mdb_vread(&nss, sizeof (nss), kaddr) == -1) { 803448Sdh155122 mdb_warn("failed to read netdstack info %p", kaddr); 813448Sdh155122 return (0); 823448Sdh155122 } 833448Sdh155122 return (nss.netstack_stackid); 843448Sdh155122 } 853448Sdh155122 863448Sdh155122 int 873448Sdh155122 sctp_stacks_walk_init(mdb_walk_state_t *wsp) 883448Sdh155122 { 893448Sdh155122 if (mdb_layered_walk("netstack", wsp) == -1) { 903448Sdh155122 mdb_warn("can't walk 'netstack'"); 913448Sdh155122 return (WALK_ERR); 923448Sdh155122 } 933448Sdh155122 return (WALK_NEXT); 943448Sdh155122 } 953448Sdh155122 963448Sdh155122 int 973448Sdh155122 sctp_stacks_walk_step(mdb_walk_state_t *wsp) 983448Sdh155122 { 993448Sdh155122 uintptr_t kaddr; 1003448Sdh155122 netstack_t nss; 1013448Sdh155122 1023448Sdh155122 if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) { 1033448Sdh155122 mdb_warn("can't read netstack at %p", wsp->walk_addr); 1043448Sdh155122 return (WALK_ERR); 1053448Sdh155122 } 1063448Sdh155122 kaddr = (uintptr_t)nss.netstack_modules[NS_SCTP]; 1073448Sdh155122 return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata)); 1083448Sdh155122 } 1093448Sdh155122 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); 166*4818Skcpoon mdb_printf("rxt_unacked\t%?u\n", fa->rxt_unacked); 1670Sstevel@tonic-gate mdb_printf("timer_mp\t%?p\tire\t\t%?p\n", fa->timer_mp, fa->ire); 168*4818Skcpoon mdb_printf("hb_enabled\t%?d\thb_pending\t%?d\n" 169*4818Skcpoon "timer_running\t%?d\tdf\t\t%?d\n" 170*4818Skcpoon "pmtu_discovered\t%?d\tisv4\t\t%?d\n" 171*4818Skcpoon "retransmissions\t%?u\n", 172*4818Skcpoon fa->hb_enabled, fa->hb_pending, fa->timer_running, fa->df, 173*4818Skcpoon fa->pmtu_discovered, fa->isv4, fa->T3expire); 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate return (DCMD_OK); 1760Sstevel@tonic-gate } 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate static void 1790Sstevel@tonic-gate print_set(sctp_set_t *sp) 1800Sstevel@tonic-gate { 1810Sstevel@tonic-gate mdb_printf("\tbegin\t%<b>%?x%</b>\t\tend\t%<b>%?x%</b>\n", 1820Sstevel@tonic-gate sp->begin, sp->end); 1830Sstevel@tonic-gate mdb_printf("\tnext\t%?p\tprev\t%?p\n", sp->next, sp->prev); 1840Sstevel@tonic-gate } 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate /* ARGSUSED */ 1870Sstevel@tonic-gate static int 1880Sstevel@tonic-gate sctp_set(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1890Sstevel@tonic-gate { 1900Sstevel@tonic-gate sctp_set_t sp[1]; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1930Sstevel@tonic-gate return (DCMD_USAGE); 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) 1960Sstevel@tonic-gate return (DCMD_ERR); 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate print_set(sp); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate return (DCMD_OK); 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate static void 2040Sstevel@tonic-gate dump_sack_info(uintptr_t addr) 2050Sstevel@tonic-gate { 2060Sstevel@tonic-gate sctp_set_t sp[1]; 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate while (addr != 0) { 2090Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) { 2100Sstevel@tonic-gate mdb_warn("failed to read sctp_set at %p", addr); 2110Sstevel@tonic-gate return; 2120Sstevel@tonic-gate } 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate addr = (uintptr_t)sp->next; 2150Sstevel@tonic-gate print_set(sp); 2160Sstevel@tonic-gate } 2170Sstevel@tonic-gate } 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate static int 2200Sstevel@tonic-gate dump_msghdr(mblk_t *meta) 2210Sstevel@tonic-gate { 2220Sstevel@tonic-gate sctp_msg_hdr_t smh; 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate if (mdb_vread(&smh, sizeof (smh), (uintptr_t)meta->b_rptr) == -1) 2250Sstevel@tonic-gate return (-1); 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate mdb_printf("%<u>msg_hdr_t at \t%?p\tsentto\t%?p%</u>\n", 2280Sstevel@tonic-gate meta->b_rptr, SCTP_CHUNK_DEST(meta)); 2290Sstevel@tonic-gate mdb_printf("\tttl\t%?ld\ttob\t%?ld\n", smh.smh_ttl, smh.smh_tob); 2300Sstevel@tonic-gate mdb_printf("\tsid\t%?u\tssn\t%?u\n", smh.smh_sid, smh.smh_ssn); 2310Sstevel@tonic-gate mdb_printf("\tppid\t%?u\tflags\t%?s\n", smh.smh_ppid, 2320Sstevel@tonic-gate smh.smh_flags & MSG_UNORDERED ? "unordered" : " "); 2330Sstevel@tonic-gate mdb_printf("\tcontext\t%?u\tmsglen\t%?d\n", smh.smh_context, 2340Sstevel@tonic-gate smh.smh_msglen); 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate return (0); 2370Sstevel@tonic-gate } 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate static int 2400Sstevel@tonic-gate dump_datahdr(mblk_t *mp) 2410Sstevel@tonic-gate { 2420Sstevel@tonic-gate sctp_data_hdr_t sdc; 2430Sstevel@tonic-gate uint16_t sdh_int16; 2440Sstevel@tonic-gate uint32_t sdh_int32; 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate if (mdb_vread(&sdc, sizeof (sdc), (uintptr_t)mp->b_rptr) == -1) 2470Sstevel@tonic-gate return (-1); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate mdb_printf("%<u>data_chunk_t \t%?p\tsentto\t%?p%</u>\n", 2500Sstevel@tonic-gate mp->b_rptr, SCTP_CHUNK_DEST(mp)); 2510Sstevel@tonic-gate mdb_printf("\tsent\t%?d\t", SCTP_CHUNK_ISSENT(mp)?1:0); 2520Sstevel@tonic-gate mdb_printf("retrans\t%?d\n", SCTP_CHUNK_WANT_REXMIT(mp)?1:0); 2530Sstevel@tonic-gate mdb_printf("\tacked\t%?d\t", SCTP_CHUNK_ISACKED(mp)?1:0); 2540Sstevel@tonic-gate mdb_printf("sackcnt\t%?u\n", SCTP_CHUNK_SACKCNT(mp)); 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_len, sizeof (sdc.sdh_len)); 2570Sstevel@tonic-gate mdb_printf("\tlen\t%?d\t", sdh_int16); 2580Sstevel@tonic-gate mdb_printf("BBIT=%d", SCTP_DATA_GET_BBIT(&sdc) == 0 ? 0 : 1); 2590Sstevel@tonic-gate mdb_printf("EBIT=%d", SCTP_DATA_GET_EBIT(&sdc) == 0 ? 0 : 1); 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_tsn, sizeof (sdc.sdh_tsn)); 2620Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_sid, sizeof (sdc.sdh_sid)); 2630Sstevel@tonic-gate mdb_printf("\ttsn\t%?x\tsid\t%?hu\n", sdh_int32, sdh_int16); 2640Sstevel@tonic-gate 2650Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_ssn, sizeof (sdc.sdh_ssn)); 2660Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_payload_id, 2670Sstevel@tonic-gate sizeof (sdc.sdh_payload_id)); 2680Sstevel@tonic-gate mdb_printf("\tssn\t%?hu\tppid\t%?d\n", sdh_int16, sdh_int32); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate return (0); 2710Sstevel@tonic-gate } 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate static int 2740Sstevel@tonic-gate sctp_sent_list(mblk_t *addr) 2750Sstevel@tonic-gate { 2760Sstevel@tonic-gate mblk_t meta, mp; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate if (!addr) 2790Sstevel@tonic-gate return (0); 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 2820Sstevel@tonic-gate return (-1); 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate for (;;) { 2850Sstevel@tonic-gate dump_msghdr(&meta); 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate if (meta.b_cont == NULL) { 2880Sstevel@tonic-gate mdb_printf("No data chunks with message header!\n"); 2890Sstevel@tonic-gate return (-1); 2900Sstevel@tonic-gate } 2910Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2924691Skcpoon (uintptr_t)meta.b_cont) == -1) { 2930Sstevel@tonic-gate return (-1); 2940Sstevel@tonic-gate } 2950Sstevel@tonic-gate for (;;) { 2960Sstevel@tonic-gate dump_datahdr(&mp); 2970Sstevel@tonic-gate if (!mp.b_next) 2980Sstevel@tonic-gate break; 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 3010Sstevel@tonic-gate (uintptr_t)(mp.b_next)) == -1) 3020Sstevel@tonic-gate return (-1); 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate if (meta.b_next == NULL) 3050Sstevel@tonic-gate break; 3060Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3070Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3080Sstevel@tonic-gate return (-1); 3090Sstevel@tonic-gate } 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate return (0); 3120Sstevel@tonic-gate } 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate static int 3150Sstevel@tonic-gate sctp_unsent_list(mblk_t *addr) 3160Sstevel@tonic-gate { 3170Sstevel@tonic-gate mblk_t meta; 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate if (!addr) 3200Sstevel@tonic-gate return (0); 3210Sstevel@tonic-gate 3220Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 3230Sstevel@tonic-gate return (-1); 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate for (;;) { 3260Sstevel@tonic-gate dump_msghdr(&meta); 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate if (meta.b_next == NULL) 3290Sstevel@tonic-gate break; 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3320Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3330Sstevel@tonic-gate return (-1); 3340Sstevel@tonic-gate } 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate return (0); 3370Sstevel@tonic-gate } 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate /* ARGSUSED */ 3400Sstevel@tonic-gate static int 3410Sstevel@tonic-gate sctp_xmit_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3420Sstevel@tonic-gate { 3430Sstevel@tonic-gate sctp_t sctp; 3440Sstevel@tonic-gate 3450Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3460Sstevel@tonic-gate return (DCMD_USAGE); 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) 3490Sstevel@tonic-gate return (DCMD_ERR); 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate mdb_printf("%<b>Chunkified TX list%</b>\n"); 3520Sstevel@tonic-gate if (sctp_sent_list(sctp.sctp_xmit_head) < 0) 3530Sstevel@tonic-gate return (DCMD_ERR); 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate mdb_printf("%<b>Unchunkified TX list%</b>\n"); 3560Sstevel@tonic-gate if (sctp_unsent_list(sctp.sctp_xmit_unsent) < 0) 3570Sstevel@tonic-gate return (DCMD_ERR); 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate return (DCMD_OK); 3600Sstevel@tonic-gate } 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate /* ARGSUSED */ 3630Sstevel@tonic-gate static int 3640Sstevel@tonic-gate sctp_mdata_chunk(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3650Sstevel@tonic-gate { 3660Sstevel@tonic-gate sctp_data_hdr_t dc; 3670Sstevel@tonic-gate mblk_t mp; 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3700Sstevel@tonic-gate return (DCMD_USAGE); 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), addr) == -1) 3730Sstevel@tonic-gate return (DCMD_ERR); 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate if (mdb_vread(&dc, sizeof (dc), (uintptr_t)mp.b_rptr) == -1) 3760Sstevel@tonic-gate return (DCMD_ERR); 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>tsn\t%?x\tsid\t%?hu\n", addr, 3790Sstevel@tonic-gate dc.sdh_tsn, dc.sdh_sid); 3800Sstevel@tonic-gate mdb_printf("%-?sssn\t%?hu\tppid\t%?x\n", "", dc.sdh_ssn, 3810Sstevel@tonic-gate dc.sdh_payload_id); 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate return (DCMD_OK); 3840Sstevel@tonic-gate } 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate /* ARGSUSED */ 3870Sstevel@tonic-gate static int 3880Sstevel@tonic-gate sctp_istr_msgs(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3890Sstevel@tonic-gate { 3900Sstevel@tonic-gate mblk_t istrmp; 3910Sstevel@tonic-gate mblk_t dmp; 3920Sstevel@tonic-gate sctp_data_hdr_t dp; 3930Sstevel@tonic-gate uintptr_t daddr; 3940Sstevel@tonic-gate uintptr_t chaddr; 3950Sstevel@tonic-gate boolean_t bbit; 3960Sstevel@tonic-gate boolean_t ebit; 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3990Sstevel@tonic-gate return (DCMD_USAGE); 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate do { 4020Sstevel@tonic-gate if (mdb_vread(&istrmp, sizeof (istrmp), addr) == -1) 4030Sstevel@tonic-gate return (DCMD_ERR); 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate mdb_printf("\tistr mblk at %p: next: %?p\n" 4060Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, istrmp.b_next, 4070Sstevel@tonic-gate istrmp.b_prev, istrmp.b_cont); 4080Sstevel@tonic-gate daddr = (uintptr_t)&istrmp; 4090Sstevel@tonic-gate do { 4100Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4110Sstevel@tonic-gate break; 4120Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4130Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4140Sstevel@tonic-gate break; 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4170Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4200Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4210Sstevel@tonic-gate 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4240Sstevel@tonic-gate } while (daddr != NULL); 4250Sstevel@tonic-gate 4260Sstevel@tonic-gate addr = (uintptr_t)istrmp.b_next; 4270Sstevel@tonic-gate } while (addr != NULL); 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate return (DCMD_OK); 4300Sstevel@tonic-gate } 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate /* ARGSUSED */ 4330Sstevel@tonic-gate static int 4340Sstevel@tonic-gate sctp_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4350Sstevel@tonic-gate { 4360Sstevel@tonic-gate sctp_reass_t srp; 4370Sstevel@tonic-gate mblk_t srpmp; 4380Sstevel@tonic-gate sctp_data_hdr_t dp; 4390Sstevel@tonic-gate mblk_t dmp; 4400Sstevel@tonic-gate uintptr_t daddr; 4410Sstevel@tonic-gate uintptr_t chaddr; 4420Sstevel@tonic-gate boolean_t bbit, ebit; 4430Sstevel@tonic-gate 4440Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4450Sstevel@tonic-gate return (DCMD_USAGE); 4460Sstevel@tonic-gate 4470Sstevel@tonic-gate do { 4480Sstevel@tonic-gate if (mdb_vread(&srpmp, sizeof (srpmp), addr) == -1) 4490Sstevel@tonic-gate return (DCMD_ERR); 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate if (mdb_vread(&srp, sizeof (srp), 4520Sstevel@tonic-gate (uintptr_t)srpmp.b_datap->db_base) == -1) 4530Sstevel@tonic-gate return (DCMD_ERR); 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 4560Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, srpmp.b_next, 4570Sstevel@tonic-gate srpmp.b_prev, srpmp.b_cont); 4580Sstevel@tonic-gate mdb_printf("\t\tssn: %hu\tneeded: %hu\tgot: %hu\ttail: %?p\n" 4590Sstevel@tonic-gate "\t\tpartial_delivered: %s\n", srp.ssn, srp.needed, 4600Sstevel@tonic-gate srp.got, srp.tail, srp.partial_delivered ? "TRUE" : 4610Sstevel@tonic-gate "FALSE"); 4620Sstevel@tonic-gate 4630Sstevel@tonic-gate /* display the contents of this ssn's reassemby list */ 4640Sstevel@tonic-gate daddr = DB_TYPE(&srpmp) == M_CTL ? (uintptr_t)srpmp.b_cont : 4650Sstevel@tonic-gate (uintptr_t)&srpmp; 4660Sstevel@tonic-gate do { 4670Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4680Sstevel@tonic-gate break; 4690Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4700Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4710Sstevel@tonic-gate break; 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4740Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4770Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4800Sstevel@tonic-gate } while (daddr != NULL); 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate addr = (uintptr_t)srpmp.b_next; 4830Sstevel@tonic-gate } while (addr != NULL); 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate return (DCMD_OK); 4860Sstevel@tonic-gate } 4870Sstevel@tonic-gate 4880Sstevel@tonic-gate /* ARGSUSED */ 4890Sstevel@tonic-gate static int 4900Sstevel@tonic-gate sctp_uo_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4910Sstevel@tonic-gate { 4920Sstevel@tonic-gate sctp_data_hdr_t dp; 4930Sstevel@tonic-gate mblk_t dmp; 4940Sstevel@tonic-gate uintptr_t chaddr; 4950Sstevel@tonic-gate boolean_t bbit; 4960Sstevel@tonic-gate boolean_t ebit; 4970Sstevel@tonic-gate boolean_t ubit; 4980Sstevel@tonic-gate 4990Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 5000Sstevel@tonic-gate return (DCMD_USAGE); 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate do { 5030Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), addr) == -1) 5040Sstevel@tonic-gate return (DCMD_ERR); 5050Sstevel@tonic-gate 5060Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 5070Sstevel@tonic-gate "\t\tprev: %?p\n", addr, dmp.b_next, dmp.b_prev); 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 5100Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 5110Sstevel@tonic-gate break; 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 5140Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 5150Sstevel@tonic-gate ubit = (SCTP_DATA_GET_UBIT(&dp) != 0); 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate mdb_printf("\t\t\tsid: %hu ssn: %hu tsn: %x " 5180Sstevel@tonic-gate "flags: %x (U=%d B=%d E=%d)\n", dp.sdh_sid, dp.sdh_ssn, 5190Sstevel@tonic-gate dp.sdh_tsn, dp.sdh_flags, ubit, bbit, ebit); 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate addr = (uintptr_t)dmp.b_next; 5220Sstevel@tonic-gate } while (addr != NULL); 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate return (DCMD_OK); 5250Sstevel@tonic-gate } 5260Sstevel@tonic-gate 5270Sstevel@tonic-gate static int 5280Sstevel@tonic-gate sctp_instr(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 5290Sstevel@tonic-gate { 5300Sstevel@tonic-gate sctp_instr_t sip; 5310Sstevel@tonic-gate 5320Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 5330Sstevel@tonic-gate return (DCMD_USAGE); 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate if (mdb_vread(&sip, sizeof (sip), addr) == -1) 5360Sstevel@tonic-gate return (DCMD_ERR); 5370Sstevel@tonic-gate 5380Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>\n\tmsglist\t%?p\tnmsgs\t%?d\n" 5390Sstevel@tonic-gate "\tnextseq\t%?d\treass\t%?p\n", addr, sip.istr_msgs, 5400Sstevel@tonic-gate sip.istr_nmsgs, sip.nextseq, sip.istr_reass); 5410Sstevel@tonic-gate mdb_set_dot(addr + sizeof (sip)); 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate return (sctp_reass_list((uintptr_t)sip.istr_reass, flags, ac, av)); 5440Sstevel@tonic-gate } 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate static const char * 5470Sstevel@tonic-gate state2str(sctp_t *sctp) 5480Sstevel@tonic-gate { 5490Sstevel@tonic-gate switch (sctp->sctp_state) { 5500Sstevel@tonic-gate case SCTPS_IDLE: return ("SCTPS_IDLE"); 5510Sstevel@tonic-gate case SCTPS_BOUND: return ("SCTPS_BOUND"); 5520Sstevel@tonic-gate case SCTPS_LISTEN: return ("SCTPS_LISTEN"); 5530Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: return ("SCTPS_COOKIE_WAIT"); 5540Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED: return ("SCTPS_COOKIE_ECHOED"); 5550Sstevel@tonic-gate case SCTPS_ESTABLISHED: return ("SCTPS_ESTABLISHED"); 5560Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: return ("SCTPS_SHUTDOWN_PENDING"); 5570Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: return ("SCTPS_SHUTDOWN_SENT"); 5580Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED: return ("SCTPS_SHUTDOWN_RECEIVED"); 5590Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: return ("SCTPS_SHUTDOWN_ACK_SENT"); 5600Sstevel@tonic-gate default: return ("UNKNOWN STATE"); 5610Sstevel@tonic-gate } 5620Sstevel@tonic-gate } 5630Sstevel@tonic-gate 5640Sstevel@tonic-gate static void 5650Sstevel@tonic-gate show_sctp_flags(sctp_t *sctp) 5660Sstevel@tonic-gate { 5670Sstevel@tonic-gate mdb_printf("\tunderstands_asconf\t%d\n", 5680Sstevel@tonic-gate sctp->sctp_understands_asconf); 5690Sstevel@tonic-gate mdb_printf("\tdebug\t\t\t%d\n", sctp->sctp_debug); 5700Sstevel@tonic-gate mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend); 5710Sstevel@tonic-gate mdb_printf("\tdgram_errind\t\t%d\n", sctp->sctp_dgram_errind); 5720Sstevel@tonic-gate 5730Sstevel@tonic-gate mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_linger); 5740Sstevel@tonic-gate if (sctp->sctp_lingering) 5750Sstevel@tonic-gate return; 5760Sstevel@tonic-gate mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering); 5770Sstevel@tonic-gate mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback); 5780Sstevel@tonic-gate mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack); 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running); 5810Sstevel@tonic-gate mdb_printf("\trecvdstaddr\t\t%d\n", sctp->sctp_recvdstaddr); 5820Sstevel@tonic-gate mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum); 5830Sstevel@tonic-gate mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip); 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all); 5860Sstevel@tonic-gate mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep); 5870Sstevel@tonic-gate mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached); 5880Sstevel@tonic-gate mdb_printf("\tsend_adaption\t\t%d\n", sctp->sctp_send_adaption); 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate mdb_printf("\trecv_adaption\t\t%d\n", sctp->sctp_recv_adaption); 5910Sstevel@tonic-gate mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay); 5920Sstevel@tonic-gate mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned); 5930Sstevel@tonic-gate mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit); 5941735Skcpoon 5950Sstevel@tonic-gate mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware); 596432Svi117747 mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal); 5971735Skcpoon mdb_printf("\trexmitting\t\t%d\n", sctp->sctp_rexmitting); 5982263Ssommerfe mdb_printf("\tzero_win_probe\t\t%d\n", sctp->sctp_zero_win_probe); 5990Sstevel@tonic-gate 6000Sstevel@tonic-gate mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo); 6010Sstevel@tonic-gate mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt); 6020Sstevel@tonic-gate mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt); 6030Sstevel@tonic-gate mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt); 6040Sstevel@tonic-gate 6050Sstevel@tonic-gate mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr); 6060Sstevel@tonic-gate mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt); 6070Sstevel@tonic-gate mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt); 6080Sstevel@tonic-gate mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt); 6090Sstevel@tonic-gate } 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate /* 6120Sstevel@tonic-gate * Given a sctp_saddr_ipif_t, print out its address. This assumes 6130Sstevel@tonic-gate * that addr contains the sctp_addr_ipif_t structure already and this 6140Sstevel@tonic-gate * function does not need to read it in. 6150Sstevel@tonic-gate */ 6160Sstevel@tonic-gate /* ARGSUSED */ 6170Sstevel@tonic-gate static int 6180Sstevel@tonic-gate print_saddr(uintptr_t ptr, const void *addr, void *cbdata) 6190Sstevel@tonic-gate { 6200Sstevel@tonic-gate sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr; 6210Sstevel@tonic-gate sctp_ipif_t ipif; 6220Sstevel@tonic-gate char *statestr; 6230Sstevel@tonic-gate 6240Sstevel@tonic-gate /* Read in the sctp_ipif object */ 6250Sstevel@tonic-gate if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) == 6260Sstevel@tonic-gate -1) { 6270Sstevel@tonic-gate mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp); 6280Sstevel@tonic-gate return (WALK_ERR); 6290Sstevel@tonic-gate } 6300Sstevel@tonic-gate 6310Sstevel@tonic-gate switch (ipif.sctp_ipif_state) { 6320Sstevel@tonic-gate case SCTP_IPIFS_CONDEMNED: 633432Svi117747 statestr = "Condemned"; 6340Sstevel@tonic-gate break; 6350Sstevel@tonic-gate case SCTP_IPIFS_INVALID: 636432Svi117747 statestr = "Invalid"; 6370Sstevel@tonic-gate break; 6380Sstevel@tonic-gate case SCTP_IPIFS_DOWN: 639432Svi117747 statestr = "Down"; 6400Sstevel@tonic-gate break; 6410Sstevel@tonic-gate case SCTP_IPIFS_UP: 642432Svi117747 statestr = "Up"; 6430Sstevel@tonic-gate break; 6440Sstevel@tonic-gate default: 645432Svi117747 statestr = "Unknown"; 6460Sstevel@tonic-gate break; 6470Sstevel@tonic-gate } 648432Svi117747 mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr, 649432Svi117747 statestr); 650432Svi117747 if (saddr->saddr_ipif_dontsrc == 1) 651432Svi117747 mdb_printf("/Dontsrc"); 652432Svi117747 if (saddr->saddr_ipif_unconfirmed == 1) 653432Svi117747 mdb_printf("/Unconfirmed"); 654432Svi117747 if (saddr->saddr_ipif_delete_pending == 1) 655432Svi117747 mdb_printf("/DeletePending"); 656432Svi117747 mdb_printf(")\n"); 657432Svi117747 mdb_printf("\t\t\tMTU %d id %d zoneid %d IPIF flags %x\n", 6580Sstevel@tonic-gate ipif.sctp_ipif_mtu, ipif.sctp_ipif_id, 659432Svi117747 ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags); 6600Sstevel@tonic-gate return (WALK_NEXT); 6610Sstevel@tonic-gate } 6620Sstevel@tonic-gate 6630Sstevel@tonic-gate /* 6640Sstevel@tonic-gate * Given a sctp_faddr_t, print out its address. This assumes that 6650Sstevel@tonic-gate * addr contains the sctp_faddr_t structure already and this function 6660Sstevel@tonic-gate * does not need to read it in. 6670Sstevel@tonic-gate */ 6680Sstevel@tonic-gate static int 6690Sstevel@tonic-gate print_faddr(uintptr_t ptr, const void *addr, void *cbdata) 6700Sstevel@tonic-gate { 671432Svi117747 char *statestr; 6720Sstevel@tonic-gate sctp_faddr_t *faddr = (sctp_faddr_t *)addr; 6730Sstevel@tonic-gate int *i = cbdata; 6740Sstevel@tonic-gate 675432Svi117747 statestr = sctp_faddr_state(faddr->state); 676432Svi117747 677432Svi117747 mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->faddr, ptr, 678432Svi117747 statestr); 6790Sstevel@tonic-gate return (WALK_NEXT); 6800Sstevel@tonic-gate } 6810Sstevel@tonic-gate 6820Sstevel@tonic-gate int 6830Sstevel@tonic-gate sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 6840Sstevel@tonic-gate { 6850Sstevel@tonic-gate sctp_t sctp; 6860Sstevel@tonic-gate conn_t connp; 6870Sstevel@tonic-gate int i; 6880Sstevel@tonic-gate uint_t opts = 0; 6890Sstevel@tonic-gate uint_t paddr = 0; 6900Sstevel@tonic-gate in_port_t lport, fport; 6910Sstevel@tonic-gate 6920Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 6930Sstevel@tonic-gate return (DCMD_USAGE); 6940Sstevel@tonic-gate 6950Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 6960Sstevel@tonic-gate mdb_warn("failed to read sctp_t at: %p\n", addr); 6970Sstevel@tonic-gate return (DCMD_ERR); 6980Sstevel@tonic-gate } 6990Sstevel@tonic-gate if (mdb_vread(&connp, sizeof (connp), 7000Sstevel@tonic-gate (uintptr_t)sctp.sctp_connp) == -1) { 7010Sstevel@tonic-gate mdb_warn("failed to read conn_t at: %p\n", sctp.sctp_connp); 7020Sstevel@tonic-gate return (DCMD_ERR); 7030Sstevel@tonic-gate } 7040Sstevel@tonic-gate 7050Sstevel@tonic-gate if (mdb_getopts(argc, argv, 7064691Skcpoon 'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts, 7074691Skcpoon 'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts, 7084691Skcpoon 'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts, 7094691Skcpoon 'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts, 7104691Skcpoon 'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts, 7114691Skcpoon 'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts, 7124691Skcpoon 'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts, 7134691Skcpoon 'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts, 7144691Skcpoon 'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts, 7154691Skcpoon 'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts, 7164691Skcpoon 'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts, 7174691Skcpoon 'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts, 7184691Skcpoon 'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts, 7194691Skcpoon 'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts, 7204691Skcpoon 'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts, 7214691Skcpoon 'P', MDB_OPT_SETBITS, 1, &paddr, 7224691Skcpoon 'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) { 7230Sstevel@tonic-gate return (DCMD_USAGE); 7240Sstevel@tonic-gate } 7250Sstevel@tonic-gate 7260Sstevel@tonic-gate /* non-verbose faddrs, suitable for pipelines to sctp_faddr */ 7270Sstevel@tonic-gate if (paddr != 0) { 7280Sstevel@tonic-gate sctp_faddr_t faddr, *fp; 7290Sstevel@tonic-gate for (fp = sctp.sctp_faddrs; fp != NULL; fp = faddr.next) { 7300Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp) 7310Sstevel@tonic-gate == -1) { 7320Sstevel@tonic-gate mdb_warn("failed to read faddr at %p", 7330Sstevel@tonic-gate fp); 7340Sstevel@tonic-gate return (DCMD_ERR); 7350Sstevel@tonic-gate } 7360Sstevel@tonic-gate mdb_printf("%p\n", fp); 7370Sstevel@tonic-gate } 7380Sstevel@tonic-gate return (DCMD_OK); 7390Sstevel@tonic-gate } 7400Sstevel@tonic-gate 7410Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 7420Sstevel@tonic-gate mdb_nhconvert(&fport, &sctp.sctp_fport, sizeof (fport)); 7433448Sdh155122 mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% STACK=%d ZONE=%d%</u>", addr, 7443448Sdh155122 state2str(&sctp), lport, fport, 7453448Sdh155122 ns_to_stackid((uintptr_t)connp.conn_netstack), connp.conn_zoneid); 7460Sstevel@tonic-gate 7470Sstevel@tonic-gate if (sctp.sctp_faddrs) { 7480Sstevel@tonic-gate sctp_faddr_t faddr; 7490Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), 7500Sstevel@tonic-gate (uintptr_t)sctp.sctp_faddrs) != -1) 7510Sstevel@tonic-gate mdb_printf("%<u> %N%</u>", &faddr.faddr); 7520Sstevel@tonic-gate } 7530Sstevel@tonic-gate mdb_printf("\n"); 7540Sstevel@tonic-gate 7550Sstevel@tonic-gate if (opts & MDB_SCTP_DUMP_ADDRS) { 7560Sstevel@tonic-gate mdb_printf("%<b>Local and Peer Addresses%</b>\n"); 7570Sstevel@tonic-gate 7580Sstevel@tonic-gate /* Display source addresses */ 7590Sstevel@tonic-gate mdb_printf("nsaddrs\t\t%?d\n", sctp.sctp_nsaddrs); 7600Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr); 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate /* Display peer addresses */ 763852Svi117747 mdb_printf("nfaddrs\t\t%?d\n", sctp.sctp_nfaddrs); 7640Sstevel@tonic-gate i = 1; 7650Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr); 7660Sstevel@tonic-gate 7670Sstevel@tonic-gate mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n", 7680Sstevel@tonic-gate sctp.sctp_lastfaddr, sctp.sctp_primary); 7690Sstevel@tonic-gate mdb_printf("current\t\t%?p\tlastdata\t%?p\n", 7700Sstevel@tonic-gate sctp.sctp_current, sctp.sctp_lastdata); 7710Sstevel@tonic-gate } 7720Sstevel@tonic-gate 7730Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_OUT) { 7740Sstevel@tonic-gate mdb_printf("%<b>Outbound Data%</b>\n"); 7750Sstevel@tonic-gate mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n", 7760Sstevel@tonic-gate sctp.sctp_xmit_head, sctp.sctp_xmit_tail); 7770Sstevel@tonic-gate mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n", 7780Sstevel@tonic-gate sctp.sctp_xmit_unsent, sctp.sctp_xmit_unsent_tail); 7790Sstevel@tonic-gate mdb_printf("xmit_unacked\t%?p\n", sctp.sctp_xmit_unacked); 7800Sstevel@tonic-gate mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n", 7810Sstevel@tonic-gate sctp.sctp_unacked, sctp.sctp_unsent); 7820Sstevel@tonic-gate mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n", 7830Sstevel@tonic-gate sctp.sctp_ltsn, sctp.sctp_lastack_rxd); 7840Sstevel@tonic-gate mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n", 7850Sstevel@tonic-gate sctp.sctp_recovery_tsn, sctp.sctp_adv_pap); 7860Sstevel@tonic-gate mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n", 7870Sstevel@tonic-gate sctp.sctp_num_ostr, sctp.sctp_ostrcntrs); 7884691Skcpoon mdb_printf("pad_mp\t\t%?p\n", sctp.sctp_pad_mp); 7890Sstevel@tonic-gate 7900Sstevel@tonic-gate mdb_printf("%<b>Default Send Parameters%</b>\n"); 7910Sstevel@tonic-gate mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n", 7920Sstevel@tonic-gate sctp.sctp_def_stream, sctp.sctp_def_flags); 7930Sstevel@tonic-gate mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n", 7940Sstevel@tonic-gate sctp.sctp_def_ppid, sctp.sctp_def_context); 7950Sstevel@tonic-gate mdb_printf("def_timetolive\t%?u\n", 7960Sstevel@tonic-gate sctp.sctp_def_timetolive); 7970Sstevel@tonic-gate } 7980Sstevel@tonic-gate 7990Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_IN) { 8000Sstevel@tonic-gate mdb_printf("%<b>Inbound Data%</b>\n"); 8010Sstevel@tonic-gate mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n", 8020Sstevel@tonic-gate sctp.sctp_sack_info, sctp.sctp_sack_gaps); 8030Sstevel@tonic-gate dump_sack_info((uintptr_t)sctp.sctp_sack_info); 8040Sstevel@tonic-gate mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n", 8050Sstevel@tonic-gate sctp.sctp_ftsn, sctp.sctp_lastacked); 8060Sstevel@tonic-gate mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n", 8070Sstevel@tonic-gate sctp.sctp_istr_nmsgs, sctp.sctp_sack_toggle); 8080Sstevel@tonic-gate mdb_printf("ack_mp\t\t%?p\n", sctp.sctp_ack_mp); 8090Sstevel@tonic-gate mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n", 8100Sstevel@tonic-gate sctp.sctp_num_istr, sctp.sctp_instr); 8110Sstevel@tonic-gate mdb_printf("unord_reass\t%?p\n", sctp.sctp_uo_frags); 8120Sstevel@tonic-gate } 8130Sstevel@tonic-gate 8140Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RTT) { 8150Sstevel@tonic-gate mdb_printf("%<b>RTT Tracking%</b>\n"); 8160Sstevel@tonic-gate mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n", 8170Sstevel@tonic-gate sctp.sctp_rtt_tsn, sctp.sctp_out_time); 8180Sstevel@tonic-gate } 8190Sstevel@tonic-gate 8200Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLOW) { 8210Sstevel@tonic-gate mdb_printf("%<b>Flow Control%</b>\n"); 8220Sstevel@tonic-gate mdb_printf("txmit_hiwater\t%?d\n" 8230Sstevel@tonic-gate "xmit_lowater\t%?d\tfrwnd\t\t%?u\n" 824852Svi117747 "rwnd\t\t%?u\tinitial rwnd\t%?u\n" 825852Svi117747 "rxqueued\t%?u\tcwnd_max\t%?u\n", sctp.sctp_xmit_hiwater, 8260Sstevel@tonic-gate sctp.sctp_xmit_lowater, sctp.sctp_frwnd, 827852Svi117747 sctp.sctp_rwnd, sctp.sctp_irwnd, sctp.sctp_rxqueued, 828852Svi117747 sctp.sctp_cwnd_max); 8290Sstevel@tonic-gate } 8300Sstevel@tonic-gate 8310Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HDR) { 8320Sstevel@tonic-gate mdb_printf("%<b>Composite Headers%</b>\n"); 8330Sstevel@tonic-gate mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n" 8340Sstevel@tonic-gate "iphc_len\t%?d\tiphc6_len\t%?d\n" 8350Sstevel@tonic-gate "hdr_len\t\t%?d\thdr6_len\t%?d\n" 8360Sstevel@tonic-gate "ipha\t\t%?p\tip6h\t\t%?p\n" 8370Sstevel@tonic-gate "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n" 8380Sstevel@tonic-gate "sctph\t\t%?p\tsctph6\t\t%?p\n" 8390Sstevel@tonic-gate "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp.sctp_iphc, 8400Sstevel@tonic-gate sctp.sctp_iphc6, sctp.sctp_iphc_len, 8410Sstevel@tonic-gate sctp.sctp_iphc6_len, sctp.sctp_hdr_len, 8420Sstevel@tonic-gate sctp.sctp_hdr6_len, sctp.sctp_ipha, sctp.sctp_ip6h, 8430Sstevel@tonic-gate sctp.sctp_ip_hdr_len, sctp.sctp_ip_hdr6_len, 8440Sstevel@tonic-gate sctp.sctp_sctph, sctp.sctp_sctph6, sctp.sctp_lvtag, 8450Sstevel@tonic-gate sctp.sctp_fvtag); 8460Sstevel@tonic-gate } 8470Sstevel@tonic-gate 8480Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_PMTUD) { 8490Sstevel@tonic-gate mdb_printf("%<b>PMTUd%</b>\n"); 8500Sstevel@tonic-gate mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n" 8510Sstevel@tonic-gate "mss\t\t%?u\n", 8520Sstevel@tonic-gate sctp.sctp_last_mtu_probe, sctp.sctp_mtu_probe_intvl, 8530Sstevel@tonic-gate sctp.sctp_mss); 8540Sstevel@tonic-gate } 8550Sstevel@tonic-gate 8560Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RXT) { 8570Sstevel@tonic-gate mdb_printf("%<b>Retransmit Info%</b>\n"); 8580Sstevel@tonic-gate mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n" 8590Sstevel@tonic-gate "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n" 8600Sstevel@tonic-gate "pp_max_rxt\t%?d\trto_max\t\t%?u\n" 8610Sstevel@tonic-gate "rto_min\t\t%?u\trto_initial\t%?u\n" 8621735Skcpoon "init_rto_max\t%?u\n" 8631735Skcpoon "rxt_nxttsn\t%?u\trxt_maxtsn\t%?u\n", sctp.sctp_cookie_mp, 8640Sstevel@tonic-gate sctp.sctp_strikes, sctp.sctp_max_init_rxt, 8650Sstevel@tonic-gate sctp.sctp_pa_max_rxt, sctp.sctp_pp_max_rxt, 8660Sstevel@tonic-gate sctp.sctp_rto_max, sctp.sctp_rto_min, 8671735Skcpoon sctp.sctp_rto_initial, sctp.sctp_init_rto_max, 8681735Skcpoon sctp.sctp_rxt_nxttsn, sctp.sctp_rxt_maxtsn); 8690Sstevel@tonic-gate } 8700Sstevel@tonic-gate 8710Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CONN) { 8720Sstevel@tonic-gate mdb_printf("%<b>Connection State%</b>\n"); 8730Sstevel@tonic-gate mdb_printf("last_secret_update%?ld\n", 8740Sstevel@tonic-gate sctp.sctp_last_secret_update); 8750Sstevel@tonic-gate 8760Sstevel@tonic-gate mdb_printf("secret\t\t"); 8770Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8780Sstevel@tonic-gate if (i % 2 == 0) 8790Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_secret[i]); 8800Sstevel@tonic-gate else 8810Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_secret[i]); 8820Sstevel@tonic-gate } 8830Sstevel@tonic-gate mdb_printf("\n"); 8840Sstevel@tonic-gate mdb_printf("old_secret\t"); 8850Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8860Sstevel@tonic-gate if (i % 2 == 0) 8870Sstevel@tonic-gate mdb_printf("0x%02x", sctp.sctp_old_secret[i]); 8880Sstevel@tonic-gate else 8890Sstevel@tonic-gate mdb_printf("%02x ", sctp.sctp_old_secret[i]); 8900Sstevel@tonic-gate } 8910Sstevel@tonic-gate mdb_printf("\n"); 8920Sstevel@tonic-gate } 8930Sstevel@tonic-gate 8940Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_STATS) { 8950Sstevel@tonic-gate mdb_printf("%<b>Stats Counters%</b>\n"); 8960Sstevel@tonic-gate mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n" 8970Sstevel@tonic-gate "odchunks\t%?llu\toudchunks\t%?llu\n" 8980Sstevel@tonic-gate "rxtchunks\t%?llu\tT1expire\t%?lu\n" 8990Sstevel@tonic-gate "T2expire\t%?lu\tT3expire\t%?lu\n" 9000Sstevel@tonic-gate "msgcount\t%?llu\tprsctpdrop\t%?llu\n" 9010Sstevel@tonic-gate "AssocStartTime\t%?lu\n", 9020Sstevel@tonic-gate sctp.sctp_opkts, sctp.sctp_obchunks, 9030Sstevel@tonic-gate sctp.sctp_odchunks, sctp.sctp_oudchunks, 9040Sstevel@tonic-gate sctp.sctp_rxtchunks, sctp.sctp_T1expire, 9050Sstevel@tonic-gate sctp.sctp_T2expire, sctp.sctp_T3expire, 9060Sstevel@tonic-gate sctp.sctp_msgcount, sctp.sctp_prsctpdrop, 9070Sstevel@tonic-gate sctp.sctp_assoc_start_time); 9080Sstevel@tonic-gate mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n" 9090Sstevel@tonic-gate "idchunks\t%?llu\tiudchunks\t%?llu\n" 9100Sstevel@tonic-gate "fragdmsgs\t%?llu\treassmsgs\t%?llu\n", 9110Sstevel@tonic-gate sctp.sctp_ipkts, sctp.sctp_ibchunks, 9120Sstevel@tonic-gate sctp.sctp_idchunks, sctp.sctp_iudchunks, 9130Sstevel@tonic-gate sctp.sctp_fragdmsgs, sctp.sctp_reassmsgs); 9140Sstevel@tonic-gate } 9150Sstevel@tonic-gate 9160Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HASH) { 9170Sstevel@tonic-gate mdb_printf("%<b>Hash Tables%</b>\n"); 9180Sstevel@tonic-gate mdb_printf("conn_hash_next\t%?p\t", sctp.sctp_conn_hash_next); 9190Sstevel@tonic-gate mdb_printf("conn_hash_prev\t%?p\n", sctp.sctp_conn_hash_prev); 9200Sstevel@tonic-gate 9210Sstevel@tonic-gate mdb_printf("listen_hash_next%?p\t", 9220Sstevel@tonic-gate sctp.sctp_listen_hash_next); 9230Sstevel@tonic-gate mdb_printf("listen_hash_prev%?p\n", 9240Sstevel@tonic-gate sctp.sctp_listen_hash_prev); 9250Sstevel@tonic-gate mdb_nhconvert(&lport, &sctp.sctp_lport, sizeof (lport)); 9260Sstevel@tonic-gate mdb_printf("[ listen_hash bucket\t%?d ]\n", 9270Sstevel@tonic-gate SCTP_LISTEN_HASH(lport)); 9280Sstevel@tonic-gate 9290Sstevel@tonic-gate mdb_printf("conn_tfp\t%?p\t", sctp.sctp_conn_tfp); 9300Sstevel@tonic-gate mdb_printf("listen_tfp\t%?p\n", sctp.sctp_listen_tfp); 9310Sstevel@tonic-gate 9320Sstevel@tonic-gate mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n", 9330Sstevel@tonic-gate sctp.sctp_bind_hash, sctp.sctp_ptpbhn); 9340Sstevel@tonic-gate mdb_printf("bind_lockp\t%?p\n", 9350Sstevel@tonic-gate sctp.sctp_bind_lockp); 9360Sstevel@tonic-gate mdb_printf("[ bind_hash bucket\t%?d ]\n", 9370Sstevel@tonic-gate SCTP_BIND_HASH(lport)); 9380Sstevel@tonic-gate } 9390Sstevel@tonic-gate 9400Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CLOSE) { 9410Sstevel@tonic-gate mdb_printf("%<b>Cleanup / Close%</b>\n"); 9420Sstevel@tonic-gate mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n" 9430Sstevel@tonic-gate "lingertime\t%?d\trefcnt\t\t%?hu\n", 9440Sstevel@tonic-gate sctp.sctp_shutdown_faddr, sctp.sctp_client_errno, 9450Sstevel@tonic-gate sctp.sctp_lingertime, sctp.sctp_refcnt); 9460Sstevel@tonic-gate } 9470Sstevel@tonic-gate 9480Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_MISC) { 9490Sstevel@tonic-gate mdb_printf("%<b>Miscellaneous%</b>\n"); 9500Sstevel@tonic-gate mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n" 9510Sstevel@tonic-gate "family\t\t%?u\tipversion\t%?hu\n" 9520Sstevel@tonic-gate "hb_interval\t%?u\tautoclose\t%?d\n" 9530Sstevel@tonic-gate "active\t\t%?ld\ttx_adaption_code%?x\n" 9543845Svi117747 "rx_adaption_code%?x\ttimer_mp\t%?p\n" 9553845Svi117747 "partial_delivery_point\t%?d\n", 9560Sstevel@tonic-gate sctp.sctp_bound_if, sctp.sctp_heartbeat_mp, 9570Sstevel@tonic-gate sctp.sctp_family, sctp.sctp_ipversion, 9580Sstevel@tonic-gate sctp.sctp_hb_interval, sctp.sctp_autoclose, 9590Sstevel@tonic-gate sctp.sctp_active, sctp.sctp_tx_adaption_code, 9603845Svi117747 sctp.sctp_rx_adaption_code, sctp.sctp_timer_mp, 9613845Svi117747 sctp.sctp_pd_point); 9620Sstevel@tonic-gate } 9630Sstevel@tonic-gate 9640Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_EXT) { 9650Sstevel@tonic-gate mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n"); 9660Sstevel@tonic-gate mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n" 9670Sstevel@tonic-gate "fcsn\t\t%?x\n", sctp.sctp_cxmit_list, sctp.sctp_lcsn, 9680Sstevel@tonic-gate sctp.sctp_fcsn); 9690Sstevel@tonic-gate } 9700Sstevel@tonic-gate 9710Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLAGS) { 9720Sstevel@tonic-gate mdb_printf("%<b>Flags%</b>\n"); 9730Sstevel@tonic-gate show_sctp_flags(&sctp); 9740Sstevel@tonic-gate } 9750Sstevel@tonic-gate 9760Sstevel@tonic-gate return (DCMD_OK); 9770Sstevel@tonic-gate } 9780Sstevel@tonic-gate 9790Sstevel@tonic-gate typedef struct fanout_walk_data { 9800Sstevel@tonic-gate int index; 9810Sstevel@tonic-gate int size; 9820Sstevel@tonic-gate uintptr_t sctp; 9830Sstevel@tonic-gate sctp_tf_t *fanout; 9840Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9850Sstevel@tonic-gate } fanout_walk_data_t; 9860Sstevel@tonic-gate 9870Sstevel@tonic-gate typedef struct fanout_init { 9883448Sdh155122 const char *nested_walker_name; 9893448Sdh155122 size_t offset; /* for what used to be a symbol */ 9903448Sdh155122 int (*getsize)(sctp_stack_t *); 9910Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9920Sstevel@tonic-gate } fanout_init_t; 9930Sstevel@tonic-gate 9940Sstevel@tonic-gate static uintptr_t 9950Sstevel@tonic-gate listen_next(sctp_t *sctp) 9960Sstevel@tonic-gate { 9970Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_listen_hash_next); 9980Sstevel@tonic-gate } 9990Sstevel@tonic-gate 10003448Sdh155122 /* ARGSUSED */ 10010Sstevel@tonic-gate static int 10023448Sdh155122 listen_size(sctp_stack_t *sctps) 10030Sstevel@tonic-gate { 10040Sstevel@tonic-gate return (SCTP_LISTEN_FANOUT_SIZE); 10050Sstevel@tonic-gate } 10060Sstevel@tonic-gate 10070Sstevel@tonic-gate static uintptr_t 10080Sstevel@tonic-gate conn_next(sctp_t *sctp) 10090Sstevel@tonic-gate { 10100Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_conn_hash_next); 10110Sstevel@tonic-gate } 10120Sstevel@tonic-gate 10130Sstevel@tonic-gate static int 10143448Sdh155122 conn_size(sctp_stack_t *sctps) 10150Sstevel@tonic-gate { 10160Sstevel@tonic-gate int size; 10173448Sdh155122 uintptr_t kaddr; 10180Sstevel@tonic-gate 10193448Sdh155122 kaddr = (uintptr_t)&sctps->sctps_conn_hash_size; 10203448Sdh155122 10213448Sdh155122 if (mdb_vread(&size, sizeof (size), kaddr) == -1) { 10223448Sdh155122 mdb_warn("can't read 'sctps_conn_hash_size' at %p", kaddr); 10230Sstevel@tonic-gate return (1); 10240Sstevel@tonic-gate } 10250Sstevel@tonic-gate return (size); 10260Sstevel@tonic-gate } 10270Sstevel@tonic-gate 10280Sstevel@tonic-gate static uintptr_t 10290Sstevel@tonic-gate bind_next(sctp_t *sctp) 10300Sstevel@tonic-gate { 10310Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_bind_hash); 10320Sstevel@tonic-gate } 10330Sstevel@tonic-gate 10343448Sdh155122 /* ARGSUSED */ 10350Sstevel@tonic-gate static int 10363448Sdh155122 bind_size(sctp_stack_t *sctps) 10370Sstevel@tonic-gate { 10380Sstevel@tonic-gate return (SCTP_BIND_FANOUT_SIZE); 10390Sstevel@tonic-gate } 10400Sstevel@tonic-gate 10410Sstevel@tonic-gate static intptr_t 10420Sstevel@tonic-gate find_next_hash_item(fanout_walk_data_t *fw) 10430Sstevel@tonic-gate { 10440Sstevel@tonic-gate sctp_tf_t tf; 10450Sstevel@tonic-gate sctp_t sctp; 10460Sstevel@tonic-gate 10470Sstevel@tonic-gate /* first try to continue down the hash chain */ 10480Sstevel@tonic-gate if (fw->sctp != NULL) { 10490Sstevel@tonic-gate /* try to get next in hash chain */ 10500Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) { 10510Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", fw->sctp); 10520Sstevel@tonic-gate return (NULL); 10530Sstevel@tonic-gate } 10540Sstevel@tonic-gate fw->sctp = fw->getnext(&sctp); 10550Sstevel@tonic-gate if (fw->sctp != NULL) 10560Sstevel@tonic-gate return (fw->sctp); 10570Sstevel@tonic-gate else 10580Sstevel@tonic-gate /* end of chain; go to next bucket */ 10590Sstevel@tonic-gate fw->index++; 10600Sstevel@tonic-gate } 10610Sstevel@tonic-gate 10620Sstevel@tonic-gate /* find a new hash chain, traversing the buckets */ 10630Sstevel@tonic-gate for (; fw->index < fw->size; fw->index++) { 10640Sstevel@tonic-gate /* read the current hash line for an sctp */ 10650Sstevel@tonic-gate if (mdb_vread(&tf, sizeof (tf), 10664691Skcpoon (uintptr_t)(fw->fanout + fw->index)) == -1) { 10670Sstevel@tonic-gate mdb_warn("failed to read tf at %p", 10680Sstevel@tonic-gate fw->fanout + fw->index); 10690Sstevel@tonic-gate return (NULL); 10700Sstevel@tonic-gate } 10710Sstevel@tonic-gate if (tf.tf_sctp != NULL) { 10720Sstevel@tonic-gate /* start of a new chain */ 10730Sstevel@tonic-gate fw->sctp = (uintptr_t)tf.tf_sctp; 10740Sstevel@tonic-gate return (fw->sctp); 10750Sstevel@tonic-gate } 10760Sstevel@tonic-gate } 10770Sstevel@tonic-gate return (NULL); 10780Sstevel@tonic-gate } 10790Sstevel@tonic-gate 10800Sstevel@tonic-gate static int 10813448Sdh155122 fanout_stack_walk_init(mdb_walk_state_t *wsp) 10820Sstevel@tonic-gate { 10830Sstevel@tonic-gate fanout_walk_data_t *lw; 10840Sstevel@tonic-gate fanout_init_t *fi = wsp->walk_arg; 10853448Sdh155122 sctp_stack_t *sctps = (sctp_stack_t *)wsp->walk_addr; 10863448Sdh155122 uintptr_t kaddr; 10870Sstevel@tonic-gate 10883448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), 10893448Sdh155122 wsp->walk_addr + fi->offset) == -1) { 10903448Sdh155122 mdb_warn("can't read sctp fanout at %p", 10913448Sdh155122 wsp->walk_addr + fi->offset); 10920Sstevel@tonic-gate return (WALK_ERR); 10930Sstevel@tonic-gate } 10940Sstevel@tonic-gate 10950Sstevel@tonic-gate lw = mdb_alloc(sizeof (*lw), UM_SLEEP); 10960Sstevel@tonic-gate lw->index = 0; 10973448Sdh155122 lw->size = fi->getsize(sctps); 10980Sstevel@tonic-gate lw->sctp = NULL; 10993448Sdh155122 lw->fanout = (sctp_tf_t *)kaddr; 11000Sstevel@tonic-gate lw->getnext = fi->getnext; 11010Sstevel@tonic-gate 11020Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(lw)) == NULL) { 11030Sstevel@tonic-gate return (WALK_DONE); 11040Sstevel@tonic-gate } 11050Sstevel@tonic-gate wsp->walk_data = lw; 11060Sstevel@tonic-gate return (WALK_NEXT); 11070Sstevel@tonic-gate } 11080Sstevel@tonic-gate 11090Sstevel@tonic-gate static int 11103448Sdh155122 fanout_stack_walk_step(mdb_walk_state_t *wsp) 11110Sstevel@tonic-gate { 11120Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11130Sstevel@tonic-gate uintptr_t addr = wsp->walk_addr; 11140Sstevel@tonic-gate sctp_t sctp; 11150Sstevel@tonic-gate int status; 11160Sstevel@tonic-gate 11170Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 11180Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", addr); 11190Sstevel@tonic-gate return (WALK_DONE); 11200Sstevel@tonic-gate } 11210Sstevel@tonic-gate 11220Sstevel@tonic-gate status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata); 11230Sstevel@tonic-gate if (status != WALK_NEXT) 11240Sstevel@tonic-gate return (status); 11250Sstevel@tonic-gate 11260Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(fw)) == NULL) 11270Sstevel@tonic-gate return (WALK_DONE); 11280Sstevel@tonic-gate 11290Sstevel@tonic-gate return (WALK_NEXT); 11300Sstevel@tonic-gate } 11310Sstevel@tonic-gate 11320Sstevel@tonic-gate static void 11333448Sdh155122 fanout_stack_walk_fini(mdb_walk_state_t *wsp) 11340Sstevel@tonic-gate { 11350Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11360Sstevel@tonic-gate 11370Sstevel@tonic-gate mdb_free(fw, sizeof (*fw)); 11380Sstevel@tonic-gate } 11390Sstevel@tonic-gate 11403448Sdh155122 int 11413448Sdh155122 fanout_walk_init(mdb_walk_state_t *wsp) 11420Sstevel@tonic-gate { 11433448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 11443448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 11453448Sdh155122 return (WALK_ERR); 11463448Sdh155122 } 11473448Sdh155122 11483448Sdh155122 return (WALK_NEXT); 11493448Sdh155122 } 11503448Sdh155122 11513448Sdh155122 int 11523448Sdh155122 fanout_walk_step(mdb_walk_state_t *wsp) 11533448Sdh155122 { 11543448Sdh155122 fanout_init_t *fi = wsp->walk_arg; 11553448Sdh155122 11563448Sdh155122 if (mdb_pwalk(fi->nested_walker_name, wsp->walk_callback, 11574691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 11583448Sdh155122 mdb_warn("couldn't walk '%s'for address %p", 11593448Sdh155122 fi->nested_walker_name, wsp->walk_addr); 11603448Sdh155122 return (WALK_ERR); 11613448Sdh155122 } 11620Sstevel@tonic-gate return (WALK_NEXT); 11630Sstevel@tonic-gate } 11640Sstevel@tonic-gate 11653448Sdh155122 int 11663448Sdh155122 sctps_walk_init(mdb_walk_state_t *wsp) 11670Sstevel@tonic-gate { 11680Sstevel@tonic-gate 11693448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 11703448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 11710Sstevel@tonic-gate return (WALK_ERR); 11720Sstevel@tonic-gate } 11733448Sdh155122 11743448Sdh155122 return (WALK_NEXT); 11753448Sdh155122 } 11760Sstevel@tonic-gate 11773448Sdh155122 int 11783448Sdh155122 sctps_walk_step(mdb_walk_state_t *wsp) 11793448Sdh155122 { 11803448Sdh155122 uintptr_t kaddr; 11813448Sdh155122 11823448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_list); 11833448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 11844691Skcpoon wsp->walk_cbdata, kaddr) == -1) { 11853448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", kaddr); 11863448Sdh155122 return (WALK_ERR); 11870Sstevel@tonic-gate } 11883448Sdh155122 return (WALK_NEXT); 11890Sstevel@tonic-gate } 11900Sstevel@tonic-gate 11910Sstevel@tonic-gate static int 11920Sstevel@tonic-gate sctp_walk_faddr_init(mdb_walk_state_t *wsp) 11930Sstevel@tonic-gate { 11940Sstevel@tonic-gate sctp_t sctp; 11950Sstevel@tonic-gate 11960Sstevel@tonic-gate if (wsp->walk_addr == NULL) 11970Sstevel@tonic-gate return (WALK_ERR); 11980Sstevel@tonic-gate 11990Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) { 12000Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12010Sstevel@tonic-gate return (WALK_ERR); 12020Sstevel@tonic-gate } 12030Sstevel@tonic-gate if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != NULL) 12040Sstevel@tonic-gate return (WALK_NEXT); 12050Sstevel@tonic-gate else 12060Sstevel@tonic-gate return (WALK_DONE); 12070Sstevel@tonic-gate } 12080Sstevel@tonic-gate 12090Sstevel@tonic-gate static int 12100Sstevel@tonic-gate sctp_walk_faddr_step(mdb_walk_state_t *wsp) 12110Sstevel@tonic-gate { 12120Sstevel@tonic-gate uintptr_t faddr_ptr = wsp->walk_addr; 12130Sstevel@tonic-gate sctp_faddr_t sctp_faddr; 12140Sstevel@tonic-gate int status; 12150Sstevel@tonic-gate 12160Sstevel@tonic-gate if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) { 12170Sstevel@tonic-gate mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr); 12180Sstevel@tonic-gate return (WALK_ERR); 12190Sstevel@tonic-gate } 12200Sstevel@tonic-gate status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata); 12210Sstevel@tonic-gate if (status != WALK_NEXT) 12220Sstevel@tonic-gate return (status); 12230Sstevel@tonic-gate if ((faddr_ptr = (uintptr_t)sctp_faddr.next) == NULL) { 12240Sstevel@tonic-gate return (WALK_DONE); 12250Sstevel@tonic-gate } else { 12260Sstevel@tonic-gate wsp->walk_addr = faddr_ptr; 12270Sstevel@tonic-gate return (WALK_NEXT); 12280Sstevel@tonic-gate } 12290Sstevel@tonic-gate } 12300Sstevel@tonic-gate 12310Sstevel@tonic-gate /* 12320Sstevel@tonic-gate * Helper structure for sctp_walk_saddr. It stores the sctp_t being walked, 12330Sstevel@tonic-gate * the current index to the sctp_saddrs[], and the current count of the 12340Sstevel@tonic-gate * sctp_saddr_ipif_t list. 12350Sstevel@tonic-gate */ 12360Sstevel@tonic-gate typedef struct { 12370Sstevel@tonic-gate sctp_t sctp; 12380Sstevel@tonic-gate int hash_index; 12390Sstevel@tonic-gate int cur_cnt; 12400Sstevel@tonic-gate } saddr_walk_t; 12410Sstevel@tonic-gate 12420Sstevel@tonic-gate static int 12430Sstevel@tonic-gate sctp_walk_saddr_init(mdb_walk_state_t *wsp) 12440Sstevel@tonic-gate { 12450Sstevel@tonic-gate sctp_t *sctp; 12460Sstevel@tonic-gate int i; 12470Sstevel@tonic-gate saddr_walk_t *swalker; 12480Sstevel@tonic-gate 12490Sstevel@tonic-gate if (wsp->walk_addr == NULL) 12500Sstevel@tonic-gate return (WALK_ERR); 12510Sstevel@tonic-gate 12520Sstevel@tonic-gate swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP); 12530Sstevel@tonic-gate sctp = &swalker->sctp; 12540Sstevel@tonic-gate if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) { 12550Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12560Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 12570Sstevel@tonic-gate return (WALK_ERR); 12580Sstevel@tonic-gate } 12590Sstevel@tonic-gate 12600Sstevel@tonic-gate /* Find the first source address. */ 12610Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 12620Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 12630Sstevel@tonic-gate list_t *addr_list; 12640Sstevel@tonic-gate 12650Sstevel@tonic-gate addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list; 12660Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(addr_list, 12670Sstevel@tonic-gate addr_list->list_head.list_next); 12680Sstevel@tonic-gate 12690Sstevel@tonic-gate /* Recode the current info */ 12700Sstevel@tonic-gate swalker->hash_index = i; 12710Sstevel@tonic-gate swalker->cur_cnt = 1; 12720Sstevel@tonic-gate wsp->walk_data = swalker; 12730Sstevel@tonic-gate 12740Sstevel@tonic-gate return (WALK_NEXT); 12750Sstevel@tonic-gate } 12760Sstevel@tonic-gate } 12770Sstevel@tonic-gate return (WALK_DONE); 12780Sstevel@tonic-gate } 12790Sstevel@tonic-gate 12800Sstevel@tonic-gate static int 12810Sstevel@tonic-gate sctp_walk_saddr_step(mdb_walk_state_t *wsp) 12820Sstevel@tonic-gate { 12830Sstevel@tonic-gate uintptr_t saddr_ptr = wsp->walk_addr; 12840Sstevel@tonic-gate sctp_saddr_ipif_t saddr; 12850Sstevel@tonic-gate saddr_walk_t *swalker; 12860Sstevel@tonic-gate sctp_t *sctp; 12870Sstevel@tonic-gate int status; 12880Sstevel@tonic-gate int i, j; 12890Sstevel@tonic-gate 12900Sstevel@tonic-gate if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) { 12910Sstevel@tonic-gate mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr); 12920Sstevel@tonic-gate return (WALK_ERR); 12930Sstevel@tonic-gate } 12940Sstevel@tonic-gate status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata); 12950Sstevel@tonic-gate if (status != WALK_NEXT) 12960Sstevel@tonic-gate return (status); 12970Sstevel@tonic-gate 12980Sstevel@tonic-gate swalker = (saddr_walk_t *)wsp->walk_data; 12990Sstevel@tonic-gate sctp = &swalker->sctp; 13000Sstevel@tonic-gate i = swalker->hash_index; 13010Sstevel@tonic-gate j = swalker->cur_cnt; 13020Sstevel@tonic-gate 13030Sstevel@tonic-gate /* 13040Sstevel@tonic-gate * If there is still a source address in the current list, return it. 13050Sstevel@tonic-gate * Otherwise, go to the next list in the sctp_saddrs[]. 13060Sstevel@tonic-gate */ 13070Sstevel@tonic-gate if (j++ < sctp->sctp_saddrs[i].ipif_count) { 13080Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next; 13090Sstevel@tonic-gate swalker->cur_cnt = j; 13100Sstevel@tonic-gate return (WALK_NEXT); 13110Sstevel@tonic-gate } else { 13120Sstevel@tonic-gate list_t *lst; 13130Sstevel@tonic-gate 13140Sstevel@tonic-gate for (i = i + 1; i < SCTP_IPIF_HASH; i++) { 13150Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 13160Sstevel@tonic-gate lst = &sctp->sctp_saddrs[i].sctp_ipif_list; 13170Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 13180Sstevel@tonic-gate lst, lst->list_head.list_next); 13190Sstevel@tonic-gate swalker->hash_index = i; 13200Sstevel@tonic-gate swalker->cur_cnt = 1; 13210Sstevel@tonic-gate return (WALK_NEXT); 13220Sstevel@tonic-gate } 13230Sstevel@tonic-gate } 13240Sstevel@tonic-gate } 13250Sstevel@tonic-gate return (WALK_DONE); 13260Sstevel@tonic-gate } 13270Sstevel@tonic-gate 13280Sstevel@tonic-gate static void 13290Sstevel@tonic-gate sctp_walk_saddr_fini(mdb_walk_state_t *wsp) 13300Sstevel@tonic-gate { 13310Sstevel@tonic-gate saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data; 13320Sstevel@tonic-gate 13330Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 13340Sstevel@tonic-gate } 13350Sstevel@tonic-gate 13363448Sdh155122 13373448Sdh155122 typedef struct ill_walk_data { 13383448Sdh155122 sctp_ill_hash_t ills[SCTP_ILL_HASH]; 13393448Sdh155122 uint32_t count; 13403448Sdh155122 } ill_walk_data_t; 13413448Sdh155122 13423448Sdh155122 typedef struct ipuf_walk_data { 13433448Sdh155122 sctp_ipif_hash_t ipifs[SCTP_IPIF_HASH]; 13443448Sdh155122 uint32_t count; 13453448Sdh155122 } ipif_walk_data_t; 13463448Sdh155122 13473448Sdh155122 13483448Sdh155122 int 13493448Sdh155122 sctp_ill_walk_init(mdb_walk_state_t *wsp) 13503448Sdh155122 { 13513448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 13523448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 13533448Sdh155122 return (WALK_ERR); 13543448Sdh155122 } 13553448Sdh155122 13563448Sdh155122 return (WALK_NEXT); 13573448Sdh155122 } 13583448Sdh155122 13593448Sdh155122 int 13603448Sdh155122 sctp_ill_walk_step(mdb_walk_state_t *wsp) 13613448Sdh155122 { 13623448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ill", wsp->walk_callback, 13634691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 13643448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ill' for addr %p", 13653448Sdh155122 wsp->walk_addr); 13663448Sdh155122 return (WALK_ERR); 13673448Sdh155122 } 13683448Sdh155122 return (WALK_NEXT); 13693448Sdh155122 } 13703448Sdh155122 13713448Sdh155122 /* 13723448Sdh155122 * wsp->walk_addr is the address of sctps_ill_list 13733448Sdh155122 */ 13740Sstevel@tonic-gate static int 13753448Sdh155122 sctp_stack_ill_walk_init(mdb_walk_state_t *wsp) 13760Sstevel@tonic-gate { 13773448Sdh155122 ill_walk_data_t iw; 13780Sstevel@tonic-gate intptr_t i; 13793448Sdh155122 uintptr_t kaddr, uaddr; 13803448Sdh155122 size_t offset; 13813448Sdh155122 13823448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_ills_count); 13833448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 13843448Sdh155122 mdb_warn("can't read sctps_ills_count at %p", kaddr); 13853448Sdh155122 return (WALK_ERR); 13863448Sdh155122 } 13873448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ills); 13883448Sdh155122 13893448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 13903448Sdh155122 mdb_warn("can't read scpts_g_ills %p", kaddr); 13913448Sdh155122 return (WALK_ERR); 13923448Sdh155122 } 13933448Sdh155122 if (mdb_vread(&iw.ills, sizeof (iw.ills), kaddr) == -1) { 13943448Sdh155122 mdb_warn("failed to read 'sctps_g_ills'"); 13953448Sdh155122 return (NULL); 13963448Sdh155122 } 13970Sstevel@tonic-gate 13980Sstevel@tonic-gate /* Find the first ill. */ 13990Sstevel@tonic-gate for (i = 0; i < SCTP_ILL_HASH; i++) { 14003448Sdh155122 if (iw.ills[i].ill_count > 0) { 14013448Sdh155122 uaddr = (uintptr_t)&iw.ills[i].sctp_ill_list; 14023448Sdh155122 offset = uaddr - (uintptr_t)&iw.ills; 14033448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 14044691Skcpoon wsp->walk_cbdata, kaddr+offset) == -1) { 14053448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 14063448Sdh155122 kaddr); 14073448Sdh155122 return (WALK_ERR); 14080Sstevel@tonic-gate } 14090Sstevel@tonic-gate } 14100Sstevel@tonic-gate } 14110Sstevel@tonic-gate return (WALK_DONE); 14120Sstevel@tonic-gate } 14130Sstevel@tonic-gate 14140Sstevel@tonic-gate static int 14153448Sdh155122 sctp_stack_ill_walk_step(mdb_walk_state_t *wsp) 14163448Sdh155122 { 14173448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 14184691Skcpoon wsp->walk_cbdata)); 14193448Sdh155122 } 14203448Sdh155122 14213448Sdh155122 int 14223448Sdh155122 sctp_ipif_walk_init(mdb_walk_state_t *wsp) 14230Sstevel@tonic-gate { 14243448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 14253448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 14263448Sdh155122 return (WALK_ERR); 14273448Sdh155122 } 14283448Sdh155122 return (WALK_NEXT); 14293448Sdh155122 } 14303448Sdh155122 14313448Sdh155122 int 14323448Sdh155122 sctp_ipif_walk_step(mdb_walk_state_t *wsp) 14333448Sdh155122 { 14343448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ipif", wsp->walk_callback, 14354691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 14363448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ipif' for addr %p", 14373448Sdh155122 wsp->walk_addr); 14383448Sdh155122 return (WALK_ERR); 14393448Sdh155122 } 14403448Sdh155122 return (WALK_NEXT); 14413448Sdh155122 } 14423448Sdh155122 14433448Sdh155122 /* 14443448Sdh155122 * wsp->walk_addr is the address of sctps_ipif_list 14453448Sdh155122 */ 14463448Sdh155122 static int 14473448Sdh155122 sctp_stack_ipif_walk_init(mdb_walk_state_t *wsp) 14483448Sdh155122 { 14493448Sdh155122 ipif_walk_data_t iw; 14500Sstevel@tonic-gate intptr_t i; 14513448Sdh155122 uintptr_t kaddr, uaddr; 14523448Sdh155122 size_t offset; 14533448Sdh155122 14543448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs_count); 14553448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 14563448Sdh155122 mdb_warn("can't read sctps_g_ipifs_count at %p", kaddr); 14573448Sdh155122 return (WALK_ERR); 14583448Sdh155122 } 14593448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs); 14600Sstevel@tonic-gate 14613448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 14623448Sdh155122 mdb_warn("can't read scpts_g_ipifs %p", kaddr); 14633448Sdh155122 return (WALK_ERR); 14643448Sdh155122 } 14653448Sdh155122 if (mdb_vread(&iw.ipifs, sizeof (iw.ipifs), kaddr) == -1) { 14663448Sdh155122 mdb_warn("failed to read 'sctps_g_ipifs'"); 14673448Sdh155122 return (NULL); 14683448Sdh155122 } 14693448Sdh155122 14703448Sdh155122 /* Find the first ipif. */ 14710Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 14723448Sdh155122 if (iw.ipifs[i].ipif_count > 0) { 14733448Sdh155122 uaddr = (uintptr_t)&iw.ipifs[i].sctp_ipif_list; 14743448Sdh155122 offset = uaddr - (uintptr_t)&iw.ipifs; 14753448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 14764691Skcpoon wsp->walk_cbdata, kaddr+offset) == -1) { 14773448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 14783448Sdh155122 kaddr); 14793448Sdh155122 return (WALK_ERR); 14803448Sdh155122 } 14810Sstevel@tonic-gate } 14820Sstevel@tonic-gate } 14830Sstevel@tonic-gate return (WALK_DONE); 14840Sstevel@tonic-gate } 14850Sstevel@tonic-gate 14860Sstevel@tonic-gate static int 14873448Sdh155122 sctp_stack_ipif_walk_step(mdb_walk_state_t *wsp) 14880Sstevel@tonic-gate { 14893448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 14904691Skcpoon wsp->walk_cbdata)); 14910Sstevel@tonic-gate } 14920Sstevel@tonic-gate 14930Sstevel@tonic-gate static void 14940Sstevel@tonic-gate sctp_help(void) 14950Sstevel@tonic-gate { 14960Sstevel@tonic-gate mdb_printf("Print information for a given SCTP sctp_t\n\n"); 14970Sstevel@tonic-gate mdb_printf("Options:\n"); 14980Sstevel@tonic-gate mdb_printf("\t-a\t All the information\n"); 14990Sstevel@tonic-gate mdb_printf("\t-f\t Flags\n"); 15000Sstevel@tonic-gate mdb_printf("\t-h\t Hash Tables\n"); 15010Sstevel@tonic-gate mdb_printf("\t-o\t Outbound Data\n"); 15020Sstevel@tonic-gate mdb_printf("\t-i\t Inbound Data\n"); 15030Sstevel@tonic-gate mdb_printf("\t-m\t Miscellaneous Information\n"); 15040Sstevel@tonic-gate mdb_printf("\t-r\t RTT Tracking\n"); 15050Sstevel@tonic-gate mdb_printf("\t-S\t Stats Counters\n"); 15060Sstevel@tonic-gate mdb_printf("\t-F\t Flow Control\n"); 15070Sstevel@tonic-gate mdb_printf("\t-H\t Composite Headers\n"); 15080Sstevel@tonic-gate mdb_printf("\t-p\t PMTUD\n"); 15090Sstevel@tonic-gate mdb_printf("\t-R\t Retransmit Information\n"); 15100Sstevel@tonic-gate mdb_printf("\t-C\t Connection State\n"); 15110Sstevel@tonic-gate mdb_printf("\t-c\t Cleanup / Close\n"); 15120Sstevel@tonic-gate mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n"); 15130Sstevel@tonic-gate mdb_printf("\t-d\t Local and Peer addresses\n"); 15140Sstevel@tonic-gate mdb_printf("\t-P\t Peer addresses\n"); 15150Sstevel@tonic-gate } 15160Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = { 15170Sstevel@tonic-gate { "sctp", ":[-afhoimrSFHpRCcedP]", 15180Sstevel@tonic-gate "display sctp control structure", sctp, sctp_help }, 15190Sstevel@tonic-gate { "sctp_set", ":", "display a SCTP set", sctp_set }, 15200Sstevel@tonic-gate { "sctp_faddr", ":", "display a faddr", sctp_faddr }, 15210Sstevel@tonic-gate { "sctp_istr_msgs", ":", "display msg list on an instream", 15220Sstevel@tonic-gate sctp_istr_msgs }, 15230Sstevel@tonic-gate { "sctp_mdata_chunk", ":", "display a data chunk in an mblk", 15240Sstevel@tonic-gate sctp_mdata_chunk }, 15250Sstevel@tonic-gate { "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list }, 15260Sstevel@tonic-gate { "sctp_instr", ":", "display instr", sctp_instr }, 15270Sstevel@tonic-gate { "sctp_reass_list", ":", "display reass list", sctp_reass_list }, 15280Sstevel@tonic-gate { "sctp_uo_reass_list", ":", "display un-ordered reass list", 15290Sstevel@tonic-gate sctp_uo_reass_list }, 15300Sstevel@tonic-gate { NULL } 15310Sstevel@tonic-gate }; 15320Sstevel@tonic-gate 15330Sstevel@tonic-gate static const fanout_init_t listen_fanout_init = { 15343448Sdh155122 "sctp_stack_listen_fanout", OFFSETOF(sctp_stack_t, sctps_listen_fanout), 15353448Sdh155122 listen_size, listen_next 15360Sstevel@tonic-gate }; 15370Sstevel@tonic-gate 15380Sstevel@tonic-gate static const fanout_init_t conn_fanout_init = { 15393448Sdh155122 "sctp_stack_conn_fanout", OFFSETOF(sctp_stack_t, sctps_conn_fanout), 15403448Sdh155122 conn_size, conn_next 15410Sstevel@tonic-gate }; 15420Sstevel@tonic-gate 15430Sstevel@tonic-gate static const fanout_init_t bind_fanout_init = { 15443448Sdh155122 "sctp_stack_bind_fanout", OFFSETOF(sctp_stack_t, sctps_bind_fanout), 15453448Sdh155122 bind_size, bind_next 15460Sstevel@tonic-gate }; 15470Sstevel@tonic-gate 15480Sstevel@tonic-gate static const mdb_walker_t walkers[] = { 15493448Sdh155122 { "sctps", "walk the full chain of sctps for all stacks", 15503448Sdh155122 sctps_walk_init, sctps_walk_step, NULL }, 15513448Sdh155122 { "sctp_listen_fanout", "walk the sctp listen fanout for all stacks", 15523448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 15530Sstevel@tonic-gate (void *)&listen_fanout_init }, 15543448Sdh155122 { "sctp_conn_fanout", "walk the sctp conn fanout for all stacks", 15553448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 15560Sstevel@tonic-gate (void *)&conn_fanout_init }, 15573448Sdh155122 { "sctp_bind_fanout", "walk the sctp bind fanout for all stacks", 15583448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 15593448Sdh155122 (void *)&bind_fanout_init }, 15603448Sdh155122 { "sctp_stack_listen_fanout", 15613448Sdh155122 "walk the sctp listen fanout for one stack", 15623448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 15633448Sdh155122 fanout_stack_walk_fini, 15643448Sdh155122 (void *)&listen_fanout_init }, 15653448Sdh155122 { "sctp_stack_conn_fanout", "walk the sctp conn fanout for one stack", 15663448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 15673448Sdh155122 fanout_stack_walk_fini, 15683448Sdh155122 (void *)&conn_fanout_init }, 15693448Sdh155122 { "sctp_stack_bind_fanout", "walk the sctp bind fanoutfor one stack", 15703448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 15713448Sdh155122 fanout_stack_walk_fini, 15720Sstevel@tonic-gate (void *)&bind_fanout_init }, 15730Sstevel@tonic-gate { "sctp_walk_faddr", "walk the peer address list of a given sctp_t", 15740Sstevel@tonic-gate sctp_walk_faddr_init, sctp_walk_faddr_step, NULL }, 15750Sstevel@tonic-gate { "sctp_walk_saddr", "walk the local address list of a given sctp_t", 15760Sstevel@tonic-gate sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini }, 15773448Sdh155122 { "sctp_walk_ill", "walk the sctp_g_ills list for all stacks", 15783448Sdh155122 sctp_ill_walk_init, sctp_ill_walk_step, NULL }, 15793448Sdh155122 { "sctp_walk_ipif", "walk the sctp_g_ipif list for all stacks", 15803448Sdh155122 sctp_ipif_walk_init, sctp_ipif_walk_step, NULL }, 15813448Sdh155122 { "sctp_stack_walk_ill", "walk the sctp_g_ills list for one stack", 15823448Sdh155122 sctp_stack_ill_walk_init, sctp_stack_ill_walk_step, NULL }, 15833448Sdh155122 { "sctp_stack_walk_ipif", "walk the sctp_g_ipif list for one stack", 15843448Sdh155122 sctp_stack_ipif_walk_init, sctp_stack_ipif_walk_step, NULL }, 15853448Sdh155122 { "sctp_stacks", "walk all the sctp_stack_t", 15863448Sdh155122 sctp_stacks_walk_init, sctp_stacks_walk_step, NULL }, 15870Sstevel@tonic-gate { NULL } 15880Sstevel@tonic-gate }; 15890Sstevel@tonic-gate 15900Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers }; 15910Sstevel@tonic-gate 15920Sstevel@tonic-gate const mdb_modinfo_t * 15930Sstevel@tonic-gate _mdb_init(void) 15940Sstevel@tonic-gate { 15950Sstevel@tonic-gate return (&modinfo); 15960Sstevel@tonic-gate } 1597