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

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



Dear Klaus Knopper et al,

First off, I'd like to take this opportunity to say thanks: I've enjoyed
using, and learning from, Knoppix immensely over the years.  It's a really
great thing!

As to the bug:  The problem is an avahi script mistakenly thinking there
is a nameserver listening on the local machine, although there is not one.
 This is really a bug in avahi, not knoppix, per se, and I submitted a bug
report and a fix for the script to their mailing list.  The script is
identical in squeeze and sid, so I don't know how long the fix will take
to propagate into Knoppix.  Meanwhile it affects the usability of Knoppix.

That said, after an interface is brought up or down, the scripts
    /etc/network/if-up.d/avahi-daemon
    /etc/network/if-post-down.d/avahi-daemon -> ../if-up.d/avahi-daemon
are executed, which in turn execute
    /usr/lib/avahi/avahi-daemon-check-dns.sh
which tests to see if there is a local nameserver configured by grepping
/etc/resolv.conf for the pattern "nameserver", and then the pattern
"nameserver 127.0.0.1|::1", the first of which finds both lines in the
default
    /KNOPPIX/etc/resolv.conf:
    1: # insert nameservers here
    2: # nameserver 127.0.0.1
whereas, the second grep finds line 2 and returns success.  This is
followed by the script waiting 10 seconds for the nonexistent nameserver
to reply.  And this happens for every interface, until either a nameserver
is added to /etc/resolv.conf, or one is started on localhost.

Now, the most expedient and reliable method for me was to replace line 2
of /etc/resolv.conf with
    # nameserver <ip address>
since /etc/resolv.conf is a file I will be paying attention to when
upgrading Knoppix, unlike /usr/lib/avahi/avahi-daemon-check-dns.sh.

I include a copy of the bug report I e-mailed to the avahi list below,
just in case anybody is interested.

-Andrew



Subject: [avahi] bug report (and fix) network up/down delayed 10 seconds
From: knoppix@rngresearch.com
Date: Thu, July 14, 2011 10:32
To: avahi@lists.freedesktop.org

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



Reply to: