summaryrefslogtreecommitdiffstats
path: root/ipv4ll.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-15 15:23:46 +0000
committerRoy Marples <roy@marples.name>2008-09-15 15:23:46 +0000
commita2a9a498da4327ecf2fdec8560bb9a3557490fa9 (patch)
tree5d89cf7c1883f60b5151b188f9220e070e910efe /ipv4ll.c
parent78c8e969a552d0076faab4065ed627e5f14cb814 (diff)
downloaddhcpcd-a2a9a498da4327ecf2fdec8560bb9a3557490fa9.tar.xz
Reboot off the last lease and use the last lease if not expired and user has asked for it. Also, add a reboot timeout toggle (default 10 seconds).
Diffstat (limited to 'ipv4ll.c')
-rw-r--r--ipv4ll.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/ipv4ll.c b/ipv4ll.c
index 0ae91005..fcd690e2 100644
--- a/ipv4ll.c
+++ b/ipv4ll.c
@@ -87,11 +87,16 @@ start_ipv4ll(void *arg)
}
}
- syslog(LOG_INFO, "%s: probing for an IPv4LL address", iface->name);
- delete_timeout(NULL, iface);
- iface->state->state = DHS_PROBING;
- free(iface->state->offer);
- iface->state->offer = make_ipv4ll_lease(0);
+ /* We maybe rebooting of an IPv4LL address. */
+ if (!iface->state->offer ||
+ !IN_LINKLOCAL(htonl(iface->state->offer->yiaddr)))
+ {
+ syslog(LOG_INFO, "%s: probing for an IPv4LL address", iface->name);
+ delete_timeout(NULL, iface);
+ free(iface->state->offer);
+ iface->state->offer = make_ipv4ll_lease(0);
+ iface->state->lease.frominfo = 0;
+ }
send_arp_probe(iface);
}
@@ -102,26 +107,25 @@ handle_ipv4ll_failure(void *arg)
time_t up;
if (iface->state->fail.s_addr == iface->state->lease.addr.s_addr) {
- if (iface->state->state == DHS_PROBING)
+ up = uptime();
+ if (iface->state->defend + DEFEND_INTERVAL > up) {
drop_config(iface, "EXPIRE");
- else {
- up = uptime();
- if (iface->state->defend + DEFEND_INTERVAL > up) {
- drop_config(iface, "EXPIRE");
- iface->state->conflicts = -1;
- } else {
- iface->state->defend = up;
- return;
- }
+ iface->state->conflicts = -1;
+ } else {
+ iface->state->defend = up;
+ return;
}
}
close_sockets(iface);
+ free(iface->state->offer);
+ iface->state->offer = NULL;
if (++iface->state->conflicts > MAX_CONFLICTS) {
syslog(LOG_ERR, "%s: failed to acquire an IPv4LL address",
iface->name);
iface->state->interval = RATE_LIMIT_INTERVAL / 2;
start_discover(iface);
- } else
+ } else {
add_timeout_sec(PROBE_WAIT, start_ipv4ll, iface);
+ }
}