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 /* 2312474SGeorge.Shepherd@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #include <sys/types.h> 270Sstevel@tonic-gate #include <sys/stream.h> 280Sstevel@tonic-gate #include <sys/mdb_modapi.h> 290Sstevel@tonic-gate #include <sys/socket.h> 300Sstevel@tonic-gate #include <sys/list.h> 310Sstevel@tonic-gate #include <sys/strsun.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <mdb/mdb_stdlib.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <netinet/in.h> 360Sstevel@tonic-gate #include <netinet/ip6.h> 370Sstevel@tonic-gate #include <netinet/sctp.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <inet/common.h> 400Sstevel@tonic-gate #include <inet/ip.h> 410Sstevel@tonic-gate #include <inet/ip6.h> 420Sstevel@tonic-gate #include <inet/ipclassifier.h> 430Sstevel@tonic-gate 440Sstevel@tonic-gate #include <sctp/sctp_impl.h> 450Sstevel@tonic-gate #include <sctp/sctp_addr.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define MDB_SCTP_SHOW_FLAGS 0x1 480Sstevel@tonic-gate #define MDB_SCTP_DUMP_ADDRS 0x2 490Sstevel@tonic-gate #define MDB_SCTP_SHOW_HASH 0x4 500Sstevel@tonic-gate #define MDB_SCTP_SHOW_OUT 0x8 510Sstevel@tonic-gate #define MDB_SCTP_SHOW_IN 0x10 520Sstevel@tonic-gate #define MDB_SCTP_SHOW_MISC 0x20 530Sstevel@tonic-gate #define MDB_SCTP_SHOW_RTT 0x40 540Sstevel@tonic-gate #define MDB_SCTP_SHOW_STATS 0x80 550Sstevel@tonic-gate #define MDB_SCTP_SHOW_FLOW 0x100 560Sstevel@tonic-gate #define MDB_SCTP_SHOW_HDR 0x200 570Sstevel@tonic-gate #define MDB_SCTP_SHOW_PMTUD 0x400 580Sstevel@tonic-gate #define MDB_SCTP_SHOW_RXT 0x800 590Sstevel@tonic-gate #define MDB_SCTP_SHOW_CONN 0x1000 600Sstevel@tonic-gate #define MDB_SCTP_SHOW_CLOSE 0x2000 610Sstevel@tonic-gate #define MDB_SCTP_SHOW_EXT 0x4000 620Sstevel@tonic-gate 630Sstevel@tonic-gate #define MDB_SCTP_SHOW_ALL 0xffffffff 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Copy from usr/src/uts/common/os/list.c. Should we have a generic 670Sstevel@tonic-gate * mdb list walker? 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate #define list_object(a, node) ((void *)(((char *)node) - (a)->list_offset)) 700Sstevel@tonic-gate 713448Sdh155122 static int 723448Sdh155122 ns_to_stackid(uintptr_t kaddr) 733448Sdh155122 { 743448Sdh155122 netstack_t nss; 753448Sdh155122 763448Sdh155122 if (mdb_vread(&nss, sizeof (nss), kaddr) == -1) { 773448Sdh155122 mdb_warn("failed to read netdstack info %p", kaddr); 783448Sdh155122 return (0); 793448Sdh155122 } 803448Sdh155122 return (nss.netstack_stackid); 813448Sdh155122 } 823448Sdh155122 833448Sdh155122 int 843448Sdh155122 sctp_stacks_walk_init(mdb_walk_state_t *wsp) 853448Sdh155122 { 863448Sdh155122 if (mdb_layered_walk("netstack", wsp) == -1) { 873448Sdh155122 mdb_warn("can't walk 'netstack'"); 883448Sdh155122 return (WALK_ERR); 893448Sdh155122 } 903448Sdh155122 return (WALK_NEXT); 913448Sdh155122 } 923448Sdh155122 933448Sdh155122 int 943448Sdh155122 sctp_stacks_walk_step(mdb_walk_state_t *wsp) 953448Sdh155122 { 963448Sdh155122 uintptr_t kaddr; 973448Sdh155122 netstack_t nss; 983448Sdh155122 993448Sdh155122 if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) { 1003448Sdh155122 mdb_warn("can't read netstack at %p", wsp->walk_addr); 1013448Sdh155122 return (WALK_ERR); 1023448Sdh155122 } 1033448Sdh155122 kaddr = (uintptr_t)nss.netstack_modules[NS_SCTP]; 1043448Sdh155122 return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata)); 1053448Sdh155122 } 1063448Sdh155122 107432Svi117747 static char * 108432Svi117747 sctp_faddr_state(int state) 109432Svi117747 { 110432Svi117747 char *statestr; 111432Svi117747 112432Svi117747 switch (state) { 113432Svi117747 case SCTP_FADDRS_UNREACH: 114432Svi117747 statestr = "Unreachable"; 115432Svi117747 break; 116432Svi117747 case SCTP_FADDRS_DOWN: 117432Svi117747 statestr = "Down"; 118432Svi117747 break; 119432Svi117747 case SCTP_FADDRS_ALIVE: 120432Svi117747 statestr = "Alive"; 121432Svi117747 break; 122432Svi117747 case SCTP_FADDRS_UNCONFIRMED: 123432Svi117747 statestr = "Unconfirmed"; 124432Svi117747 break; 125432Svi117747 default: 126432Svi117747 statestr = "Unknown"; 127432Svi117747 break; 128432Svi117747 } 129432Svi117747 return (statestr); 130432Svi117747 } 131432Svi117747 1320Sstevel@tonic-gate /* ARGSUSED */ 1330Sstevel@tonic-gate static int 1340Sstevel@tonic-gate sctp_faddr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1350Sstevel@tonic-gate { 1360Sstevel@tonic-gate sctp_faddr_t fa[1]; 1370Sstevel@tonic-gate char *statestr; 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1400Sstevel@tonic-gate return (DCMD_USAGE); 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate if (mdb_vread(fa, sizeof (*fa), addr) == -1) { 1430Sstevel@tonic-gate mdb_warn("cannot read fadder at %p", addr); 1440Sstevel@tonic-gate return (DCMD_ERR); 1450Sstevel@tonic-gate } 1460Sstevel@tonic-gate 147432Svi117747 statestr = sctp_faddr_state(fa->state); 1480Sstevel@tonic-gate mdb_printf("%<u>%p\t%<b>%N%</b>\t%s%</u>\n", addr, &fa->faddr, 1490Sstevel@tonic-gate statestr); 1500Sstevel@tonic-gate mdb_printf("next\t\t%?p\tsaddr\t%N\n", fa->next, &fa->saddr); 1510Sstevel@tonic-gate mdb_printf("rto\t\t%?d\tsrtt\t\t%?d\n", fa->rto, fa->srtt); 1520Sstevel@tonic-gate mdb_printf("rttvar\t\t%?d\trtt_updates\t%?u\n", fa->rttvar, 1530Sstevel@tonic-gate fa->rtt_updates); 1540Sstevel@tonic-gate mdb_printf("strikes\t\t%?d\tmax_retr\t%?d\n", fa->strikes, 1550Sstevel@tonic-gate fa->max_retr); 1560Sstevel@tonic-gate mdb_printf("hb_expiry\t%?ld\thb_interval\t%?u\n", fa->hb_expiry, 1570Sstevel@tonic-gate fa->hb_interval); 1580Sstevel@tonic-gate mdb_printf("pmss\t\t%?u\tcwnd\t\t%?u\n", fa->sfa_pmss, fa->cwnd); 1590Sstevel@tonic-gate mdb_printf("ssthresh\t%?u\tsuna\t\t%?u\n", fa->ssthresh, fa->suna); 1600Sstevel@tonic-gate mdb_printf("pba\t\t%?u\tacked\t\t%?u\n", fa->pba, fa->acked); 1610Sstevel@tonic-gate mdb_printf("lastactive\t%?ld\thb_secret\t%?#lx\n", fa->lastactive, 1620Sstevel@tonic-gate fa->hb_secret); 1634818Skcpoon mdb_printf("rxt_unacked\t%?u\n", fa->rxt_unacked); 16411042SErik.Nordmark@Sun.COM mdb_printf("timer_mp\t%?p\tixa\t\t%?p\n", fa->timer_mp, fa->ixa); 1654818Skcpoon mdb_printf("hb_enabled\t%?d\thb_pending\t%?d\n" 1664818Skcpoon "timer_running\t%?d\tdf\t\t%?d\n" 1674818Skcpoon "pmtu_discovered\t%?d\tisv4\t\t%?d\n" 1684818Skcpoon "retransmissions\t%?u\n", 1694818Skcpoon fa->hb_enabled, fa->hb_pending, fa->timer_running, fa->df, 1704818Skcpoon fa->pmtu_discovered, fa->isv4, fa->T3expire); 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate return (DCMD_OK); 1730Sstevel@tonic-gate } 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate static void 1760Sstevel@tonic-gate print_set(sctp_set_t *sp) 1770Sstevel@tonic-gate { 1780Sstevel@tonic-gate mdb_printf("\tbegin\t%<b>%?x%</b>\t\tend\t%<b>%?x%</b>\n", 1790Sstevel@tonic-gate sp->begin, sp->end); 1800Sstevel@tonic-gate mdb_printf("\tnext\t%?p\tprev\t%?p\n", sp->next, sp->prev); 1810Sstevel@tonic-gate } 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* ARGSUSED */ 1840Sstevel@tonic-gate static int 1850Sstevel@tonic-gate sctp_set(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1860Sstevel@tonic-gate { 1870Sstevel@tonic-gate sctp_set_t sp[1]; 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 1900Sstevel@tonic-gate return (DCMD_USAGE); 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) 1930Sstevel@tonic-gate return (DCMD_ERR); 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate print_set(sp); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate return (DCMD_OK); 1980Sstevel@tonic-gate } 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate static void 2010Sstevel@tonic-gate dump_sack_info(uintptr_t addr) 2020Sstevel@tonic-gate { 2030Sstevel@tonic-gate sctp_set_t sp[1]; 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate while (addr != 0) { 2060Sstevel@tonic-gate if (mdb_vread(sp, sizeof (*sp), addr) == -1) { 2070Sstevel@tonic-gate mdb_warn("failed to read sctp_set at %p", addr); 2080Sstevel@tonic-gate return; 2090Sstevel@tonic-gate } 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate addr = (uintptr_t)sp->next; 2120Sstevel@tonic-gate print_set(sp); 2130Sstevel@tonic-gate } 2140Sstevel@tonic-gate } 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate static int 2170Sstevel@tonic-gate dump_msghdr(mblk_t *meta) 2180Sstevel@tonic-gate { 2190Sstevel@tonic-gate sctp_msg_hdr_t smh; 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate if (mdb_vread(&smh, sizeof (smh), (uintptr_t)meta->b_rptr) == -1) 2220Sstevel@tonic-gate return (-1); 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate mdb_printf("%<u>msg_hdr_t at \t%?p\tsentto\t%?p%</u>\n", 2250Sstevel@tonic-gate meta->b_rptr, SCTP_CHUNK_DEST(meta)); 2260Sstevel@tonic-gate mdb_printf("\tttl\t%?ld\ttob\t%?ld\n", smh.smh_ttl, smh.smh_tob); 2270Sstevel@tonic-gate mdb_printf("\tsid\t%?u\tssn\t%?u\n", smh.smh_sid, smh.smh_ssn); 2280Sstevel@tonic-gate mdb_printf("\tppid\t%?u\tflags\t%?s\n", smh.smh_ppid, 2290Sstevel@tonic-gate smh.smh_flags & MSG_UNORDERED ? "unordered" : " "); 2300Sstevel@tonic-gate mdb_printf("\tcontext\t%?u\tmsglen\t%?d\n", smh.smh_context, 2310Sstevel@tonic-gate smh.smh_msglen); 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate return (0); 2340Sstevel@tonic-gate } 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate static int 2370Sstevel@tonic-gate dump_datahdr(mblk_t *mp) 2380Sstevel@tonic-gate { 2390Sstevel@tonic-gate sctp_data_hdr_t sdc; 2400Sstevel@tonic-gate uint16_t sdh_int16; 2410Sstevel@tonic-gate uint32_t sdh_int32; 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate if (mdb_vread(&sdc, sizeof (sdc), (uintptr_t)mp->b_rptr) == -1) 2440Sstevel@tonic-gate return (-1); 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate mdb_printf("%<u>data_chunk_t \t%?p\tsentto\t%?p%</u>\n", 2470Sstevel@tonic-gate mp->b_rptr, SCTP_CHUNK_DEST(mp)); 2480Sstevel@tonic-gate mdb_printf("\tsent\t%?d\t", SCTP_CHUNK_ISSENT(mp)?1:0); 2490Sstevel@tonic-gate mdb_printf("retrans\t%?d\n", SCTP_CHUNK_WANT_REXMIT(mp)?1:0); 2500Sstevel@tonic-gate mdb_printf("\tacked\t%?d\t", SCTP_CHUNK_ISACKED(mp)?1:0); 2510Sstevel@tonic-gate mdb_printf("sackcnt\t%?u\n", SCTP_CHUNK_SACKCNT(mp)); 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_len, sizeof (sdc.sdh_len)); 2540Sstevel@tonic-gate mdb_printf("\tlen\t%?d\t", sdh_int16); 2550Sstevel@tonic-gate mdb_printf("BBIT=%d", SCTP_DATA_GET_BBIT(&sdc) == 0 ? 0 : 1); 2560Sstevel@tonic-gate mdb_printf("EBIT=%d", SCTP_DATA_GET_EBIT(&sdc) == 0 ? 0 : 1); 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_tsn, sizeof (sdc.sdh_tsn)); 2590Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_sid, sizeof (sdc.sdh_sid)); 2600Sstevel@tonic-gate mdb_printf("\ttsn\t%?x\tsid\t%?hu\n", sdh_int32, sdh_int16); 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate mdb_nhconvert(&sdh_int16, &sdc.sdh_ssn, sizeof (sdc.sdh_ssn)); 2630Sstevel@tonic-gate mdb_nhconvert(&sdh_int32, &sdc.sdh_payload_id, 2640Sstevel@tonic-gate sizeof (sdc.sdh_payload_id)); 2650Sstevel@tonic-gate mdb_printf("\tssn\t%?hu\tppid\t%?d\n", sdh_int16, sdh_int32); 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate return (0); 2680Sstevel@tonic-gate } 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate static int 2710Sstevel@tonic-gate sctp_sent_list(mblk_t *addr) 2720Sstevel@tonic-gate { 2730Sstevel@tonic-gate mblk_t meta, mp; 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate if (!addr) 2760Sstevel@tonic-gate return (0); 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 2790Sstevel@tonic-gate return (-1); 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate for (;;) { 2820Sstevel@tonic-gate dump_msghdr(&meta); 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate if (meta.b_cont == NULL) { 2850Sstevel@tonic-gate mdb_printf("No data chunks with message header!\n"); 2860Sstevel@tonic-gate return (-1); 2870Sstevel@tonic-gate } 2880Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2894691Skcpoon (uintptr_t)meta.b_cont) == -1) { 2900Sstevel@tonic-gate return (-1); 2910Sstevel@tonic-gate } 2920Sstevel@tonic-gate for (;;) { 2930Sstevel@tonic-gate dump_datahdr(&mp); 2940Sstevel@tonic-gate if (!mp.b_next) 2950Sstevel@tonic-gate break; 2960Sstevel@tonic-gate 2970Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), 2980Sstevel@tonic-gate (uintptr_t)(mp.b_next)) == -1) 2990Sstevel@tonic-gate return (-1); 3000Sstevel@tonic-gate } 3010Sstevel@tonic-gate if (meta.b_next == NULL) 3020Sstevel@tonic-gate break; 3030Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3040Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3050Sstevel@tonic-gate return (-1); 3060Sstevel@tonic-gate } 3070Sstevel@tonic-gate 3080Sstevel@tonic-gate return (0); 3090Sstevel@tonic-gate } 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate static int 3120Sstevel@tonic-gate sctp_unsent_list(mblk_t *addr) 3130Sstevel@tonic-gate { 3140Sstevel@tonic-gate mblk_t meta; 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate if (!addr) 3170Sstevel@tonic-gate return (0); 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), (uintptr_t)addr) == -1) 3200Sstevel@tonic-gate return (-1); 3210Sstevel@tonic-gate 3220Sstevel@tonic-gate for (;;) { 3230Sstevel@tonic-gate dump_msghdr(&meta); 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate if (meta.b_next == NULL) 3260Sstevel@tonic-gate break; 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate if (mdb_vread(&meta, sizeof (meta), 3290Sstevel@tonic-gate (uintptr_t)meta.b_next) == -1) 3300Sstevel@tonic-gate return (-1); 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate return (0); 3340Sstevel@tonic-gate } 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate /* ARGSUSED */ 3370Sstevel@tonic-gate static int 3380Sstevel@tonic-gate sctp_xmit_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3390Sstevel@tonic-gate { 3400Sstevel@tonic-gate sctp_t sctp; 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(&sctp, sizeof (sctp), addr) == -1) 3460Sstevel@tonic-gate return (DCMD_ERR); 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate mdb_printf("%<b>Chunkified TX list%</b>\n"); 3490Sstevel@tonic-gate if (sctp_sent_list(sctp.sctp_xmit_head) < 0) 3500Sstevel@tonic-gate return (DCMD_ERR); 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate mdb_printf("%<b>Unchunkified TX list%</b>\n"); 3530Sstevel@tonic-gate if (sctp_unsent_list(sctp.sctp_xmit_unsent) < 0) 3540Sstevel@tonic-gate return (DCMD_ERR); 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_mdata_chunk(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3620Sstevel@tonic-gate { 3630Sstevel@tonic-gate sctp_data_hdr_t dc; 3640Sstevel@tonic-gate mblk_t mp; 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3670Sstevel@tonic-gate return (DCMD_USAGE); 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate if (mdb_vread(&mp, sizeof (mp), addr) == -1) 3700Sstevel@tonic-gate return (DCMD_ERR); 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate if (mdb_vread(&dc, sizeof (dc), (uintptr_t)mp.b_rptr) == -1) 3730Sstevel@tonic-gate return (DCMD_ERR); 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>tsn\t%?x\tsid\t%?hu\n", addr, 3760Sstevel@tonic-gate dc.sdh_tsn, dc.sdh_sid); 3770Sstevel@tonic-gate mdb_printf("%-?sssn\t%?hu\tppid\t%?x\n", "", dc.sdh_ssn, 3780Sstevel@tonic-gate dc.sdh_payload_id); 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate return (DCMD_OK); 3810Sstevel@tonic-gate } 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate /* ARGSUSED */ 3840Sstevel@tonic-gate static int 3850Sstevel@tonic-gate sctp_istr_msgs(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 3860Sstevel@tonic-gate { 3870Sstevel@tonic-gate mblk_t istrmp; 3880Sstevel@tonic-gate mblk_t dmp; 3890Sstevel@tonic-gate sctp_data_hdr_t dp; 3900Sstevel@tonic-gate uintptr_t daddr; 3910Sstevel@tonic-gate uintptr_t chaddr; 3920Sstevel@tonic-gate boolean_t bbit; 3930Sstevel@tonic-gate boolean_t ebit; 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 3960Sstevel@tonic-gate return (DCMD_USAGE); 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate do { 3990Sstevel@tonic-gate if (mdb_vread(&istrmp, sizeof (istrmp), addr) == -1) 4000Sstevel@tonic-gate return (DCMD_ERR); 4010Sstevel@tonic-gate 4020Sstevel@tonic-gate mdb_printf("\tistr mblk at %p: next: %?p\n" 4030Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, istrmp.b_next, 4040Sstevel@tonic-gate istrmp.b_prev, istrmp.b_cont); 4050Sstevel@tonic-gate daddr = (uintptr_t)&istrmp; 4060Sstevel@tonic-gate do { 4070Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4080Sstevel@tonic-gate break; 4090Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4100Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4110Sstevel@tonic-gate break; 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4140Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4170Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4210Sstevel@tonic-gate } while (daddr != NULL); 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate addr = (uintptr_t)istrmp.b_next; 4240Sstevel@tonic-gate } while (addr != NULL); 4250Sstevel@tonic-gate 4260Sstevel@tonic-gate return (DCMD_OK); 4270Sstevel@tonic-gate } 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate /* ARGSUSED */ 4300Sstevel@tonic-gate static int 4310Sstevel@tonic-gate sctp_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4320Sstevel@tonic-gate { 4330Sstevel@tonic-gate sctp_reass_t srp; 4340Sstevel@tonic-gate mblk_t srpmp; 4350Sstevel@tonic-gate sctp_data_hdr_t dp; 4360Sstevel@tonic-gate mblk_t dmp; 4370Sstevel@tonic-gate uintptr_t daddr; 4380Sstevel@tonic-gate uintptr_t chaddr; 4390Sstevel@tonic-gate boolean_t bbit, ebit; 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4420Sstevel@tonic-gate return (DCMD_USAGE); 4430Sstevel@tonic-gate 4440Sstevel@tonic-gate do { 4450Sstevel@tonic-gate if (mdb_vread(&srpmp, sizeof (srpmp), addr) == -1) 4460Sstevel@tonic-gate return (DCMD_ERR); 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate if (mdb_vread(&srp, sizeof (srp), 4490Sstevel@tonic-gate (uintptr_t)srpmp.b_datap->db_base) == -1) 4500Sstevel@tonic-gate return (DCMD_ERR); 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 4530Sstevel@tonic-gate "\t\tprev: %?p\tcont: %?p\n", addr, srpmp.b_next, 4540Sstevel@tonic-gate srpmp.b_prev, srpmp.b_cont); 4550Sstevel@tonic-gate mdb_printf("\t\tssn: %hu\tneeded: %hu\tgot: %hu\ttail: %?p\n" 4560Sstevel@tonic-gate "\t\tpartial_delivered: %s\n", srp.ssn, srp.needed, 4570Sstevel@tonic-gate srp.got, srp.tail, srp.partial_delivered ? "TRUE" : 4580Sstevel@tonic-gate "FALSE"); 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* display the contents of this ssn's reassemby list */ 4610Sstevel@tonic-gate daddr = DB_TYPE(&srpmp) == M_CTL ? (uintptr_t)srpmp.b_cont : 4620Sstevel@tonic-gate (uintptr_t)&srpmp; 4630Sstevel@tonic-gate do { 4640Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), daddr) == -1) 4650Sstevel@tonic-gate break; 4660Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 4670Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 4680Sstevel@tonic-gate break; 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 4710Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate mdb_printf("\t\t\ttsn: %x bbit: %d ebit: %d\n", 4740Sstevel@tonic-gate dp.sdh_tsn, bbit, ebit); 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate daddr = (uintptr_t)dmp.b_cont; 4770Sstevel@tonic-gate } while (daddr != NULL); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate addr = (uintptr_t)srpmp.b_next; 4800Sstevel@tonic-gate } while (addr != NULL); 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate return (DCMD_OK); 4830Sstevel@tonic-gate } 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate /* ARGSUSED */ 4860Sstevel@tonic-gate static int 4870Sstevel@tonic-gate sctp_uo_reass_list(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 4880Sstevel@tonic-gate { 4890Sstevel@tonic-gate sctp_data_hdr_t dp; 4900Sstevel@tonic-gate mblk_t dmp; 4910Sstevel@tonic-gate uintptr_t chaddr; 4920Sstevel@tonic-gate boolean_t bbit; 4930Sstevel@tonic-gate boolean_t ebit; 4940Sstevel@tonic-gate boolean_t ubit; 4950Sstevel@tonic-gate 4960Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 4970Sstevel@tonic-gate return (DCMD_USAGE); 4980Sstevel@tonic-gate 4990Sstevel@tonic-gate do { 5000Sstevel@tonic-gate if (mdb_vread(&dmp, sizeof (dmp), addr) == -1) 5010Sstevel@tonic-gate return (DCMD_ERR); 5020Sstevel@tonic-gate 5030Sstevel@tonic-gate mdb_printf("\treassembly mblk at %p: next: %?p\n" 5040Sstevel@tonic-gate "\t\tprev: %?p\n", addr, dmp.b_next, dmp.b_prev); 5050Sstevel@tonic-gate 5060Sstevel@tonic-gate chaddr = (uintptr_t)dmp.b_rptr; 5070Sstevel@tonic-gate if (mdb_vread(&dp, sizeof (dp), chaddr) == -1) 5080Sstevel@tonic-gate break; 5090Sstevel@tonic-gate 5100Sstevel@tonic-gate bbit = (SCTP_DATA_GET_BBIT(&dp) != 0); 5110Sstevel@tonic-gate ebit = (SCTP_DATA_GET_EBIT(&dp) != 0); 5120Sstevel@tonic-gate ubit = (SCTP_DATA_GET_UBIT(&dp) != 0); 5130Sstevel@tonic-gate 5140Sstevel@tonic-gate mdb_printf("\t\t\tsid: %hu ssn: %hu tsn: %x " 5150Sstevel@tonic-gate "flags: %x (U=%d B=%d E=%d)\n", dp.sdh_sid, dp.sdh_ssn, 5160Sstevel@tonic-gate dp.sdh_tsn, dp.sdh_flags, ubit, bbit, ebit); 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate addr = (uintptr_t)dmp.b_next; 5190Sstevel@tonic-gate } while (addr != NULL); 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate return (DCMD_OK); 5220Sstevel@tonic-gate } 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate static int 5250Sstevel@tonic-gate sctp_instr(uintptr_t addr, uint_t flags, int ac, const mdb_arg_t *av) 5260Sstevel@tonic-gate { 5270Sstevel@tonic-gate sctp_instr_t sip; 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 5300Sstevel@tonic-gate return (DCMD_USAGE); 5310Sstevel@tonic-gate 5320Sstevel@tonic-gate if (mdb_vread(&sip, sizeof (sip), addr) == -1) 5330Sstevel@tonic-gate return (DCMD_ERR); 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate mdb_printf("%<b>%-?p%</b>\n\tmsglist\t%?p\tnmsgs\t%?d\n" 5360Sstevel@tonic-gate "\tnextseq\t%?d\treass\t%?p\n", addr, sip.istr_msgs, 5370Sstevel@tonic-gate sip.istr_nmsgs, sip.nextseq, sip.istr_reass); 5380Sstevel@tonic-gate mdb_set_dot(addr + sizeof (sip)); 5390Sstevel@tonic-gate 5400Sstevel@tonic-gate return (sctp_reass_list((uintptr_t)sip.istr_reass, flags, ac, av)); 5410Sstevel@tonic-gate } 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate static const char * 5440Sstevel@tonic-gate state2str(sctp_t *sctp) 5450Sstevel@tonic-gate { 5460Sstevel@tonic-gate switch (sctp->sctp_state) { 5470Sstevel@tonic-gate case SCTPS_IDLE: return ("SCTPS_IDLE"); 5480Sstevel@tonic-gate case SCTPS_BOUND: return ("SCTPS_BOUND"); 5490Sstevel@tonic-gate case SCTPS_LISTEN: return ("SCTPS_LISTEN"); 5500Sstevel@tonic-gate case SCTPS_COOKIE_WAIT: return ("SCTPS_COOKIE_WAIT"); 5510Sstevel@tonic-gate case SCTPS_COOKIE_ECHOED: return ("SCTPS_COOKIE_ECHOED"); 5520Sstevel@tonic-gate case SCTPS_ESTABLISHED: return ("SCTPS_ESTABLISHED"); 5530Sstevel@tonic-gate case SCTPS_SHUTDOWN_PENDING: return ("SCTPS_SHUTDOWN_PENDING"); 5540Sstevel@tonic-gate case SCTPS_SHUTDOWN_SENT: return ("SCTPS_SHUTDOWN_SENT"); 5550Sstevel@tonic-gate case SCTPS_SHUTDOWN_RECEIVED: return ("SCTPS_SHUTDOWN_RECEIVED"); 5560Sstevel@tonic-gate case SCTPS_SHUTDOWN_ACK_SENT: return ("SCTPS_SHUTDOWN_ACK_SENT"); 5570Sstevel@tonic-gate default: return ("UNKNOWN STATE"); 5580Sstevel@tonic-gate } 5590Sstevel@tonic-gate } 5600Sstevel@tonic-gate 5610Sstevel@tonic-gate static void 5620Sstevel@tonic-gate show_sctp_flags(sctp_t *sctp) 5630Sstevel@tonic-gate { 5640Sstevel@tonic-gate mdb_printf("\tunderstands_asconf\t%d\n", 5650Sstevel@tonic-gate sctp->sctp_understands_asconf); 56611042SErik.Nordmark@Sun.COM mdb_printf("\tdebug\t\t\t%d\n", sctp->sctp_connp->conn_debug); 5670Sstevel@tonic-gate mdb_printf("\tcchunk_pend\t\t%d\n", sctp->sctp_cchunk_pend); 56811042SErik.Nordmark@Sun.COM mdb_printf("\tdgram_errind\t\t%d\n", 56911042SErik.Nordmark@Sun.COM sctp->sctp_connp->conn_dgram_errind); 5700Sstevel@tonic-gate 57111042SErik.Nordmark@Sun.COM mdb_printf("\tlinger\t\t\t%d\n", sctp->sctp_connp->conn_linger); 5720Sstevel@tonic-gate if (sctp->sctp_lingering) 5730Sstevel@tonic-gate return; 5740Sstevel@tonic-gate mdb_printf("\tlingering\t\t%d\n", sctp->sctp_lingering); 5750Sstevel@tonic-gate mdb_printf("\tloopback\t\t%d\n", sctp->sctp_loopback); 5760Sstevel@tonic-gate mdb_printf("\tforce_sack\t\t%d\n", sctp->sctp_force_sack); 5770Sstevel@tonic-gate 5780Sstevel@tonic-gate mdb_printf("\tack_timer_runing\t%d\n", sctp->sctp_ack_timer_running); 57911042SErik.Nordmark@Sun.COM mdb_printf("\trecvdstaddr\t\t%d\n", 58011042SErik.Nordmark@Sun.COM sctp->sctp_connp->conn_recv_ancillary.crb_recvdstaddr); 5810Sstevel@tonic-gate mdb_printf("\thwcksum\t\t\t%d\n", sctp->sctp_hwcksum); 5820Sstevel@tonic-gate mdb_printf("\tunderstands_addip\t%d\n", sctp->sctp_understands_addip); 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate mdb_printf("\tbound_to_all\t\t%d\n", sctp->sctp_bound_to_all); 5850Sstevel@tonic-gate mdb_printf("\tcansleep\t\t%d\n", sctp->sctp_cansleep); 5860Sstevel@tonic-gate mdb_printf("\tdetached\t\t%d\n", sctp->sctp_detached); 5875586Skcpoon mdb_printf("\tsend_adaptation\t\t%d\n", sctp->sctp_send_adaptation); 5880Sstevel@tonic-gate 5895586Skcpoon mdb_printf("\trecv_adaptation\t\t%d\n", sctp->sctp_recv_adaptation); 5900Sstevel@tonic-gate mdb_printf("\tndelay\t\t\t%d\n", sctp->sctp_ndelay); 5910Sstevel@tonic-gate mdb_printf("\tcondemned\t\t%d\n", sctp->sctp_condemned); 5920Sstevel@tonic-gate mdb_printf("\tchk_fast_rexmit\t\t%d\n", sctp->sctp_chk_fast_rexmit); 5931735Skcpoon 5940Sstevel@tonic-gate mdb_printf("\tprsctp_aware\t\t%d\n", sctp->sctp_prsctp_aware); 595432Svi117747 mdb_printf("\tlinklocal\t\t%d\n", sctp->sctp_linklocal); 5961735Skcpoon mdb_printf("\trexmitting\t\t%d\n", sctp->sctp_rexmitting); 5972263Ssommerfe mdb_printf("\tzero_win_probe\t\t%d\n", sctp->sctp_zero_win_probe); 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate mdb_printf("\trecvsndrcvinfo\t\t%d\n", sctp->sctp_recvsndrcvinfo); 6000Sstevel@tonic-gate mdb_printf("\trecvassocevnt\t\t%d\n", sctp->sctp_recvassocevnt); 6010Sstevel@tonic-gate mdb_printf("\trecvpathevnt\t\t%d\n", sctp->sctp_recvpathevnt); 6020Sstevel@tonic-gate mdb_printf("\trecvsendfailevnt\t%d\n", sctp->sctp_recvsendfailevnt); 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate mdb_printf("\trecvpeerevnt\t\t%d\n", sctp->sctp_recvpeererr); 6050Sstevel@tonic-gate mdb_printf("\trecvchutdownevnt\t%d\n", sctp->sctp_recvshutdownevnt); 6060Sstevel@tonic-gate mdb_printf("\trecvcpdnevnt\t\t%d\n", sctp->sctp_recvpdevnt); 6070Sstevel@tonic-gate mdb_printf("\trecvcalevnt\t\t%d\n\n", sctp->sctp_recvalevnt); 6080Sstevel@tonic-gate } 6090Sstevel@tonic-gate 6100Sstevel@tonic-gate /* 6110Sstevel@tonic-gate * Given a sctp_saddr_ipif_t, print out its address. This assumes 6120Sstevel@tonic-gate * that addr contains the sctp_addr_ipif_t structure already and this 6130Sstevel@tonic-gate * function does not need to read it in. 6140Sstevel@tonic-gate */ 6150Sstevel@tonic-gate /* ARGSUSED */ 6160Sstevel@tonic-gate static int 6170Sstevel@tonic-gate print_saddr(uintptr_t ptr, const void *addr, void *cbdata) 6180Sstevel@tonic-gate { 6190Sstevel@tonic-gate sctp_saddr_ipif_t *saddr = (sctp_saddr_ipif_t *)addr; 6200Sstevel@tonic-gate sctp_ipif_t ipif; 6210Sstevel@tonic-gate char *statestr; 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate /* Read in the sctp_ipif object */ 6240Sstevel@tonic-gate if (mdb_vread(&ipif, sizeof (ipif), (uintptr_t)saddr->saddr_ipifp) == 6250Sstevel@tonic-gate -1) { 6260Sstevel@tonic-gate mdb_warn("cannot read ipif at %p", saddr->saddr_ipifp); 6270Sstevel@tonic-gate return (WALK_ERR); 6280Sstevel@tonic-gate } 6290Sstevel@tonic-gate 6300Sstevel@tonic-gate switch (ipif.sctp_ipif_state) { 6310Sstevel@tonic-gate case SCTP_IPIFS_CONDEMNED: 632432Svi117747 statestr = "Condemned"; 6330Sstevel@tonic-gate break; 6340Sstevel@tonic-gate case SCTP_IPIFS_INVALID: 635432Svi117747 statestr = "Invalid"; 6360Sstevel@tonic-gate break; 6370Sstevel@tonic-gate case SCTP_IPIFS_DOWN: 638432Svi117747 statestr = "Down"; 6390Sstevel@tonic-gate break; 6400Sstevel@tonic-gate case SCTP_IPIFS_UP: 641432Svi117747 statestr = "Up"; 6420Sstevel@tonic-gate break; 6430Sstevel@tonic-gate default: 644432Svi117747 statestr = "Unknown"; 6450Sstevel@tonic-gate break; 6460Sstevel@tonic-gate } 647432Svi117747 mdb_printf("\t%p\t%N% (%s", saddr->saddr_ipifp, &ipif.sctp_ipif_saddr, 648432Svi117747 statestr); 649432Svi117747 if (saddr->saddr_ipif_dontsrc == 1) 650432Svi117747 mdb_printf("/Dontsrc"); 651432Svi117747 if (saddr->saddr_ipif_unconfirmed == 1) 652432Svi117747 mdb_printf("/Unconfirmed"); 653432Svi117747 if (saddr->saddr_ipif_delete_pending == 1) 654432Svi117747 mdb_printf("/DeletePending"); 655432Svi117747 mdb_printf(")\n"); 65611042SErik.Nordmark@Sun.COM mdb_printf("\t\t\tid %d zoneid %d IPIF flags %x\n", 65711042SErik.Nordmark@Sun.COM ipif.sctp_ipif_id, 658432Svi117747 ipif.sctp_ipif_zoneid, ipif.sctp_ipif_flags); 6590Sstevel@tonic-gate return (WALK_NEXT); 6600Sstevel@tonic-gate } 6610Sstevel@tonic-gate 6620Sstevel@tonic-gate /* 6630Sstevel@tonic-gate * Given a sctp_faddr_t, print out its address. This assumes that 6640Sstevel@tonic-gate * addr contains the sctp_faddr_t structure already and this function 6650Sstevel@tonic-gate * does not need to read it in. 6660Sstevel@tonic-gate */ 6670Sstevel@tonic-gate static int 6680Sstevel@tonic-gate print_faddr(uintptr_t ptr, const void *addr, void *cbdata) 6690Sstevel@tonic-gate { 670432Svi117747 char *statestr; 6710Sstevel@tonic-gate sctp_faddr_t *faddr = (sctp_faddr_t *)addr; 6720Sstevel@tonic-gate int *i = cbdata; 6730Sstevel@tonic-gate 674432Svi117747 statestr = sctp_faddr_state(faddr->state); 675432Svi117747 676432Svi117747 mdb_printf("\t%d:\t%N\t%?p (%s)\n", (*i)++, &faddr->faddr, ptr, 677432Svi117747 statestr); 6780Sstevel@tonic-gate return (WALK_NEXT); 6790Sstevel@tonic-gate } 6800Sstevel@tonic-gate 6810Sstevel@tonic-gate int 6820Sstevel@tonic-gate sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 6830Sstevel@tonic-gate { 68411042SErik.Nordmark@Sun.COM sctp_t sctps, *sctp; 68511042SErik.Nordmark@Sun.COM conn_t conns, *connp; 6860Sstevel@tonic-gate int i; 6870Sstevel@tonic-gate uint_t opts = 0; 6880Sstevel@tonic-gate uint_t paddr = 0; 6890Sstevel@tonic-gate in_port_t lport, fport; 6900Sstevel@tonic-gate 6910Sstevel@tonic-gate if (!(flags & DCMD_ADDRSPEC)) 6920Sstevel@tonic-gate return (DCMD_USAGE); 6930Sstevel@tonic-gate 69411042SErik.Nordmark@Sun.COM if (mdb_vread(&sctps, sizeof (sctps), addr) == -1) { 6950Sstevel@tonic-gate mdb_warn("failed to read sctp_t at: %p\n", addr); 6960Sstevel@tonic-gate return (DCMD_ERR); 6970Sstevel@tonic-gate } 69811042SErik.Nordmark@Sun.COM sctp = &sctps; 69911042SErik.Nordmark@Sun.COM 70011042SErik.Nordmark@Sun.COM if (mdb_vread(&conns, sizeof (conns), 70111042SErik.Nordmark@Sun.COM (uintptr_t)sctp->sctp_connp) == -1) { 70211042SErik.Nordmark@Sun.COM mdb_warn("failed to read conn_t at: %p\n", sctp->sctp_connp); 7030Sstevel@tonic-gate return (DCMD_ERR); 7040Sstevel@tonic-gate } 7050Sstevel@tonic-gate 70611042SErik.Nordmark@Sun.COM connp = &conns; 70711042SErik.Nordmark@Sun.COM 70811042SErik.Nordmark@Sun.COM connp->conn_sctp = sctp; 70911042SErik.Nordmark@Sun.COM sctp->sctp_connp = connp; 71011042SErik.Nordmark@Sun.COM 7110Sstevel@tonic-gate if (mdb_getopts(argc, argv, 7124691Skcpoon 'a', MDB_OPT_SETBITS, MDB_SCTP_SHOW_ALL, &opts, 7134691Skcpoon 'f', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLAGS, &opts, 7144691Skcpoon 'h', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HASH, &opts, 7154691Skcpoon 'o', MDB_OPT_SETBITS, MDB_SCTP_SHOW_OUT, &opts, 7164691Skcpoon 'i', MDB_OPT_SETBITS, MDB_SCTP_SHOW_IN, &opts, 7174691Skcpoon 'm', MDB_OPT_SETBITS, MDB_SCTP_SHOW_MISC, &opts, 7184691Skcpoon 'r', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RTT, &opts, 7194691Skcpoon 'S', MDB_OPT_SETBITS, MDB_SCTP_SHOW_STATS, &opts, 7204691Skcpoon 'F', MDB_OPT_SETBITS, MDB_SCTP_SHOW_FLOW, &opts, 7214691Skcpoon 'H', MDB_OPT_SETBITS, MDB_SCTP_SHOW_HDR, &opts, 7224691Skcpoon 'p', MDB_OPT_SETBITS, MDB_SCTP_SHOW_PMTUD, &opts, 7234691Skcpoon 'R', MDB_OPT_SETBITS, MDB_SCTP_SHOW_RXT, &opts, 7244691Skcpoon 'C', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CONN, &opts, 7254691Skcpoon 'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts, 7264691Skcpoon 'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts, 7274691Skcpoon 'P', MDB_OPT_SETBITS, 1, &paddr, 7284691Skcpoon 'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) { 7290Sstevel@tonic-gate return (DCMD_USAGE); 7300Sstevel@tonic-gate } 7310Sstevel@tonic-gate 7320Sstevel@tonic-gate /* non-verbose faddrs, suitable for pipelines to sctp_faddr */ 7330Sstevel@tonic-gate if (paddr != 0) { 7340Sstevel@tonic-gate sctp_faddr_t faddr, *fp; 73511042SErik.Nordmark@Sun.COM for (fp = sctp->sctp_faddrs; fp != NULL; fp = faddr.next) { 7360Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), (uintptr_t)fp) 7370Sstevel@tonic-gate == -1) { 7380Sstevel@tonic-gate mdb_warn("failed to read faddr at %p", 7390Sstevel@tonic-gate fp); 7400Sstevel@tonic-gate return (DCMD_ERR); 7410Sstevel@tonic-gate } 7420Sstevel@tonic-gate mdb_printf("%p\n", fp); 7430Sstevel@tonic-gate } 7440Sstevel@tonic-gate return (DCMD_OK); 7450Sstevel@tonic-gate } 7460Sstevel@tonic-gate 74711042SErik.Nordmark@Sun.COM mdb_nhconvert(&lport, &connp->conn_lport, sizeof (lport)); 74811042SErik.Nordmark@Sun.COM mdb_nhconvert(&fport, &connp->conn_fport, sizeof (fport)); 7493448Sdh155122 mdb_printf("%<u>%p% %22s S=%-6hu D=%-6hu% STACK=%d ZONE=%d%</u>", addr, 75011042SErik.Nordmark@Sun.COM state2str(sctp), lport, fport, 75111042SErik.Nordmark@Sun.COM ns_to_stackid((uintptr_t)connp->conn_netstack), connp->conn_zoneid); 7520Sstevel@tonic-gate 75311042SErik.Nordmark@Sun.COM if (sctp->sctp_faddrs) { 7540Sstevel@tonic-gate sctp_faddr_t faddr; 7550Sstevel@tonic-gate if (mdb_vread(&faddr, sizeof (faddr), 75611042SErik.Nordmark@Sun.COM (uintptr_t)sctp->sctp_faddrs) != -1) 7570Sstevel@tonic-gate mdb_printf("%<u> %N%</u>", &faddr.faddr); 7580Sstevel@tonic-gate } 7590Sstevel@tonic-gate mdb_printf("\n"); 7600Sstevel@tonic-gate 7610Sstevel@tonic-gate if (opts & MDB_SCTP_DUMP_ADDRS) { 7620Sstevel@tonic-gate mdb_printf("%<b>Local and Peer Addresses%</b>\n"); 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate /* Display source addresses */ 76511042SErik.Nordmark@Sun.COM mdb_printf("nsaddrs\t\t%?d\n", sctp->sctp_nsaddrs); 7660Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_saddr", print_saddr, NULL, addr); 7670Sstevel@tonic-gate 7680Sstevel@tonic-gate /* Display peer addresses */ 76911042SErik.Nordmark@Sun.COM mdb_printf("nfaddrs\t\t%?d\n", sctp->sctp_nfaddrs); 7700Sstevel@tonic-gate i = 1; 7710Sstevel@tonic-gate (void) mdb_pwalk("sctp_walk_faddr", print_faddr, &i, addr); 7720Sstevel@tonic-gate 7730Sstevel@tonic-gate mdb_printf("lastfaddr\t%?p\tprimary\t\t%?p\n", 77411042SErik.Nordmark@Sun.COM sctp->sctp_lastfaddr, sctp->sctp_primary); 7750Sstevel@tonic-gate mdb_printf("current\t\t%?p\tlastdata\t%?p\n", 77611042SErik.Nordmark@Sun.COM sctp->sctp_current, sctp->sctp_lastdata); 7770Sstevel@tonic-gate } 7780Sstevel@tonic-gate 7790Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_OUT) { 7800Sstevel@tonic-gate mdb_printf("%<b>Outbound Data%</b>\n"); 7810Sstevel@tonic-gate mdb_printf("xmit_head\t%?p\txmit_tail\t%?p\n", 78211042SErik.Nordmark@Sun.COM sctp->sctp_xmit_head, sctp->sctp_xmit_tail); 7830Sstevel@tonic-gate mdb_printf("xmit_unsent\t%?p\txmit_unsent_tail%?p\n", 78411042SErik.Nordmark@Sun.COM sctp->sctp_xmit_unsent, sctp->sctp_xmit_unsent_tail); 78511042SErik.Nordmark@Sun.COM mdb_printf("xmit_unacked\t%?p\n", sctp->sctp_xmit_unacked); 7860Sstevel@tonic-gate mdb_printf("unacked\t\t%?u\tunsent\t\t%?ld\n", 78711042SErik.Nordmark@Sun.COM sctp->sctp_unacked, sctp->sctp_unsent); 7880Sstevel@tonic-gate mdb_printf("ltsn\t\t%?x\tlastack_rxd\t%?x\n", 78911042SErik.Nordmark@Sun.COM sctp->sctp_ltsn, sctp->sctp_lastack_rxd); 7900Sstevel@tonic-gate mdb_printf("recovery_tsn\t%?x\tadv_pap\t\t%?x\n", 79111042SErik.Nordmark@Sun.COM sctp->sctp_recovery_tsn, sctp->sctp_adv_pap); 7920Sstevel@tonic-gate mdb_printf("num_ostr\t%?hu\tostrcntrs\t%?p\n", 79311042SErik.Nordmark@Sun.COM sctp->sctp_num_ostr, sctp->sctp_ostrcntrs); 7944964Skcpoon mdb_printf("pad_mp\t\t%?p\terr_chunks\t%?p\n", 79511042SErik.Nordmark@Sun.COM sctp->sctp_pad_mp, sctp->sctp_err_chunks); 79611042SErik.Nordmark@Sun.COM mdb_printf("err_len\t\t%?u\n", sctp->sctp_err_len); 7970Sstevel@tonic-gate 7980Sstevel@tonic-gate mdb_printf("%<b>Default Send Parameters%</b>\n"); 7990Sstevel@tonic-gate mdb_printf("def_stream\t%?u\tdef_flags\t%?x\n", 80011042SErik.Nordmark@Sun.COM sctp->sctp_def_stream, sctp->sctp_def_flags); 8010Sstevel@tonic-gate mdb_printf("def_ppid\t%?x\tdef_context\t%?x\n", 80211042SErik.Nordmark@Sun.COM sctp->sctp_def_ppid, sctp->sctp_def_context); 8030Sstevel@tonic-gate mdb_printf("def_timetolive\t%?u\n", 80411042SErik.Nordmark@Sun.COM sctp->sctp_def_timetolive); 8050Sstevel@tonic-gate } 8060Sstevel@tonic-gate 8070Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_IN) { 8080Sstevel@tonic-gate mdb_printf("%<b>Inbound Data%</b>\n"); 8090Sstevel@tonic-gate mdb_printf("sack_info\t%?p\tsack_gaps\t%?d\n", 81011042SErik.Nordmark@Sun.COM sctp->sctp_sack_info, sctp->sctp_sack_gaps); 81111042SErik.Nordmark@Sun.COM dump_sack_info((uintptr_t)sctp->sctp_sack_info); 8120Sstevel@tonic-gate mdb_printf("ftsn\t\t%?x\tlastacked\t%?x\n", 81311042SErik.Nordmark@Sun.COM sctp->sctp_ftsn, sctp->sctp_lastacked); 8140Sstevel@tonic-gate mdb_printf("istr_nmsgs\t%?d\tsack_toggle\t%?d\n", 81511042SErik.Nordmark@Sun.COM sctp->sctp_istr_nmsgs, sctp->sctp_sack_toggle); 81611042SErik.Nordmark@Sun.COM mdb_printf("ack_mp\t\t%?p\n", sctp->sctp_ack_mp); 8170Sstevel@tonic-gate mdb_printf("num_istr\t%?hu\tinstr\t\t%?p\n", 81811042SErik.Nordmark@Sun.COM sctp->sctp_num_istr, sctp->sctp_instr); 81911042SErik.Nordmark@Sun.COM mdb_printf("unord_reass\t%?p\n", sctp->sctp_uo_frags); 8200Sstevel@tonic-gate } 8210Sstevel@tonic-gate 8220Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RTT) { 8230Sstevel@tonic-gate mdb_printf("%<b>RTT Tracking%</b>\n"); 8240Sstevel@tonic-gate mdb_printf("rtt_tsn\t\t%?x\tout_time\t%?ld\n", 82511042SErik.Nordmark@Sun.COM sctp->sctp_rtt_tsn, sctp->sctp_out_time); 8260Sstevel@tonic-gate } 8270Sstevel@tonic-gate 8280Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLOW) { 8290Sstevel@tonic-gate mdb_printf("%<b>Flow Control%</b>\n"); 83011042SErik.Nordmark@Sun.COM mdb_printf("tconn_sndbuf\t%?d\n" 83111042SErik.Nordmark@Sun.COM "conn_sndlowat\t%?d\tfrwnd\t\t%?u\n" 832852Svi117747 "rwnd\t\t%?u\tinitial rwnd\t%?u\n" 83311042SErik.Nordmark@Sun.COM "rxqueued\t%?u\tcwnd_max\t%?u\n", connp->conn_sndbuf, 83411042SErik.Nordmark@Sun.COM connp->conn_sndlowat, sctp->sctp_frwnd, 83511042SErik.Nordmark@Sun.COM sctp->sctp_rwnd, sctp->sctp_irwnd, sctp->sctp_rxqueued, 83611042SErik.Nordmark@Sun.COM sctp->sctp_cwnd_max); 8370Sstevel@tonic-gate } 8380Sstevel@tonic-gate 8390Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HDR) { 8400Sstevel@tonic-gate mdb_printf("%<b>Composite Headers%</b>\n"); 8410Sstevel@tonic-gate mdb_printf("iphc\t\t%?p\tiphc6\t\t%?p\n" 8420Sstevel@tonic-gate "iphc_len\t%?d\tiphc6_len\t%?d\n" 8430Sstevel@tonic-gate "hdr_len\t\t%?d\thdr6_len\t%?d\n" 8440Sstevel@tonic-gate "ipha\t\t%?p\tip6h\t\t%?p\n" 8450Sstevel@tonic-gate "ip_hdr_len\t%?d\tip_hdr6_len\t%?d\n" 8460Sstevel@tonic-gate "sctph\t\t%?p\tsctph6\t\t%?p\n" 84711042SErik.Nordmark@Sun.COM "lvtag\t\t%?x\tfvtag\t\t%?x\n", sctp->sctp_iphc, 84811042SErik.Nordmark@Sun.COM sctp->sctp_iphc6, sctp->sctp_iphc_len, 84911042SErik.Nordmark@Sun.COM sctp->sctp_iphc6_len, sctp->sctp_hdr_len, 85011042SErik.Nordmark@Sun.COM sctp->sctp_hdr6_len, sctp->sctp_ipha, sctp->sctp_ip6h, 85111042SErik.Nordmark@Sun.COM sctp->sctp_ip_hdr_len, sctp->sctp_ip_hdr6_len, 85211042SErik.Nordmark@Sun.COM sctp->sctp_sctph, sctp->sctp_sctph6, sctp->sctp_lvtag, 85311042SErik.Nordmark@Sun.COM sctp->sctp_fvtag); 8540Sstevel@tonic-gate } 8550Sstevel@tonic-gate 8560Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_PMTUD) { 8570Sstevel@tonic-gate mdb_printf("%<b>PMTUd%</b>\n"); 8580Sstevel@tonic-gate mdb_printf("last_mtu_probe\t%?ld\tmtu_probe_intvl\t%?ld\n" 8590Sstevel@tonic-gate "mss\t\t%?u\n", 86011042SErik.Nordmark@Sun.COM sctp->sctp_last_mtu_probe, sctp->sctp_mtu_probe_intvl, 86111042SErik.Nordmark@Sun.COM sctp->sctp_mss); 8620Sstevel@tonic-gate } 8630Sstevel@tonic-gate 8640Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_RXT) { 8650Sstevel@tonic-gate mdb_printf("%<b>Retransmit Info%</b>\n"); 8660Sstevel@tonic-gate mdb_printf("cookie_mp\t%?p\tstrikes\t\t%?d\n" 8670Sstevel@tonic-gate "max_init_rxt\t%?d\tpa_max_rxt\t%?d\n" 8680Sstevel@tonic-gate "pp_max_rxt\t%?d\trto_max\t\t%?u\n" 8690Sstevel@tonic-gate "rto_min\t\t%?u\trto_initial\t%?u\n" 8701735Skcpoon "init_rto_max\t%?u\n" 87111042SErik.Nordmark@Sun.COM "rxt_nxttsn\t%?u\trxt_maxtsn\t%?u\n", sctp->sctp_cookie_mp, 87211042SErik.Nordmark@Sun.COM sctp->sctp_strikes, sctp->sctp_max_init_rxt, 87311042SErik.Nordmark@Sun.COM sctp->sctp_pa_max_rxt, sctp->sctp_pp_max_rxt, 87411042SErik.Nordmark@Sun.COM sctp->sctp_rto_max, sctp->sctp_rto_min, 87512474SGeorge.Shepherd@Sun.COM sctp->sctp_rto_initial, sctp->sctp_rto_max_init, 87611042SErik.Nordmark@Sun.COM sctp->sctp_rxt_nxttsn, sctp->sctp_rxt_maxtsn); 8770Sstevel@tonic-gate } 8780Sstevel@tonic-gate 8790Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CONN) { 8800Sstevel@tonic-gate mdb_printf("%<b>Connection State%</b>\n"); 8810Sstevel@tonic-gate mdb_printf("last_secret_update%?ld\n", 88211042SErik.Nordmark@Sun.COM sctp->sctp_last_secret_update); 8830Sstevel@tonic-gate 8840Sstevel@tonic-gate mdb_printf("secret\t\t"); 8850Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8860Sstevel@tonic-gate if (i % 2 == 0) 88711042SErik.Nordmark@Sun.COM mdb_printf("0x%02x", sctp->sctp_secret[i]); 8880Sstevel@tonic-gate else 88911042SErik.Nordmark@Sun.COM mdb_printf("%02x ", sctp->sctp_secret[i]); 8900Sstevel@tonic-gate } 8910Sstevel@tonic-gate mdb_printf("\n"); 8920Sstevel@tonic-gate mdb_printf("old_secret\t"); 8930Sstevel@tonic-gate for (i = 0; i < SCTP_SECRET_LEN; i++) { 8940Sstevel@tonic-gate if (i % 2 == 0) 89511042SErik.Nordmark@Sun.COM mdb_printf("0x%02x", sctp->sctp_old_secret[i]); 8960Sstevel@tonic-gate else 89711042SErik.Nordmark@Sun.COM mdb_printf("%02x ", sctp->sctp_old_secret[i]); 8980Sstevel@tonic-gate } 8990Sstevel@tonic-gate mdb_printf("\n"); 9000Sstevel@tonic-gate } 9010Sstevel@tonic-gate 9020Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_STATS) { 9030Sstevel@tonic-gate mdb_printf("%<b>Stats Counters%</b>\n"); 9040Sstevel@tonic-gate mdb_printf("opkts\t\t%?llu\tobchunks\t%?llu\n" 9050Sstevel@tonic-gate "odchunks\t%?llu\toudchunks\t%?llu\n" 9060Sstevel@tonic-gate "rxtchunks\t%?llu\tT1expire\t%?lu\n" 9070Sstevel@tonic-gate "T2expire\t%?lu\tT3expire\t%?lu\n" 9080Sstevel@tonic-gate "msgcount\t%?llu\tprsctpdrop\t%?llu\n" 9090Sstevel@tonic-gate "AssocStartTime\t%?lu\n", 91011042SErik.Nordmark@Sun.COM sctp->sctp_opkts, sctp->sctp_obchunks, 91111042SErik.Nordmark@Sun.COM sctp->sctp_odchunks, sctp->sctp_oudchunks, 91211042SErik.Nordmark@Sun.COM sctp->sctp_rxtchunks, sctp->sctp_T1expire, 91311042SErik.Nordmark@Sun.COM sctp->sctp_T2expire, sctp->sctp_T3expire, 91411042SErik.Nordmark@Sun.COM sctp->sctp_msgcount, sctp->sctp_prsctpdrop, 91511042SErik.Nordmark@Sun.COM sctp->sctp_assoc_start_time); 9160Sstevel@tonic-gate mdb_printf("ipkts\t\t%?llu\tibchunks\t%?llu\n" 9170Sstevel@tonic-gate "idchunks\t%?llu\tiudchunks\t%?llu\n" 9180Sstevel@tonic-gate "fragdmsgs\t%?llu\treassmsgs\t%?llu\n", 91911042SErik.Nordmark@Sun.COM sctp->sctp_ipkts, sctp->sctp_ibchunks, 92011042SErik.Nordmark@Sun.COM sctp->sctp_idchunks, sctp->sctp_iudchunks, 92111042SErik.Nordmark@Sun.COM sctp->sctp_fragdmsgs, sctp->sctp_reassmsgs); 9220Sstevel@tonic-gate } 9230Sstevel@tonic-gate 9240Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_HASH) { 9250Sstevel@tonic-gate mdb_printf("%<b>Hash Tables%</b>\n"); 92611042SErik.Nordmark@Sun.COM mdb_printf("conn_hash_next\t%?p\t", sctp->sctp_conn_hash_next); 92711042SErik.Nordmark@Sun.COM mdb_printf("conn_hash_prev\t%?p\n", sctp->sctp_conn_hash_prev); 9280Sstevel@tonic-gate 9290Sstevel@tonic-gate mdb_printf("listen_hash_next%?p\t", 93011042SErik.Nordmark@Sun.COM sctp->sctp_listen_hash_next); 9310Sstevel@tonic-gate mdb_printf("listen_hash_prev%?p\n", 93211042SErik.Nordmark@Sun.COM sctp->sctp_listen_hash_prev); 93311042SErik.Nordmark@Sun.COM mdb_nhconvert(&lport, &connp->conn_lport, sizeof (lport)); 9340Sstevel@tonic-gate mdb_printf("[ listen_hash bucket\t%?d ]\n", 9350Sstevel@tonic-gate SCTP_LISTEN_HASH(lport)); 9360Sstevel@tonic-gate 93711042SErik.Nordmark@Sun.COM mdb_printf("conn_tfp\t%?p\t", sctp->sctp_conn_tfp); 93811042SErik.Nordmark@Sun.COM mdb_printf("listen_tfp\t%?p\n", sctp->sctp_listen_tfp); 9390Sstevel@tonic-gate 9400Sstevel@tonic-gate mdb_printf("bind_hash\t%?p\tptpbhn\t\t%?p\n", 94111042SErik.Nordmark@Sun.COM sctp->sctp_bind_hash, sctp->sctp_ptpbhn); 9420Sstevel@tonic-gate mdb_printf("bind_lockp\t%?p\n", 94311042SErik.Nordmark@Sun.COM sctp->sctp_bind_lockp); 9440Sstevel@tonic-gate mdb_printf("[ bind_hash bucket\t%?d ]\n", 9450Sstevel@tonic-gate SCTP_BIND_HASH(lport)); 9460Sstevel@tonic-gate } 9470Sstevel@tonic-gate 9480Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_CLOSE) { 9490Sstevel@tonic-gate mdb_printf("%<b>Cleanup / Close%</b>\n"); 9500Sstevel@tonic-gate mdb_printf("shutdown_faddr\t%?p\tclient_errno\t%?d\n" 9510Sstevel@tonic-gate "lingertime\t%?d\trefcnt\t\t%?hu\n", 95211042SErik.Nordmark@Sun.COM sctp->sctp_shutdown_faddr, sctp->sctp_client_errno, 95311042SErik.Nordmark@Sun.COM connp->conn_lingertime, sctp->sctp_refcnt); 9540Sstevel@tonic-gate } 9550Sstevel@tonic-gate 9560Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_MISC) { 9570Sstevel@tonic-gate mdb_printf("%<b>Miscellaneous%</b>\n"); 9580Sstevel@tonic-gate mdb_printf("bound_if\t%?u\theartbeat_mp\t%?p\n" 9590Sstevel@tonic-gate "family\t\t%?u\tipversion\t%?hu\n" 9600Sstevel@tonic-gate "hb_interval\t%?u\tautoclose\t%?d\n" 9615586Skcpoon "active\t\t%?ld\ttx_adaptation_code%?x\n" 9625586Skcpoon "rx_adaptation_code%?x\ttimer_mp\t%?p\n" 9633845Svi117747 "partial_delivery_point\t%?d\n", 96411042SErik.Nordmark@Sun.COM connp->conn_bound_if, sctp->sctp_heartbeat_mp, 96511042SErik.Nordmark@Sun.COM connp->conn_family, 96611042SErik.Nordmark@Sun.COM connp->conn_ipversion, 96711042SErik.Nordmark@Sun.COM sctp->sctp_hb_interval, sctp->sctp_autoclose, 96811042SErik.Nordmark@Sun.COM sctp->sctp_active, sctp->sctp_tx_adaptation_code, 96911042SErik.Nordmark@Sun.COM sctp->sctp_rx_adaptation_code, sctp->sctp_timer_mp, 97011042SErik.Nordmark@Sun.COM sctp->sctp_pd_point); 9710Sstevel@tonic-gate } 9720Sstevel@tonic-gate 9730Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_EXT) { 9740Sstevel@tonic-gate mdb_printf("%<b>Extensions and Reliable Ctl Chunks%</b>\n"); 9750Sstevel@tonic-gate mdb_printf("cxmit_list\t%?p\tlcsn\t\t%?x\n" 97611042SErik.Nordmark@Sun.COM "fcsn\t\t%?x\n", sctp->sctp_cxmit_list, sctp->sctp_lcsn, 97711042SErik.Nordmark@Sun.COM sctp->sctp_fcsn); 9780Sstevel@tonic-gate } 9790Sstevel@tonic-gate 9800Sstevel@tonic-gate if (opts & MDB_SCTP_SHOW_FLAGS) { 9810Sstevel@tonic-gate mdb_printf("%<b>Flags%</b>\n"); 98211042SErik.Nordmark@Sun.COM show_sctp_flags(sctp); 9830Sstevel@tonic-gate } 9840Sstevel@tonic-gate 9850Sstevel@tonic-gate return (DCMD_OK); 9860Sstevel@tonic-gate } 9870Sstevel@tonic-gate 9880Sstevel@tonic-gate typedef struct fanout_walk_data { 9890Sstevel@tonic-gate int index; 9900Sstevel@tonic-gate int size; 9910Sstevel@tonic-gate uintptr_t sctp; 9920Sstevel@tonic-gate sctp_tf_t *fanout; 9930Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 9940Sstevel@tonic-gate } fanout_walk_data_t; 9950Sstevel@tonic-gate 9960Sstevel@tonic-gate typedef struct fanout_init { 9973448Sdh155122 const char *nested_walker_name; 9983448Sdh155122 size_t offset; /* for what used to be a symbol */ 9993448Sdh155122 int (*getsize)(sctp_stack_t *); 10000Sstevel@tonic-gate uintptr_t (*getnext)(sctp_t *); 10010Sstevel@tonic-gate } fanout_init_t; 10020Sstevel@tonic-gate 10030Sstevel@tonic-gate static uintptr_t 10040Sstevel@tonic-gate listen_next(sctp_t *sctp) 10050Sstevel@tonic-gate { 10060Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_listen_hash_next); 10070Sstevel@tonic-gate } 10080Sstevel@tonic-gate 10093448Sdh155122 /* ARGSUSED */ 10100Sstevel@tonic-gate static int 10113448Sdh155122 listen_size(sctp_stack_t *sctps) 10120Sstevel@tonic-gate { 10130Sstevel@tonic-gate return (SCTP_LISTEN_FANOUT_SIZE); 10140Sstevel@tonic-gate } 10150Sstevel@tonic-gate 10160Sstevel@tonic-gate static uintptr_t 10170Sstevel@tonic-gate conn_next(sctp_t *sctp) 10180Sstevel@tonic-gate { 10190Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_conn_hash_next); 10200Sstevel@tonic-gate } 10210Sstevel@tonic-gate 10220Sstevel@tonic-gate static int 10233448Sdh155122 conn_size(sctp_stack_t *sctps) 10240Sstevel@tonic-gate { 10250Sstevel@tonic-gate int size; 10263448Sdh155122 uintptr_t kaddr; 10270Sstevel@tonic-gate 10283448Sdh155122 kaddr = (uintptr_t)&sctps->sctps_conn_hash_size; 10293448Sdh155122 10303448Sdh155122 if (mdb_vread(&size, sizeof (size), kaddr) == -1) { 10313448Sdh155122 mdb_warn("can't read 'sctps_conn_hash_size' at %p", kaddr); 10320Sstevel@tonic-gate return (1); 10330Sstevel@tonic-gate } 10340Sstevel@tonic-gate return (size); 10350Sstevel@tonic-gate } 10360Sstevel@tonic-gate 10370Sstevel@tonic-gate static uintptr_t 10380Sstevel@tonic-gate bind_next(sctp_t *sctp) 10390Sstevel@tonic-gate { 10400Sstevel@tonic-gate return ((uintptr_t)sctp->sctp_bind_hash); 10410Sstevel@tonic-gate } 10420Sstevel@tonic-gate 10433448Sdh155122 /* ARGSUSED */ 10440Sstevel@tonic-gate static int 10453448Sdh155122 bind_size(sctp_stack_t *sctps) 10460Sstevel@tonic-gate { 10470Sstevel@tonic-gate return (SCTP_BIND_FANOUT_SIZE); 10480Sstevel@tonic-gate } 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate static intptr_t 10510Sstevel@tonic-gate find_next_hash_item(fanout_walk_data_t *fw) 10520Sstevel@tonic-gate { 10530Sstevel@tonic-gate sctp_tf_t tf; 10540Sstevel@tonic-gate sctp_t sctp; 10550Sstevel@tonic-gate 10560Sstevel@tonic-gate /* first try to continue down the hash chain */ 10570Sstevel@tonic-gate if (fw->sctp != NULL) { 10580Sstevel@tonic-gate /* try to get next in hash chain */ 10590Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), fw->sctp) == -1) { 10600Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", fw->sctp); 10610Sstevel@tonic-gate return (NULL); 10620Sstevel@tonic-gate } 10630Sstevel@tonic-gate fw->sctp = fw->getnext(&sctp); 10640Sstevel@tonic-gate if (fw->sctp != NULL) 10650Sstevel@tonic-gate return (fw->sctp); 10660Sstevel@tonic-gate else 10670Sstevel@tonic-gate /* end of chain; go to next bucket */ 10680Sstevel@tonic-gate fw->index++; 10690Sstevel@tonic-gate } 10700Sstevel@tonic-gate 10710Sstevel@tonic-gate /* find a new hash chain, traversing the buckets */ 10720Sstevel@tonic-gate for (; fw->index < fw->size; fw->index++) { 10730Sstevel@tonic-gate /* read the current hash line for an sctp */ 10740Sstevel@tonic-gate if (mdb_vread(&tf, sizeof (tf), 10754691Skcpoon (uintptr_t)(fw->fanout + fw->index)) == -1) { 10760Sstevel@tonic-gate mdb_warn("failed to read tf at %p", 10770Sstevel@tonic-gate fw->fanout + fw->index); 10780Sstevel@tonic-gate return (NULL); 10790Sstevel@tonic-gate } 10800Sstevel@tonic-gate if (tf.tf_sctp != NULL) { 10810Sstevel@tonic-gate /* start of a new chain */ 10820Sstevel@tonic-gate fw->sctp = (uintptr_t)tf.tf_sctp; 10830Sstevel@tonic-gate return (fw->sctp); 10840Sstevel@tonic-gate } 10850Sstevel@tonic-gate } 10860Sstevel@tonic-gate return (NULL); 10870Sstevel@tonic-gate } 10880Sstevel@tonic-gate 10890Sstevel@tonic-gate static int 10903448Sdh155122 fanout_stack_walk_init(mdb_walk_state_t *wsp) 10910Sstevel@tonic-gate { 10920Sstevel@tonic-gate fanout_walk_data_t *lw; 10930Sstevel@tonic-gate fanout_init_t *fi = wsp->walk_arg; 10943448Sdh155122 sctp_stack_t *sctps = (sctp_stack_t *)wsp->walk_addr; 10953448Sdh155122 uintptr_t kaddr; 10960Sstevel@tonic-gate 10973448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), 10983448Sdh155122 wsp->walk_addr + fi->offset) == -1) { 10993448Sdh155122 mdb_warn("can't read sctp fanout at %p", 11003448Sdh155122 wsp->walk_addr + fi->offset); 11010Sstevel@tonic-gate return (WALK_ERR); 11020Sstevel@tonic-gate } 11030Sstevel@tonic-gate 11040Sstevel@tonic-gate lw = mdb_alloc(sizeof (*lw), UM_SLEEP); 11050Sstevel@tonic-gate lw->index = 0; 11063448Sdh155122 lw->size = fi->getsize(sctps); 11070Sstevel@tonic-gate lw->sctp = NULL; 11083448Sdh155122 lw->fanout = (sctp_tf_t *)kaddr; 11090Sstevel@tonic-gate lw->getnext = fi->getnext; 11100Sstevel@tonic-gate 11110Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(lw)) == NULL) { 11120Sstevel@tonic-gate return (WALK_DONE); 11130Sstevel@tonic-gate } 11140Sstevel@tonic-gate wsp->walk_data = lw; 11150Sstevel@tonic-gate return (WALK_NEXT); 11160Sstevel@tonic-gate } 11170Sstevel@tonic-gate 11180Sstevel@tonic-gate static int 11193448Sdh155122 fanout_stack_walk_step(mdb_walk_state_t *wsp) 11200Sstevel@tonic-gate { 11210Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11220Sstevel@tonic-gate uintptr_t addr = wsp->walk_addr; 11230Sstevel@tonic-gate sctp_t sctp; 11240Sstevel@tonic-gate int status; 11250Sstevel@tonic-gate 11260Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), addr) == -1) { 11270Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", addr); 11280Sstevel@tonic-gate return (WALK_DONE); 11290Sstevel@tonic-gate } 11300Sstevel@tonic-gate 11310Sstevel@tonic-gate status = wsp->walk_callback(addr, &sctp, wsp->walk_cbdata); 11320Sstevel@tonic-gate if (status != WALK_NEXT) 11330Sstevel@tonic-gate return (status); 11340Sstevel@tonic-gate 11350Sstevel@tonic-gate if ((wsp->walk_addr = find_next_hash_item(fw)) == NULL) 11360Sstevel@tonic-gate return (WALK_DONE); 11370Sstevel@tonic-gate 11380Sstevel@tonic-gate return (WALK_NEXT); 11390Sstevel@tonic-gate } 11400Sstevel@tonic-gate 11410Sstevel@tonic-gate static void 11423448Sdh155122 fanout_stack_walk_fini(mdb_walk_state_t *wsp) 11430Sstevel@tonic-gate { 11440Sstevel@tonic-gate fanout_walk_data_t *fw = wsp->walk_data; 11450Sstevel@tonic-gate 11460Sstevel@tonic-gate mdb_free(fw, sizeof (*fw)); 11470Sstevel@tonic-gate } 11480Sstevel@tonic-gate 11493448Sdh155122 int 11503448Sdh155122 fanout_walk_init(mdb_walk_state_t *wsp) 11510Sstevel@tonic-gate { 11523448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 11533448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 11543448Sdh155122 return (WALK_ERR); 11553448Sdh155122 } 11563448Sdh155122 11573448Sdh155122 return (WALK_NEXT); 11583448Sdh155122 } 11593448Sdh155122 11603448Sdh155122 int 11613448Sdh155122 fanout_walk_step(mdb_walk_state_t *wsp) 11623448Sdh155122 { 11633448Sdh155122 fanout_init_t *fi = wsp->walk_arg; 11643448Sdh155122 11653448Sdh155122 if (mdb_pwalk(fi->nested_walker_name, wsp->walk_callback, 11664691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 11673448Sdh155122 mdb_warn("couldn't walk '%s'for address %p", 11683448Sdh155122 fi->nested_walker_name, wsp->walk_addr); 11693448Sdh155122 return (WALK_ERR); 11703448Sdh155122 } 11710Sstevel@tonic-gate return (WALK_NEXT); 11720Sstevel@tonic-gate } 11730Sstevel@tonic-gate 11743448Sdh155122 int 11753448Sdh155122 sctps_walk_init(mdb_walk_state_t *wsp) 11760Sstevel@tonic-gate { 11770Sstevel@tonic-gate 11783448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 11793448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 11800Sstevel@tonic-gate return (WALK_ERR); 11810Sstevel@tonic-gate } 11823448Sdh155122 11833448Sdh155122 return (WALK_NEXT); 11843448Sdh155122 } 11850Sstevel@tonic-gate 11863448Sdh155122 int 11873448Sdh155122 sctps_walk_step(mdb_walk_state_t *wsp) 11883448Sdh155122 { 11893448Sdh155122 uintptr_t kaddr; 11903448Sdh155122 11913448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_list); 11923448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 11934691Skcpoon wsp->walk_cbdata, kaddr) == -1) { 11943448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", kaddr); 11953448Sdh155122 return (WALK_ERR); 11960Sstevel@tonic-gate } 11973448Sdh155122 return (WALK_NEXT); 11980Sstevel@tonic-gate } 11990Sstevel@tonic-gate 12000Sstevel@tonic-gate static int 12010Sstevel@tonic-gate sctp_walk_faddr_init(mdb_walk_state_t *wsp) 12020Sstevel@tonic-gate { 12030Sstevel@tonic-gate sctp_t sctp; 12040Sstevel@tonic-gate 12050Sstevel@tonic-gate if (wsp->walk_addr == NULL) 12060Sstevel@tonic-gate return (WALK_ERR); 12070Sstevel@tonic-gate 12080Sstevel@tonic-gate if (mdb_vread(&sctp, sizeof (sctp), wsp->walk_addr) == -1) { 12090Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12100Sstevel@tonic-gate return (WALK_ERR); 12110Sstevel@tonic-gate } 12120Sstevel@tonic-gate if ((wsp->walk_addr = (uintptr_t)sctp.sctp_faddrs) != NULL) 12130Sstevel@tonic-gate return (WALK_NEXT); 12140Sstevel@tonic-gate else 12150Sstevel@tonic-gate return (WALK_DONE); 12160Sstevel@tonic-gate } 12170Sstevel@tonic-gate 12180Sstevel@tonic-gate static int 12190Sstevel@tonic-gate sctp_walk_faddr_step(mdb_walk_state_t *wsp) 12200Sstevel@tonic-gate { 12210Sstevel@tonic-gate uintptr_t faddr_ptr = wsp->walk_addr; 12220Sstevel@tonic-gate sctp_faddr_t sctp_faddr; 12230Sstevel@tonic-gate int status; 12240Sstevel@tonic-gate 12250Sstevel@tonic-gate if (mdb_vread(&sctp_faddr, sizeof (sctp_faddr_t), faddr_ptr) == -1) { 12260Sstevel@tonic-gate mdb_warn("failed to read sctp_faddr_t at %p", faddr_ptr); 12270Sstevel@tonic-gate return (WALK_ERR); 12280Sstevel@tonic-gate } 12290Sstevel@tonic-gate status = wsp->walk_callback(faddr_ptr, &sctp_faddr, wsp->walk_cbdata); 12300Sstevel@tonic-gate if (status != WALK_NEXT) 12310Sstevel@tonic-gate return (status); 12320Sstevel@tonic-gate if ((faddr_ptr = (uintptr_t)sctp_faddr.next) == NULL) { 12330Sstevel@tonic-gate return (WALK_DONE); 12340Sstevel@tonic-gate } else { 12350Sstevel@tonic-gate wsp->walk_addr = faddr_ptr; 12360Sstevel@tonic-gate return (WALK_NEXT); 12370Sstevel@tonic-gate } 12380Sstevel@tonic-gate } 12390Sstevel@tonic-gate 12400Sstevel@tonic-gate /* 12410Sstevel@tonic-gate * Helper structure for sctp_walk_saddr. It stores the sctp_t being walked, 12420Sstevel@tonic-gate * the current index to the sctp_saddrs[], and the current count of the 12430Sstevel@tonic-gate * sctp_saddr_ipif_t list. 12440Sstevel@tonic-gate */ 12450Sstevel@tonic-gate typedef struct { 12460Sstevel@tonic-gate sctp_t sctp; 12470Sstevel@tonic-gate int hash_index; 12480Sstevel@tonic-gate int cur_cnt; 12490Sstevel@tonic-gate } saddr_walk_t; 12500Sstevel@tonic-gate 12510Sstevel@tonic-gate static int 12520Sstevel@tonic-gate sctp_walk_saddr_init(mdb_walk_state_t *wsp) 12530Sstevel@tonic-gate { 12540Sstevel@tonic-gate sctp_t *sctp; 12550Sstevel@tonic-gate int i; 12560Sstevel@tonic-gate saddr_walk_t *swalker; 12570Sstevel@tonic-gate 12580Sstevel@tonic-gate if (wsp->walk_addr == NULL) 12590Sstevel@tonic-gate return (WALK_ERR); 12600Sstevel@tonic-gate 12610Sstevel@tonic-gate swalker = mdb_alloc(sizeof (saddr_walk_t), UM_SLEEP); 12620Sstevel@tonic-gate sctp = &swalker->sctp; 12630Sstevel@tonic-gate if (mdb_vread(sctp, sizeof (sctp_t), wsp->walk_addr) == -1) { 12640Sstevel@tonic-gate mdb_warn("failed to read sctp at %p", wsp->walk_addr); 12650Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 12660Sstevel@tonic-gate return (WALK_ERR); 12670Sstevel@tonic-gate } 12680Sstevel@tonic-gate 12690Sstevel@tonic-gate /* Find the first source address. */ 12700Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 12710Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 12720Sstevel@tonic-gate list_t *addr_list; 12730Sstevel@tonic-gate 12740Sstevel@tonic-gate addr_list = &sctp->sctp_saddrs[i].sctp_ipif_list; 12750Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object(addr_list, 12760Sstevel@tonic-gate addr_list->list_head.list_next); 12770Sstevel@tonic-gate 12780Sstevel@tonic-gate /* Recode the current info */ 12790Sstevel@tonic-gate swalker->hash_index = i; 12800Sstevel@tonic-gate swalker->cur_cnt = 1; 12810Sstevel@tonic-gate wsp->walk_data = swalker; 12820Sstevel@tonic-gate 12830Sstevel@tonic-gate return (WALK_NEXT); 12840Sstevel@tonic-gate } 12850Sstevel@tonic-gate } 12860Sstevel@tonic-gate return (WALK_DONE); 12870Sstevel@tonic-gate } 12880Sstevel@tonic-gate 12890Sstevel@tonic-gate static int 12900Sstevel@tonic-gate sctp_walk_saddr_step(mdb_walk_state_t *wsp) 12910Sstevel@tonic-gate { 12920Sstevel@tonic-gate uintptr_t saddr_ptr = wsp->walk_addr; 12930Sstevel@tonic-gate sctp_saddr_ipif_t saddr; 12940Sstevel@tonic-gate saddr_walk_t *swalker; 12950Sstevel@tonic-gate sctp_t *sctp; 12960Sstevel@tonic-gate int status; 12970Sstevel@tonic-gate int i, j; 12980Sstevel@tonic-gate 12990Sstevel@tonic-gate if (mdb_vread(&saddr, sizeof (sctp_saddr_ipif_t), saddr_ptr) == -1) { 13000Sstevel@tonic-gate mdb_warn("failed to read sctp_saddr_ipif_t at %p", saddr_ptr); 13010Sstevel@tonic-gate return (WALK_ERR); 13020Sstevel@tonic-gate } 13030Sstevel@tonic-gate status = wsp->walk_callback(saddr_ptr, &saddr, wsp->walk_cbdata); 13040Sstevel@tonic-gate if (status != WALK_NEXT) 13050Sstevel@tonic-gate return (status); 13060Sstevel@tonic-gate 13070Sstevel@tonic-gate swalker = (saddr_walk_t *)wsp->walk_data; 13080Sstevel@tonic-gate sctp = &swalker->sctp; 13090Sstevel@tonic-gate i = swalker->hash_index; 13100Sstevel@tonic-gate j = swalker->cur_cnt; 13110Sstevel@tonic-gate 13120Sstevel@tonic-gate /* 13130Sstevel@tonic-gate * If there is still a source address in the current list, return it. 13140Sstevel@tonic-gate * Otherwise, go to the next list in the sctp_saddrs[]. 13150Sstevel@tonic-gate */ 13160Sstevel@tonic-gate if (j++ < sctp->sctp_saddrs[i].ipif_count) { 13170Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)saddr.saddr_ipif.list_next; 13180Sstevel@tonic-gate swalker->cur_cnt = j; 13190Sstevel@tonic-gate return (WALK_NEXT); 13200Sstevel@tonic-gate } else { 13210Sstevel@tonic-gate list_t *lst; 13220Sstevel@tonic-gate 13230Sstevel@tonic-gate for (i = i + 1; i < SCTP_IPIF_HASH; i++) { 13240Sstevel@tonic-gate if (sctp->sctp_saddrs[i].ipif_count > 0) { 13250Sstevel@tonic-gate lst = &sctp->sctp_saddrs[i].sctp_ipif_list; 13260Sstevel@tonic-gate wsp->walk_addr = (uintptr_t)list_object( 13270Sstevel@tonic-gate lst, lst->list_head.list_next); 13280Sstevel@tonic-gate swalker->hash_index = i; 13290Sstevel@tonic-gate swalker->cur_cnt = 1; 13300Sstevel@tonic-gate return (WALK_NEXT); 13310Sstevel@tonic-gate } 13320Sstevel@tonic-gate } 13330Sstevel@tonic-gate } 13340Sstevel@tonic-gate return (WALK_DONE); 13350Sstevel@tonic-gate } 13360Sstevel@tonic-gate 13370Sstevel@tonic-gate static void 13380Sstevel@tonic-gate sctp_walk_saddr_fini(mdb_walk_state_t *wsp) 13390Sstevel@tonic-gate { 13400Sstevel@tonic-gate saddr_walk_t *swalker = (saddr_walk_t *)wsp->walk_data; 13410Sstevel@tonic-gate 13420Sstevel@tonic-gate mdb_free(swalker, sizeof (saddr_walk_t)); 13430Sstevel@tonic-gate } 13440Sstevel@tonic-gate 13453448Sdh155122 13463448Sdh155122 typedef struct ill_walk_data { 13473448Sdh155122 sctp_ill_hash_t ills[SCTP_ILL_HASH]; 13483448Sdh155122 uint32_t count; 13493448Sdh155122 } ill_walk_data_t; 13503448Sdh155122 13513448Sdh155122 typedef struct ipuf_walk_data { 13523448Sdh155122 sctp_ipif_hash_t ipifs[SCTP_IPIF_HASH]; 13533448Sdh155122 uint32_t count; 13543448Sdh155122 } ipif_walk_data_t; 13553448Sdh155122 13563448Sdh155122 13573448Sdh155122 int 13583448Sdh155122 sctp_ill_walk_init(mdb_walk_state_t *wsp) 13593448Sdh155122 { 13603448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 13613448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 13623448Sdh155122 return (WALK_ERR); 13633448Sdh155122 } 13643448Sdh155122 13653448Sdh155122 return (WALK_NEXT); 13663448Sdh155122 } 13673448Sdh155122 13683448Sdh155122 int 13693448Sdh155122 sctp_ill_walk_step(mdb_walk_state_t *wsp) 13703448Sdh155122 { 13713448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ill", wsp->walk_callback, 13724691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 13733448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ill' for addr %p", 13743448Sdh155122 wsp->walk_addr); 13753448Sdh155122 return (WALK_ERR); 13763448Sdh155122 } 13773448Sdh155122 return (WALK_NEXT); 13783448Sdh155122 } 13793448Sdh155122 13803448Sdh155122 /* 13813448Sdh155122 * wsp->walk_addr is the address of sctps_ill_list 13823448Sdh155122 */ 13830Sstevel@tonic-gate static int 13843448Sdh155122 sctp_stack_ill_walk_init(mdb_walk_state_t *wsp) 13850Sstevel@tonic-gate { 13863448Sdh155122 ill_walk_data_t iw; 13870Sstevel@tonic-gate intptr_t i; 13883448Sdh155122 uintptr_t kaddr, uaddr; 13893448Sdh155122 size_t offset; 13903448Sdh155122 13913448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_ills_count); 13923448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 13933448Sdh155122 mdb_warn("can't read sctps_ills_count at %p", kaddr); 13943448Sdh155122 return (WALK_ERR); 13953448Sdh155122 } 13963448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ills); 13973448Sdh155122 13983448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 13993448Sdh155122 mdb_warn("can't read scpts_g_ills %p", kaddr); 14003448Sdh155122 return (WALK_ERR); 14013448Sdh155122 } 14023448Sdh155122 if (mdb_vread(&iw.ills, sizeof (iw.ills), kaddr) == -1) { 14033448Sdh155122 mdb_warn("failed to read 'sctps_g_ills'"); 14043448Sdh155122 return (NULL); 14053448Sdh155122 } 14060Sstevel@tonic-gate 14070Sstevel@tonic-gate /* Find the first ill. */ 14080Sstevel@tonic-gate for (i = 0; i < SCTP_ILL_HASH; i++) { 14093448Sdh155122 if (iw.ills[i].ill_count > 0) { 14103448Sdh155122 uaddr = (uintptr_t)&iw.ills[i].sctp_ill_list; 14113448Sdh155122 offset = uaddr - (uintptr_t)&iw.ills; 14123448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 14134691Skcpoon wsp->walk_cbdata, kaddr+offset) == -1) { 14143448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 14153448Sdh155122 kaddr); 14163448Sdh155122 return (WALK_ERR); 14170Sstevel@tonic-gate } 14180Sstevel@tonic-gate } 14190Sstevel@tonic-gate } 14200Sstevel@tonic-gate return (WALK_DONE); 14210Sstevel@tonic-gate } 14220Sstevel@tonic-gate 14230Sstevel@tonic-gate static int 14243448Sdh155122 sctp_stack_ill_walk_step(mdb_walk_state_t *wsp) 14253448Sdh155122 { 14263448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 14274691Skcpoon wsp->walk_cbdata)); 14283448Sdh155122 } 14293448Sdh155122 14303448Sdh155122 int 14313448Sdh155122 sctp_ipif_walk_init(mdb_walk_state_t *wsp) 14320Sstevel@tonic-gate { 14333448Sdh155122 if (mdb_layered_walk("sctp_stacks", wsp) == -1) { 14343448Sdh155122 mdb_warn("can't walk 'sctp_stacks'"); 14353448Sdh155122 return (WALK_ERR); 14363448Sdh155122 } 14373448Sdh155122 return (WALK_NEXT); 14383448Sdh155122 } 14393448Sdh155122 14403448Sdh155122 int 14413448Sdh155122 sctp_ipif_walk_step(mdb_walk_state_t *wsp) 14423448Sdh155122 { 14433448Sdh155122 if (mdb_pwalk("sctp_stack_walk_ipif", wsp->walk_callback, 14444691Skcpoon wsp->walk_cbdata, wsp->walk_addr) == -1) { 14453448Sdh155122 mdb_warn("couldn't walk 'sctp_stack_walk_ipif' for addr %p", 14463448Sdh155122 wsp->walk_addr); 14473448Sdh155122 return (WALK_ERR); 14483448Sdh155122 } 14493448Sdh155122 return (WALK_NEXT); 14503448Sdh155122 } 14513448Sdh155122 14523448Sdh155122 /* 14533448Sdh155122 * wsp->walk_addr is the address of sctps_ipif_list 14543448Sdh155122 */ 14553448Sdh155122 static int 14563448Sdh155122 sctp_stack_ipif_walk_init(mdb_walk_state_t *wsp) 14573448Sdh155122 { 14583448Sdh155122 ipif_walk_data_t iw; 14590Sstevel@tonic-gate intptr_t i; 14603448Sdh155122 uintptr_t kaddr, uaddr; 14613448Sdh155122 size_t offset; 14623448Sdh155122 14633448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs_count); 14643448Sdh155122 if (mdb_vread(&iw.count, sizeof (iw.count), kaddr) == -1) { 14653448Sdh155122 mdb_warn("can't read sctps_g_ipifs_count at %p", kaddr); 14663448Sdh155122 return (WALK_ERR); 14673448Sdh155122 } 14683448Sdh155122 kaddr = wsp->walk_addr + OFFSETOF(sctp_stack_t, sctps_g_ipifs); 14690Sstevel@tonic-gate 14703448Sdh155122 if (mdb_vread(&kaddr, sizeof (kaddr), kaddr) == -1) { 14713448Sdh155122 mdb_warn("can't read scpts_g_ipifs %p", kaddr); 14723448Sdh155122 return (WALK_ERR); 14733448Sdh155122 } 14743448Sdh155122 if (mdb_vread(&iw.ipifs, sizeof (iw.ipifs), kaddr) == -1) { 14753448Sdh155122 mdb_warn("failed to read 'sctps_g_ipifs'"); 14763448Sdh155122 return (NULL); 14773448Sdh155122 } 14783448Sdh155122 14793448Sdh155122 /* Find the first ipif. */ 14800Sstevel@tonic-gate for (i = 0; i < SCTP_IPIF_HASH; i++) { 14813448Sdh155122 if (iw.ipifs[i].ipif_count > 0) { 14823448Sdh155122 uaddr = (uintptr_t)&iw.ipifs[i].sctp_ipif_list; 14833448Sdh155122 offset = uaddr - (uintptr_t)&iw.ipifs; 14843448Sdh155122 if (mdb_pwalk("list", wsp->walk_callback, 14854691Skcpoon wsp->walk_cbdata, kaddr+offset) == -1) { 14863448Sdh155122 mdb_warn("couldn't walk 'list' for address %p", 14873448Sdh155122 kaddr); 14883448Sdh155122 return (WALK_ERR); 14893448Sdh155122 } 14900Sstevel@tonic-gate } 14910Sstevel@tonic-gate } 14920Sstevel@tonic-gate return (WALK_DONE); 14930Sstevel@tonic-gate } 14940Sstevel@tonic-gate 14950Sstevel@tonic-gate static int 14963448Sdh155122 sctp_stack_ipif_walk_step(mdb_walk_state_t *wsp) 14970Sstevel@tonic-gate { 14983448Sdh155122 return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer, 14994691Skcpoon wsp->walk_cbdata)); 15000Sstevel@tonic-gate } 15010Sstevel@tonic-gate 1502*12869SKacheong.Poon@Sun.COM /* 1503*12869SKacheong.Poon@Sun.COM * Initialization function for the per CPU SCTP stats counter walker of a given 1504*12869SKacheong.Poon@Sun.COM * SCTP stack. 1505*12869SKacheong.Poon@Sun.COM */ 1506*12869SKacheong.Poon@Sun.COM int 1507*12869SKacheong.Poon@Sun.COM sctps_sc_walk_init(mdb_walk_state_t *wsp) 1508*12869SKacheong.Poon@Sun.COM { 1509*12869SKacheong.Poon@Sun.COM sctp_stack_t sctps; 1510*12869SKacheong.Poon@Sun.COM 1511*12869SKacheong.Poon@Sun.COM if (wsp->walk_addr == NULL) 1512*12869SKacheong.Poon@Sun.COM return (WALK_ERR); 1513*12869SKacheong.Poon@Sun.COM 1514*12869SKacheong.Poon@Sun.COM if (mdb_vread(&sctps, sizeof (sctps), wsp->walk_addr) == -1) { 1515*12869SKacheong.Poon@Sun.COM mdb_warn("failed to read sctp_stack_t at %p", wsp->walk_addr); 1516*12869SKacheong.Poon@Sun.COM return (WALK_ERR); 1517*12869SKacheong.Poon@Sun.COM } 1518*12869SKacheong.Poon@Sun.COM if (sctps.sctps_sc_cnt == 0) 1519*12869SKacheong.Poon@Sun.COM return (WALK_DONE); 1520*12869SKacheong.Poon@Sun.COM 1521*12869SKacheong.Poon@Sun.COM /* 1522*12869SKacheong.Poon@Sun.COM * Store the sctp_stack_t pointer in walk_data. The stepping function 1523*12869SKacheong.Poon@Sun.COM * used it to calculate if the end of the counter has reached. 1524*12869SKacheong.Poon@Sun.COM */ 1525*12869SKacheong.Poon@Sun.COM wsp->walk_data = (void *)wsp->walk_addr; 1526*12869SKacheong.Poon@Sun.COM wsp->walk_addr = (uintptr_t)sctps.sctps_sc; 1527*12869SKacheong.Poon@Sun.COM return (WALK_NEXT); 1528*12869SKacheong.Poon@Sun.COM } 1529*12869SKacheong.Poon@Sun.COM 1530*12869SKacheong.Poon@Sun.COM /* 1531*12869SKacheong.Poon@Sun.COM * Stepping function for the per CPU SCTP stats counterwalker. 1532*12869SKacheong.Poon@Sun.COM */ 1533*12869SKacheong.Poon@Sun.COM int 1534*12869SKacheong.Poon@Sun.COM sctps_sc_walk_step(mdb_walk_state_t *wsp) 1535*12869SKacheong.Poon@Sun.COM { 1536*12869SKacheong.Poon@Sun.COM int status; 1537*12869SKacheong.Poon@Sun.COM sctp_stack_t sctps; 1538*12869SKacheong.Poon@Sun.COM sctp_stats_cpu_t *stats; 1539*12869SKacheong.Poon@Sun.COM char *next, *end; 1540*12869SKacheong.Poon@Sun.COM 1541*12869SKacheong.Poon@Sun.COM if (mdb_vread(&sctps, sizeof (sctps), (uintptr_t)wsp->walk_data) == 1542*12869SKacheong.Poon@Sun.COM -1) { 1543*12869SKacheong.Poon@Sun.COM mdb_warn("failed to read sctp_stack_t at %p", wsp->walk_addr); 1544*12869SKacheong.Poon@Sun.COM return (WALK_ERR); 1545*12869SKacheong.Poon@Sun.COM } 1546*12869SKacheong.Poon@Sun.COM if (mdb_vread(&stats, sizeof (stats), wsp->walk_addr) == -1) { 1547*12869SKacheong.Poon@Sun.COM mdb_warn("failed ot read sctp_stats_cpu_t at %p", 1548*12869SKacheong.Poon@Sun.COM wsp->walk_addr); 1549*12869SKacheong.Poon@Sun.COM return (WALK_ERR); 1550*12869SKacheong.Poon@Sun.COM } 1551*12869SKacheong.Poon@Sun.COM status = wsp->walk_callback((uintptr_t)stats, &stats, wsp->walk_cbdata); 1552*12869SKacheong.Poon@Sun.COM if (status != WALK_NEXT) 1553*12869SKacheong.Poon@Sun.COM return (status); 1554*12869SKacheong.Poon@Sun.COM 1555*12869SKacheong.Poon@Sun.COM next = (char *)wsp->walk_addr + sizeof (sctp_stats_cpu_t *); 1556*12869SKacheong.Poon@Sun.COM end = (char *)sctps.sctps_sc + sctps.sctps_sc_cnt * 1557*12869SKacheong.Poon@Sun.COM sizeof (sctp_stats_cpu_t *); 1558*12869SKacheong.Poon@Sun.COM if (next >= end) 1559*12869SKacheong.Poon@Sun.COM return (WALK_DONE); 1560*12869SKacheong.Poon@Sun.COM wsp->walk_addr = (uintptr_t)next; 1561*12869SKacheong.Poon@Sun.COM return (WALK_NEXT); 1562*12869SKacheong.Poon@Sun.COM } 1563*12869SKacheong.Poon@Sun.COM 15640Sstevel@tonic-gate static void 15650Sstevel@tonic-gate sctp_help(void) 15660Sstevel@tonic-gate { 15670Sstevel@tonic-gate mdb_printf("Print information for a given SCTP sctp_t\n\n"); 15680Sstevel@tonic-gate mdb_printf("Options:\n"); 15690Sstevel@tonic-gate mdb_printf("\t-a\t All the information\n"); 15700Sstevel@tonic-gate mdb_printf("\t-f\t Flags\n"); 15710Sstevel@tonic-gate mdb_printf("\t-h\t Hash Tables\n"); 15720Sstevel@tonic-gate mdb_printf("\t-o\t Outbound Data\n"); 15730Sstevel@tonic-gate mdb_printf("\t-i\t Inbound Data\n"); 15740Sstevel@tonic-gate mdb_printf("\t-m\t Miscellaneous Information\n"); 15750Sstevel@tonic-gate mdb_printf("\t-r\t RTT Tracking\n"); 15760Sstevel@tonic-gate mdb_printf("\t-S\t Stats Counters\n"); 15770Sstevel@tonic-gate mdb_printf("\t-F\t Flow Control\n"); 15780Sstevel@tonic-gate mdb_printf("\t-H\t Composite Headers\n"); 15790Sstevel@tonic-gate mdb_printf("\t-p\t PMTUD\n"); 15800Sstevel@tonic-gate mdb_printf("\t-R\t Retransmit Information\n"); 15810Sstevel@tonic-gate mdb_printf("\t-C\t Connection State\n"); 15820Sstevel@tonic-gate mdb_printf("\t-c\t Cleanup / Close\n"); 15830Sstevel@tonic-gate mdb_printf("\t-e\t Extensions and Reliable Control Chunks\n"); 15840Sstevel@tonic-gate mdb_printf("\t-d\t Local and Peer addresses\n"); 15850Sstevel@tonic-gate mdb_printf("\t-P\t Peer addresses\n"); 15860Sstevel@tonic-gate } 1587*12869SKacheong.Poon@Sun.COM 15880Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = { 15890Sstevel@tonic-gate { "sctp", ":[-afhoimrSFHpRCcedP]", 15900Sstevel@tonic-gate "display sctp control structure", sctp, sctp_help }, 15910Sstevel@tonic-gate { "sctp_set", ":", "display a SCTP set", sctp_set }, 15920Sstevel@tonic-gate { "sctp_faddr", ":", "display a faddr", sctp_faddr }, 15930Sstevel@tonic-gate { "sctp_istr_msgs", ":", "display msg list on an instream", 15940Sstevel@tonic-gate sctp_istr_msgs }, 15950Sstevel@tonic-gate { "sctp_mdata_chunk", ":", "display a data chunk in an mblk", 15960Sstevel@tonic-gate sctp_mdata_chunk }, 15970Sstevel@tonic-gate { "sctp_xmit_list", ":", "display sctp xmit lists", sctp_xmit_list }, 15980Sstevel@tonic-gate { "sctp_instr", ":", "display instr", sctp_instr }, 15990Sstevel@tonic-gate { "sctp_reass_list", ":", "display reass list", sctp_reass_list }, 16000Sstevel@tonic-gate { "sctp_uo_reass_list", ":", "display un-ordered reass list", 16010Sstevel@tonic-gate sctp_uo_reass_list }, 16020Sstevel@tonic-gate { NULL } 16030Sstevel@tonic-gate }; 16040Sstevel@tonic-gate 16050Sstevel@tonic-gate static const fanout_init_t listen_fanout_init = { 16063448Sdh155122 "sctp_stack_listen_fanout", OFFSETOF(sctp_stack_t, sctps_listen_fanout), 16073448Sdh155122 listen_size, listen_next 16080Sstevel@tonic-gate }; 16090Sstevel@tonic-gate 16100Sstevel@tonic-gate static const fanout_init_t conn_fanout_init = { 16113448Sdh155122 "sctp_stack_conn_fanout", OFFSETOF(sctp_stack_t, sctps_conn_fanout), 16123448Sdh155122 conn_size, conn_next 16130Sstevel@tonic-gate }; 16140Sstevel@tonic-gate 16150Sstevel@tonic-gate static const fanout_init_t bind_fanout_init = { 16163448Sdh155122 "sctp_stack_bind_fanout", OFFSETOF(sctp_stack_t, sctps_bind_fanout), 16173448Sdh155122 bind_size, bind_next 16180Sstevel@tonic-gate }; 16190Sstevel@tonic-gate 16200Sstevel@tonic-gate static const mdb_walker_t walkers[] = { 16213448Sdh155122 { "sctps", "walk the full chain of sctps for all stacks", 16223448Sdh155122 sctps_walk_init, sctps_walk_step, NULL }, 16233448Sdh155122 { "sctp_listen_fanout", "walk the sctp listen fanout for all stacks", 16243448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 16250Sstevel@tonic-gate (void *)&listen_fanout_init }, 16263448Sdh155122 { "sctp_conn_fanout", "walk the sctp conn fanout for all stacks", 16273448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 16280Sstevel@tonic-gate (void *)&conn_fanout_init }, 16293448Sdh155122 { "sctp_bind_fanout", "walk the sctp bind fanout for all stacks", 16303448Sdh155122 fanout_walk_init, fanout_walk_step, NULL, 16313448Sdh155122 (void *)&bind_fanout_init }, 16323448Sdh155122 { "sctp_stack_listen_fanout", 16333448Sdh155122 "walk the sctp listen fanout for one stack", 16343448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 16353448Sdh155122 fanout_stack_walk_fini, 16363448Sdh155122 (void *)&listen_fanout_init }, 16373448Sdh155122 { "sctp_stack_conn_fanout", "walk the sctp conn fanout for one stack", 16383448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 16393448Sdh155122 fanout_stack_walk_fini, 16403448Sdh155122 (void *)&conn_fanout_init }, 16413448Sdh155122 { "sctp_stack_bind_fanout", "walk the sctp bind fanoutfor one stack", 16423448Sdh155122 fanout_stack_walk_init, fanout_stack_walk_step, 16433448Sdh155122 fanout_stack_walk_fini, 16440Sstevel@tonic-gate (void *)&bind_fanout_init }, 16450Sstevel@tonic-gate { "sctp_walk_faddr", "walk the peer address list of a given sctp_t", 16460Sstevel@tonic-gate sctp_walk_faddr_init, sctp_walk_faddr_step, NULL }, 16470Sstevel@tonic-gate { "sctp_walk_saddr", "walk the local address list of a given sctp_t", 16480Sstevel@tonic-gate sctp_walk_saddr_init, sctp_walk_saddr_step, sctp_walk_saddr_fini }, 16493448Sdh155122 { "sctp_walk_ill", "walk the sctp_g_ills list for all stacks", 16503448Sdh155122 sctp_ill_walk_init, sctp_ill_walk_step, NULL }, 16513448Sdh155122 { "sctp_walk_ipif", "walk the sctp_g_ipif list for all stacks", 16523448Sdh155122 sctp_ipif_walk_init, sctp_ipif_walk_step, NULL }, 16533448Sdh155122 { "sctp_stack_walk_ill", "walk the sctp_g_ills list for one stack", 16543448Sdh155122 sctp_stack_ill_walk_init, sctp_stack_ill_walk_step, NULL }, 16553448Sdh155122 { "sctp_stack_walk_ipif", "walk the sctp_g_ipif list for one stack", 16563448Sdh155122 sctp_stack_ipif_walk_init, sctp_stack_ipif_walk_step, NULL }, 1657*12869SKacheong.Poon@Sun.COM { "sctps_sc", "walk all the per CPU stats counters of a sctp_stack_t", 1658*12869SKacheong.Poon@Sun.COM sctps_sc_walk_init, sctps_sc_walk_step, NULL }, 16590Sstevel@tonic-gate { NULL } 16600Sstevel@tonic-gate }; 16610Sstevel@tonic-gate 16620Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers }; 16630Sstevel@tonic-gate 16640Sstevel@tonic-gate const mdb_modinfo_t * 16650Sstevel@tonic-gate _mdb_init(void) 16660Sstevel@tonic-gate { 16670Sstevel@tonic-gate return (&modinfo); 16680Sstevel@tonic-gate } 1669