mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Add ddb support to the "new" link layer code ("new-arp"):
- show all lltables [1] (optional flag to also show the llentries as well) - show lltable <struct lltable *> - show llentry <struct llentry *> MFC after: 6 days
This commit is contained in:
parent
ee48488f0b
commit
335b943f8e
@ -27,6 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_inet.h"
|
||||
#include "opt_inet6.h"
|
||||
|
||||
@ -42,6 +43,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/rwlock.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -382,3 +387,134 @@ vnet_lltable_init()
|
||||
VNET_SYSINIT(vnet_lltable_init, SI_SUB_PSEUDO, SI_ORDER_FIRST,
|
||||
vnet_lltable_init, NULL);
|
||||
|
||||
#ifdef DDB
|
||||
struct llentry_sa {
|
||||
struct llentry base;
|
||||
struct sockaddr l3_addr;
|
||||
};
|
||||
|
||||
static void
|
||||
llatbl_lle_show(struct llentry_sa *la)
|
||||
{
|
||||
struct llentry *lle;
|
||||
uint8_t octet[6];
|
||||
|
||||
lle = &la->base;
|
||||
db_printf("lle=%p\n", lle);
|
||||
db_printf(" lle_next=%p\n", lle->lle_next.le_next);
|
||||
db_printf(" lle_lock=%p\n", &lle->lle_lock);
|
||||
db_printf(" lle_tbl=%p\n", lle->lle_tbl);
|
||||
db_printf(" lle_head=%p\n", lle->lle_head);
|
||||
db_printf(" la_hold=%p\n", lle->la_hold);
|
||||
db_printf(" la_expire=%ju\n", (uintmax_t)lle->la_expire);
|
||||
db_printf(" la_flags=0x%04x\n", lle->la_flags);
|
||||
db_printf(" la_asked=%u\n", lle->la_asked);
|
||||
db_printf(" la_preempt=%u\n", lle->la_preempt);
|
||||
db_printf(" ln_byhint=%u\n", lle->ln_byhint);
|
||||
db_printf(" ln_state=%d\n", lle->ln_state);
|
||||
db_printf(" ln_router=%u\n", lle->ln_router);
|
||||
db_printf(" ln_ntick=%ju\n", (uintmax_t)lle->ln_ntick);
|
||||
db_printf(" lle_refcnt=%d\n", lle->lle_refcnt);
|
||||
bcopy(&lle->ll_addr.mac16, octet, sizeof(octet));
|
||||
db_printf(" ll_addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
octet[0], octet[1], octet[2], octet[3], octet[4], octet[5]);
|
||||
db_printf(" la_timer=%p\n", &lle->la_timer);
|
||||
|
||||
switch (la->l3_addr.sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *sin;
|
||||
char l3s[INET_ADDRSTRLEN];
|
||||
|
||||
sin = (struct sockaddr_in *)&la->l3_addr;
|
||||
inet_ntoa_r(sin->sin_addr, l3s);
|
||||
db_printf(" l3_addr=%s\n", l3s);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6;
|
||||
char l3s[INET6_ADDRSTRLEN];
|
||||
|
||||
sin6 = (struct sockaddr_in6 *)&la->l3_addr;
|
||||
ip6_sprintf(l3s, &sin6->sin6_addr);
|
||||
db_printf(" l3_addr=%s\n", l3s);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
db_printf(" l3_addr=N/A (af=%d)\n", la->l3_addr.sa_family);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DB_SHOW_COMMAND(llentry, db_show_llentry)
|
||||
{
|
||||
|
||||
if (!have_addr) {
|
||||
db_printf("usage: show llentry <struct llentry *>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
llatbl_lle_show((struct llentry_sa *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
llatbl_llt_show(struct lltable *llt)
|
||||
{
|
||||
int i;
|
||||
struct llentry *lle;
|
||||
|
||||
db_printf("llt=%p llt_af=%d llt_ifp=%p\n",
|
||||
llt, llt->llt_af, llt->llt_ifp);
|
||||
|
||||
for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) {
|
||||
LIST_FOREACH(lle, &llt->lle_head[i], lle_next) {
|
||||
|
||||
llatbl_lle_show((struct llentry_sa *)lle);
|
||||
if (db_pager_quit)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DB_SHOW_COMMAND(lltable, db_show_lltable)
|
||||
{
|
||||
|
||||
if (!have_addr) {
|
||||
db_printf("usage: show lltable <struct lltable *>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
llatbl_llt_show((struct lltable *)addr);
|
||||
}
|
||||
|
||||
DB_SHOW_ALL_COMMAND(lltables, db_show_all_lltables)
|
||||
{
|
||||
VNET_ITERATOR_DECL(vnet_iter);
|
||||
struct lltable *llt;
|
||||
|
||||
VNET_FOREACH(vnet_iter) {
|
||||
CURVNET_SET_QUIET(vnet_iter);
|
||||
#ifdef VIMAGE
|
||||
db_printf("vnet=%p\n", curvnet);
|
||||
#endif
|
||||
SLIST_FOREACH(llt, &V_lltables, llt_link) {
|
||||
db_printf("llt=%p llt_af=%d llt_ifp=%p(%s)\n",
|
||||
llt, llt->llt_af, llt->llt_ifp,
|
||||
(llt->llt_ifp != NULL) ?
|
||||
llt->llt_ifp->if_xname : "?");
|
||||
if (have_addr && addr != 0) /* verbose */
|
||||
llatbl_llt_show(llt);
|
||||
if (db_pager_quit) {
|
||||
CURVNET_RESTORE();
|
||||
return;
|
||||
}
|
||||
}
|
||||
CURVNET_RESTORE();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user