Module Name: src
Committed By: mrg
Date: Fri Dec 23 06:22:00 UTC 2016
Modified Files:
src/usr.bin/netstat: inet.c
Log Message:
in getpcblist_sysctl() if sysctlnametomib() fails, return NULL and
set *len = 0, rather than bailing. now "netstat" doesn't give up
early on kernels without INET6.
To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/netstat/inet.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.106 src/usr.bin/netstat/inet.c:1.107
--- src/usr.bin/netstat/inet.c:1.106 Sun Feb 8 15:09:45 2015
+++ src/usr.bin/netstat/inet.c Fri Dec 23 06:22:00 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: inet.c,v 1.106 2015/02/08 15:09:45 christos Exp $ */
+/* $NetBSD: inet.c,v 1.107 2016/12/23 06:22:00 mrg Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-__RCSID("$NetBSD: inet.c,v 1.106 2015/02/08 15:09:45 christos Exp $");
+__RCSID("$NetBSD: inet.c,v 1.107 2016/12/23 06:22:00 mrg Exp $");
#endif
#endif /* not lint */
@@ -88,6 +88,8 @@ __RCSID("$NetBSD: inet.c,v 1.106 2015/02
#include <stdlib.h>
#include <err.h>
#include <util.h>
+#include <errno.h>
+
#include "netstat.h"
#include "vtw.h"
#include "prog_ops.h"
@@ -240,8 +242,14 @@ getpcblist_sysctl(const char *name, size
err(1, "asprintf");
/* get dynamic pcblist node */
- if (sysctlnametomib(mibname, mib, &namelen) == -1)
+ if (sysctlnametomib(mibname, mib, &namelen) == -1) {
+ if (errno == ENOENT) {
+ *len = 0;
+ return NULL;
+ }
+
err(1, "sysctlnametomib: %s", mibname);
+ }
free(mibname);