summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-11-25 17:03:03 +0000
committerkrw <krw@openbsd.org>2014-11-25 17:03:03 +0000
commit98de8786ce32a37c9ef8ac1b216784e47b2f5278 (patch)
tree20ae0ff1f9c258708765c01af8b30d913b4d6193
parentMove guts of setbuf.3 into setvbuf.3 to make it clear which one (diff)
downloadwireguard-openbsd-98de8786ce32a37c9ef8ac1b216784e47b2f5278.tar.xz
wireguard-openbsd-98de8786ce32a37c9ef8ac1b216784e47b2f5278.zip
r1.118 starting using LINK_STATE_IS_UP() to check the link status
info provided in RTM_IFINFO messages. But it didn't replicate the checks for IFI_NOMEDIA and (IFF_UP | IFF_RUNNING) used in interface_status() to set ifi->linkstat. So the test (LINK_STATE_IS_UP() != ifi->linkstat) was comparing kiwi fruit and hairballs. Do the additional checks using info present in the RTM_IFINFO message. As a result interface_status() need not be called to update ifi->linkstat. Thus avoiding opening/closing a socket and some ioctls to re-obtain the info already provided in the RTM_IFINFO message. Using RTM_IFINFO data ok mpi@
-rw-r--r--sbin/dhclient/dhclient.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 8fc644324f3..73ccaad4dfc 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.334 2014/11/23 18:22:45 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.335 2014/11/25 17:03:03 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -337,13 +337,17 @@ routehandler(void)
linkstat =
LINK_STATE_IS_UP(ifm->ifm_data.ifi_link_state) ? 1 : 0;
+ linkstat = linkstat || (ifi->flags & IFI_NOMEDIA);
+ linkstat = linkstat &&
+ ((ifm->ifm_flags & (IFF_UP | IFF_RUNNING)) ==
+ (IFF_UP | IFF_RUNNING));
if (linkstat != ifi->linkstat) {
#ifdef DEBUG
debug("link state %s -> %s",
ifi->linkstat ? "up" : "down",
linkstat ? "up" : "down");
#endif
- ifi->linkstat = interface_status(ifi->name);
+ ifi->linkstat = linkstat;
if (ifi->linkstat) {
client->state = S_REBOOTING;
state_reboot();