diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-01-01 17:38:46 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-01-01 17:38:46 +0000 |
commit | c03907c46c64c5057651d5d4ee0b4d447ea2c3be (patch) | |
tree | c2d9378d1c1e2bc809830f705359fcb43080ec11 /usr.bin | |
parent | 165aedbfc202a8daaaa9dfd9a2f06674c4fcc526 (diff) |
The "-P" option does not need to read routing table symbols so do not
check for them.
ok benno@, bluhm@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/main.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index ddcac13fdf0..418b1366f7b 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.108 2015/10/23 08:18:57 tedu Exp $ */ +/* $OpenBSD: main.c,v 1.109 2016/01/01 17:38:45 mpi Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -124,7 +124,7 @@ main(int argc, char *argv[]) int Tflag = 0; int repeatcount = 0; int proto = 0; - int need_nlist; + int need_nlist, kvm_flags = O_RDONLY; af = AF_UNSPEC; tableid = getrtable(); @@ -325,10 +325,11 @@ main(int argc, char *argv[]) * The remaining code may need kvm so lets try to open it. * -r and -P are the only bits left that actually can use this. */ - need_nlist = nlistf != NULL || memf != NULL || Pflag || (Aflag && rflag); + need_nlist = (nlistf != NULL) || (memf != NULL) || (Aflag && rflag); + if (!need_nlist && !Pflag) + kvm_flags |= KVM_NO_FILES; - if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY | - (need_nlist ? 0 : KVM_NO_FILES), buf)) == NULL) + if ((kvmd = kvm_openfiles(nlistf, memf, NULL, kvm_flags, buf)) == NULL) errx(1, "kvm_openfiles: %s", buf); if (need_nlist && (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0)) { |