diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-05-09 05:19:15 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-05-09 05:19:15 +0000 |
commit | 02db58fa9d0c3680d164ba2017cdba712d977365 (patch) | |
tree | a94df6006f7d3f9695e84fe8fa904d458f55654c /sbin/dhclient/dispatch.c | |
parent | d79fe0902bd789511d7ab7d040d668007459034f (diff) |
- don't give up when the link is not available on startup: dhclient
goes to background and listens on the routing socket for link to come
up before it retries.
- renew the lease whenever the link was lost and becomes active again.
- listen for link state changes on non-ethernet devices like wireless,
the link state becomes active when the wireless has been associated to
the AP and becomes active. this helps to automatically renew the lease
when the user is roaming.
ok beck@, deraadt@
Diffstat (limited to 'sbin/dhclient/dispatch.c')
-rw-r--r-- | sbin/dhclient/dispatch.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index f02aabead3c..182c08c81b9 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.40 2007/11/12 10:14:40 dlg Exp $ */ +/* $OpenBSD: dispatch.c,v 1.41 2008/05/09 05:19:14 reyk Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -133,6 +133,9 @@ dispatch(void) * a timeout registered, time out the select call then. */ another: + if (!ifi->linkstat) + interfaces_invalidated = 0; + if (timeouts) { struct timeout *t; @@ -181,7 +184,8 @@ another: } if ((fds[0].revents & (POLLIN | POLLHUP))) { - if (ifi && ifi->rfdesc != -1) + if (ifi->linkstat && + ifi && ifi->rfdesc != -1) got_one(); } if ((fds[1].revents & (POLLIN | POLLHUP))) { @@ -321,16 +325,10 @@ interface_status(void) goto active; } if (ifmr.ifm_status & IFM_AVALID) { - switch (ifmr.ifm_active & IFM_NMASK) { - case IFM_ETHER: - if (ifmr.ifm_status & IFM_ACTIVE) - goto active; - else - goto inactive; - break; - default: + if (ifmr.ifm_status & IFM_ACTIVE) + goto active; + else goto inactive; - } } inactive: return (0); @@ -442,12 +440,10 @@ interface_link_status(char *ifname) close(sock); if (ifmr.ifm_status & IFM_AVALID) { - if ((ifmr.ifm_active & IFM_NMASK) == IFM_ETHER) { - if (ifmr.ifm_status & IFM_ACTIVE) - return (1); - else - return (0); - } + if (ifmr.ifm_status & IFM_ACTIVE) + return (1); + else + return (0); } return (1); } |