Index: kern/subr_stack.c =================================================================== --- kern/subr_stack.c (revision 194811) +++ kern/subr_stack.c (working copy) @@ -42,10 +42,10 @@ static MALLOC_DEFINE(M_STACK, "stack", "Stack Traces"); -static void stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen, +static int stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen, long *offset); #ifdef DDB -static void stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset); +static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset); #endif struct stack * @@ -98,12 +98,33 @@ KASSERT(st->depth <= STACK_MAX, ("bogus stack")); for (i = 0; i < st->depth; i++) { - stack_symbol(st->pcs[i], namebuf, sizeof(namebuf), &offset); + (void)stack_symbol(st->pcs[i], namebuf, sizeof(namebuf), + &offset); printf("#%d %p at %s+%#lx\n", i, (void *)st->pcs[i], namebuf, offset); } } +void +stack_print_short(struct stack *st) +{ + char namebuf[64]; + long offset; + int i; + + KASSERT(st->depth <= STACK_MAX, ("bogus stack")); + for (i = 0; i < st->depth; i++) { + if (i > 0) + printf(" "); + if (stack_symbol(st->pcs[i], namebuf, sizeof(namebuf), + &offset) == 0) + printf("%s+%#lx", namebuf, offset); + else + printf("%p", (void *)st->pcs[i]); + } + printf("\n"); +} + #ifdef DDB void stack_print_ddb(struct stack *st) @@ -119,6 +140,25 @@ name, offset); } } + +void +stack_print_short_ddb(struct stack *st) +{ + const char *name; + long offset; + int i; + + KASSERT(st->depth <= STACK_MAX, ("bogus stack")); + for (i = 0; i < st->depth; i++) { + if (i > 0) + printf(" "); + if (stack_symbol_ddb(st->pcs[i], &name, &offset) == 0) + printf("%s+%#lx", name, offset); + else + printf("%p", (void *)st->pcs[i]); + } + printf("\n"); +} #endif /* @@ -134,7 +174,8 @@ KASSERT(st->depth <= STACK_MAX, ("bogus stack")); for (i = 0; i < st->depth; i++) { - stack_symbol(st->pcs[i], namebuf, sizeof(namebuf), &offset); + (void)stack_symbol(st->pcs[i], namebuf, sizeof(namebuf), + &offset); sbuf_printf(sb, "#%d %p at %s+%#lx\n", i, (void *)st->pcs[i], namebuf, offset); } @@ -150,7 +191,7 @@ KASSERT(st->depth <= STACK_MAX, ("bogus stack")); for (i = 0; i < st->depth; i++) { - stack_symbol_ddb(st->pcs[i], &name, &offset); + (void)stack_symbol_ddb(st->pcs[i], &name, &offset); sbuf_printf(sb, "#%d %p at %s+%#lx\n", i, (void *)st->pcs[i], name, offset); } @@ -188,7 +229,7 @@ if (depth == 0 || st->depth < depth) depth = st->depth; for (i = 0; i < depth; i++) { - stack_symbol_ddb(st->pcs[i], &name, &offset); + (void)stack_symbol_ddb(st->pcs[i], &name, &offset); ktr_tracepoint(mask, file, line, "#%d %p at %s+%#lx", i, st->pcs[i], (u_long)name, offset, 0, 0); } @@ -201,7 +242,7 @@ * Two variants of stack symbol lookup -- one that uses the DDB interfaces * and bypasses linker locking, and the other that doesn't. */ -static void +static int stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen, long *offset) { @@ -209,11 +250,13 @@ offset) != 0) { *offset = 0; strlcpy(namebuf, "??", buflen); - } + return (ENOENT); + } else + return (0); } #ifdef DDB -static void +static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset) { linker_symval_t symval; @@ -225,10 +268,11 @@ goto out; if (symval.name != NULL) { *name = symval.name; - return; + return (0); } out: *offset = 0; *name = "??"; + return (ENOENT); } #endif Index: netinet/in.c =================================================================== --- netinet/in.c (revision 194811) +++ netinet/in.c (working copy) @@ -306,6 +306,42 @@ break; } + switch (cmd) { + case SIOCAIFADDR: + printf("SIOCAIFADDR %s\n", ifp->if_xname); + break; + case SIOCSIFADDR: + printf("SIOCSIFADDR %s\n", ifp->if_xname); + break; + case SIOCSIFBRDADDR: + printf("SIOCSIFBRDADDR %s\n", ifp->if_xname); + break; + case SIOCSIFNETMASK: + printf("SIOCSIFNETMASK %s\n", ifp->if_xname); + break; + case SIOCSIFDSTADDR: + printf("SIOCSIFDSTADDR %s\n", ifp->if_xname); + break; + case SIOCDIFADDR: + printf("SIOCDIFADDR %s\n", ifp->if_xname); + break; + case SIOCGIFADDR: + printf("SIOCGIFADDR %s\n", ifp->if_xname); + break; + case SIOCGIFNETMASK: + printf("SIOCGIFNETMASK %s\n", ifp->if_xname); + break; + case SIOCGIFDSTADDR: + printf("SIOCGIFDSTADDR %s\n", ifp->if_xname); + break; + case SIOCGIFBRDADDR: + printf("SIOCGIFBRDADDR %s\n", ifp->if_xname); + break; + default: + printf("cmd %lu %s\n", cmd, ifp->if_xname); + break; + } + /* * Find address for this interface, if it exists. * Index: net/if.c =================================================================== --- net/if.c (revision 194821) +++ net/if.c (working copy) @@ -48,13 +48,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -1424,25 +1424,48 @@ void ifa_init(struct ifaddr *ifa) { + struct stack st; mtx_init(&ifa->ifa_mtx, "ifaddr", NULL, MTX_DEF); refcount_init(&ifa->ifa_refcnt, 1); + + stack_zero(&st); + stack_save(&st); + printf("ifa_init %p\n", ifa); + stack_print_short_ddb(&st); } void ifa_ref(struct ifaddr *ifa) { + struct stack st; refcount_acquire(&ifa->ifa_refcnt); + + stack_zero(&st); + stack_save(&st); + printf("ifa_ref %p (now %u)\n", ifa, ifa->ifa_refcnt); + stack_print_short_ddb(&st); } void ifa_free(struct ifaddr *ifa) { + struct stack st; + stack_zero(&st); + stack_save(&st); if (refcount_release(&ifa->ifa_refcnt)) { + printf("ifa_free %p (now %u, will free)\n", ifa, + ifa->ifa_refcnt); + stack_print_short_ddb(&st); + mtx_destroy(&ifa->ifa_mtx); free(ifa, M_IFADDR); + } else { + printf("ifa_free %p (now %u, won't free)\n", ifa, + ifa->ifa_refcnt); + stack_print_short_ddb(&st); } } Index: sys/stack.h =================================================================== --- sys/stack.h (revision 194811) +++ sys/stack.h (working copy) @@ -41,6 +41,8 @@ void stack_zero(struct stack *); void stack_print(struct stack *); void stack_print_ddb(struct stack *); +void stack_print_short(struct stack *); +void stack_print_short_ddb(struct stack *); void stack_sbuf_print(struct sbuf *, struct stack *); void stack_sbuf_print_ddb(struct sbuf *, struct stack *); #ifdef KTR