Print this page
2602 mdb ::sockparams SEGV
2602 mdb ::sockparams SEGV
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
+++ new/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/stropts.h>
28 28 #include <sys/socket.h>
29 29 #include <sys/socketvar.h>
30 30
31 31 #include <mdb/mdb_modapi.h>
32 32 #include <mdb/mdb_ks.h>
33 33
34 34 /*
35 35 * Look up the symbol name for the given sockparams list and walk
36 36 * all the entries.
37 37 */
38 38 static boolean_t
39 39 sockparams_walk_list(const char *symname, int argc, const mdb_arg_t *argv)
40 40 {
41 41 GElf_Sym sym;
42 42
43 43 if (mdb_lookup_by_name(symname, &sym)) {
44 44 mdb_warn("can't find symbol %s", symname);
45 45 return (B_FALSE);
46 46 }
47 47
48 48 if (mdb_pwalk_dcmd("list", "sockfs`sockparams", argc, argv,
49 49 sym.st_value) != 0) {
50 50 mdb_warn("can't walk %s", symname);
51 51 return (B_FALSE);
52 52 }
53 53
54 54 return (B_TRUE);
55 55 }
56 56
57 57 /*
58 58 * dcmd to print sockparams info.
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
59 59 *
60 60 * If no address is given then the default is to print all sockparams on the
61 61 * global list (i.e., installed with soconfig(1)). To also print the ephemeral
62 62 * entries the '-e' flag should be used. Only ephemeral entries can be printed
63 63 * by specifying the '-E' flag.
64 64 */
65 65 static int
66 66 sockparams_prt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
67 67 {
68 68 struct sockparams sp;
69 + char strdev[MAXPATHLEN];
70 + char sockmod[MODMAXNAMELEN];
69 71
70 72 if ((flags & DCMD_ADDRSPEC) == 0) {
71 73 uint_t opt_e = 0;
72 74 uint_t opt_E = 0;
73 75
74 76 /*
75 77 * Determine what lists should be printed
76 78 */
77 79 if (mdb_getopts(argc, argv,
78 80 'e', MDB_OPT_SETBITS, 1, &opt_e,
79 81 'E', MDB_OPT_SETBITS, 1, &opt_E) != argc)
80 82 return (DCMD_USAGE);
81 83
82 84 if (!opt_E) {
83 85 if (!sockparams_walk_list("sphead", argc, argv))
84 86 return (DCMD_ERR);
85 87 }
86 88
87 89 if (opt_e || opt_E) {
88 90 if (!sockparams_walk_list("sp_ephem_list", argc, argv))
89 91 return (DCMD_ERR);
90 92 }
91 93
92 94 return (DCMD_OK);
93 95 }
94 96
95 97 /*
96 98 * If we are piping the output, then just print out the address,
97 99 * otherwise summarize the sockparams info.
98 100 */
99 101 if ((flags & DCMD_PIPE_OUT) != 0) {
100 102 mdb_printf("%#lr\n", addr);
101 103 return (DCMD_OK);
102 104 }
103 105
104 106 if (DCMD_HDRSPEC(flags)) {
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
105 107 mdb_printf("%-?s %3s %3s %3s %15s %15s %6s %6s\n",
106 108 "ADDR", "FAM", "TYP", "PRO", "STRDEV", "SOCKMOD", "REFS",
107 109 "FLGS");
108 110 }
109 111
110 112 if (mdb_vread(&sp, sizeof (sp), addr) == -1) {
111 113 mdb_warn("failed to read sockparams at %0?p", addr);
112 114 return (DCMD_ERR);
113 115 }
114 116
117 + if ((sp.sp_sdev_info.sd_devpath == NULL) ||
118 + (mdb_readstr(strdev, sizeof (strdev),
119 + (uintptr_t)sp.sp_sdev_info.sd_devpath) <= 0))
120 + strcpy(strdev, "-");
121 + if (mdb_readstr(sockmod, sizeof (sockmod),
122 + (uintptr_t)sp.sp_smod_name) <= 0)
123 + strcpy(sockmod, "");
124 +
115 125 mdb_printf("%0?p %3u %3u %3u %15s %15s %6u %#6x\n",
116 126 addr,
117 127 sp.sp_family, sp.sp_type, sp.sp_protocol,
118 - (sp.sp_sdev_info.sd_devpath != 0) ?
119 - sp.sp_sdev_info.sd_devpath : "-",
120 - sp.sp_smod_name, sp.sp_refcnt,
128 + strdev, sockmod, sp.sp_refcnt,
121 129 sp.sp_flags);
122 130
123 131
124 132 return (DCMD_OK);
125 133 }
126 134
127 135 /*
128 136 * Help function
129 137 */
130 138 void
131 139 sockparams_help(void)
132 140 {
133 141 mdb_printf("Print sockparams information for a give sockparams ptr.\n"
134 142 "Without the address, list available sockparams. Default "
135 143 "behavior is to list only entries that were installed by the "
136 144 "admin (via soconfig(1M)).\n\n"
137 145 "Options:\n"
138 146 " -e:\t\tlist ephemeral sockparams\n"
139 147 " -E:\t\tonly list ephemeral sockparams\n");
140 148 }
141 149
142 150 static const mdb_dcmd_t dcmds[] = {
143 151 { "sockparams", "[-eE]", "print sockparams", sockparams_prt,
144 152 sockparams_help },
145 153 { NULL }
146 154 };
147 155
148 156 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, NULL };
149 157
150 158 const mdb_modinfo_t *
151 159 _mdb_init(void)
152 160 {
153 161 return (&modinfo);
154 162 }
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX