diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 6e567790640..284e1c355e3 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -321,6 +321,11 @@ int arp_send(in_addr_t ipaddr) * sending the ARP request if it is not. */ + /* The optimal delay would be the work case round trip time. */ + + delay.tv_sec = CONFIG_ARP_SEND_DELAYSEC; + delay.tv_nsec = CONFIG_ARP_SEND_DELAYNSEC; + ret = -ETIMEDOUT; /* Assume a timeout failure */ while (state.snd_retries < CONFIG_ARP_SEND_MAXTRIES) @@ -377,13 +382,7 @@ int arp_send(in_addr_t ipaddr) break; } - /* Now wait for response to the ARP response to be received. The - * optimal delay would be the work case round trip time. - * NOTE: The network is locked. - */ - - delay.tv_sec = CONFIG_ARP_SEND_DELAYSEC; - delay.tv_nsec = CONFIG_ARP_SEND_DELAYNSEC; + /* Now wait for response to the ARP response to be received. */ ret = arp_wait(¬ify, &delay); @@ -398,9 +397,10 @@ int arp_send(in_addr_t ipaddr) break; } - /* Increment the retry count */ + /* Increment the retry count and double the delay time */ state.snd_retries++; + clock_timespec_add(&delay, &delay, &delay); nerr("ERROR: arp_wait failed: %d\n", ret); } diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c index 254a4da5b9b..b9c89fb4b27 100644 --- a/net/icmpv6/icmpv6_autoconfig.c +++ b/net/icmpv6/icmpv6_autoconfig.c @@ -259,49 +259,6 @@ errout_with_semaphore: return ret; } -/**************************************************************************** - * Name: icmpv6_wait_radvertise - * - * Description: - * Wait for the receipt of the Router Advertisement matching the Router - * Solicitation that we just sent. - * - * Input Parameters: - * dev - The device to use to send the solicitation - * notify - The pre-initialized notification structure - * - * Returned Value: - * Zero (OK) is returned on success; On error a negated errno value is - * returned. - * - * Assumptions: - * The network is locked. - * - ****************************************************************************/ - -static int icmpv6_wait_radvertise(FAR struct net_driver_s *dev, - FAR struct icmpv6_rnotify_s *notify) -{ - struct timespec delay; - int ret; - - /* Wait for response to the Router Advertisement to be received. The - * optimal delay would be the work case round trip time. - * NOTE: The network is locked. - */ - - delay.tv_sec = CONFIG_ICMPv6_AUTOCONF_DELAYSEC; - delay.tv_nsec = CONFIG_ICMPv6_AUTOCONF_DELAYNSEC; - - ret = icmpv6_rwait(notify, &delay); - - /* icmpv6_wait will return OK if and only if the matching Router - * Advertisement is received. Otherwise, it will return -ETIMEDOUT. - */ - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -333,6 +290,7 @@ static int icmpv6_wait_radvertise(FAR struct net_driver_s *dev, int icmpv6_autoconfig(FAR struct net_driver_s *dev) { struct icmpv6_rnotify_s notify; + struct timespec delay; net_ipv6addr_t lladdr; int retries; int ret; @@ -419,6 +377,11 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) netdev_ifup(dev); + /* The optimal delay would be the work case round trip time. */ + + delay.tv_sec = CONFIG_ICMPv6_AUTOCONF_DELAYSEC; + delay.tv_nsec = CONFIG_ICMPv6_AUTOCONF_DELAYNSEC; + /* 4. Router Contact: The node next attempts to contact a local router for * more information on continuing the configuration. This is done either * by listening for Router Advertisement messages sent periodically by @@ -445,7 +408,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) /* Wait to receive the Router Advertisement message */ - ret = icmpv6_wait_radvertise(dev, ¬ify); + ret = icmpv6_rwait(¬ify, &delay); if (ret != -ETIMEDOUT) { /* ETIMEDOUT is the only expected failure. We will retry on that @@ -455,6 +418,9 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) break; } + /* Double the delay time for the next loop */ + + clock_timespec_add(&delay, &delay, &delay); ninfo("Timed out... retrying %d\n", retries + 1); } diff --git a/net/icmpv6/icmpv6_neighbor.c b/net/icmpv6/icmpv6_neighbor.c index bf24de82e0e..2b07e8e536a 100644 --- a/net/icmpv6/icmpv6_neighbor.c +++ b/net/icmpv6/icmpv6_neighbor.c @@ -295,6 +295,11 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) * re-sending the Neighbor Solicitation if it is not. */ + /* The optimal delay would be the work case round trip time. */ + + delay.tv_sec = CONFIG_ICMPv6_NEIGHBOR_DELAYSEC; + delay.tv_nsec = CONFIG_ICMPv6_NEIGHBOR_DELAYNSEC; + ret = -ETIMEDOUT; /* Assume a timeout failure */ while (state.snd_retries < CONFIG_ICMPv6_NEIGHBOR_MAXTRIES) @@ -341,13 +346,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) } while (!state.snd_sent); - /* Now wait for response to the Neighbor Advertisement to be received. - * The optimal delay would be the work case round trip time. - * NOTE: The network is locked. - */ - - delay.tv_sec = CONFIG_ICMPv6_NEIGHBOR_DELAYSEC; - delay.tv_nsec = CONFIG_ICMPv6_NEIGHBOR_DELAYNSEC; + /* Now wait for response to the Neighbor Advertisement to be received. */ ret = icmpv6_wait(¬ify, &delay); @@ -360,8 +359,9 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) break; } - /* Increment the retry count */ + /* Increment the retry count and double the delay time */ + clock_timespec_add(&delay, &delay, &delay); state.snd_retries++; }