getaddrinfo for "localhost" gives a strange IP-address
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer:sender; b=dNPzUJH+OUIcF0tLsZ7Lvtq9hdeQXNprb1siCNyiyU5c3E78xDHAxJ00x1Gh8muHvNVQSF5PpVPLXuyVY0GKhvT3jrDxMtIEZhbGdA1ajxnzeNeojZUmtmcxr7X6Jhf3ZapkL8ZtHMWxyZF3WKcaP1SylTc5XQJ3YmtrSvJIB6A= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer:sender; b=nWNAJUML4j9hRY04gs1MZpYjDgh47NoXPzMNkgz1eCTNO48GB4DVZSBEBkNekw5RGhjk47aTSRR1qAs9bvzmHzQdy2bCsozw5Rp3WGKTtDEp55TESvQdO9jXcavNh4wRCJ6YvKJE1KFlM2HD2zGihjiKcbTAxl+bCCL+xE79klA= Hello, ./test localhost resolving name=localhost family=30 sock_type=1 protocol=6 flags=0x0 canonname=(null) ip=::1 serv=0 family=2 sock_type=1 protocol=6 flags=0x0 canonname=(null) ip=173.19.2.144 serv=0 family=2 sock_type=1 protocol=6 flags=0x0 canonname=(null) ip=127.0.0.1 serv=0. Here is the contests of /etc/hosts cat /etc/hosts ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost Iso-Imakki 255.255.255.255 broadcasthost ::1 localhost #127.0.0.1 localhost localhost. localhost.local localhost.localdomain And here is the ouput of "nidump hosts /" ::1 localhost 127.0.0.1 localhost 255.255.255.255 broadcasthost Finally the test program code. --- cut -- #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #include <stdio.h> static char rcsid[] = "$Header$"; int main(int argc, char *argv[]) { struct addrinfo hints, *res, *res0; int error; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; char *name = "localhost"; memset(&hints, 0, sizeof(hints)); if (argc == 2) { name = argv[1]; } printf("resolving name=%s\n", name); printf("ip=%s serv=%s\n", hbuf, sbuf); } freeaddrinfo(res0); return (0); } --- cut -- - Ville In my imac I've got this strange problem. Executing ruby's testsuite will take a very long time. I've isolated the reason to resolving of "localhost" address. The ruby uses getaddrinfo. At the end o fthis mailis a test code that show this strange behaviour. Running it will give the following output Eg. the first localhost ip is "173.19.2.144". This IP is not configured in my mac. Here is the ifconfig -a lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 00:17:f2:cd:43:55 media: autoselect status: inactive supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full- duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 tunnel inet --> inet 192.168.222.2 netmask 0xffffff00 broadcast 192.168.222.255 ether 00:19:e3:0c:b2:d4 media: autoselect status: active supported media: autoselect vlan: 0 parent interface: <none> bond interfaces: <none> wlt1: flags=41<UP,RUNNING> mtu 1500 fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 2030 lladdr 00:16:cb:ff:fe:76:5c:12 media: autoselect <full-duplex> status: inactive supported media: autoselect <full-duplex> vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 172.16.47.1 netmask 0xffffff00 broadcast 172.16.47.255 ether 00:50:56:c0:00:08 vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.91.1 netmask 0xffffff00 broadcast 192.168.91.255 ether 00:50:56:c0:00:01 en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 inet6 fe80::201:23ff:fe45:6789%en2 prefixlen 64 scopeid 0xa inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255 ether 00:01:23:45:67:89 media: autoselect status: active supported media: autoselect en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 inet6 fe80::210:32ff:fe54:7698%en3 prefixlen 64 scopeid 0xb inet 10.211.55.100 netmask 0xffffff00 broadcast 10.211.55.255 ether 00:10:32:54:76:98 media: autoselect status: active supported media: autoselect I've got both vmware fusion and parallels installed neither of them was not running when I run the test program. hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; error = getaddrinfo(name, NULL, &hints, &res0); if (error) { errx(1, "%s", gai_strerror(error)); /*NOTREACHED*/ } for (res = res0; res; res = res->ai_next) { printf("family=%d sock_type=%d protocol=%d flags=0x%x canonname=% s\n", res->ai_family, res->ai_socktype, res->ai_protocol, res->ai_flags, res->ai_canonname); memset(hbuf, 0, sizeof(hbuf)); memset(sbuf, 0, sizeof(sbuf)); error =getnameinfo(res->ai_addr, res->ai_addr->sa_len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV/ * NI_NAMEREQD*/); if (error) { errx(1, "%s", gai_strerror(error)); } _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Ville Mattila