|
@@ -17,12 +17,23 @@ enum
|
|
|
Udp, Tcp,
|
|
|
|
|
|
Maxdest= 24, /* maximum destinations for a request message */
|
|
|
- Maxtrans= 3, /* maximum transmissions to a server */
|
|
|
- Maxretries= 3, /* cname+actual resends: was 32; have pity on user */
|
|
|
- Maxwaitms= 1000, /* wait no longer for a remote dns query */
|
|
|
- Minwaitms= 100, /* willing to wait for a remote dns query */
|
|
|
- Remntretry= 15, /* min. sec.s between /net.alt remount tries */
|
|
|
Maxoutstanding= 15, /* max. outstanding queries per domain name */
|
|
|
+ Remntretry= 15, /* min. sec.s between /net.alt remount tries */
|
|
|
+
|
|
|
+ /*
|
|
|
+ * these are the old values; we're trying longer timeouts now
|
|
|
+ * primarily for the benefit of remote nameservers querying us
|
|
|
+ * during times of bad connectivity.
|
|
|
+ */
|
|
|
+// Maxtrans= 3, /* maximum transmissions to a server */
|
|
|
+// Maxretries= 3, /* cname+actual resends: was 32; have pity on user */
|
|
|
+// Maxwaitms= 1000, /* wait no longer for a remote dns query */
|
|
|
+// Minwaitms= 100, /* willing to wait for a remote dns query */
|
|
|
+
|
|
|
+ Maxtrans= 5, /* maximum transmissions to a server */
|
|
|
+ Maxretries= 5, /* cname+actual resends: was 32; have pity on user */
|
|
|
+ Maxwaitms= 5000, /* wait no longer for a remote dns query */
|
|
|
+ Minwaitms= 500, /* willing to wait for a remote dns query */
|
|
|
|
|
|
Destmagic= 0xcafebabe,
|
|
|
Querymagic= 0xdeadbeef,
|
|
@@ -116,6 +127,18 @@ procgetname(void)
|
|
|
return strdup(lp+1);
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+rrfreelistptr(RR **rpp)
|
|
|
+{
|
|
|
+ RR *rp;
|
|
|
+
|
|
|
+ if (rpp == nil || *rpp == nil)
|
|
|
+ return;
|
|
|
+ rp = *rpp;
|
|
|
+ *rpp = nil; /* update pointer in memory before freeing */
|
|
|
+ rrfreelist(rp);
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* lookup 'type' info for domain name 'name'. If it doesn't exist, try
|
|
|
* looking it up as a canonical name.
|
|
@@ -608,11 +631,10 @@ mkreq(DN *dp, int type, uchar *buf, int flags, ushort reqno)
|
|
|
void
|
|
|
freeanswers(DNSmsg *mp)
|
|
|
{
|
|
|
- rrfreelist(mp->qd);
|
|
|
- rrfreelist(mp->an);
|
|
|
- rrfreelist(mp->ns);
|
|
|
- rrfreelist(mp->ar);
|
|
|
- mp->qd = mp->an = mp->ns = mp->ar = nil;
|
|
|
+ rrfreelistptr(&mp->qd);
|
|
|
+ rrfreelistptr(&mp->an);
|
|
|
+ rrfreelistptr(&mp->ns);
|
|
|
+ rrfreelistptr(&mp->ar);
|
|
|
}
|
|
|
|
|
|
/* timed read of reply. sets srcip */
|
|
@@ -656,7 +678,7 @@ readnet(Query *qp, int medium, uchar *ibuf, uvlong endms, uchar **replyp,
|
|
|
dnslog("readnet: %s: tcp fd unset for dest %I",
|
|
|
qp->dp->name, qp->tcpip);
|
|
|
else if (readn(fd, lenbuf, 2) != 2) {
|
|
|
- dnslog("readnet: short read of tcp size from %I",
|
|
|
+ dnslog("readnet: short read of 2-byte tcp msg size from %I",
|
|
|
qp->tcpip);
|
|
|
/* probably a time-out */
|
|
|
notestats(startns, 1, qp->type);
|
|
@@ -893,10 +915,8 @@ cacheneg(DN *dp, int type, int rcode, RR *soarr)
|
|
|
|
|
|
/* no cache time specified, don't make anything up */
|
|
|
if(soarr != nil){
|
|
|
- if(soarr->next != nil){
|
|
|
- rrfreelist(soarr->next);
|
|
|
- soarr->next = nil;
|
|
|
- }
|
|
|
+ if(soarr->next != nil)
|
|
|
+ rrfreelistptr(&soarr->next);
|
|
|
soaowner = soarr->owner;
|
|
|
} else
|
|
|
soaowner = nil;
|
|
@@ -1169,8 +1189,7 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
|
|
|
p->code = Rserver;
|
|
|
return -1;
|
|
|
}
|
|
|
- rrfreelist(mp->ns);
|
|
|
- mp->ns = nil;
|
|
|
+ rrfreelistptr(&mp->ns);
|
|
|
}
|
|
|
|
|
|
/* remove any soa's from the authority section */
|
|
@@ -1182,6 +1201,7 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
|
|
|
unique(mp->ns);
|
|
|
unique(mp->ar);
|
|
|
unlock(&dnlock);
|
|
|
+
|
|
|
if(mp->an)
|
|
|
rrattach(mp->an, (mp->flags & Fauth) != 0);
|
|
|
if(mp->ar)
|
|
@@ -1191,15 +1211,12 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
|
|
|
rrattach(mp->ns, Notauthoritative);
|
|
|
} else {
|
|
|
ndp = nil;
|
|
|
- rrfreelist(mp->ns);
|
|
|
- mp->ns = nil;
|
|
|
+ rrfreelistptr(&mp->ns);
|
|
|
}
|
|
|
|
|
|
/* free the question */
|
|
|
- if(mp->qd) {
|
|
|
- rrfreelist(mp->qd);
|
|
|
- mp->qd = nil;
|
|
|
- }
|
|
|
+ if(mp->qd)
|
|
|
+ rrfreelistptr(&mp->qd);
|
|
|
|
|
|
/*
|
|
|
* Any reply from an authoritative server,
|
|
@@ -1254,7 +1271,7 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
|
|
|
* netquery, which current holds qp->dp->querylck,
|
|
|
* so release it now and acquire it upon return.
|
|
|
*/
|
|
|
-// lcktype = qtype2lck(qp->type);
|
|
|
+// lcktype = qtype2lck(qp->type); /* someday try this again */
|
|
|
// qunlock(&qp->dp->querylck[lcktype]);
|
|
|
|
|
|
nqp = emalloc(sizeof *nqp);
|