From 461a00bbdee50a46ba7fcfb3f9f2847d3bda5ad3 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Mon, 7 Feb 2000 18:39:20 +0000 Subject: [PATCH] ignore any ioctl() errors that may occur during interface iteration (after reporting them); in particular, do not INSIST() that no such errors occur. Clarify the way this works by using the new ISC_R_IGNORE result code. --- lib/isc/unix/ifiter_ioctl.c | 14 +++++++------- lib/isc/unix/ifiter_sysctl.c | 10 +++++----- lib/isc/unix/interfaceiter.c | 12 ++++-------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index a51826c534..dbbe5ec0f5 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -175,9 +175,9 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) /* * Get information about the current interface to iter->current. * If successful, return ISC_R_SUCCESS. - * If the interface has an unsupported address family, - * return ISC_R_FAILURE. In case of other failure, - * return ISC_R_UNEXPECTED. + * If the interface has an unsupported address family, or if + * some operation on it fails, return ISC_R_IGNORE to make + * the higher-level iterator code ignore it. */ static isc_result_t @@ -196,7 +196,7 @@ internal_current(isc_interfaceiter_t *iter) { family = lifreq.lifr_addr.ss_family; if (family != AF_INET && family != AF_INET6) - return (ISC_R_FAILURE); + return (ISC_R_IGNORE); memset(&iter->current, 0, sizeof(iter->current)); iter->current.af = family; @@ -216,7 +216,7 @@ internal_current(isc_interfaceiter_t *iter) { "%s: getting interface flags: %s", lifreq.lifr_name, strerror(errno)); - return (ISC_R_UNEXPECTED); + return (ISC_R_IGNORE); } if ((lifreq.lifr_flags & IFF_UP) != 0) @@ -235,7 +235,7 @@ internal_current(isc_interfaceiter_t *iter) { "%s: getting destination address: %s", lifreq.lifr_name, strerror(errno)); - return (ISC_R_UNEXPECTED); + return (ISC_R_IGNORE); } get_addr(family, &iter->current.dstaddress, (struct sockaddr *)&lifreq.lifr_dstaddr); @@ -251,7 +251,7 @@ internal_current(isc_interfaceiter_t *iter) { "%s: getting netmask: %s", lifreq.lifr_name, strerror(errno)); - return (ISC_R_UNEXPECTED); + return (ISC_R_IGNORE); } get_addr(family, &iter->current.netmask, (struct sockaddr *)&lifreq.lifr_addr); diff --git a/lib/isc/unix/ifiter_sysctl.c b/lib/isc/unix/ifiter_sysctl.c index b4248967e3..aba22db69d 100644 --- a/lib/isc/unix/ifiter_sysctl.c +++ b/lib/isc/unix/ifiter_sysctl.c @@ -129,7 +129,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) * Get information about the current interface to iter->current. * If successful, return ISC_R_SUCCESS. * If the interface has an unsupported address family, - * return ISC_R_FAILURE. In case of other failure, + * return ISC_R_IGNORE. In case of other failure, * return ISC_R_UNEXPECTED. */ @@ -171,7 +171,7 @@ internal_current(isc_interfaceiter_t *iter) { * This is not an interface address. * Force another iteration. */ - return (ISC_R_FAILURE); + return (ISC_R_IGNORE); } else if (ifam->ifam_type == RTM_NEWADDR) { int i; int family; @@ -217,11 +217,11 @@ internal_current(isc_interfaceiter_t *iter) { } if (addr_sa == NULL) - return (ISC_R_FAILURE); + return (ISC_R_IGNORE); family = addr_sa->sa_family; if (family != AF_INET) /* XXX IP6 */ - return (ISC_R_FAILURE); + return (ISC_R_IGNORE); iter->current.af = family; @@ -237,7 +237,7 @@ internal_current(isc_interfaceiter_t *iter) { return (ISC_R_SUCCESS); } else { printf("warning: unexpected interface list message type\n"); - return (ISC_R_FAILURE); + return (ISC_R_IGNORE); } } diff --git a/lib/isc/unix/interfaceiter.c b/lib/isc/unix/interfaceiter.c index d5e2d5b108..9714cd04de 100644 --- a/lib/isc/unix/interfaceiter.c +++ b/lib/isc/unix/interfaceiter.c @@ -102,13 +102,11 @@ isc_interfaceiter_first(isc_interfaceiter_t *iter) { iter->pos = 0; for (;;) { result = internal_current(iter); - if (result == ISC_R_SUCCESS) + if (result != ISC_R_IGNORE) break; - INSIST(result == ISC_R_FAILURE); result = internal_next(iter); - if (result == ISC_R_NOMORE) + if (result != ISC_R_SUCCESS) break; - INSIST(result == ISC_R_SUCCESS); } iter->result = result; return (result); @@ -123,13 +121,11 @@ isc_interfaceiter_next(isc_interfaceiter_t *iter) { for (;;) { result = internal_next(iter); - if (result == ISC_R_NOMORE) + if (result != ISC_R_SUCCESS) break; - INSIST(result == ISC_R_SUCCESS); result = internal_current(iter); - if (result == ISC_R_SUCCESS) + if (result != ISC_R_IGNORE) break; - INSIST(result == ISC_R_FAILURE); } iter->result = result; return (result);