From: Roy Marples Date: Wed, 12 May 2010 16:20:55 +0000 (+0000) Subject: Fix IPv4LL defending and add a bit more logging. X-Git-Tag: v5.2.3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3870b2ccc7b4845d5128eb20127fd5723f7481e;p=thirdparty%2Fdhcpcd.git Fix IPv4LL defending and add a bit more logging. --- diff --git a/arp.c b/arp.c index e6a2928e..89d63fe8 100644 --- a/arp.c +++ b/arp.c @@ -78,10 +78,18 @@ send_arp(const struct interface *iface, int op, in_addr_t sip, in_addr_t tip) static void handle_arp_failure(struct interface *iface) { - if (iface->state->offer->cookie != htonl(MAGIC_COOKIE)) { + + /* If we failed without a magic cookie then we need to try + * and defend our IPv4LL address. */ + if ((iface->state->offer != NULL && + iface->state->offer->cookie != htonl(MAGIC_COOKIE)) || + (iface->state->new != NULL && + iface->state->new->cookie != htonl(MAGIC_COOKIE))) + { handle_ipv4ll_failure(iface); return; } + unlink(iface->leasefile); if (!iface->state->lease.frominfo) send_decline(iface); diff --git a/ipv4ll.c b/ipv4ll.c index 7a8e585d..3d365b36 100644 --- a/ipv4ll.c +++ b/ipv4ll.c @@ -125,12 +125,17 @@ handle_ipv4ll_failure(void *arg) struct interface *iface = arg; time_t up; - if (iface->state->fail.s_addr == iface->state->lease.addr.s_addr) { + if (iface->state->fail.s_addr == iface->addr.s_addr) { up = uptime(); if (iface->state->defend + DEFEND_INTERVAL > up) { + syslog(LOG_DEBUG, + "%s: IPv4LL %d second defence failed", + iface->name, DEFEND_INTERVAL); drop_config(iface, "EXPIRE"); iface->state->conflicts = -1; } else { + syslog(LOG_DEBUG, "%s: defended IPv4LL address", + iface->name); iface->state->defend = up; return; }