diff options
author | 2017-08-26 18:52:56 +0000 | |
---|---|---|
committer | 2017-08-26 18:52:56 +0000 | |
commit | 69848eff6a84b047aa45d9ddf3c662630e61badc (patch) | |
tree | bcdf881c147e511e825ca9b6745141d0ebc20211 | |
parent | bug fix (diff) | |
download | wireguard-openbsd-69848eff6a84b047aa45d9ddf3c662630e61badc.tar.xz wireguard-openbsd-69848eff6a84b047aa45d9ddf3c662630e61badc.zip |
Since we no longer try to uniquely label routes added
by dhclients, there is no need to retry adding a route
if the first attempt fails with EEXIST. And EUNREACHABLE
should be considered final since the address if any is
already configured.
Use log_getverbose() to allow logging of EEXIST errors.
-rw-r--r-- | sbin/dhclient/kroute.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index b4eb806ecb0..4af542eedcf 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.141 2017/08/26 15:36:25 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.142 2017/08/26 18:52:56 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -285,7 +285,7 @@ priv_add_route(char *name, int rdomain, int routefd, struct iovec iov[5]; struct rt_msghdr rtm; struct sockaddr_in dest, gateway, mask; - int i, index, iovcnt = 0; + int index, iovcnt = 0; index = if_nametoindex(name); if (index == 0) @@ -337,19 +337,15 @@ priv_add_route(char *name, int rdomain, int routefd, iov[iovcnt].iov_base = &mask; iov[iovcnt++].iov_len = sizeof(mask); - /* Check for EEXIST since other dhclient may not be done. */ - for (i = 0; i < 5; i++) { - if (writev(routefd, iov, iovcnt) != -1) - break; - if (i == 4) { + if (writev(routefd, iov, iovcnt) == -1) { + if (errno != EEXIST || log_getverbose() != 0) { strlcpy(destbuf, inet_ntoa(imsg->dest), sizeof(destbuf)); strlcpy(maskbuf, inet_ntoa(imsg->netmask), sizeof(maskbuf)); log_warn("failed to add route (%s/%s via %s)", destbuf, maskbuf, inet_ntoa(imsg->gateway)); - } else if (errno == EEXIST || errno == ENETUNREACH) - sleep(1); + } } } |