1381a2a9aSdr146992 /* 2381a2a9aSdr146992 * CDDL HEADER START 3381a2a9aSdr146992 * 4381a2a9aSdr146992 * The contents of this file are subject to the terms of the 5381a2a9aSdr146992 * Common Development and Distribution License (the "License"). 6381a2a9aSdr146992 * You may not use this file except in compliance with the License. 7381a2a9aSdr146992 * 8381a2a9aSdr146992 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9381a2a9aSdr146992 * or http://www.opensolaris.org/os/licensing. 10381a2a9aSdr146992 * See the License for the specific language governing permissions 11381a2a9aSdr146992 * and limitations under the License. 12381a2a9aSdr146992 * 13381a2a9aSdr146992 * When distributing Covered Code, include this CDDL HEADER in each 14381a2a9aSdr146992 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15381a2a9aSdr146992 * If applicable, add the following below this CDDL HEADER, with the 16381a2a9aSdr146992 * fields enclosed by brackets "[]" replaced with your own identifying 17381a2a9aSdr146992 * information: Portions Copyright [yyyy] [name of copyright owner] 18381a2a9aSdr146992 * 19381a2a9aSdr146992 * CDDL HEADER END 20381a2a9aSdr146992 */ 21381a2a9aSdr146992 /* 22*7ddc9b1aSDarren Reed * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23381a2a9aSdr146992 * Use is subject to license terms. 24381a2a9aSdr146992 */ 25381a2a9aSdr146992 26381a2a9aSdr146992 #include <sys/types.h> 27381a2a9aSdr146992 #include <sys/rwlock.h> 28381a2a9aSdr146992 #include <mdb/mdb_modapi.h> 29381a2a9aSdr146992 #include <sys/queue.h> 30381a2a9aSdr146992 #include <sys/neti.h> 31381a2a9aSdr146992 32381a2a9aSdr146992 33381a2a9aSdr146992 /* 34381a2a9aSdr146992 * PROT_LENGTH is the max length. If the true length is bigger 35381a2a9aSdr146992 * it is truncated. 36381a2a9aSdr146992 */ 37381a2a9aSdr146992 #define PROT_LENGTH 32 38381a2a9aSdr146992 39381a2a9aSdr146992 /* 40381a2a9aSdr146992 * List pfhooks netinfo information. 41381a2a9aSdr146992 */ 42381a2a9aSdr146992 /*ARGSUSED*/ 43381a2a9aSdr146992 int 44381a2a9aSdr146992 netinfolist(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 45381a2a9aSdr146992 { 46f4b3ec61Sdh155122 struct neti_stack *nts; 47381a2a9aSdr146992 struct netd_listhead nlh; 48381a2a9aSdr146992 struct net_data nd, *p; 49381a2a9aSdr146992 char str[PROT_LENGTH]; 50381a2a9aSdr146992 51381a2a9aSdr146992 if (argc) 52381a2a9aSdr146992 return (DCMD_USAGE); 53381a2a9aSdr146992 54f4b3ec61Sdh155122 if (mdb_vread((void *)&nts, sizeof (nts), 55f4b3ec61Sdh155122 (uintptr_t)(addr + OFFSETOF(netstack_t, netstack_neti))) == -1) { 56f4b3ec61Sdh155122 mdb_warn("couldn't read netstack_neti"); 57f4b3ec61Sdh155122 return (DCMD_ERR); 58f4b3ec61Sdh155122 } 59f4b3ec61Sdh155122 60f4b3ec61Sdh155122 if (mdb_vread((void *)&nlh, sizeof (nlh), (uintptr_t)((uintptr_t)nts + 61f4b3ec61Sdh155122 OFFSETOF(neti_stack_t, nts_netd_head))) == -1) { 62f4b3ec61Sdh155122 mdb_warn("couldn't read netd list head"); 63381a2a9aSdr146992 return (DCMD_ERR); 64381a2a9aSdr146992 } 65381a2a9aSdr146992 mdb_printf("%<u>%?s %?s %10s%</u>\n", 66381a2a9aSdr146992 "ADDR(netinfo)", "ADDR(hookevent)", "netinfo"); 67381a2a9aSdr146992 p = LIST_FIRST(&nlh); 68381a2a9aSdr146992 while (p) { 69381a2a9aSdr146992 if (mdb_vread((void *)&nd, sizeof (nd), (uintptr_t)p) == -1) { 70381a2a9aSdr146992 mdb_warn("couldn't read netinfo at %p", p); 71381a2a9aSdr146992 return (DCMD_ERR); 72381a2a9aSdr146992 } 73*7ddc9b1aSDarren Reed if (!nd.netd_info.netp_name) { 74381a2a9aSdr146992 mdb_warn("netinfo at %p has null protocol", 75*7ddc9b1aSDarren Reed nd.netd_info.netp_name); 76381a2a9aSdr146992 return (DCMD_ERR); 77381a2a9aSdr146992 } 78381a2a9aSdr146992 if (mdb_readstr((char *)str, sizeof (str), 79*7ddc9b1aSDarren Reed (uintptr_t)nd.netd_info.netp_name) == -1) { 80381a2a9aSdr146992 mdb_warn("couldn't read protocol at %p", 81*7ddc9b1aSDarren Reed nd.netd_info.netp_name); 82381a2a9aSdr146992 return (DCMD_ERR); 83381a2a9aSdr146992 } 84381a2a9aSdr146992 85381a2a9aSdr146992 mdb_printf("%0?p %0?p %10s\n", 86381a2a9aSdr146992 (char *)p + (uintptr_t)&((struct net_data *)0)->netd_info, 87381a2a9aSdr146992 nd.netd_hooks, str); 88381a2a9aSdr146992 89381a2a9aSdr146992 p = LIST_NEXT(&nd, netd_list); 90381a2a9aSdr146992 } 91381a2a9aSdr146992 92381a2a9aSdr146992 return (DCMD_OK); 93381a2a9aSdr146992 } 94381a2a9aSdr146992 95381a2a9aSdr146992 static const mdb_dcmd_t dcmds[] = { 96381a2a9aSdr146992 { "netinfolist", "", "display netinfo information", 97381a2a9aSdr146992 netinfolist, NULL }, 98381a2a9aSdr146992 { NULL } 99381a2a9aSdr146992 }; 100381a2a9aSdr146992 101381a2a9aSdr146992 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds }; 102381a2a9aSdr146992 103381a2a9aSdr146992 const mdb_modinfo_t * 104381a2a9aSdr146992 _mdb_init(void) 105381a2a9aSdr146992 { 106381a2a9aSdr146992 return (&modinfo); 107381a2a9aSdr146992 } 108