shithub: riscv

Download patch

ref: 501e69d0108812d41f9772dc21cb075af9c65490
parent: 887d02274d367018873a6533c658708cb0056be7
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Dec 7 20:26:07 EST 2014

ndb/dns: ignore terminating authoritative flag for no-answer when more nameservers are provided

continue recursing when we get empty but non-negative answer
from a (claimed) authoritative nameserer that provides more
nameservers.

this fixes wordpress dns:

63766.3: sending to 192.0.80.93/ns1.wordpress.com bossypally.files.wordpress.com ip
63766: rcvd OK from 192.0.80.93 (authoritative)
	Q:    bossypally.files.wordpress.com ip
	Auth: files.wordpress.com              5 min           ns   	mdns1.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns2.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns3.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns4.wordpress.com
	      files.wordpress.com              5 min           ns   	mdns5.wordpress.com
	Hint: mdns1.wordpress.com              4 hr            ip   	192.0.75.7
	      mdns2.wordpress.com              4 hr            ip   	198.181.117.7
	      mdns3.wordpress.com              4 hr            ip   	198.181.116.7
	      mdns4.wordpress.com              4 hr            ip   	198.181.118.7
	      mdns5.wordpress.com              4 hr            ip   	192.0.74.7


63766.4: sending to 192.0.75.7/mdns1.wordpress.com bossypally.files.wordpress.com ip
63766: rcvd OK from 192.0.75.7 (authoritative)
	Q:    bossypally.files.wordpress.com ip
	Ans:  bossypally.files.wordpress.com   5 min           ip   	192.0.72.2
	      bossypally.files.wordpress.com   5 min           ip   	192.0.72.3
----------------------------
answer bossypally.files.wordpress.com   5 min           ip   	192.0.72.2
answer bossypally.files.wordpress.com   5 min           ip   	192.0.72.3
----------------------------

note the authoritative flag in the first response from ns1.wordpress.com that
would otherwise terminate the search.

--- a/sys/src/cmd/ndb/dnresolve.c
+++ b/sys/src/cmd/ndb/dnresolve.c
@@ -1229,11 +1229,12 @@
 	}
 
 	/*
-	 *  Any reply from an authoritative server,
+	 *  Any reply from an authoritative server
+	 *  that does not provide more nameservers,
 	 *  or a positive reply terminates the search.
 	 *  A negative response now also terminates the search.
 	 */
-	if(mp->an != nil || (mp->flags & Fauth)){
+	if(mp->an || (mp->flags & Fauth) && mp->ns == nil){
 		if(isnegrname(mp))
 			qp->dp->respcode = Rname;
 		else
@@ -1267,7 +1268,7 @@
 	 *  if we're a pure resolver, don't recurse, we have
 	 *  to forward to a fixed set of named servers.
 	 */
-	if(!mp->ns || cfg.resolver && cfg.justforw)
+	if(mp->ns == nil || cfg.resolver && cfg.justforw)
 		return Answnone;
 	tp = rrlookup(ndp, Tns, NOneg);
 	if(contains(qp->nsrp, tp)){