From 1e7fe9f955a3d9d24a8f7545a033f8b90126e3bf Mon Sep 17 00:00:00 2001 From: fenner Date: Wed, 17 Oct 2001 04:12:29 +0000 Subject: 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 --- tools/tools/ifinfo/ifinfo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') 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 #include +#include #include #include #include @@ -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; -- cgit v1.1