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
This commit is contained in:
parent
30b9cadca4
commit
c9fdacdac8
81
sys/net/if.c
81
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
|
||||
|
Loading…
Reference in New Issue
Block a user