summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ndb/dnresolve.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2013-11-15 02:00:47 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2013-11-15 02:00:47 +0100
commit5f87d8dcc814700f10f40c10a0225400e4828ef9 (patch)
treef02fdb418247151afe1f22cc7c47e8646bdf5659 /sys/src/cmd/ndb/dnresolve.c
parent2ce68c5aa1bb1691fe05622052d25859e6d6294f (diff)
ndb/dns: various changes
stop absolute/relative dual use of RR.ttl. now RR.ttl is *always* the *relative* ttl value. we derive absolute timeout in RR.expire. remove unused lookuptime field in DN. replace refs and keep with mark field in DN. we do not care about the number of references. only *iff* it is referenced, so use a single bit for that (bit 0). for keep, we use bit 1. remove dolock parameter in dnagenever(), it is not needed. we always need to lock. mark local dns servers and domains as never to be aged. the keeper bit is *just* a cache optimization, preventing the domain and the domains it points to from being flushed. it should not be used as a write protect bit in rrattach() for preventing spoofing as it will prevent updates of say, cname domains. remove "removing spam ..." message. these are usualy just hints, so normal. still, remove the hint as we currently do no check if the nameserver has authority over the cname domain. remove "mydnsquery: trying to send to myself (%s); bzzzt" message. this can happen when myaddr() fails for other reasons. myaddr() will print error for us anyway.
Diffstat (limited to 'sys/src/cmd/ndb/dnresolve.c')
-rw-r--r--sys/src/cmd/ndb/dnresolve.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/sys/src/cmd/ndb/dnresolve.c b/sys/src/cmd/ndb/dnresolve.c
index b21289c2b..6e8709e94 100644
--- a/sys/src/cmd/ndb/dnresolve.c
+++ b/sys/src/cmd/ndb/dnresolve.c
@@ -346,7 +346,7 @@ issuequery(Query *qp, char *name, int class, int depth, int recurse)
nsrp = randomize(rrlookup(nsdp, Tns, NOneg));
/* if the entry timed out, ignore it */
- if(nsrp && nsrp->ttl < now)
+ if(nsrp && !nsrp->db && (long)(nsrp->expire - now) <= 0)
rrfreelistptr(&nsrp);
if(nsrp){
@@ -397,7 +397,7 @@ dnresolve1(char *name, int class, int type, Request *req, int depth,
}
} else
/* cached entry must still be valid */
- if(rp->ttl > now)
+ if((long)(rp->expire - now) > 0)
/* but Tall entries are special */
if(type != Tall || rp->query == Tall) {
noteinmem();
@@ -850,7 +850,7 @@ cacheneg(DN *dp, int type, int rcode, RR *soarr)
/* the attach can cause soarr to be freed so mine it now */
if(soarr != nil && soarr->soa != nil)
- ttl = soarr->soa->minttl+now;
+ ttl = soarr->soa->minttl;
else
ttl = 5*Min;
@@ -893,11 +893,8 @@ mydnsquery(Query *qp, int medium, uchar *udppkt, int len)
rv = -1;
snprint(domain, sizeof(domain), "%I", udppkt);
- if (myaddr(domain)) {
- dnslog("mydnsquery: trying to send to myself (%s); bzzzt",
- domain);
+ if (myaddr(domain))
return rv;
- }
switch (medium) {
case Udp:
nfd = dup(qp->udpfd, -1);
@@ -1094,13 +1091,11 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
if(mp->an){
/*
* only use cname answer when returned. some dns servers
- * attach spam address records which poisons the cache.
+ * attach (potential) spam hint address records which poisons the cache.
*/
if((tp = rrremtype(&mp->an, Tcname)) != 0){
- if(mp->an){
- dnslog("removing spam %Q for %Q from %I", mp->an, tp, srcip);
+ if(mp->an)
rrfreelist(mp->an);
- }
mp->an = tp;
}
rrattach(mp->an, (mp->flags & Fauth) != 0);