INN commit: branches/2.5 (6 files)
INN Commit
rra at isc.org
Mon Sep 19 21:05:01 UTC 2011
Date: Monday, September 19, 2011 @ 14:05:01
Author: eagle
Revision: 9380
Stop using INADDR_LOOPBACK
It looks like the byte order of INADDR_LOOPBACK is indeterminate and may
require htonl on some systems and not on others. Avoid the issue by
not using it and instead just using htonl(0x7f000001UL).
Modified:
branches/2.5/frontends/ovdb_server.c
branches/2.5/include/portable/socket.h
branches/2.5/lib/getaddrinfo.c
branches/2.5/storage/ovdb/ovdb.c
branches/2.5/tests/lib/getaddrinfo-t.c
branches/2.5/tests/lib/network-t.c
---------------------------+
frontends/ovdb_server.c | 2 +-
include/portable/socket.h | 5 -----
lib/getaddrinfo.c | 5 ++++-
storage/ovdb/ovdb.c | 2 +-
tests/lib/getaddrinfo-t.c | 4 ++--
tests/lib/network-t.c | 2 +-
6 files changed, 9 insertions(+), 11 deletions(-)
Modified: frontends/ovdb_server.c
===================================================================
--- frontends/ovdb_server.c 2011-09-19 21:03:19 UTC (rev 9379)
+++ frontends/ovdb_server.c 2011-09-19 21:05:01 UTC (rev 9380)
@@ -659,7 +659,7 @@
#else
sa.sin_family = AF_INET;
sa.sin_port = htons(OVDB_SERVER_PORT);
- sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sa.sin_addr.s_addr = htonl(0x7f000001UL);
ret = bind(listensock, (struct sockaddr *)&sa, sizeof sa);
Modified: include/portable/socket.h
===================================================================
--- include/portable/socket.h 2011-09-19 21:03:19 UTC (rev 9379)
+++ include/portable/socket.h 2011-09-19 21:05:01 UTC (rev 9380)
@@ -47,11 +47,6 @@
extern const char * inet_ntop(int, const void *, char *, socklen_t);
#endif
-/* Some systems don't define INADDR_LOOPBACK. */
-#ifndef INADDR_LOOPBACK
-# define INADDR_LOOPBACK 0x7f000001UL
-#endif
-
/* Defined by RFC 3493, used to store a generic address. Note that this
doesn't do the alignment mangling that RFC 3493 does; it's not clear if
that should be added.... */
Modified: lib/getaddrinfo.c
===================================================================
--- lib/getaddrinfo.c 2011-09-19 21:03:19 UTC (rev 9379)
+++ lib/getaddrinfo.c 2011-09-19 21:05:01 UTC (rev 9380)
@@ -356,7 +356,10 @@
else {
if (servname == NULL)
return EAI_NONAME;
- addr.s_addr = (flags & AI_PASSIVE) ? INADDR_ANY : INADDR_LOOPBACK;
+ if ((flags & AI_PASSIVE) == AI_PASSIVE)
+ addr.s_addr = INADDR_ANY;
+ else
+ addr.s_addr = htonl(0x7f000001UL);
ai = gai_addrinfo_new(socktype, NULL, addr, port);
if (ai == NULL)
return EAI_MEMORY;
Modified: storage/ovdb/ovdb.c
===================================================================
--- storage/ovdb/ovdb.c 2011-09-19 21:03:19 UTC (rev 9379)
+++ storage/ovdb/ovdb.c 2011-09-19 21:05:01 UTC (rev 9380)
@@ -282,7 +282,7 @@
#else
sa.sin_family = AF_INET;
sa.sin_port = 0;
- sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sa.sin_addr.s_addr = htonl(0x7f000001UL);
bind(clientfd, (struct sockaddr *) &sa, sizeof sa);
sa.sin_port = htons(OVDB_SERVER_PORT);
r = connect(clientfd, (struct sockaddr *) &sa, sizeof sa);
Modified: tests/lib/getaddrinfo-t.c
===================================================================
--- tests/lib/getaddrinfo-t.c 2011-09-19 21:03:19 UTC (rev 9379)
+++ tests/lib/getaddrinfo-t.c 2011-09-19 21:05:01 UTC (rev 9380)
@@ -50,7 +50,7 @@
ok(10, ai->ai_addrlen == sizeof(struct sockaddr_in));
saddr = (struct sockaddr_in *) ai->ai_addr;
ok(11, saddr->sin_port == htons(25));
- ok(12, saddr->sin_addr.s_addr == INADDR_LOOPBACK);
+ ok(12, saddr->sin_addr.s_addr == htonl(0x7f000001UL));
test_freeaddrinfo(ai);
memset(&hints, 0, sizeof(hints));
@@ -78,7 +78,7 @@
ok(24, test_getaddrinfo(NULL, "25", &hints, &ai) == 0);
saddr = (struct sockaddr_in *) ai->ai_addr;
ok(25, saddr->sin_port == htons(25));
- ok(26, saddr->sin_addr.s_addr == INADDR_LOOPBACK);
+ ok(26, saddr->sin_addr.s_addr == htonl(0x7f000001UL));
test_freeaddrinfo(ai);
ok(27, test_getaddrinfo(NULL, NULL, NULL, &ai) == EAI_NONAME);
Modified: tests/lib/network-t.c
===================================================================
--- tests/lib/network-t.c 2011-09-19 21:03:19 UTC (rev 9379)
+++ tests/lib/network-t.c 2011-09-19 21:05:01 UTC (rev 9380)
@@ -227,7 +227,7 @@
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(11119);
- sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sin.sin_addr.s_addr = htonl(0x7f000001UL);
if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
_exit(1);
out = fdopen(fd, "w");
More information about the inn-committers
mailing list