dnsd: Fails "Got recursion not available from ..."

Denys Vlasenko vda.linux at googlemail.com
Sat Feb 6 21:46:48 UTC 2010


Hi.

Super delayed reply alert.

On Tuesday 11 August 2009 23:15, Lars J Aas wrote:
>    Hi all,
> 
> I am using busybox udhcpd and dnsd on a Popcorn Hour A110 to manage my  
> home LAN. The A110 is a multimedia streamer, and it is always running  
> as a server, even in stand-by mode, so I deemed it the most suitable  
> device for this sort of thing.

I was reviewing code and spotted a bug in dnsd.c
Fix:

-       move_to_unaligned32((uint16_t *)answb, htons(outr_rlen));
+       move_to_unaligned16((uint16_t *)answb, htons(outr_rlen));

It only affected big endian. If your processor big or little endian?


> Then I try to resolve a local name:
> 
>  > nslookup wii
> ;; Got recursion not available from 192.168.82.21, trying next server
> ;; Got recursion not available from 192.168.82.21, trying next server
> Server:		130.67.60.68
> Address:	130.67.60.68#53
> 
> ** server can't find wii: NXDOMAIN
> 
> If I do an "nslookup -d2", I get the following:
> main parsing wii
> addlookup()
> make_empty_lookup()
> [...]
> send_udp(0x151198)
> bringup_timer()
> have local timeout of 1
> working on lookup 0x802a08, query 0x151198
> sockcount=2
> recving with lookup=0x802a08, query=0x151198, sock=0x153128
> recvcount=1
> sending a request
> ;; Got recursion not available from 192.168.82.21, trying next server
> clear_query(0x151008)
> sockcount=1
> check_next_lookup(0x802a08)
> still have a worker
> unlock_lookup /SourceCache/bind9/bind9-26.1.5/bind9/bin/dig/dighost.c: 
> 3006
> [...]
> 
> If I do an "nslookup -norec", then it works however:
>  > nslookup -norec wii
> Server:		192.168.82.21
> Address:	192.168.82.21#53
> 
> Name:	wii
> Address: 192.168.82.22

It looks like dnsd always responds with RA bit unchanged.
Here is where execution comes when we have a valid reply:

        /* QR = 1 "response",
         * AA = 1 "Authoritative Answer",
         * RCODE = 0 "success" */
        outr_flags = htons(0x8000 | 0x0400 | 0);   <====
        /* we have one answer */
        head->nansw = htons(1);

 empty_packet:
        head->flags |= outr_flags;     <====
        head->nauth = head->nadd = 0;
        head->nquer = htons(1); // why???

        return answb - buf;


Look closely at ->flags. Below is the doc, look at RA bit.
In the code above, we never set RA bit.
You can try adding 0x80 to "htons(0x8000 | 0x0400 | 0x80 | 0)"
to set RA bit, and let me know if this helps.

4.1.1. Header section format
      0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      ID                       |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |QR|   OPCODE  |AA|TC|RD|RA| 0  0  0|   RCODE   |<== flags word
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
...
ID      16 bit random identifier assigned by querying peer.
        Used to match query/response.
QR      message is a query (0), or a response (1).
OPCODE  0   standard query (QUERY)
        1   inverse query (IQUERY)
        2   server status request (STATUS)
AA      Authoritative Answer - this bit is valid in responses.
        Responding name server is an authority for the domain name
        in question section. Answer section may have multiple owner names
        because of aliases.  The AA bit corresponds to the name which matches
        the query name, or the first owner name in the answer section.
TC      TrunCation - this message was truncated.
RD      Recursion Desired - this bit may be set in a query and
        is copied into the response.  If RD is set, it directs
        the name server to pursue the query recursively.
        Recursive query support is optional.
RA      Recursion Available - this be is set or cleared in a
        response, and denotes whether recursive query support is
        available in the name server.
RCODE   Response code.
        0   No error condition
        1   Format error
        2   Server failure - server was unable to process the query
            due to a problem with the name server.
        3   Name Error - meaningful only for responses from
            an authoritative name server. The referenced domain name
            does not exist.
        4   Not Implemented.
        5   Refused.



-- 
vda


More information about the busybox mailing list