ndb/dns: purge db records on refresh for resolvers, remove old debug and testing code
when ndb/dns runs as a resolver only (cfg.cachedb == 0), we still want to purge the "local#" db records to reread dns server configuration or react to changed ip addresses. removing old poolcheck and dncheck code, these bugs have been fixed a long time ago.
This commit is contained in:
parent
4821c261c4
commit
2dc97202de
4 changed files with 12 additions and 84 deletions
|
@ -579,23 +579,6 @@ doaxfr(Ndb *db, char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* read the all the soa's from the database to determine area's.
|
|
||||||
* this is only used when we're not caching the database.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
dbfile2area(Ndb *db)
|
|
||||||
{
|
|
||||||
Ndbtuple *t;
|
|
||||||
|
|
||||||
if(debug)
|
|
||||||
dnslog("rereading %s", db->file);
|
|
||||||
Bseek(&db->b, 0, 0);
|
|
||||||
while(t = ndbparse(db))
|
|
||||||
ndbfree(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read the database into the cache
|
* read the database into the cache
|
||||||
*/
|
*/
|
||||||
|
@ -750,23 +733,23 @@ db2cache(int doit)
|
||||||
/* reload straddle-server configuration */
|
/* reload straddle-server configuration */
|
||||||
loaddomsrvs();
|
loaddomsrvs();
|
||||||
|
|
||||||
if(cfg.cachedb){
|
/* mark all db records as timed out */
|
||||||
/* mark all db records as timed out */
|
dnagedb();
|
||||||
dnagedb();
|
|
||||||
|
|
||||||
|
if(cfg.cachedb){
|
||||||
/* read in new entries */
|
/* read in new entries */
|
||||||
for(ndb = db; ndb; ndb = ndb->next)
|
for(ndb = db; ndb; ndb = ndb->next)
|
||||||
dbfile2cache(ndb);
|
dbfile2cache(ndb);
|
||||||
|
}
|
||||||
|
|
||||||
/* mark as authoritative anything in our domain */
|
/*
|
||||||
dnauthdb();
|
* mark as authoritative anything in our domain,
|
||||||
|
* delete timed out db records
|
||||||
|
*/
|
||||||
|
dnauthdb();
|
||||||
|
|
||||||
/* remove old entries */
|
/* remove old entries */
|
||||||
dnageall(1);
|
dnageall(1);
|
||||||
} else
|
|
||||||
/* read all the soa's to get database defaults */
|
|
||||||
for(ndb = db; ndb; ndb = ndb->next)
|
|
||||||
dbfile2area(ndb);
|
|
||||||
|
|
||||||
doit = 0;
|
doit = 0;
|
||||||
lastyoungest = youngest;
|
lastyoungest = youngest;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include <pool.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
|
|
||||||
|
@ -702,15 +701,10 @@ putactivity(int recursive)
|
||||||
}
|
}
|
||||||
unlock(&dnvars);
|
unlock(&dnvars);
|
||||||
|
|
||||||
dncheck();
|
|
||||||
|
|
||||||
db2cache(needrefresh);
|
db2cache(needrefresh);
|
||||||
dncheck();
|
|
||||||
|
|
||||||
dnageall(0);
|
dnageall(0);
|
||||||
|
|
||||||
dncheck();
|
|
||||||
|
|
||||||
/* let others back in */
|
/* let others back in */
|
||||||
lastclean = now;
|
lastclean = now;
|
||||||
needrefresh = 0;
|
needrefresh = 0;
|
||||||
|
@ -1548,39 +1542,6 @@ slave(Request *req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* chasing down double free's
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
dncheck(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
DN *dp;
|
|
||||||
RR *rp;
|
|
||||||
|
|
||||||
if(!testing)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock(&dnlock);
|
|
||||||
poolcheck(mainmem);
|
|
||||||
for(i = 0; i < HTLEN; i++)
|
|
||||||
for(dp = ht[i]; dp; dp = dp->next){
|
|
||||||
assert(dp->magic == DNmagic);
|
|
||||||
for(rp = dp->rr; rp; rp = rp->next){
|
|
||||||
assert(rp->magic == RRmagic);
|
|
||||||
assert(rp->cached);
|
|
||||||
assert(rp->owner == dp);
|
|
||||||
/* also check for duplicate rrs */
|
|
||||||
if (rronlist(rp, rp->next)) {
|
|
||||||
dnslog("%R duplicates its next chain "
|
|
||||||
"(%R); aborting", rp, rp->next);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unlock(&dnlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rrequiv(RR *r1, RR *r2)
|
rrequiv(RR *r1, RR *r2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <fcall.h>
|
#include <fcall.h>
|
||||||
#include <bio.h>
|
#include <bio.h>
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
#include <pool.h>
|
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -69,7 +68,6 @@ int needrefresh;
|
||||||
ulong now;
|
ulong now;
|
||||||
vlong nowns;
|
vlong nowns;
|
||||||
int sendnotifies;
|
int sendnotifies;
|
||||||
int testing;
|
|
||||||
char *trace;
|
char *trace;
|
||||||
int traceactivity;
|
int traceactivity;
|
||||||
char *zonerefreshprogram;
|
char *zonerefreshprogram;
|
||||||
|
@ -107,7 +105,7 @@ static char *respond(Job*, Mfile*, RR*, char*, int, int);
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: %s [-FnorRst] [-a maxage] [-f ndb-file] [-N target] "
|
fprint(2, "usage: %s [-FnorRs] [-a maxage] [-f ndb-file] [-N target] "
|
||||||
"[-T forwip] [-x netmtpt] [-z refreshprog]\n", argv0);
|
"[-T forwip] [-x netmtpt] [-z refreshprog]\n", argv0);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
@ -158,9 +156,6 @@ main(int argc, char *argv[])
|
||||||
cfg.serve = 1; /* serve network */
|
cfg.serve = 1; /* serve network */
|
||||||
cfg.cachedb = 1;
|
cfg.cachedb = 1;
|
||||||
break;
|
break;
|
||||||
case 't':
|
|
||||||
testing = 1;
|
|
||||||
break;
|
|
||||||
case 'T':
|
case 'T':
|
||||||
addforwtarg(EARGF(usage()));
|
addforwtarg(EARGF(usage()));
|
||||||
break;
|
break;
|
||||||
|
@ -178,9 +173,6 @@ main(int argc, char *argv[])
|
||||||
if(argc != 0)
|
if(argc != 0)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if(testing)
|
|
||||||
mainmem->flags |= POOL_NOREUSE | POOL_ANTAGONISM;
|
|
||||||
mainmem->flags |= POOL_ANTAGONISM;
|
|
||||||
rfork(RFREND|RFNOTEG);
|
rfork(RFREND|RFNOTEG);
|
||||||
|
|
||||||
cfg.inside = (*mntpt == '\0' || strcmp(mntpt, "/net") == 0);
|
cfg.inside = (*mntpt == '\0' || strcmp(mntpt, "/net") == 0);
|
||||||
|
@ -206,9 +198,6 @@ main(int argc, char *argv[])
|
||||||
sysfatal("%s exists; another dns instance is running",
|
sysfatal("%s exists; another dns instance is running",
|
||||||
servefile);
|
servefile);
|
||||||
free(dir);
|
free(dir);
|
||||||
// unmount(servefile, mntpt);
|
|
||||||
// remove(servefile);
|
|
||||||
|
|
||||||
mountinit(servefile, mntpt); /* forks, parent exits */
|
mountinit(servefile, mntpt); /* forks, parent exits */
|
||||||
|
|
||||||
srand(now*getpid());
|
srand(now*getpid());
|
||||||
|
@ -733,12 +722,8 @@ rwrite(Job *job, Mfile *mf, Request *req)
|
||||||
send = 1;
|
send = 1;
|
||||||
if(strcmp(job->request.data, "debug")==0)
|
if(strcmp(job->request.data, "debug")==0)
|
||||||
debug ^= 1;
|
debug ^= 1;
|
||||||
else if(strcmp(job->request.data, "testing")==0)
|
|
||||||
testing ^= 1;
|
|
||||||
else if(strcmp(job->request.data, "dump")==0)
|
else if(strcmp(job->request.data, "dump")==0)
|
||||||
dndump("/lib/ndb/dnsdump");
|
dndump("/lib/ndb/dnsdump");
|
||||||
else if(strcmp(job->request.data, "poolcheck")==0)
|
|
||||||
poolcheck(mainmem);
|
|
||||||
else if(strcmp(job->request.data, "refresh")==0)
|
else if(strcmp(job->request.data, "refresh")==0)
|
||||||
needrefresh = 1;
|
needrefresh = 1;
|
||||||
else if(strcmp(job->request.data, "restart")==0)
|
else if(strcmp(job->request.data, "restart")==0)
|
||||||
|
|
|
@ -448,7 +448,6 @@ void dnageall(int);
|
||||||
void dnagedb(void);
|
void dnagedb(void);
|
||||||
void dnagenever(DN *);
|
void dnagenever(DN *);
|
||||||
void dnauthdb(void);
|
void dnauthdb(void);
|
||||||
void dncheck(void);
|
|
||||||
void dndump(char*);
|
void dndump(char*);
|
||||||
void dnget(void);
|
void dnget(void);
|
||||||
void dninit(void);
|
void dninit(void);
|
||||||
|
|
Loading…
Reference in a new issue