Browse Source

Plan 9 from Bell Labs 2007-04-29

David du Colombier 14 years ago
parent
commit
6da756a6cd

+ 7 - 7
dist/replica/_plan9.db

@@ -397,7 +397,7 @@
 386/bin/sam - 775 sys sys 1168633586 159364
 386/bin/scat - 775 sys sys 1176520494 284766
 386/bin/scp - 775 sys sys 1176520495 152584
-386/bin/scuzz - 775 sys sys 1176520495 113699
+386/bin/scuzz - 775 sys sys 1177730506 115274
 386/bin/sed - 775 sys sys 1168402348 89763
 386/bin/seq - 775 sys sys 1162241047 38441
 386/bin/sha1sum - 775 sys sys 1168402348 61366
@@ -5480,7 +5480,7 @@ rc/bin/delkey - 775 sys sys 1109429137 643
 rc/bin/dial - 20000000775 sys sys 1059180057 0
 rc/bin/diffy - 775 sys sys 1140694870 277
 rc/bin/dircp - 775 sys sys 1169490692 234
-rc/bin/diskparts - 775 sys sys 1176151301 559
+rc/bin/diskparts - 775 sys sys 1177742148 605
 rc/bin/doc2ps - 775 sys sys 1069793831 244
 rc/bin/doc2txt - 775 sys sys 1025197880 563
 rc/bin/doctype - 775 sys sys 1162921755 1727
@@ -5488,7 +5488,7 @@ rc/bin/dosmnt - 775 sys sys 1109288224 303
 rc/bin/eject - 775 sys sys 945617207 123
 rc/bin/fax - 775 sys sys 1127394677 2385
 rc/bin/fedex - 775 sys sys 1060187356 1244
-rc/bin/fshalt - 775 sys sys 1173737783 1652
+rc/bin/fshalt - 775 sys sys 1177742142 1658
 rc/bin/homespool - 775 sys sys 945617207 339
 rc/bin/ipconf - 20000000775 sys sys 1058791152 0
 rc/bin/ipconf/inside - 775 sys sys 1058790955 427
@@ -7730,7 +7730,7 @@ sys/man/6/mnihongo - 664 sys sys 1158064572 716
 sys/man/6/mpictures - 664 sys sys 944959678 2899
 sys/man/6/ms - 664 sys sys 958249504 6815
 sys/man/6/namespace - 664 sys sys 1048637182 1576
-sys/man/6/ndb - 664 sys sys 1177100292 6745
+sys/man/6/ndb - 664 sys sys 1177742177 6776
 sys/man/6/plot - 664 sys sys 944959679 6739
 sys/man/6/plumb - 664 sys sys 969499892 10918
 sys/man/6/regexp - 664 sys sys 954089523 2050
@@ -12797,11 +12797,11 @@ sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1175901582 11659
 sys/src/cmd/ndb/cs.c - 664 sys sys 1176931848 33123
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1174626119 1073
 sys/src/cmd/ndb/dblookup.c - 664 sys sys 1175901604 21010
-sys/src/cmd/ndb/dn.c - 664 sys sys 1175925585 32939
+sys/src/cmd/ndb/dn.c - 664 sys sys 1177811830 32939
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1175664421 2519
 sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1175901450 3147
 sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1176837575 30062
-sys/src/cmd/ndb/dns.c - 664 sys sys 1175901186 16013
+sys/src/cmd/ndb/dns.c - 664 sys sys 1177811831 16021
 sys/src/cmd/ndb/dns.h - 664 sys sys 1175901645 10640
 sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1176746985 8741
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1175901160 4392
@@ -15812,4 +15812,4 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-386/bin/scuzz - 775 sys sys 1177730506 115274
+386/bin/ndb/dns - 775 sys sys 1177816951 286892

+ 6 - 6
dist/replica/plan9.db

@@ -341,7 +341,7 @@
 386/bin/ndb - 20000000775 sys sys 985743147 0
 386/bin/ndb/cs - 775 sys sys 1176488417 150835
 386/bin/ndb/csquery - 775 sys sys 1176488418 61652
-386/bin/ndb/dns - 775 sys sys 1176866482 286892
+386/bin/ndb/dns - 775 sys sys 1177816951 286892
 386/bin/ndb/dnsdebug - 775 sys sys 1176866483 261751
 386/bin/ndb/dnsquery - 775 sys sys 1174704818 64417
 386/bin/ndb/dnstcp - 775 sys sys 1176866483 260215
@@ -5480,7 +5480,7 @@ rc/bin/delkey - 775 sys sys 1109429137 643
 rc/bin/dial - 20000000775 sys sys 1059180057 0
 rc/bin/diffy - 775 sys sys 1140694870 277
 rc/bin/dircp - 775 sys sys 1169490692 234
-rc/bin/diskparts - 775 sys sys 1176151301 559
+rc/bin/diskparts - 775 sys sys 1177742148 605
 rc/bin/doc2ps - 775 sys sys 1069793831 244
 rc/bin/doc2txt - 775 sys sys 1025197880 563
 rc/bin/doctype - 775 sys sys 1162921755 1727
@@ -5488,7 +5488,7 @@ rc/bin/dosmnt - 775 sys sys 1109288224 303
 rc/bin/eject - 775 sys sys 945617207 123
 rc/bin/fax - 775 sys sys 1127394677 2385
 rc/bin/fedex - 775 sys sys 1060187356 1244
-rc/bin/fshalt - 775 sys sys 1173737783 1652
+rc/bin/fshalt - 775 sys sys 1177742142 1658
 rc/bin/homespool - 775 sys sys 945617207 339
 rc/bin/ipconf - 20000000775 sys sys 1058791152 0
 rc/bin/ipconf/inside - 775 sys sys 1058790955 427
@@ -7730,7 +7730,7 @@ sys/man/6/mnihongo - 664 sys sys 1158064572 716
 sys/man/6/mpictures - 664 sys sys 944959678 2899
 sys/man/6/ms - 664 sys sys 958249504 6815
 sys/man/6/namespace - 664 sys sys 1048637182 1576
-sys/man/6/ndb - 664 sys sys 1177100292 6745
+sys/man/6/ndb - 664 sys sys 1177742177 6776
 sys/man/6/plot - 664 sys sys 944959679 6739
 sys/man/6/plumb - 664 sys sys 969499892 10918
 sys/man/6/regexp - 664 sys sys 954089523 2050
@@ -12797,11 +12797,11 @@ sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1175901582 11659
 sys/src/cmd/ndb/cs.c - 664 sys sys 1176931848 33123
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1174626119 1073
 sys/src/cmd/ndb/dblookup.c - 664 sys sys 1175901604 21010
-sys/src/cmd/ndb/dn.c - 664 sys sys 1175925585 32939
+sys/src/cmd/ndb/dn.c - 664 sys sys 1177811830 32939
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1175664421 2519
 sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1175901450 3147
 sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1176837575 30062
-sys/src/cmd/ndb/dns.c - 664 sys sys 1175901186 16013
+sys/src/cmd/ndb/dns.c - 664 sys sys 1177811831 16021
 sys/src/cmd/ndb/dns.h - 664 sys sys 1175901645 10640
 sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1176746985 8741
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1175901160 4392

+ 6 - 0
dist/replica/plan9.log

@@ -48515,3 +48515,9 @@
 1177704005 0 c sys/src/cmd/scuzz/scsireq.c - 664 sys sys 1177702327 13464
 1177707605 0 c rc/bin/termrc - 775 sys sys 1177705963 2281
 1177731006 0 c 386/bin/scuzz - 775 sys sys 1177730506 115274
+1177743607 0 c rc/bin/fshalt - 775 sys sys 1177742142 1658
+1177743607 1 c rc/bin/diskparts - 775 sys sys 1177742148 605
+1177743607 2 c sys/man/6/ndb - 664 sys sys 1177742177 6776
+1177812011 0 c sys/src/cmd/ndb/dn.c - 664 sys sys 1177811830 32939
+1177812011 1 c sys/src/cmd/ndb/dns.c - 664 sys sys 1177811831 16021
+1177817412 0 c 386/bin/ndb/dns - 775 sys sys 1177816951 286892

+ 2 - 0
rc/bin/diskparts

@@ -16,6 +16,8 @@ for(disk in /dev/sd[0-9A-Zabd-z]*) {
 sysname=`{cat /dev/sysname}
 
 # set up any fs(3) partitions
+if (! test -e /dev/fs/ctl)
+	bind -a '#k' /dev
 if (~ $#sysname 1 && ! ~ $sysname '' &&
     test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
 	read -m /cfg/$sysname/fsconfig >/dev/fs/ctl

+ 2 - 2
rc/bin/fshalt

@@ -23,7 +23,7 @@ f=`{ls /srv/fscons*>[2]/dev/null}
 k=`{ls /srv/kfs*cmd >[2]/dev/null|sort -r}
 
 echo -n syncing...
-for(i in $f){
+for(i in $f) @ {
 	echo -n $i...
 	{
 		echo
@@ -68,7 +68,7 @@ bind /tmp /bin
 fn x {
 	echo
 	echo -n halting...
-	for(i in $f){
+	for(i in $f) @ {
 		echo -n $i...
 		{
 			echo fsys all halt

+ 2 - 2
sys/man/6/ndb

@@ -158,10 +158,10 @@ They are:
 .TF dnsdomain
 .TP
 .B sys
-system name
+system name (a short name)
 .TP
 .B dom
-Internet domain name
+Internet fully-qualified domain name
 .TP
 .B ip
 Internet address,

+ 1 - 1
sys/src/cmd/ndb/dn.c

@@ -287,7 +287,7 @@ upref(DN *dp)
  *  about 1780 names, so 4000 is not a lot.
  */
 enum {
-	Deftarget = 8000,
+	Deftarget = 6000,
 };
 
 ulong target = Deftarget;

+ 55 - 37
sys/src/cmd/ndb/dnresolve.c

@@ -232,7 +232,7 @@ static void
 queryinit(Query *qp, DN *dp, int type, Request *req)
 {
 	memset(qp, 0, sizeof *qp);
-	qp->udpfd = -1;
+	qp->udpfd = qp->tcpfd = qp->tcpctlfd = -1;
 	qp->dp = dp;
 	qp->type = type;
 	qp->req = req;
@@ -248,6 +248,22 @@ queryck(Query *qp)
 	assert(qp->magic == Querymagic);
 }
 
+static void
+querydestroy(Query *qp)
+{
+	queryck(qp);
+	if (qp->udpfd > 0)
+		close(qp->udpfd);
+	if (qp->tcpfd > 0)
+		close(qp->tcpfd);
+	if (qp->tcpctlfd > 0) {
+		hangup(qp->tcpctlfd);
+		close(qp->tcpctlfd);
+	}
+	memset(qp, 0, sizeof *qp);	/* prevent accidents */
+	qp->udpfd = qp->tcpfd = qp->tcpctlfd = -1;
+}
+
 static void
 destinit(Dest *p)
 {
@@ -322,8 +338,7 @@ dnresolve1(char *name, int class, int type, Request *req, int depth,
 			query.nsrp = nsrp;
 			if(netquery(&query, depth+1)){
 				rrfreelist(nsrp);
-				/* prevent accidents */
-				memset(&query, 0, sizeof query);
+				querydestroy(&query);
 				return rrlookup(dp, type, OKneg);
 			}
 			rrfreelist(nsrp);
@@ -343,8 +358,7 @@ dnresolve1(char *name, int class, int type, Request *req, int depth,
 		if(dbnsrp && dbnsrp->local){
 			rp = dblookup(name, class, type, 1, dbnsrp->ttl);
 			rrfreelist(dbnsrp);
-			/* prevent accidents */
-			memset(&query, 0, sizeof query);
+			querydestroy(&query);
 			return rp;
 		}
 
@@ -377,8 +391,7 @@ dnresolve1(char *name, int class, int type, Request *req, int depth,
 			query.nsrp = nsrp;
 			if(netquery(&query, depth+1)){
 				rrfreelist(nsrp);
-				/* prevent accidents */
-				memset(&query, 0, sizeof query);
+				querydestroy(&query);
 				return rrlookup(dp, type, OKneg);
 			}
 			rrfreelist(nsrp);
@@ -392,14 +405,13 @@ dnresolve1(char *name, int class, int type, Request *req, int depth,
 			if(netquery(&query, depth+1)){
 				/* we got an answer */
 				rrfreelist(dbnsrp);
-				/* prevent accidents */
-				memset(&query, 0, sizeof query);
+				querydestroy(&query);
 				return rrlookup(dp, type, NOneg);
 			}
 			rrfreelist(dbnsrp);
 		}
 	}
-	memset(&query, 0, sizeof query);	/* prevent accidents */
+	querydestroy(&query);
 
 	/* settle for a non-authoritative answer */
 	rp = rrlookup(dp, type, OKneg);
@@ -524,13 +536,21 @@ readnet(Query *qp, int medium, uchar *ibuf, ulong endtime, uchar **replyp,
 	/* timed read of reply */
 	alarm((endtime - time(nil)) * 1000);
 	reply = ibuf;
+	len = -1;			/* pessimism */
+	memset(srcip, 0, IPaddrlen);
 	if (medium == Udp) {
-		len = read(qp->udpfd, ibuf, OUdphdrsize+Maxudpin);
-		len -= OUdphdrsize;
-		memmove(srcip, ibuf, IPaddrlen);
-		reply += OUdphdrsize;
+		if (qp->udpfd <= 0) 
+			dnslog("readnet: qp->udpfd closed");
+		else {
+			len = read(qp->udpfd, ibuf, OUdphdrsize+Maxudpin);
+			if (len >= IPaddrlen)
+				memmove(srcip, ibuf, IPaddrlen);
+			if (len >= OUdphdrsize) {
+				len   -= OUdphdrsize;
+				reply += OUdphdrsize;
+			}
+		}
 	} else {
-		len = -1;			/* pessimism */
 		if (!qp->tcpset)
 			dnslog("readnet: tcp params not set");
 		fd = qp->tcpfd;
@@ -820,9 +840,14 @@ mydnsquery(Query *qp, int medium, uchar *udppkt, int len)
 	queryck(qp);
 	switch (medium) {
 	case Udp:
-		if(write(qp->udpfd, udppkt, len+OUdphdrsize) != len+OUdphdrsize)
-			warning("sending udp msg %r");
-		rv = 0;
+		if (qp->udpfd <= 0)
+			dnslog("mydnsquery: qp->udpfd closed");
+		else {
+			if (write(qp->udpfd, udppkt, len+OUdphdrsize) !=
+			    len+OUdphdrsize)
+				warning("sending udp msg %r");
+			rv = 0;
+		}
 		break;
 	case Tcp:
 		/* send via TCP & keep fd around for reply */
@@ -871,8 +896,6 @@ xmitquery(Query *qp, int medium, int depth, uchar *obuf, int inns, int len)
 	Dest *p;
 
 	queryck(qp);
-//	dnslog("xmitquery xmit loop: now %ld aborttime %ld", time(nil),
-//		qp->req->aborttime);
 	if(time(nil) >= qp->req->aborttime)
 		return -1;
 
@@ -897,7 +920,8 @@ xmitquery(Query *qp, int medium, int depth, uchar *obuf, int inns, int len)
 				if (setdestoutns(qp->curdest, n) < 0)
 					break;
 		} else {
-			dnslog("xmitquery: %s: no nameservers", qp->dp->name);
+			/* it's probably just a bogus domain, don't log it */
+			// dnslog("xmitquery: %s: no nameservers", qp->dp->name);
 			return -1;
 		}
 
@@ -1039,7 +1063,7 @@ procansw(Query *qp, DNSmsg *mp, uchar *srcip, int depth, Dest *p)
 
 //	qlock(&qp->dp->querylck);
 	rrfreelist(tp);
-	memset(&nquery, 0, sizeof nquery); /* prevent accidents */
+	querydestroy(&nquery);
 	return rv;
 }
 
@@ -1051,25 +1075,22 @@ static int
 tcpquery(Query *qp, DNSmsg *mp, int depth, uchar *ibuf, uchar *obuf, int len,
 	int waitsecs, int inns, ushort req)
 {
+	int rv = 0;
 	ulong endtime;
 
 	endtime = time(nil) + waitsecs;
 	if(endtime > qp->req->aborttime)
 		endtime = qp->req->aborttime;
 
+	dnslog("%s: udp reply truncated; retrying query via tcp to %I",
+		qp->dp->name, qp->tcpip);
+
 	qlock(&qp->tcplock);
 	memmove(obuf, ibuf, IPaddrlen);		/* send back to respondent */
 	/* sets qp->tcpip from obuf's udp header */
-	if (xmitquery(qp, Tcp, depth, obuf, inns, len) < 0) {
-		qunlock(&qp->tcplock);
-		return -1;
-	}
-	dnslog("%s: udp reply truncated; retrying query via tcp to %I",
-		qp->dp->name, qp->tcpip);
-	if (readreply(qp, Tcp, req, ibuf, mp, endtime) < 0) {
-		qunlock(&qp->tcplock);
-		return -1;
-	}
+	if (xmitquery(qp, Tcp, depth, obuf, inns, len) < 0 ||
+	    readreply(qp, Tcp, req, ibuf, mp, endtime) < 0)
+		rv = -1;
 	if (qp->tcpfd > 0) {
 		hangup(qp->tcpctlfd);
 		close(qp->tcpctlfd);
@@ -1077,10 +1098,7 @@ tcpquery(Query *qp, DNSmsg *mp, int depth, uchar *ibuf, uchar *obuf, int len,
 	}
 	qp->tcpfd = qp->tcpctlfd = -1;
 	qunlock(&qp->tcplock);
-
-//	dnslog("%s: %s answer by tcp", qp->dp->name,
-//		(mp->an? "got": "didn't get"));
-	return 0;
+	return rv;
 }
 
 /*
@@ -1352,6 +1370,6 @@ seerootns(void)
 	queryinit(&query, dnlookup(root, Cin, 1), Tns, &req);
 	query.nsrp = dblookup(root, Cin, Tns, 0, 0);
 	rv = netquery(&query, 0);
-	memset(&query, 0, sizeof query);	/* prevent accidents */
+	querydestroy(&query);
 	return rv;
 }

+ 1 - 1
sys/src/cmd/ndb/dns.c

@@ -15,7 +15,7 @@ enum
 	Maxrrr=			32,		/* was 16 */
 	Maxfdata=		8192,
 
-	Defmaxage=		3*60*60,	/* tune; was 1 hour */
+	Defmaxage=		60*60,		/* tunable; was 1 then 3 hrs */
 
 	Qdir=			0,
 	Qdns=			1,