[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#490530: libc6: gethostbyaddr() times out if reverse dns not found



Package: libc6
Version: 2.7-10
Severity: normal


I noticed that when I tried pinging kalus.dk (which does not have
reverse DNS at the time of writing), ping would only send a packet
every 5 seconds.

R@h ~> host kalus.dk
kalus.dk has address 89.233.27.15
kalus.dk mail is handled by 10 mail.kalus.dk.
R@h ~> host 89.233.27.15
Host 15.27.233.89.in-addr.arpa. not found: 3(NXDOMAIN)
R@h ~> ping kalus.dk
PING kalus.dk (89.233.27.15) 56(84) bytes of data.
[5 second pause]
64 bytes from 89.233.27.15: icmp_seq=1 ttl=56 time=6.21 ms
[5 second pause]
64 bytes from 89.233.27.15: icmp_seq=2 ttl=56 time=5.89 ms
[5 second pause]
64 bytes from 89.233.27.15: icmp_seq=3 ttl=56 time=5.98 ms
[5 second pause]
64 bytes from 89.233.27.15: icmp_seq=4 ttl=56 time=4.48 ms

I tracked it down to the function call char *pr_addr in ping.c, when calling gethostbyaddr() :
/*  pr_addr --  Return an ascii host address as a dotted quad and optionally with a hostname. */
char *pr_addr(__u32 addr) {
        struct hostent *hp;
[...]
        hp = gethostbyaddr((char *)&addr, 4, AF_INET);
[...]
}

I see no reason why it should take 5 seconds to find out that reverse DNS is not available, when the "host" command returns the answer immediately.

Doing a strace I get (selected parts of trace):

stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=131, ...}) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("83.221.148.2")}, 28) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
poll([{fd=4, events=POLLOUT, revents=POLLOUT}], 1, 0) = 1
sendto(4, "\t,\1\0\0\1\0\0\0\0\0\0\00215\00227\003233\00289\7in-a"..., 43, MSG_NOSIGNAL, NULL, 0) = 43
poll([{fd=4, events=POLLIN, revents=POLLIN}], 1, 5000) = 1
ioctl(4, FIONREAD, [103])               = 0
recvfrom(4, "\t,\201\203\0\1\0\0\0\1\0\0\00215\00227\003233\00289\7"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("83.221.148.2")}, [16]) = 103
close(4)                                = 0
socket(PF_FILE, SOCK_STREAM, 0)         = 4
fcntl(4, F_GETFD)                       = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
connect(4, {sa_family=AF_FILE, path="/var/run/avahi-daemon/socket"}, 110) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fstat(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2afcdfb72000
lseek(4, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(4, "RESOLVE-ADDRESS 89.233.27.15\n", 29) = 29
read(4, 

[***Here there is a 5 second wait***]

"-15 Timeout reached\n", 1024)  = 20
close(4)                                = 0


I noted the 
lseek(4, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
Which seems suspecious.

Regards, Thue

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.24-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libc6 depends on:
ii  libgcc1                       1:4.3.1-2  GCC support library

libc6 recommends no packages.

-- debconf information:
* glibc/upgrade: true
  glibc/restart-failed:
* glibc/restart-services: openbsd-inetd exim4 cupsys cron atd



Reply to: