From: Roy Marples Date: Thu, 29 May 2008 19:26:16 +0000 (+0000) Subject: Make the timings more random by using the full range of poll timeout. X-Git-Tag: v4.0.2~304 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c02568a28483fb384bd9eedc208e19154c9310a;p=thirdparty%2Fdhcpcd.git Make the timings more random by using the full range of poll timeout. --- diff --git a/client.c b/client.c index 79c2453c..db9e7e03 100644 --- a/client.c +++ b/client.c @@ -58,8 +58,6 @@ # error "IPv4LL requires ENABLE_ARP to work" # endif # define IPV4LL_LEASETIME 2 -# define MAX_CONFLICTS 10 -# define DEFEND_INTERVAL 10 #endif /* Some platforms don't define INFTIM */ diff --git a/net.c b/net.c index 13ffdd70..1deed0a1 100644 --- a/net.c +++ b/net.c @@ -683,10 +683,8 @@ arp_claim(struct interface *iface, struct in_addr address) if (timeout > 0) { /* Obey IPV4LL timings, but make us faster for * routeable addresses */ - if (IN_LINKLOCAL(htonl(address.s_addr))) - timeout *= 1000; - else - timeout *= 200; + if (!IN_LINKLOCAL(htonl(address.s_addr))) + timeout /= 6; s = poll(fds, 2, timeout); if (s == -1) { if (errno != EINTR) diff --git a/net.h b/net.h index 77e4b6f9..b8b6cb6c 100644 --- a/net.h +++ b/net.h @@ -171,14 +171,15 @@ ssize_t send_raw_packet(const struct interface *, int, ssize_t get_packet(struct interface *, void *, ssize_t); #ifdef ENABLE_ARP -/* These are really for IPV4LL */ -#define PROBE_WAIT 1 -#define PROBE_NUM 3 -#define PROBE_MIN 1 -#define PROBE_MAX 2 -#define ANNOUNCE_WAIT 2 -#define ANNOUNCE_NUM 2 -#define ANNOUNCE_INTERVAL 2 +/* These are really for IPV4LL, RFC 3927. + * We multiply some numbers by 1000 so they are suitable for use in poll(). */ +#define PROBE_WAIT 1 * 1000 +#define PROBE_NUM 3 +#define PROBE_MIN 1 * 1000 +#define PROBE_MAX 2 * 1000 +#define ANNOUNCE_WAIT 2 * 1000 +#define ANNOUNCE_NUM 2 +#define ANNOUNCE_INTERVAL 2 * 1000 #define MAX_CONFLICTS 10 #define RATE_LIMIT_INTERVAL 60 #define DEFEND_INTERVAL 10