Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * RFC3927 ZeroConf IPv4 Link-Local addressing |
| 3 | * (see <http://www.zeroconf.org/>) |
| 4 | * |
| 5 | * Copied from BusyBox - networking/zcip.c |
| 6 | * |
| 7 | * Copyright (C) 2003 by Arthur van Hoff (avh@strangeberry.com) |
| 8 | * Copyright (C) 2004 by David Brownell |
| 9 | * Copyright (C) 2010 by Joe Hershberger |
| 10 | * |
| 11 | * Licensed under the GPL v2 or later |
| 12 | */ |
| 13 | |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 14 | #include <env.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 15 | #include <log.h> |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 16 | #include <net.h> |
Simon Glass | ecd1f81 | 2019-11-14 12:57:13 -0700 | [diff] [blame] | 17 | #include <rand.h> |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 18 | #include "arp.h" |
| 19 | #include "net_rand.h" |
| 20 | |
| 21 | /* We don't need more than 32 bits of the counter */ |
| 22 | #define MONOTONIC_MS() ((unsigned)get_timer(0) * (1000 / CONFIG_SYS_HZ)) |
| 23 | |
| 24 | enum { |
| 25 | /* 169.254.0.0 */ |
| 26 | LINKLOCAL_ADDR = 0xa9fe0000, |
| 27 | |
| 28 | IN_CLASSB_NET = 0xffff0000, |
| 29 | IN_CLASSB_HOST = 0x0000ffff, |
| 30 | |
| 31 | /* protocol timeout parameters, specified in seconds */ |
| 32 | PROBE_WAIT = 1, |
| 33 | PROBE_MIN = 1, |
| 34 | PROBE_MAX = 2, |
| 35 | PROBE_NUM = 3, |
| 36 | MAX_CONFLICTS = 10, |
| 37 | RATE_LIMIT_INTERVAL = 60, |
| 38 | ANNOUNCE_WAIT = 2, |
| 39 | ANNOUNCE_NUM = 2, |
| 40 | ANNOUNCE_INTERVAL = 2, |
| 41 | DEFEND_INTERVAL = 10 |
| 42 | }; |
| 43 | |
| 44 | /* States during the configuration process. */ |
| 45 | static enum ll_state_t { |
| 46 | PROBE = 0, |
| 47 | RATE_LIMIT_PROBE, |
| 48 | ANNOUNCE, |
| 49 | MONITOR, |
| 50 | DEFEND, |
| 51 | DISABLED |
| 52 | } state = DISABLED; |
| 53 | |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 54 | static struct in_addr ip; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 55 | static int timeout_ms = -1; |
| 56 | static unsigned deadline_ms; |
| 57 | static unsigned conflicts; |
| 58 | static unsigned nprobes; |
| 59 | static unsigned nclaims; |
| 60 | static int ready; |
Michael Walle | b90b97a | 2012-06-05 11:33:15 +0000 | [diff] [blame] | 61 | static unsigned int seed; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 62 | |
| 63 | static void link_local_timeout(void); |
| 64 | |
| 65 | /** |
| 66 | * Pick a random link local IP address on 169.254/16, except that |
| 67 | * the first and last 256 addresses are reserved. |
| 68 | */ |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 69 | static struct in_addr pick(void) |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 70 | { |
| 71 | unsigned tmp; |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 72 | struct in_addr ip; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 73 | |
| 74 | do { |
Michael Walle | b90b97a | 2012-06-05 11:33:15 +0000 | [diff] [blame] | 75 | tmp = rand_r(&seed) & IN_CLASSB_HOST; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 76 | } while (tmp > (IN_CLASSB_HOST - 0x0200)); |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 77 | ip.s_addr = htonl((LINKLOCAL_ADDR + 0x0100) + tmp); |
| 78 | return ip; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Return milliseconds of random delay, up to "secs" seconds. |
| 83 | */ |
| 84 | static inline unsigned random_delay_ms(unsigned secs) |
| 85 | { |
Michael Walle | b90b97a | 2012-06-05 11:33:15 +0000 | [diff] [blame] | 86 | return rand_r(&seed) % (secs * 1000); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static void configure_wait(void) |
| 90 | { |
| 91 | if (timeout_ms == -1) |
| 92 | return; |
| 93 | |
| 94 | /* poll, being ready to adjust current timeout */ |
| 95 | if (!timeout_ms) |
| 96 | timeout_ms = random_delay_ms(PROBE_WAIT); |
| 97 | |
| 98 | /* set deadline_ms to the point in time when we timeout */ |
| 99 | deadline_ms = MONOTONIC_MS() + timeout_ms; |
| 100 | |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 101 | debug_cond(DEBUG_DEV_PKT, "...wait %d %s nprobes=%u, nclaims=%u\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 102 | timeout_ms, eth_get_name(), nprobes, nclaims); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 103 | |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 104 | net_set_timeout_handler(timeout_ms, link_local_timeout); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void link_local_start(void) |
| 108 | { |
Simon Glass | da1a134 | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 109 | ip = env_get_ip("llipaddr"); |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 110 | if (ip.s_addr != 0 && |
| 111 | (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) { |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 112 | puts("invalid link address"); |
| 113 | net_set_state(NETLOOP_FAIL); |
| 114 | return; |
| 115 | } |
Alexandre Messier | d26427f | 2017-03-14 15:03:31 -0400 | [diff] [blame] | 116 | net_netmask.s_addr = htonl(IN_CLASSB_NET); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 117 | |
Michael Walle | b90b97a | 2012-06-05 11:33:15 +0000 | [diff] [blame] | 118 | seed = seed_mac(); |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 119 | if (ip.s_addr == 0) |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 120 | ip = pick(); |
| 121 | |
| 122 | state = PROBE; |
| 123 | timeout_ms = 0; |
| 124 | conflicts = 0; |
| 125 | nprobes = 0; |
| 126 | nclaims = 0; |
| 127 | ready = 0; |
| 128 | |
| 129 | configure_wait(); |
| 130 | } |
| 131 | |
| 132 | static void link_local_timeout(void) |
| 133 | { |
| 134 | switch (state) { |
| 135 | case PROBE: |
| 136 | /* timeouts in the PROBE state mean no conflicting ARP packets |
| 137 | have been received, so we can progress through the states */ |
| 138 | if (nprobes < PROBE_NUM) { |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 139 | struct in_addr zero_ip = {.s_addr = 0}; |
| 140 | |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 141 | nprobes++; |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 142 | debug_cond(DEBUG_LL_STATE, "probe/%u %s@%pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 143 | nprobes, eth_get_name(), &ip); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 144 | arp_raw_request(zero_ip, net_null_ethaddr, ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 145 | timeout_ms = PROBE_MIN * 1000; |
| 146 | timeout_ms += random_delay_ms(PROBE_MAX - PROBE_MIN); |
| 147 | } else { |
| 148 | /* Switch to announce state */ |
| 149 | state = ANNOUNCE; |
| 150 | nclaims = 0; |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 151 | debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 152 | nclaims, eth_get_name(), &ip); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 153 | arp_raw_request(ip, net_ethaddr, ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 154 | timeout_ms = ANNOUNCE_INTERVAL * 1000; |
| 155 | } |
| 156 | break; |
| 157 | case RATE_LIMIT_PROBE: |
| 158 | /* timeouts in the RATE_LIMIT_PROBE state mean no conflicting |
| 159 | ARP packets have been received, so we can move immediately |
| 160 | to the announce state */ |
| 161 | state = ANNOUNCE; |
| 162 | nclaims = 0; |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 163 | debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 164 | nclaims, eth_get_name(), &ip); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 165 | arp_raw_request(ip, net_ethaddr, ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 166 | timeout_ms = ANNOUNCE_INTERVAL * 1000; |
| 167 | break; |
| 168 | case ANNOUNCE: |
| 169 | /* timeouts in the ANNOUNCE state mean no conflicting ARP |
| 170 | packets have been received, so we can progress through |
| 171 | the states */ |
| 172 | if (nclaims < ANNOUNCE_NUM) { |
| 173 | nclaims++; |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 174 | debug_cond(DEBUG_LL_STATE, "announce/%u %s@%pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 175 | nclaims, eth_get_name(), &ip); |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 176 | arp_raw_request(ip, net_ethaddr, ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 177 | timeout_ms = ANNOUNCE_INTERVAL * 1000; |
| 178 | } else { |
| 179 | /* Switch to monitor state */ |
| 180 | state = MONITOR; |
| 181 | printf("Successfully assigned %pI4\n", &ip); |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 182 | net_copy_ip(&net_ip, &ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 183 | ready = 1; |
| 184 | conflicts = 0; |
| 185 | timeout_ms = -1; |
| 186 | /* Never timeout in the monitor state */ |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 187 | net_set_timeout_handler(0, NULL); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 188 | |
| 189 | /* NOTE: all other exit paths should deconfig ... */ |
| 190 | net_set_state(NETLOOP_SUCCESS); |
| 191 | return; |
| 192 | } |
| 193 | break; |
| 194 | case DEFEND: |
| 195 | /* We won! No ARP replies, so just go back to monitor */ |
| 196 | state = MONITOR; |
| 197 | timeout_ms = -1; |
| 198 | conflicts = 0; |
| 199 | break; |
| 200 | default: |
| 201 | /* Invalid, should never happen. Restart the whole protocol */ |
| 202 | state = PROBE; |
| 203 | ip = pick(); |
| 204 | timeout_ms = 0; |
| 205 | nprobes = 0; |
| 206 | nclaims = 0; |
| 207 | break; |
| 208 | } |
| 209 | configure_wait(); |
| 210 | } |
| 211 | |
| 212 | void link_local_receive_arp(struct arp_hdr *arp, int len) |
| 213 | { |
| 214 | int source_ip_conflict; |
| 215 | int target_ip_conflict; |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 216 | struct in_addr null_ip = {.s_addr = 0}; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 217 | |
| 218 | if (state == DISABLED) |
| 219 | return; |
| 220 | |
| 221 | /* We need to adjust the timeout in case we didn't receive a |
| 222 | conflicting packet. */ |
| 223 | if (timeout_ms > 0) { |
| 224 | unsigned diff = deadline_ms - MONOTONIC_MS(); |
| 225 | if ((int)(diff) < 0) { |
| 226 | /* Current time is greater than the expected timeout |
| 227 | time. This should never happen */ |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 228 | debug_cond(DEBUG_LL_STATE, |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 229 | "missed an expected timeout\n"); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 230 | timeout_ms = 0; |
| 231 | } else { |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 232 | debug_cond(DEBUG_INT_STATE, "adjusting timeout\n"); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 233 | timeout_ms = diff | 1; /* never 0 */ |
| 234 | } |
| 235 | } |
benoit.thebaudeau@advans | 4f2abfb | 2012-07-19 01:19:34 +0000 | [diff] [blame] | 236 | #if 0 |
| 237 | /* XXX Don't bother with ethernet link just yet */ |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 238 | if ((fds[0].revents & POLLIN) == 0) { |
| 239 | if (fds[0].revents & POLLERR) { |
Wolfgang Denk | 42a3f52 | 2012-07-10 09:18:33 +0200 | [diff] [blame] | 240 | /* |
| 241 | * FIXME: links routinely go down; |
| 242 | */ |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 243 | bb_error_msg("iface %s is down", eth_get_name()); |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 244 | if (ready) |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 245 | run(argv, "deconfig", &ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 246 | return EXIT_FAILURE; |
| 247 | } |
| 248 | continue; |
| 249 | } |
benoit.thebaudeau@advans | 4f2abfb | 2012-07-19 01:19:34 +0000 | [diff] [blame] | 250 | #endif |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 251 | |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 252 | debug_cond(DEBUG_INT_STATE, "%s recv arp type=%d, op=%d,\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 253 | eth_get_name(), ntohs(arp->ar_pro), |
| 254 | ntohs(arp->ar_op)); |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 255 | debug_cond(DEBUG_INT_STATE, "\tsource=%pM %pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 256 | &arp->ar_sha, |
| 257 | &arp->ar_spa); |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 258 | debug_cond(DEBUG_INT_STATE, "\ttarget=%pM %pI4\n", |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 259 | &arp->ar_tha, |
| 260 | &arp->ar_tpa); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 261 | |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 262 | if (arp->ar_op != htons(ARPOP_REQUEST) && |
| 263 | arp->ar_op != htons(ARPOP_REPLY)) { |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 264 | configure_wait(); |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | source_ip_conflict = 0; |
| 269 | target_ip_conflict = 0; |
| 270 | |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 271 | if (memcmp(&arp->ar_spa, &ip, ARP_PLEN) == 0 && |
| 272 | memcmp(&arp->ar_sha, net_ethaddr, ARP_HLEN) != 0) |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 273 | source_ip_conflict = 1; |
Joe Hershberger | 5fb50bf | 2013-02-08 14:18:53 -0600 | [diff] [blame] | 274 | |
| 275 | /* |
| 276 | * According to RFC 3927, section 2.2.1: |
| 277 | * Check if packet is an ARP probe by checking for a null source IP |
| 278 | * then check that target IP is equal to ours and source hw addr |
| 279 | * is not equal to ours. This condition should cause a conflict only |
| 280 | * during probe. |
| 281 | */ |
| 282 | if (arp->ar_op == htons(ARPOP_REQUEST) && |
| 283 | memcmp(&arp->ar_spa, &null_ip, ARP_PLEN) == 0 && |
| 284 | memcmp(&arp->ar_tpa, &ip, ARP_PLEN) == 0 && |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 285 | memcmp(&arp->ar_sha, net_ethaddr, ARP_HLEN) != 0) { |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 286 | target_ip_conflict = 1; |
| 287 | } |
| 288 | |
Joe Hershberger | 05a377b | 2012-05-23 08:01:04 +0000 | [diff] [blame] | 289 | debug_cond(DEBUG_NET_PKT, |
Joe Hershberger | c3e92a7 | 2015-04-08 01:41:18 -0500 | [diff] [blame] | 290 | "state = %d, source ip conflict = %d, target ip conflict = " |
| 291 | "%d\n", state, source_ip_conflict, target_ip_conflict); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 292 | switch (state) { |
| 293 | case PROBE: |
| 294 | case ANNOUNCE: |
| 295 | /* When probing or announcing, check for source IP conflicts |
| 296 | and other hosts doing ARP probes (target IP conflicts). */ |
| 297 | if (source_ip_conflict || target_ip_conflict) { |
| 298 | conflicts++; |
| 299 | state = PROBE; |
| 300 | if (conflicts >= MAX_CONFLICTS) { |
| 301 | debug("%s ratelimit\n", eth_get_name()); |
| 302 | timeout_ms = RATE_LIMIT_INTERVAL * 1000; |
| 303 | state = RATE_LIMIT_PROBE; |
| 304 | } |
| 305 | |
| 306 | /* restart the whole protocol */ |
| 307 | ip = pick(); |
| 308 | timeout_ms = 0; |
| 309 | nprobes = 0; |
| 310 | nclaims = 0; |
| 311 | } |
| 312 | break; |
| 313 | case MONITOR: |
| 314 | /* If a conflict, we try to defend with a single ARP probe */ |
| 315 | if (source_ip_conflict) { |
| 316 | debug("monitor conflict -- defending\n"); |
| 317 | state = DEFEND; |
| 318 | timeout_ms = DEFEND_INTERVAL * 1000; |
Joe Hershberger | 8ecdbed | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 319 | arp_raw_request(ip, net_ethaddr, ip); |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 320 | } |
| 321 | break; |
| 322 | case DEFEND: |
| 323 | /* Well, we tried. Start over (on conflict) */ |
| 324 | if (source_ip_conflict) { |
| 325 | state = PROBE; |
| 326 | debug("defend conflict -- starting over\n"); |
| 327 | ready = 0; |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 328 | net_ip.s_addr = 0; |
Joe Hershberger | b35a3a6 | 2012-05-23 08:00:12 +0000 | [diff] [blame] | 329 | |
| 330 | /* restart the whole protocol */ |
| 331 | ip = pick(); |
| 332 | timeout_ms = 0; |
| 333 | nprobes = 0; |
| 334 | nclaims = 0; |
| 335 | } |
| 336 | break; |
| 337 | default: |
| 338 | /* Invalid, should never happen. Restart the whole protocol */ |
| 339 | debug("invalid state -- starting over\n"); |
| 340 | state = PROBE; |
| 341 | ip = pick(); |
| 342 | timeout_ms = 0; |
| 343 | nprobes = 0; |
| 344 | nclaims = 0; |
| 345 | break; |
| 346 | } |
| 347 | configure_wait(); |
| 348 | } |