From 5ab40f016d560705efb150b492de1bc6810606c2 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 14 Jun 2010 20:27:14 +0000 Subject: [PATCH] Fixed bug #30039: AutoIP does not reuse previous addresses --- CHANGELOG | 3 +++ src/core/ipv4/autoip.c | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c0890387..d109c76a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -220,6 +220,9 @@ HISTORY ++ Bugfixes: + 2010-06-14: Simon Goldschmidt + * autoip.c: Fixed bug #30039: AutoIP does not reuse previous addresses + 2010-06-12: Simon Goldschmidt * dhcp.c: Fixed bug #30038: dhcp_network_changed doesn't reset AUTOIP coop state diff --git a/src/core/ipv4/autoip.c b/src/core/ipv4/autoip.c index 33a5fa20..f5fbe34e 100644 --- a/src/core/ipv4/autoip.c +++ b/src/core/ipv4/autoip.c @@ -150,6 +150,17 @@ autoip_set_struct(struct netif *netif, struct autoip *autoip) netif->autoip = autoip; } +/** Restart AutoIP client and check the next address (conflict detected) + * + * @param netif The netif under AutoIP control + */ +static void +autoip_restart(struct netif *netif) +{ + netif->autoip->tried_llipaddr++; + autoip_start(netif); +} + /** * Handle a IP address conflict after an ARP conflict detection */ @@ -168,7 +179,7 @@ autoip_handle_arp_conflict(struct netif *netif) ("autoip_handle_arp_conflict(): we are defending, but in DEFEND_INTERVAL, retreating\n")); /* TODO: close all TCP sessions */ - autoip_start(netif); + autoip_restart(netif); } else { LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("autoip_handle_arp_conflict(): we are defend, send ARP Announce\n")); @@ -179,7 +190,7 @@ autoip_handle_arp_conflict(struct netif *netif) LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("autoip_handle_arp_conflict(): we do not defend, retreating\n")); /* TODO: close all TCP sessions */ - autoip_start(netif); + autoip_restart(netif); } } @@ -321,7 +332,6 @@ autoip_start(struct netif *netif) } autoip_create_addr(netif, &(autoip->llipaddr)); - autoip->tried_llipaddr++; autoip_start_probing(netif); return result; @@ -511,7 +521,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) !eth_addr_cmp(&netifaddr, &hdr->shwaddr))) { LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | LWIP_DBG_LEVEL_WARNING, ("autoip_arp_reply(): Probe Conflict detected\n")); - autoip_start(netif); + autoip_restart(netif); } } else { /* RFC 3927 Section 2.5: