summaryrefslogtreecommitdiffstats
path: root/tools/tools/ifinfo
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2001-10-17 04:12:29 +0000
committerfenner <fenner@FreeBSD.org>2001-10-17 04:12:29 +0000
commit1e7fe9f955a3d9d24a8f7545a033f8b90126e3bf (patch)
tree3a092a48e9ca517c0577423fc3e3894299750bb4 /tools/tools/ifinfo
parentb69c7c0b789e7ca4de555baab2ee087e1bb5d231 (diff)
downloadFreeBSD-src-1e7fe9f955a3d9d24a8f7545a033f8b90126e3bf.zip
FreeBSD-src-1e7fe9f955a3d9d24a8f7545a033f8b90126e3bf.tar.gz
The interface index space may be sparsely populated (e.g. when an
interface in the middle is if_detach()'d). Return (and handle) ENOENT when the ifmib(4) is accessed for a nonexistent interface. MFC after: 14 days
Diffstat (limited to 'tools/tools/ifinfo')
-rw-r--r--tools/tools/ifinfo/ifinfo.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/tools/ifinfo/ifinfo.c b/tools/tools/ifinfo/ifinfo.c
index 8e462dd..54ca164 100644
--- a/tools/tools/ifinfo/ifinfo.c
+++ b/tools/tools/ifinfo/ifinfo.c
@@ -34,6 +34,7 @@
#include <sys/time.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -99,9 +100,13 @@ main(int argc, char **argv)
name[3] = IFMIB_IFDATA;
name[4] = i;
name[5] = IFDATA_GENERAL;
- if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0)
+ if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0) {
+ if (errno == ENOENT)
+ continue;
+
err(EX_OSERR, "sysctl(net.link.ifdata.%d.general)",
i);
+ }
if (!isit(argc - optind, argv + optind, ifmd.ifmd_name))
continue;
OpenPOWER on IntegriCloud