From c03907c46c64c5057651d5d4ee0b4d447ea2c3be Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Fri, 1 Jan 2016 17:38:46 +0000 Subject: The "-P" option does not need to read routing table symbols so do not check for them. ok benno@, bluhm@ --- usr.bin/netstat/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'usr.bin') 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)) { -- cgit v1.2.3