Do not randomize resolving of IP addresses in getaddr()
PATCH 1/1 Do not randomize resolving of IP addresses in getaddr()
From: David Sommerseth <[email protected]...>
Based on a discussion on the mailing list and in the IRC meeting Feb 18, it was decided to remove get_random() from the getaddr() function as that can conflict with round-robin/randomization done by DNS servers.
This change must be documented in the release notes.
Signed-off-by David Sommerseth <[email protected]...>
--- socket.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
socket.c +2 -3
@@ -212,12 +212,11 @@ getaddr (unsigned int flags, ++n;ASSERT (n >=2 ); -msg (D_RESOLVE_ERRORS ,"RESOLVE: NOTE: %s resolves to %d addresses, choosing one by random" , +msg (D_RESOLVE_ERRORS ,"RESOLVE: NOTE: %s resolves to %d addresses, choosing the first resolved IP address" , hostname, n); -/* choose address randomly, for basic load-balancing capability */ - ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random () % n]); + ia.s_addr = *(in_addr_t *) (h->h_addr_list[0 ]); } }
Signature · 1 line
1.6.6
Hi,
ACK for the idea, but this...
socket.c getaddr (unsigned int flags, · line 220
Quoted 4 lines · David Sommerseth
socket.c +1
-2-/* choose address randomly, for basic load-balancing capability */ - ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random () % n]); + ia.s_addr = *(in_addr_t *) (h->h_addr_list[0 ]); }
... is sort of redundant, because the code further up already sets
ia.s_addr = *(in_addr_t *) (h->h_addr_list[0]);
- in about line 202 in my copy of socket.c:
---------------- snip -------------
ia.s_addr = *(in_addr_t *) (h->h_addr_list[0]);
if (ia.s_addr)
{
if (h->h_addr_list[1]) /* more than one address returned */---------------- snip -------------
so the if() could be reduced even further, to just print the message.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...