Browse Source

Plan 9 from Bell Labs 2007-05-02

David du Colombier 14 years ago
parent
commit
a46c29b439

+ 8 - 6
dist/replica/_plan9.db

@@ -7970,7 +7970,7 @@ sys/src/9/ip/ptclbsum.c - 664 sys sys 1022588099 1243
 sys/src/9/ip/rudp.c - 664 sys sys 1055700790 21415
 sys/src/9/ip/tcp.c - 664 sys sys 1170031827 65877
 sys/src/9/ip/tripmedium.c - 664 sys sys 1045063515 7136
-sys/src/9/ip/udp.c - 664 sys sys 1077376216 13146
+sys/src/9/ip/udp.c - 664 sys sys 1178057621 13132
 sys/src/9/mkfile - 664 sys sys 1063857477 205
 sys/src/9/mtx - 20000000775 sys sys 1123676466 0
 sys/src/9/mtx/clock.c - 664 sys sys 1032053278 1293
@@ -8206,7 +8206,7 @@ sys/src/9/port/portmkfile - 664 sys sys 1173788325 2069
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
 sys/src/9/port/proc.c - 664 sys sys 1176658321 28742
 sys/src/9/port/qio.c - 664 sys sys 1070287837 23562
-sys/src/9/port/qlock.c - 664 sys sys 1139666988 3200
+sys/src/9/port/qlock.c - 664 sys sys 1178057654 3300
 sys/src/9/port/rdb.c - 664 sys sys 1018721202 1698
 sys/src/9/port/rebootcmd.c - 664 sys sys 1015278340 1561
 sys/src/9/port/sd.h - 664 sys sys 1134411408 2494
@@ -12513,15 +12513,15 @@ sys/src/cmd/ip/imap4d/search.c - 664 sys sys 1015013077 4520
 sys/src/cmd/ip/imap4d/store.c - 664 sys sys 1066317059 1910
 sys/src/cmd/ip/imap4d/utils.c - 664 sys sys 1168894057 2587
 sys/src/cmd/ip/ipconfig - 20000000775 sys sys 1176933436 0
-sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1177092388 5536
-sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1177092388 19783
-sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1177541727 37984
+sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1178051838 5666
+sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1178051839 19588
+sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1178051838 37982
 sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1177092388 236
 sys/src/cmd/ip/ipconfig/ppp.c - 664 sys sys 1177092388 1128
 sys/src/cmd/ip/linklocal.c - 664 sys sys 1177099730 867
 sys/src/cmd/ip/measure.c - 664 sys sys 944961011 3733
 sys/src/cmd/ip/mkfile - 664 sys sys 1177479927 1260
-sys/src/cmd/ip/ping.c - 664 sys sys 1175868270 9699
+sys/src/cmd/ip/ping.c - 664 sys sys 1178055342 9699
 sys/src/cmd/ip/ppp - 20000000775 sys sys 1065963823 0
 sys/src/cmd/ip/ppp/block.c - 664 sys sys 1015090266 5353
 sys/src/cmd/ip/ppp/compress.c - 664 sys sys 1072729513 11774
@@ -15812,3 +15812,5 @@ 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/ip/ipconfig - 775 sys sys 1178076139 158720
+386/bin/ip/ping - 775 sys sys 1178076139 84614

+ 8 - 8
dist/replica/plan9.db

@@ -302,9 +302,9 @@
 386/bin/ip/httpd/wikipost - 775 sys sys 1177283321 115228
 386/bin/ip/httpfile - 775 sys sys 1168402324 284262
 386/bin/ip/imap4d - 775 sys sys 1169265834 238152
-386/bin/ip/ipconfig - 775 sys sys 1177557987 158902
+386/bin/ip/ipconfig - 775 sys sys 1178076139 158720
 386/bin/ip/linklocal - 775 sys sys 1177530964 42790
-386/bin/ip/ping - 775 sys sys 1175887160 84684
+386/bin/ip/ping - 775 sys sys 1178076139 84614
 386/bin/ip/ppp - 775 sys sys 1169612026 220423
 386/bin/ip/pppoe - 775 sys sys 1168402326 77787
 386/bin/ip/pptp - 775 sys sys 1169612026 127215
@@ -7970,7 +7970,7 @@ sys/src/9/ip/ptclbsum.c - 664 sys sys 1022588099 1243
 sys/src/9/ip/rudp.c - 664 sys sys 1055700790 21415
 sys/src/9/ip/tcp.c - 664 sys sys 1170031827 65877
 sys/src/9/ip/tripmedium.c - 664 sys sys 1045063515 7136
-sys/src/9/ip/udp.c - 664 sys sys 1077376216 13146
+sys/src/9/ip/udp.c - 664 sys sys 1178057621 13132
 sys/src/9/mkfile - 664 sys sys 1063857477 205
 sys/src/9/mtx - 20000000775 sys sys 1123676466 0
 sys/src/9/mtx/clock.c - 664 sys sys 1032053278 1293
@@ -8206,7 +8206,7 @@ sys/src/9/port/portmkfile - 664 sys sys 1173788325 2069
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
 sys/src/9/port/proc.c - 664 sys sys 1176658321 28742
 sys/src/9/port/qio.c - 664 sys sys 1070287837 23562
-sys/src/9/port/qlock.c - 664 sys sys 1139666988 3200
+sys/src/9/port/qlock.c - 664 sys sys 1178057654 3300
 sys/src/9/port/rdb.c - 664 sys sys 1018721202 1698
 sys/src/9/port/rebootcmd.c - 664 sys sys 1015278340 1561
 sys/src/9/port/sd.h - 664 sys sys 1134411408 2494
@@ -12513,15 +12513,15 @@ sys/src/cmd/ip/imap4d/search.c - 664 sys sys 1015013077 4520
 sys/src/cmd/ip/imap4d/store.c - 664 sys sys 1066317059 1910
 sys/src/cmd/ip/imap4d/utils.c - 664 sys sys 1168894057 2587
 sys/src/cmd/ip/ipconfig - 20000000775 sys sys 1176933436 0
-sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1177092388 5536
-sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1177092388 19783
-sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1177541727 37984
+sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1178051838 5666
+sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1178051839 19588
+sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1178051838 37982
 sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1177092388 236
 sys/src/cmd/ip/ipconfig/ppp.c - 664 sys sys 1177092388 1128
 sys/src/cmd/ip/linklocal.c - 664 sys sys 1177099730 867
 sys/src/cmd/ip/measure.c - 664 sys sys 944961011 3733
 sys/src/cmd/ip/mkfile - 664 sys sys 1177479927 1260
-sys/src/cmd/ip/ping.c - 664 sys sys 1175868270 9699
+sys/src/cmd/ip/ping.c - 664 sys sys 1178055342 9699
 sys/src/cmd/ip/ppp - 20000000775 sys sys 1065963823 0
 sys/src/cmd/ip/ppp/block.c - 664 sys sys 1015090266 5353
 sys/src/cmd/ip/ppp/compress.c - 664 sys sys 1072729513 11774

+ 8 - 0
dist/replica/plan9.log

@@ -48525,3 +48525,11 @@
 1177876816 0 c 386/bin/ndb/dns - 775 sys sys 1177876681 287094
 1177876816 1 c 386/bin/ndb/dnsdebug - 775 sys sys 1177876681 261953
 1177876816 2 c 386/bin/ndb/dnstcp - 775 sys sys 1177876682 260417
+1178053206 0 c sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1178051838 5666
+1178053206 1 c sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1178051839 19588
+1178053206 2 c sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1178051838 37982
+1178056806 0 c sys/src/cmd/ip/ping.c - 664 sys sys 1178055342 9699
+1178058606 0 c sys/src/9/ip/udp.c - 664 sys sys 1178057621 13132
+1178058606 1 c sys/src/9/port/qlock.c - 664 sys sys 1178057654 3300
+1178076606 0 c 386/bin/ip/ipconfig - 775 sys sys 1178076139 158720
+1178076606 1 c 386/bin/ip/ping - 775 sys sys 1178076139 84614

+ 0 - 2
sys/src/9/ip/udp.c

@@ -175,8 +175,6 @@ udpclose(Conv *c)
 
 	ucb = (Udpcb*)c->ptcl;
 	ucb->headers = 0;
-
-	qunlock(c);
 }
 
 void

+ 3 - 0
sys/src/9/port/qlock.c

@@ -68,6 +68,9 @@ qunlock(QLock *q)
 	Proc *p;
 
 	lock(&q->use);
+	if (q->locked == 0)
+		print("qunlock called with qlock not held, from %#p\n",
+			getcallerpc(&q));
 	p = q->head;
 	if(p){
 		q->head = p->qnext;

+ 9 - 11
sys/src/cmd/ip/ipconfig/ipconfig.h

@@ -47,9 +47,9 @@ struct Conf
 	 */
 
 	/* solicitation specific - XXX add support for IPv6 leases */
-	ulong	solicit_retries;
+//	ulong	solicit_retries;
 
-	/* router related */
+	/* router-advertisement related */
 	uchar	sendra;
 	uchar	recvra;
 	uchar	mflag;
@@ -60,19 +60,17 @@ struct Conf
 	int	reachtime;	/* 3,600,000 msec, default 0 */
 	int	rxmitra;	/* default 0 */
 	int	ttl;		/* default 0 (unspecified) */
-
-	/* def gateway params */
+	/* default gateway params */
 	uchar	v6gaddr[IPaddrlen];
 	int	routerlt;	/* router life time */
-	int	force;
 
 	/* prefix related */
 	uchar	v6pref[IPaddrlen];
 	int	prefixlen;
-	uchar	onlink;
-	uchar	autoflag;
-	ulong	validlt;
-	ulong	preflt;
+	uchar	onlink;		/* flag: address is `on-link' */
+	uchar	autoflag;	/* flag: autonomous */
+	ulong	validlt;	/* valid lifetime (seconds) */
+	ulong	preflt;		/* preferred lifetime (seconds) */
 };
 
 struct Ctl
@@ -142,11 +140,11 @@ void	writendb(char*, int, int);
  * IPv6
  */
 
-void	dov6stuff(int);
+void	doipv6(int);
 int	ipconfig6(int);
 void	recvra6(void);
 void	sendra6(void);
-void	v6paraminit(void);
+void	v6paraminit(Conf *);
 
 typedef struct Headers Headers;
 typedef struct Ip4hdr  Ip4hdr;

+ 78 - 54
sys/src/cmd/ip/ipconfig/ipv6.c

@@ -171,25 +171,24 @@ ipv62smcast(uchar *smcast, uchar *a)
 }
 
 void
-v6paraminit(void)
+v6paraminit(Conf *cf)
 {
-	conf.sendra = conf.recvra = 0;
-	conf.mflag = 0;
-	conf.oflag = 0;
-	conf.maxraint = MAX_INIT_RTR_ADVERT_INTVL;
-	conf.minraint = MAX_INIT_RTR_ADVERT_INTVL / 4;
-	conf.linkmtu = 1500;
-	conf.reachtime = REACHABLE_TIME;
-	conf.rxmitra = RETRANS_TIMER;
-	conf.ttl = MAXTTL;
-
-	conf.routerlt = 0;
-	conf.force = 0;
-
-	conf.prefixlen = 64;
-	conf.onlink = 0;
-	conf.autoflag = 0;
-	conf.validlt = conf.preflt = ~0L;
+	cf->sendra = cf->recvra = 0;
+	cf->mflag = 0;
+	cf->oflag = 0;
+	cf->maxraint = MAX_INIT_RTR_ADVERT_INTVL;
+	cf->minraint = MAX_INIT_RTR_ADVERT_INTVL / 4;
+	cf->linkmtu = 1500;
+	cf->reachtime = REACHABLE_TIME;
+	cf->rxmitra = RETRANS_TIMER;
+	cf->ttl = MAXTTL;
+
+	cf->routerlt = 0;
+
+	cf->prefixlen = 64;
+	cf->onlink = 0;
+	cf->autoflag = 0;
+	cf->validlt = cf->preflt = ~0L;
 }
 
 static char*
@@ -482,11 +481,58 @@ recvrarouter(uchar buf[], int pktlen)
 
 /* host receiving a router advertisement calls this */
 
+static void
+ewrite(int fd, char *str)
+{
+	int n;
+
+	n = strlen(str);
+	if (write(fd, str, n) != n)
+		ralog("write(%s) failed: %r", str);
+}
+
+static void
+issuebasera6(Conf *cf)
+{
+	char *cfg;
+
+	cfg = smprint("ra6 mflag %d oflag %d reachtime %d rxmitra %d "
+		"ttl %d routerlt %d",
+		cf->mflag, cf->oflag, cf->reachtime, cf->rxmitra,
+		cf->ttl, cf->routerlt);
+	ewrite(cf->cfd, cfg);
+	free(cfg);
+}
+
+static void
+issuerara6(Conf *cf)
+{
+	char *cfg;
+
+	cfg = smprint("ra6 sendra %d recvra %d maxraint %d minraint %d "
+		"linkmtu %d",
+		cf->sendra, cf->recvra, cf->maxraint, cf->minraint,
+		cf->linkmtu);
+	ewrite(cf->cfd, cfg);
+	free(cfg);
+}
+
+static void
+issueadd6(Conf *cf)
+{
+	char *cfg;
+
+	cfg = smprint("add6 %I %d %d %d %lud %lud", cf->v6pref, cf->prefixlen,
+		cf->onlink, cf->autoflag, cf->validlt, cf->preflt);
+	ewrite(cf->cfd, cfg);
+	free(cfg);
+}
+
 static void
 recvrahost(uchar buf[], int pktlen)
 {
 	int arpfd, m, n;
-	char abuf[100], configcmd[256];
+	char abuf[100];
 	uchar optype;
 	Lladdropt *llao;
 	Mtuopt *mtuo;
@@ -494,8 +540,7 @@ recvrahost(uchar buf[], int pktlen)
 	Routeradv *ra;
 
 	ra = (Routeradv*)buf;
-	memmove(conf.v6gaddr, ra->src, IPaddrlen);
-	conf.force = 0;
+//	memmove(conf.v6gaddr, ra->src, IPaddrlen);
 	conf.ttl = ra->cttl;
 	conf.mflag = (MFMASK & ra->mor);
 	conf.oflag = (OCMASK & ra->mor);
@@ -503,11 +548,10 @@ recvrahost(uchar buf[], int pktlen)
 	conf.reachtime = nhgetl(ra->rchbltime);
 	conf.rxmitra =   nhgetl(ra->rxmtimer);
 
-	n = snprint(configcmd, sizeof configcmd, "%s %I %d %d %d %d %d %d %d",
-		"gate6", conf.v6gaddr, conf.force, conf.ttl, conf.mflag,
-		conf.oflag, conf.routerlt, conf.reachtime, conf.rxmitra);
-	if (write(conf.cfd, configcmd, n) < 0)
-		ralog("write (%s) failed", configcmd);
+	// issueadd6(&conf);	// for conf.v6gaddr?
+	if (fprint(conf.cfd, "ra6 recvra 1") < 0)
+		ralog("write(ra6 recvra 1) failed: %r");
+	issuebasera6(&conf);
 
 	m = sizeof *ra;
 	while (pktlen - m > 0) {
@@ -570,13 +614,7 @@ recvrahost(uchar buf[], int pktlen)
 			conf.autoflag = ((prfo->lar & AFMASK) != 0);
 			conf.validlt = nhgetl(prfo->validlt);
 			conf.preflt =  nhgetl(prfo->preflt);
-			n = snprint(configcmd, sizeof configcmd,
-				"%s %I %d %d %d %uld %uld",
-				"addpref6", conf.v6pref, conf.prefixlen,
-				conf.onlink, conf.autoflag,
-				conf.validlt, conf.preflt);
-			if (write(conf.cfd, configcmd, n) < 0)
-				ralog("write (%s) failed", configcmd);
+			issueadd6(&conf);
 			break;
 		default:
 			m += 8 * buf[m+1];
@@ -866,7 +904,7 @@ sendra6(void)
 }
 
 void
-ra6(void)
+startra6(void)
 {
 	static char routeon[] = "iprouting 1";
 
@@ -885,11 +923,8 @@ ra6(void)
 }
 
 void
-dov6stuff(int what)
+doipv6(int what)
 {
-	char buf[256];
-	int n;
-
 	nip = nipifcs(conf.mpoint);
 	if(!noconfig){
 		lookforip(conf.mpoint);
@@ -900,25 +935,14 @@ dov6stuff(int what)
 	switch (what) {
 	default:
 		fprint(2, "%s: unknown IPv6 verb\n", argv0);
-		break;
+		exits("usage");
 	case Vaddpref6:
-		n = snprint(buf, sizeof buf, "addpref6 %I %d %d %d %uld %uld",
-			conf.v6pref, conf.prefixlen, conf.onlink, conf.autoflag,
-			conf.validlt, conf.preflt);
-		if (write(conf.cfd, buf, n) < n)
-			fprint(2, "%s: write (%s) failed\n", argv0, buf);
+		issueadd6(&conf);
 		break;
 	case Vra6:
-		n = snprint(buf, sizeof buf,
-			"ra6 sendra %d recvra %d mflag %d oflag %d"
-			" maxraint %d minraint %d linkmtu %d reachtime %d"
-			" rxmitra %d ttl %d routerlt %d",
-			conf.sendra, conf.recvra, conf.mflag, conf.oflag,
-			conf.maxraint, conf.minraint, conf.linkmtu,
-			conf.reachtime, conf.rxmitra, conf.ttl, conf.routerlt);
-		if (write(conf.cfd, buf, n) < n)
-			fprint(2, "%s: write (%s) failed\n", argv0, buf);
-		ra6();
+		issuebasera6(&conf);
+		issuerara6(&conf);
+		startra6();
 		break;
 	}
 }

+ 3 - 3
sys/src/cmd/ip/ipconfig/main.c

@@ -164,7 +164,7 @@ char *verbs[] = {
 [Vgbe]		"gbe",
 [Vppp]		"ppp",
 [Vloopback]	"loopback",
-[Vaddpref6]	"addpref6",
+[Vaddpref6]	"add6",
 [Vra6]		"ra6",
 };
 
@@ -352,7 +352,7 @@ init(void)
 		conf.cputype = "386";
 
 	ctll = &firstctl;
-	v6paraminit();
+	v6paraminit(&conf);
 
 	/* init set of requested dhcp parameters with the default */
 	nrequested = sizeof defrequested;
@@ -529,7 +529,7 @@ main(int argc, char **argv)
 		break;
 	case Vaddpref6:
 	case Vra6:
-		dov6stuff(action);
+		doipv6(action);
 		break;
 	}
 	exits(0);

+ 2 - 2
sys/src/cmd/ip/ping.c

@@ -549,8 +549,8 @@ main(int argc, char **argv)
 		msglen = proto->icmphdrsz;
 	if(msglen < 64)
 		msglen = 64;
-	if(msglen >= 65*1024)
-		msglen = 65*1024-1;
+	if(msglen >= 64*1024)
+		msglen = 64*1024-1;
 	if(interval <= 0 && !flood)
 		interval = SLEEPMS;