[avahi] bug report (and fix) network up/down delayed 10 seconds

knoppix at rngresearch.com knoppix at rngresearch.com
Thu Jul 14 07:32:08 PDT 2011


First of all, I did try to use bugs.freedesktop.org, but it told me
"Sorry, entering a bug into the product avahi has been disabled."

Network up/down is unnecessarily delayed by 10 seconds per interface.
(lo is the only interface not affected.)  This concerns Version 0.6.30-5
(Debian sid (unstable)) as well as 0.6.27-2 (Debian squeeze (stable)).

Details:
The problem is caused by a small error in the way
/usr/lib/avahi/avahi-daemon-check-dns.sh checks for nameserver entries in
/etc/resolv.conf, and it occurs when there is no nameserver, but the
"wrong" text appears, e.g., in a comment, in /etc/resolv.conf.  For
example:
    /etc/resolv.conf:
    1: # insert nameservers here
    2: # nameserver 127.0.0.1
will result in a 10 second delay per interface as avahi tries to resolve
the name "local".

Fix:
Change two greps in avahi-daemon-check-dns.sh that search for lines that
_contain_ the text "nameserver" to search for lines that _begin_with_ the
_word_ "nameserver".  In the second case, the grep is intended to discover
if there is a nameserver configured on either 127.0.0.1 or ::1.  As
originally written, it would "find" that there is a local nameserver
provided that any line contains the text "::1", even in a comment, and it
would fail to find a nameserver actually configured on 127.0.0.1 if the
whitespace between "nameserver" and the address were any legal combination
of tabs and spaces other than a single space.

diff -Naur a/avahi-daemon/usr/lib/avahi/avahi-daemon-check-dns.sh
b/avahi-daemon/usr/lib/avahi/avahi-daemon-check-dns.sh
--- a/avahi-daemon/usr/lib/avahi/avahi-daemon-check-dns.sh        2011-07-02
08:53:33.000000000 +0000
+++ b/avahi-daemon/usr/lib/avahi/avahi-daemon-check-dns.sh        2011-07-14
14:00:23.000000000 +0000
@@ -26,11 +26,11 @@

 dns_reachable() {
   # If there are no nameserver entries in resolv.conf there is no dns
reachable
-  $(grep -q nameserver /etc/resolv.conf) || return 1;
+  $(grep -wq ^nameserver /etc/resolv.conf) || return 1;

   # If there is no local nameserver and no we have no global ip addresses
   # then we can't reach any nameservers
-  if ! $(egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf); then
+  if ! $(egrep -wq "^nameserver[[:space:]]+(127.0.0.1|::1)"
/etc/resolv.conf ); then
     # Get addresses of all running interfaces
     ADDRS=$(LC_ALL=C ifconfig | grep ' addr:')
     # Filter out all local addresses

I hope to see this fix implemented.  Thanks.

-Andrew




More information about the avahi mailing list