From 9155b30f6d436d2197dcad2e75dac6de146f9499 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 17 Nov 2013 06:55:39 +0100 Subject: [PATCH] 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. --- sys/src/cmd/ndb/dnresolve.c | 30 ++++++++++++++++++------------ 1 file 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){