2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 00:25:29 +00:00

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.
This commit is contained in:
Andreas Gustafsson
2000-02-07 18:39:20 +00:00
parent 3a2487c9e3
commit 461a00bbde
3 changed files with 16 additions and 20 deletions

View File

@@ -175,9 +175,9 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp)
/* /*
* Get information about the current interface to iter->current. * Get information about the current interface to iter->current.
* If successful, return ISC_R_SUCCESS. * If successful, return ISC_R_SUCCESS.
* If the interface has an unsupported address family, * If the interface has an unsupported address family, or if
* return ISC_R_FAILURE. In case of other failure, * some operation on it fails, return ISC_R_IGNORE to make
* return ISC_R_UNEXPECTED. * the higher-level iterator code ignore it.
*/ */
static isc_result_t static isc_result_t
@@ -196,7 +196,7 @@ internal_current(isc_interfaceiter_t *iter) {
family = lifreq.lifr_addr.ss_family; family = lifreq.lifr_addr.ss_family;
if (family != AF_INET && family != AF_INET6) if (family != AF_INET && family != AF_INET6)
return (ISC_R_FAILURE); return (ISC_R_IGNORE);
memset(&iter->current, 0, sizeof(iter->current)); memset(&iter->current, 0, sizeof(iter->current));
iter->current.af = family; iter->current.af = family;
@@ -216,7 +216,7 @@ internal_current(isc_interfaceiter_t *iter) {
"%s: getting interface flags: %s", "%s: getting interface flags: %s",
lifreq.lifr_name, lifreq.lifr_name,
strerror(errno)); strerror(errno));
return (ISC_R_UNEXPECTED); return (ISC_R_IGNORE);
} }
if ((lifreq.lifr_flags & IFF_UP) != 0) if ((lifreq.lifr_flags & IFF_UP) != 0)
@@ -235,7 +235,7 @@ internal_current(isc_interfaceiter_t *iter) {
"%s: getting destination address: %s", "%s: getting destination address: %s",
lifreq.lifr_name, lifreq.lifr_name,
strerror(errno)); strerror(errno));
return (ISC_R_UNEXPECTED); return (ISC_R_IGNORE);
} }
get_addr(family, &iter->current.dstaddress, get_addr(family, &iter->current.dstaddress,
(struct sockaddr *)&lifreq.lifr_dstaddr); (struct sockaddr *)&lifreq.lifr_dstaddr);
@@ -251,7 +251,7 @@ internal_current(isc_interfaceiter_t *iter) {
"%s: getting netmask: %s", "%s: getting netmask: %s",
lifreq.lifr_name, lifreq.lifr_name,
strerror(errno)); strerror(errno));
return (ISC_R_UNEXPECTED); return (ISC_R_IGNORE);
} }
get_addr(family, &iter->current.netmask, get_addr(family, &iter->current.netmask,
(struct sockaddr *)&lifreq.lifr_addr); (struct sockaddr *)&lifreq.lifr_addr);

View File

@@ -129,7 +129,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp)
* Get information about the current interface to iter->current. * Get information about the current interface to iter->current.
* If successful, return ISC_R_SUCCESS. * If successful, return ISC_R_SUCCESS.
* If the interface has an unsupported address family, * 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. * return ISC_R_UNEXPECTED.
*/ */
@@ -171,7 +171,7 @@ internal_current(isc_interfaceiter_t *iter) {
* This is not an interface address. * This is not an interface address.
* Force another iteration. * Force another iteration.
*/ */
return (ISC_R_FAILURE); return (ISC_R_IGNORE);
} else if (ifam->ifam_type == RTM_NEWADDR) { } else if (ifam->ifam_type == RTM_NEWADDR) {
int i; int i;
int family; int family;
@@ -217,11 +217,11 @@ internal_current(isc_interfaceiter_t *iter) {
} }
if (addr_sa == NULL) if (addr_sa == NULL)
return (ISC_R_FAILURE); return (ISC_R_IGNORE);
family = addr_sa->sa_family; family = addr_sa->sa_family;
if (family != AF_INET) /* XXX IP6 */ if (family != AF_INET) /* XXX IP6 */
return (ISC_R_FAILURE); return (ISC_R_IGNORE);
iter->current.af = family; iter->current.af = family;
@@ -237,7 +237,7 @@ internal_current(isc_interfaceiter_t *iter) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} else { } else {
printf("warning: unexpected interface list message type\n"); printf("warning: unexpected interface list message type\n");
return (ISC_R_FAILURE); return (ISC_R_IGNORE);
} }
} }

View File

@@ -102,13 +102,11 @@ isc_interfaceiter_first(isc_interfaceiter_t *iter) {
iter->pos = 0; iter->pos = 0;
for (;;) { for (;;) {
result = internal_current(iter); result = internal_current(iter);
if (result == ISC_R_SUCCESS) if (result != ISC_R_IGNORE)
break; break;
INSIST(result == ISC_R_FAILURE);
result = internal_next(iter); result = internal_next(iter);
if (result == ISC_R_NOMORE) if (result != ISC_R_SUCCESS)
break; break;
INSIST(result == ISC_R_SUCCESS);
} }
iter->result = result; iter->result = result;
return (result); return (result);
@@ -123,13 +121,11 @@ isc_interfaceiter_next(isc_interfaceiter_t *iter) {
for (;;) { for (;;) {
result = internal_next(iter); result = internal_next(iter);
if (result == ISC_R_NOMORE) if (result != ISC_R_SUCCESS)
break; break;
INSIST(result == ISC_R_SUCCESS);
result = internal_current(iter); result = internal_current(iter);
if (result == ISC_R_SUCCESS) if (result != ISC_R_IGNORE)
break; break;
INSIST(result == ISC_R_FAILURE);
} }
iter->result = result; iter->result = result;
return (result); return (result);