diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-11-17 06:55:39 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2013-11-17 06:55:39 +0100 |
commit | 9155b30f6d436d2197dcad2e75dac6de146f9499 (patch) | |
tree | 19bfab70e689d5a7920f00d127b92552249c4c04 | |
parent | c45386588ba849f2859833ab9c368b7bc6cc0a31 (diff) | |
download | plan9front-9155b30f6d436d2197dcad2e75dac6de146f9499.tar.xz |
ndb/dns: another attempt...
we have to fail the whole query that got no cached
nameservers and nameservers are looping, not just omit
the looping nameserver. issuequery() will refresh
nameserver info for the domain when recursing up.
-rw-r--r-- | sys/src/cmd/ndb/dnresolve.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/src/cmd/ndb/dnresolve.c b/sys/src/cmd/ndb/dnresolve.c index 3c5942093..971a2c0d8 100644 --- a/sys/src/cmd/ndb/dnresolve.c +++ b/sys/src/cmd/ndb/dnresolve.c @@ -748,24 +748,22 @@ ipisbm(uchar *ip) static int queryloops(Query *qp, RR *rp) { - DN *ns; - - ns = rp->host; + DN *ns = rp->host; /* - * avoid loops looking up a server under itself + * looking up a server under itself */ if(subsume(rp->owner->name, ns->name)) return 1; /* - * must not cycle on name servers refering + * cycle on name servers refering * to each another. */ - for(qp = qp->prev; qp; qp = qp->prev) - for(rp = qp->nsrp; rp; rp = rp->next) - if(rp->host == ns) - return 1; + for(; qp; qp = qp->prev) + if(qp->dp == ns) + return 1; + return 0; } @@ -812,13 +810,20 @@ serveraddrs(Query *qp, int nd, int depth) * server addresses, try resolving one via the network. * Mark any we try to resolve so we don't try a second time. */ - if(arp == 0) + if(arp == 0){ + for(rp = qp->nsrp; rp; rp = rp->next) + if(queryloops(qp, rp)) + /* + * give up as we should have got the address + * by higher up nameserver when recursing + * down, or will be queried when recursing up. + */ + return nd; + for(rp = qp->nsrp; rp; rp = rp->next){ if(rp->marker) continue; rp->marker = 1; - if(queryloops(qp, rp)) - continue; arp = dnresolve(rp->host->name, Cin, Ta, qp->req, 0, depth+1, Recurse, 1, 0); if(arp == nil) @@ -828,6 +833,7 @@ serveraddrs(Query *qp, int nd, int depth) if(arp) break; } + } /* use any addresses that we found */ for(trp = arp; trp && nd < Maxdest; trp = trp->next){ |