diff options
| author | christos <christos@NetBSD.org> | 2016-12-30 21:08:23 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2016-12-30 21:08:23 +0000 |
| commit | 4bf5e2d88774d4bbb73d7e89f336dcf17d2aed46 (patch) | |
| tree | a2cc18dd1239a859ff398e178074d99c484c14c4 /usr.bin/fstat | |
| parent | f0b7247e272124de73f5d66d13c452d17e46c521 (diff) | |
Print the interface for bpf.
Diffstat (limited to 'usr.bin/fstat')
| -rw-r--r-- | usr.bin/fstat/fstat.c | 14 | ||||
| -rw-r--r-- | usr.bin/fstat/misc.c | 19 |
2 files changed, 23 insertions, 10 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 415994b6d3c..4a6ed1c2f57 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $NetBSD: fstat.c,v 1.110 2015/12/22 23:35:21 christos Exp $ */ +/* $NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 christos Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\ #if 0 static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95"; #else -__RCSID("$NetBSD: fstat.c,v 1.110 2015/12/22 23:35:21 christos Exp $"); +__RCSID("$NetBSD: fstat.c,v 1.111 2016/12/30 21:08:23 christos Exp $"); #endif #endif /* not lint */ @@ -651,23 +651,23 @@ vtrans(struct vnode *vp, int i, int flag, long addr) char buf[1024]; (void)snprintb(buf, sizeof(buf), VNODE_FLAGBITS, vn.v_iflag | vn.v_vflag | vn.v_uflag); - (void)printf(" flags %s\n", buf); + (void)printf(" flags %s\n", buf); return; } else if (badtype) { - (void)printf(" - - %10s -\n", badtype); + (void)printf(" - - %10s -\n", badtype); return; } if (nflg) - (void)printf(" %2llu,%-2llu", + (void)printf(" %2llu,%-2llu", (unsigned long long)major(fst.fsid), (unsigned long long)minor(fst.fsid)); else - (void)printf(" %-8s", getmnton(vn.v_mount)); + (void)printf(" %-8s", getmnton(vn.v_mount)); if (nflg) (void)snprintf(mode, sizeof mode, "%o", fst.mode); else strmode(fst.mode, mode); - (void)printf(" %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode); + (void)printf(" %7"PRIu64" %*s", fst.fileid, nflg ? 5 : 10, mode); switch (vn.v_type) { case VBLK: case VCHR: { diff --git a/usr.bin/fstat/misc.c b/usr.bin/fstat/misc.c index 4de7fda8f23..69ca70f02fd 100644 --- a/usr.bin/fstat/misc.c +++ b/usr.bin/fstat/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $ */ +/* $NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: misc.c,v 1.16 2016/01/23 16:12:03 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.17 2016/12/30 21:08:23 christos Exp $"); #include <stdbool.h> #include <sys/param.h> @@ -113,12 +113,25 @@ static int p_bpf(struct file *f) { struct bpf_d bpf; + struct bpf_if bi; + struct ifnet ifn; + + strlcpy(ifn.if_xname, "???", sizeof(ifn.if_xname)); if (!KVM_READ(f->f_data, &bpf, sizeof(bpf))) { dprintf("can't read bpf at %p for pid %d", f->f_data, Pid); return 0; } - (void)printf("* bpf rec=%lu, dr=%lu, cap=%lu, pid=%lu", + if (bpf.bd_bif != NULL) { + if (!KVM_READ(bpf.bd_bif, &bi, sizeof(bi))) + dprintf("can't read bpf interface at %p for pid %d", + bpf.bd_bif, Pid); + if (bi.bif_ifp != NULL) + if (!KVM_READ(bi.bif_ifp, &ifn, sizeof(ifn))) + dprintf("can't read net interfsace" + " at %p for pid %d", bi.bif_ifp, Pid); + } + (void)printf("* bpf@%s rec=%lu, dr=%lu, cap=%lu, pid=%lu", ifn.if_xname, bpf.bd_rcount, bpf.bd_dcount, bpf.bd_ccount, (unsigned long)bpf.bd_pid); if (bpf.bd_promisc) |
