[avahi] problem with nss_mdns4 doing long timesouts looking up dotted decimals

Norman Ramsey nr at eecs.harvard.edu
Sat Mar 10 09:20:20 PST 2007

With a recent update, it now takes me 10 or 15 seconds to do any opeation
involving ssh.  Using strace, I believe I've tracked the problem 
to avahi's lair.  Here's a fragment of an strace: the NSS opens
libness_mdns4, which connects to an avahi-daemon socket and asks it to
resolve a dotted-decimal address.  It takes 5 seconds to time out
(i.e., it takes 5 seconds for the read() to complete).  For reasons I
don't understand, ssh does this lookup *twice* to make a connection.
Result: every little remote cvs operation comes with a 10-second
delay.  This is driving me crazy; can anyone think of a workaround?

     0.000028 open("/lib/libnss_mdns4.so.2", O_RDONLY) = 5
     0.000029 read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\t\0\000"..., 512) = 512
     0.000048 fstat64(5, {st_mode=S_IFREG|0644, st_size=7208, ...}) = 0
     0.000049 mmap2(NULL, 10164, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0xb7a70000
     0.000034 mmap2(0xb7a72000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x1) = 0xb7a72000
     0.000053 close(5)                  = 0
     0.000074 socket(PF_FILE, SOCK_STREAM, 0) = 5
     0.000042 fcntl64(5, F_GETFD)       = 0
     0.000022 fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
     0.000038 connect(5, {sa_family=AF_FILE, path="/var/run/avahi-daemon/socket"}, 110) = 0
     0.000108 fcntl64(5, F_GETFL)       = 0x2 (flags O_RDWR)
     0.000029 fstat64(5, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
     0.000042 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7a6f000
     0.000037 _llseek(5, 0, 0xbf8b0dd8, SEEK_CUR) = -1 ESPIPE (Illegal seek)
     0.000063 write(5, "RESOLVE-ADDRESS\n", 31) = 31
     0.000151 read(5, "-15 Timeout reached\n", 1024) = 20
     5.002519 close(5)                  = 0

More information about my system:

/etc/nsswitch.conf says:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

I'm running Debian, which has this to say about versions:

: nr at curlycoat 10212 ; dpkg -s libnss-mdns
Package: libnss-mdns
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 120
Maintainer: Anand Kumria <wildfire at progsoc.org>
Architecture: i386
Source: nss-mdns
Version: 0.9-0.2
Depends: libc6 (>= 2.3.6-6), base-files (>= 3.1.10), perl,
avahi-daemon (>= 0.6.16-1)
Suggests: avahi-autoipd | zeroconf
Description: NSS module for Multicast DNS name resolution
 nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality
 of the GNU C Library (glibc) providing host name resolution via Multicast
 DNS (using Zeroconf, aka Apple Bonjour / Apple Rendezvous ), effectively
 allowing name resolution by common Unix/Linux programs in the ad-hoc mDNS
 domain .local.

Package: avahi-daemon
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 352
Maintainer: Utopia Maintenance Team <pkg-utopia-maintainers at lists.alioth.debian.org>
Architecture: i386
Source: avahi
Version: 0.6.16-2
Depends: libavahi-common3, libavahi-core4, libc6 (>= 2.3.6-6), libcap1, libdaemon0, libdbus-1-3 (>= 0.94), libexpat1 (>= 1.95.8), adduser, dbus (>= 0.60)
Recommends: libnss-mdns
Suggests: avahi-autoipd
Conflicts: mdnsresponder
 /etc/network/if-up.d/avahi-daemon 452d35fa8a17091f748aa6c1efa79967
 /etc/avahi/hosts 0d3e0f267e7e9dc29bd4472e9a531661
 /etc/avahi/avahi-daemon.conf 68d55e401a5d00a93b2cb43d5586bcfc
 /etc/default/avahi-daemon ce04a82b0303fa1cf9f74c4740c8f4ee
 /etc/init.d/avahi-daemon 12cfb3c66930893a49d1cf5b19ee151f
 /etc/dbus-1/system.d/avahi-dbus.conf 8da3bce2b76ee263115202c7cace9e2b
 /etc/resolvconf/update-libc.d/avahi-daemon 32a12dd375563a33cf476f009e40400c
Description: Avahi mDNS/DNS-SD daemon
 Avahi is a fully LGPL framework for Multicast DNS Service Discovery.
 It allows programs to publish and discover services and hosts
 running on a local network with no specific configuration.  For
 example you can plug into a network and instantly find printers to
 print to, files to look at and people to talk to.
 This package contains the Avahi Daemon which represents your machine
 on the network and allows other applications to publish and resolve
 mDNS/DNS-SD records.

More information about the avahi mailing list