]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net/if_debug.c
ident(1): Normalizing date format
[FreeBSD/FreeBSD.git] / sys / net / if_debug.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2010 Bjoern A. Zeeb <bz@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31
32 #include "opt_ddb.h"
33
34 #include <sys/param.h>
35 #include <sys/socket.h>
36 #include <sys/types.h>
37
38 #ifdef DDB
39 #include <ddb/ddb.h>
40 #endif
41
42 #include <net/if.h>
43 #include <net/if_types.h>
44 #include <net/if_var.h>
45 #include <net/vnet.h>
46
47 #ifdef DDB
48 struct ifindex_entry {
49         struct  ifnet *ife_ifnet;
50 };
51 VNET_DECLARE(struct ifindex_entry *, ifindex_table);
52 #define V_ifindex_table         VNET(ifindex_table)
53
54 static void
55 if_show_ifnet(struct ifnet *ifp)
56 {
57
58         if (ifp == NULL)
59                 return;
60         db_printf("%s:\n", ifp->if_xname);
61 #define IF_DB_PRINTF(f, e)      db_printf("   %s = " f "\n", #e, ifp->e);
62         IF_DB_PRINTF("%s", if_dname);
63         IF_DB_PRINTF("%d", if_dunit);
64         IF_DB_PRINTF("%s", if_description);
65         IF_DB_PRINTF("%u", if_index);
66         IF_DB_PRINTF("%u", if_refcount);
67         IF_DB_PRINTF("%d", if_index_reserved);
68         IF_DB_PRINTF("%p", if_softc);
69         IF_DB_PRINTF("%p", if_l2com);
70         IF_DB_PRINTF("%p", if_llsoftc);
71         IF_DB_PRINTF("%d", if_amcount);
72         IF_DB_PRINTF("%p", if_addr);
73         IF_DB_PRINTF("%p", if_broadcastaddr);
74         IF_DB_PRINTF("%p", if_afdata);
75         IF_DB_PRINTF("%d", if_afdata_initialized);
76         IF_DB_PRINTF("%u", if_fib);
77         IF_DB_PRINTF("%p", if_vnet);
78         IF_DB_PRINTF("%p", if_home_vnet);
79         IF_DB_PRINTF("%p", if_vlantrunk);
80         IF_DB_PRINTF("%p", if_bpf);
81         IF_DB_PRINTF("%u", if_pcount);
82         IF_DB_PRINTF("%p", if_bridge);
83         IF_DB_PRINTF("%p", if_lagg);
84         IF_DB_PRINTF("%p", if_pf_kif);
85         IF_DB_PRINTF("%p", if_carp);
86         IF_DB_PRINTF("%p", if_label);
87         IF_DB_PRINTF("%p", if_netmap);
88         IF_DB_PRINTF("0x%08x", if_flags);
89         IF_DB_PRINTF("0x%08x", if_drv_flags);
90         IF_DB_PRINTF("0x%08x", if_capabilities);
91         IF_DB_PRINTF("0x%08x", if_capenable);
92         IF_DB_PRINTF("%p", if_snd.ifq_head);
93         IF_DB_PRINTF("%p", if_snd.ifq_tail);
94         IF_DB_PRINTF("%d", if_snd.ifq_len);
95         IF_DB_PRINTF("%d", if_snd.ifq_maxlen);
96         IF_DB_PRINTF("%p", if_snd.ifq_drv_head);
97         IF_DB_PRINTF("%p", if_snd.ifq_drv_tail);
98         IF_DB_PRINTF("%d", if_snd.ifq_drv_len);
99         IF_DB_PRINTF("%d", if_snd.ifq_drv_maxlen);
100         IF_DB_PRINTF("%d", if_snd.altq_type);
101         IF_DB_PRINTF("%x", if_snd.altq_flags);
102 #undef IF_DB_PRINTF
103 }
104
105 DB_SHOW_COMMAND(ifnet, db_show_ifnet)
106 {
107
108         if (!have_addr) {
109                 db_printf("usage: show ifnet <struct ifnet *>\n");
110                 return;
111         }
112
113         if_show_ifnet((struct ifnet *)addr);
114 }
115
116 DB_SHOW_ALL_COMMAND(ifnets, db_show_all_ifnets)
117 {
118         VNET_ITERATOR_DECL(vnet_iter);
119         struct ifnet *ifp;
120         u_short idx;
121
122         VNET_FOREACH(vnet_iter) {
123                 CURVNET_SET_QUIET(vnet_iter);
124 #ifdef VIMAGE
125                 db_printf("vnet=%p\n", curvnet);
126 #endif
127                 for (idx = 1; idx <= V_if_index; idx++) {
128                         ifp = V_ifindex_table[idx].ife_ifnet;
129                         if (ifp == NULL)
130                                 continue;
131                         db_printf( "%20s ifp=%p\n", ifp->if_xname, ifp);
132                         if (db_pager_quit)
133                                 break;
134                 }
135                 CURVNET_RESTORE();
136         }
137 }
138 #endif