summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/main.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-01-01 17:38:45 +0000
committermpi <mpi@openbsd.org>2016-01-01 17:38:45 +0000
commit7ddfc071a239c41949b4868c5f3a64a60382d0fc (patch)
tree4b4f1cf6c1cf5b63130b768657d90f2bde7d0089 /usr.bin/netstat/main.c
parentTweak the installation notes regarding references to FTP. (diff)
downloadwireguard-openbsd-7ddfc071a239c41949b4868c5f3a64a60382d0fc.tar.xz
wireguard-openbsd-7ddfc071a239c41949b4868c5f3a64a60382d0fc.zip
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/netstat/main.c')
-rw-r--r--usr.bin/netstat/main.c11
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)) {