diff options
author | bz <bz@FreeBSD.org> | 2010-02-20 22:09:48 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2010-02-20 22:09:48 +0000 |
commit | 27d5a929855c22e5f53d9b4a4564e54f5d48693a (patch) | |
tree | 77aad414093bae1f7cdb0dce9e0cade7c67cd119 | |
parent | de671b7499b7dbd80423b0b49227a506bfc4b6fe (diff) | |
download | FreeBSD-src-27d5a929855c22e5f53d9b4a4564e54f5d48693a.zip FreeBSD-src-27d5a929855c22e5f53d9b4a4564e54f5d48693a.tar.gz |
Start to implement ifnet DDB support:
- 'show ifnets' prints a list of ifnet *s per virtual network stack,
- 'show ifnet <struct ifnet *>' prints fields matching the given ifp.
We do not yet print the complete set of fields and might want to
factor this out to an extra if_debug.c file in case this grows
a lot[1]. We may also want to grow 'show ifnet <if_xname>' support[1].
Sponsored by: ISPsystem
Suggested by: rwatson [1]
Reviewed by: rwatson
MFC after: 5 days
-rw-r--r-- | sys/net/if.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 68f49ef..9413da4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -34,6 +34,7 @@ #include "opt_inet6.h" #include "opt_inet.h" #include "opt_carp.h" +#include "opt_ddb.h" #include <sys/param.h> #include <sys/types.h> @@ -62,6 +63,10 @@ #include <machine/stdarg.h> #include <vm/uma.h> +#ifdef DDB +#include <ddb/ddb.h> +#endif + #include <net/if.h> #include <net/if_arp.h> #include <net/if_clone.h> @@ -3331,3 +3336,79 @@ if_deregister_com_alloc(u_char type) if_com_alloc[type] = NULL; if_com_free[type] = NULL; } + +#ifdef DDB +static void +if_show_ifnet(struct ifnet *ifp) +{ + + if (ifp == NULL) + return; + db_printf("%s:\n", ifp->if_xname); +#define IF_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, ifp->e); + IF_DB_PRINTF("%s", if_dname); + IF_DB_PRINTF("%d", if_dunit); + IF_DB_PRINTF("%s", if_description); + IF_DB_PRINTF("%u", if_index); + IF_DB_PRINTF("%u", if_refcount); + IF_DB_PRINTF("%d", if_index_reserved); + IF_DB_PRINTF("%p", if_softc); + IF_DB_PRINTF("%p", if_l2com); + IF_DB_PRINTF("%p", if_vnet); + IF_DB_PRINTF("%p", if_home_vnet); + IF_DB_PRINTF("%p", if_addr); + IF_DB_PRINTF("%p", if_llsoftc); + IF_DB_PRINTF("%p", if_label); + IF_DB_PRINTF("%u", if_pcount); + IF_DB_PRINTF("0x%08x", if_flags); + IF_DB_PRINTF("0x%08x", if_drv_flags); + IF_DB_PRINTF("0x%08x", if_capabilities); + IF_DB_PRINTF("0x%08x", if_capenable); + IF_DB_PRINTF("%p", if_snd.ifq_head); + IF_DB_PRINTF("%p", if_snd.ifq_tail); + IF_DB_PRINTF("%d", if_snd.ifq_len); + IF_DB_PRINTF("%d", if_snd.ifq_maxlen); + IF_DB_PRINTF("%d", if_snd.ifq_drops); + IF_DB_PRINTF("%p", if_snd.ifq_drv_head); + IF_DB_PRINTF("%p", if_snd.ifq_drv_tail); + IF_DB_PRINTF("%d", if_snd.ifq_drv_len); + IF_DB_PRINTF("%d", if_snd.ifq_drv_maxlen); + IF_DB_PRINTF("%d", if_snd.altq_type); + IF_DB_PRINTF("%x", if_snd.altq_flags); +#undef IF_DB_PRINTF +} + +DB_SHOW_COMMAND(ifnet, db_show_ifnet) +{ + + if (!have_addr) { + db_printf("usage: show ifnet <struct ifnet *>\n"); + return; + } + + if_show_ifnet((struct ifnet *)addr); +} + +DB_SHOW_COMMAND(ifnets, db_show_ifnets) +{ + VNET_ITERATOR_DECL(vnet_iter); + struct ifnet *ifp; + u_short idx; + + VNET_FOREACH(vnet_iter) { + CURVNET_SET_QUIET(vnet_iter); +#ifdef VIMAGE + db_printf("vnet=%p\n", curvnet); +#endif + for (idx = 1; idx <= V_if_index; idx++) { + ifp = V_ifindex_table[idx].ife_ifnet; + if (ifp == NULL) + continue; + db_printf( "%20s ifp=%p\n", ifp->if_xname, ifp); + if (db_pager_quit) + break; + } + CURVNET_RESTORE(); + } +} +#endif |