ref: 9155b30f6d436d2197dcad2e75dac6de146f9499
parent: c45386588ba849f2859833ab9c368b7bc6cc0a31
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 17 01:55:39 EST 2013
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.
--- a/sys/src/cmd/ndb/dnresolve.c
+++ b/sys/src/cmd/ndb/dnresolve.c
@@ -748,24 +748,22 @@
static int
queryloops(Query *qp, RR *rp)
{- DN *ns;
+ DN *ns = rp->host;
- 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 @@
* 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 @@
if(arp)
break;
}
+ }
/* use any addresses that we found */
for(trp = arp; trp && nd < Maxdest; trp = trp->next){--
⑨