Browse Source

Plan 9 from Bell Labs 2006-10-06

David du Colombier 14 years ago
parent
commit
b6b27a1d0b

+ 8 - 8
dist/replica/_plan9.db

@@ -284,7 +284,7 @@
 386/bin/iostats - 775 sys sys 1148500650 100476
 386/bin/ip - 20000000775 sys sys 1016920851 0
 386/bin/ip/dhcpclient - 775 sys sys 1148500650 94471
-386/bin/ip/dhcpd - 775 sys sys 1157916202 150774
+386/bin/ip/dhcpd - 775 sys sys 1160103260 151069
 386/bin/ip/dhcpleases - 775 sys sys 1148500652 86543
 386/bin/ip/ftpd - 775 sys sys 1148500653 170760
 386/bin/ip/gizzard - 775 sys sys 1081480408 101521
@@ -7711,7 +7711,7 @@ sys/man/8/booting - 664 sys sys 1015024984 4136
 sys/man/8/checkarenas - 664 sys sys 1019866709 669
 sys/man/8/cpurc - 664 sys sys 971455510 1275
 sys/man/8/cron - 664 sys sys 1063858596 1867
-sys/man/8/dhcpd - 664 sys sys 1032654987 5237
+sys/man/8/dhcpd - 664 sys sys 1160071627 5460
 sys/man/8/disksim - 664 sys sys 1144150487 1476
 sys/man/8/drawterm - 664 sys sys 1135901219 1741
 sys/man/8/fossilcons - 664 sys sys 1155362671 18291
@@ -7969,16 +7969,16 @@ sys/src/9/pc/dma.c - 664 sys sys 1142966373 5332
 sys/src/9/pc/ether2000.c - 664 sys sys 1089299187 4819
 sys/src/9/pc/ether2114x.c - 664 sys sys 1145359795 41693
 sys/src/9/pc/ether589.c - 664 sys sys 1015014516 4644
-sys/src/9/pc/ether79c970.c - 664 sys sys 1131290338 13953
+sys/src/9/pc/ether79c970.c - 664 sys sys 1160070602 14088
 sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
-sys/src/9/pc/ether8139.c - 664 sys sys 1131290376 18400
-sys/src/9/pc/ether8169.c - 664 sys sys 1156429147 25232
+sys/src/9/pc/ether8139.c - 664 sys sys 1160066369 18561
+sys/src/9/pc/ether8169.c - 664 sys sys 1160066369 25393
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1131290377 32294
 sys/src/9/pc/ether82557.c - 664 sys sys 1153082663 30197
 sys/src/9/pc/ether83815.c - 664 sys sys 1140271743 26125
 sys/src/9/pc/ether8390.c - 664 sys sys 1131290377 17702
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
-sys/src/9/pc/etherdp83820.c - 664 sys sys 1134042756 29166
+sys/src/9/pc/etherdp83820.c - 664 sys sys 1160069116 29352
 sys/src/9/pc/etherec2t.c - 664 sys sys 1135784135 4092
 sys/src/9/pc/etherelnk3.c - 664 sys sys 1158012427 48807
 sys/src/9/pc/etherga620.c - 664 sys sys 1134390125 28760
@@ -7990,7 +7990,7 @@ sys/src/9/pc/ethermii.h - 664 sys sys 1086873891 3258
 sys/src/9/pc/etherrhine.c - 664 sys sys 1081706478 13799
 sys/src/9/pc/ethersink.c - 664 sys sys 1048644103 1076
 sys/src/9/pc/ethersmc.c - 664 sys sys 1071245461 15103
-sys/src/9/pc/ethervgbe.c - 664 sys sys 1138114457 26558
+sys/src/9/pc/ethervgbe.c - 664 sys sys 1160066496 26838
 sys/src/9/pc/ethervt6102.c - 664 sys sys 1131907459 22286
 sys/src/9/pc/etherwavelan.c - 664 sys sys 1131290380 3747
 sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
@@ -12313,7 +12313,7 @@ sys/src/cmd/ip/dhcpclient.c - 664 sys sys 1050714660 11978
 sys/src/cmd/ip/dhcpd - 20000000775 sys sys 988249979 0
 sys/src/cmd/ip/dhcpd/dat.h - 664 sys sys 1084471353 2522
 sys/src/cmd/ip/dhcpd/db.c - 664 sys sys 1143670612 7466
-sys/src/cmd/ip/dhcpd/dhcpd.c - 664 sys sys 1084471366 32795
+sys/src/cmd/ip/dhcpd/dhcpd.c - 664 sys sys 1160071607 33096
 sys/src/cmd/ip/dhcpd/dhcpleases.c - 664 sys sys 1032655001 779
 sys/src/cmd/ip/dhcpd/mkfile - 664 sys sys 1063897571 433
 sys/src/cmd/ip/dhcpd/ndb.c - 664 sys sys 1084471375 6063

+ 8 - 8
dist/replica/plan9.db

@@ -284,7 +284,7 @@
 386/bin/iostats - 775 sys sys 1148500650 100476
 386/bin/ip - 20000000775 sys sys 1016920851 0
 386/bin/ip/dhcpclient - 775 sys sys 1148500650 94471
-386/bin/ip/dhcpd - 775 sys sys 1157916202 150774
+386/bin/ip/dhcpd - 775 sys sys 1160103260 151069
 386/bin/ip/dhcpleases - 775 sys sys 1148500652 86543
 386/bin/ip/ftpd - 775 sys sys 1148500653 170760
 386/bin/ip/gizzard - 775 sys sys 1081480408 101521
@@ -7711,7 +7711,7 @@ sys/man/8/booting - 664 sys sys 1015024984 4136
 sys/man/8/checkarenas - 664 sys sys 1019866709 669
 sys/man/8/cpurc - 664 sys sys 971455510 1275
 sys/man/8/cron - 664 sys sys 1063858596 1867
-sys/man/8/dhcpd - 664 sys sys 1032654987 5237
+sys/man/8/dhcpd - 664 sys sys 1160071627 5460
 sys/man/8/disksim - 664 sys sys 1144150487 1476
 sys/man/8/drawterm - 664 sys sys 1135901219 1741
 sys/man/8/fossilcons - 664 sys sys 1155362671 18291
@@ -7969,16 +7969,16 @@ sys/src/9/pc/dma.c - 664 sys sys 1142966373 5332
 sys/src/9/pc/ether2000.c - 664 sys sys 1089299187 4819
 sys/src/9/pc/ether2114x.c - 664 sys sys 1145359795 41693
 sys/src/9/pc/ether589.c - 664 sys sys 1015014516 4644
-sys/src/9/pc/ether79c970.c - 664 sys sys 1131290338 13953
+sys/src/9/pc/ether79c970.c - 664 sys sys 1160070602 14088
 sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
-sys/src/9/pc/ether8139.c - 664 sys sys 1131290376 18400
-sys/src/9/pc/ether8169.c - 664 sys sys 1156429147 25232
+sys/src/9/pc/ether8139.c - 664 sys sys 1160066369 18561
+sys/src/9/pc/ether8169.c - 664 sys sys 1160066369 25393
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1131290377 32294
 sys/src/9/pc/ether82557.c - 664 sys sys 1153082663 30197
 sys/src/9/pc/ether83815.c - 664 sys sys 1140271743 26125
 sys/src/9/pc/ether8390.c - 664 sys sys 1131290377 17702
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
-sys/src/9/pc/etherdp83820.c - 664 sys sys 1134042756 29166
+sys/src/9/pc/etherdp83820.c - 664 sys sys 1160069116 29352
 sys/src/9/pc/etherec2t.c - 664 sys sys 1135784135 4092
 sys/src/9/pc/etherelnk3.c - 664 sys sys 1158012427 48807
 sys/src/9/pc/etherga620.c - 664 sys sys 1134390125 28760
@@ -7990,7 +7990,7 @@ sys/src/9/pc/ethermii.h - 664 sys sys 1086873891 3258
 sys/src/9/pc/etherrhine.c - 664 sys sys 1081706478 13799
 sys/src/9/pc/ethersink.c - 664 sys sys 1048644103 1076
 sys/src/9/pc/ethersmc.c - 664 sys sys 1071245461 15103
-sys/src/9/pc/ethervgbe.c - 664 sys sys 1138114457 26558
+sys/src/9/pc/ethervgbe.c - 664 sys sys 1160066496 26838
 sys/src/9/pc/ethervt6102.c - 664 sys sys 1131907459 22286
 sys/src/9/pc/etherwavelan.c - 664 sys sys 1131290380 3747
 sys/src/9/pc/floppy.h - 664 sys sys 1055700609 3835
@@ -12313,7 +12313,7 @@ sys/src/cmd/ip/dhcpclient.c - 664 sys sys 1050714660 11978
 sys/src/cmd/ip/dhcpd - 20000000775 sys sys 988249979 0
 sys/src/cmd/ip/dhcpd/dat.h - 664 sys sys 1084471353 2522
 sys/src/cmd/ip/dhcpd/db.c - 664 sys sys 1143670612 7466
-sys/src/cmd/ip/dhcpd/dhcpd.c - 664 sys sys 1084471366 32795
+sys/src/cmd/ip/dhcpd/dhcpd.c - 664 sys sys 1160071607 33096
 sys/src/cmd/ip/dhcpd/dhcpleases.c - 664 sys sys 1032655001 779
 sys/src/cmd/ip/dhcpd/mkfile - 664 sys sys 1063897571 433
 sys/src/cmd/ip/dhcpd/ndb.c - 664 sys sys 1084471375 6063

+ 8 - 0
dist/replica/plan9.log

@@ -30518,3 +30518,11 @@
 1159731006 0 c 386/bin/aux/cddb - 775 sys sys 1159730491 72635
 1159736406 0 a sys/src/9/pc/a100p.cp - 444 sys sys 1159735144 21984
 1159822807 0 c sys/src/9/port/devuart.c - 664 sys sys 1159822860 12193
+1160067605 0 c sys/src/9/pc/ether8139.c - 664 sys sys 1160066369 18561
+1160067605 1 c sys/src/9/pc/ethervgbe.c - 664 sys sys 1160066496 26838
+1160067605 2 c sys/src/9/pc/ether8169.c - 664 sys sys 1160066369 25393
+1160069406 0 c sys/src/9/pc/etherdp83820.c - 664 sys sys 1160069116 29352
+1160071216 0 c sys/src/9/pc/ether79c970.c - 664 sys sys 1160070602 14088
+1160073012 0 c sys/man/8/dhcpd - 664 sys sys 1160071627 5460
+1160073012 1 c sys/src/cmd/ip/dhcpd/dhcpd.c - 664 sys sys 1160071607 33096
+1160103606 0 c 386/bin/ip/dhcpd - 775 sys sys 1160103260 151069

+ 12 - 2
sys/man/8/dhcpd

@@ -4,7 +4,7 @@ dhcpd, dhcpleases, rarpd, tftpd \- Internet booting
 .SH SYNOPSIS
 .PP
 .B ip/dhcpd
-.RB [ -mdsnp ]
+.RB [ -mdsSnpr ]
 .RB [ -f
 .IR ndb-file ]
 .RB [ -x
@@ -176,9 +176,13 @@ Specify a file other than
 as the network database.
 .TP
 .B s
-Sleep 2 seconds before answering requests.  This is used to make a server
+Sleep 2 seconds before answering requests for static addresses.
+This is used to make a server
 be a backup only.
 .TP
+.B S
+Sleep 2 seconds before answering requests for dynamic addresses.
+.TP
 .B n
 Don't answer
 .SM BOOTP
@@ -191,6 +195,12 @@ requests from
 .SM PPTP
 clients only.
 .TP
+.B r
+Mute static addresses: don't reply to requests for static addresses,
+just log them and what
+.I dhcpd
+would have done.
+.TP
 .B x
 The IP stack to use is mounted at 
 .IR netmtpt .

+ 8 - 0
sys/src/9/pc/ether79c970.c

@@ -300,6 +300,12 @@ promiscuous(void* arg, int on)
 	iunlock(ctlr);
 }
 
+static void
+multicast(void* arg, uchar*, int)
+{
+	promiscuous(arg, 1);
+}
+
 static void
 txstart(Ether* ether)
 {
@@ -626,6 +632,8 @@ reset(Ether* ether)
 
 	ether->arg = ether;
 	ether->promiscuous = promiscuous;
+	ether->multicast = multicast;
+//	ether->shutdown = shutdown;
 
 	return 0;
 }

+ 8 - 0
sys/src/9/pc/ether8139.c

@@ -234,6 +234,12 @@ rtl8139promiscuous(void* arg, int on)
 	iunlock(&ctlr->ilock);
 }
 
+static void
+rtl8139multicast(void* arg, uchar*, int)
+{
+	rtl8139promiscuous(arg, 1);
+}
+
 static long
 rtl8139ifstat(Ether* edev, void* a, long n, ulong offset)
 {
@@ -738,6 +744,8 @@ rtl8139pnp(Ether* edev)
 
 	edev->arg = edev;
 	edev->promiscuous = rtl8139promiscuous;
+	edev->multicast = rtl8139multicast;
+//	edev->shutdown = rtl8139shutdown;
 
 	/*
 	 * This should be much more dynamic but will do for now.

+ 8 - 0
sys/src/9/pc/ether8169.c

@@ -414,6 +414,12 @@ rtl8169promiscuous(void* arg, int on)
 	iunlock(&ctlr->ilock);
 }
 
+static void
+rtl8169multicast(void* arg, uchar*, int)
+{
+	rtl8169promiscuous(arg, 1);
+}
+
 static long
 rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
 {
@@ -1112,6 +1118,8 @@ rtl8169pnp(Ether* edev)
 
 	edev->arg = edev;
 	edev->promiscuous = rtl8169promiscuous;
+	edev->multicast = rtl8169multicast;
+//	edev->shutdown = rtl8169shutdown;
 
 	rtl8169link(edev);
 

+ 9 - 1
sys/src/9/pc/etherdp83820.c

@@ -656,7 +656,7 @@ dp83820init(Ether* edev)
 		csr32w(ctlr, Rfcr, i);
 		csr32w(ctlr, Rfdr, (edev->ea[i+1]<<8)|edev->ea[i]);
 	}
-	csr32w(ctlr, Rfcr, Rfen|Aab|Apm);
+	csr32w(ctlr, Rfcr, Rfen|Aab|Aam|Apm);
 
 	ctlr->rxcfg = Stripcrc|(((2*(ETHERMINTU+4))/8)<<RxdrthSHFT);
 	ctlr->imr |= Rxorn|Rxidle|Rxearly|Rxdesc|Rxok;
@@ -967,6 +967,12 @@ dp83820promiscuous(void* arg, int on)
 	USED(arg, on);
 }
 
+/* multicast already on, don't need to do anything */
+static void
+dp83820multicast(void*, uchar*, int)
+{
+}
+
 static int
 atc93c46r(Ctlr* ctlr, int address)
 {
@@ -1209,6 +1215,8 @@ dp83820pnp(Ether* edev)
 
 	edev->arg = edev;
 	edev->promiscuous = dp83820promiscuous;
+	edev->multicast = dp83820multicast;
+//	edev->shutdown = dp83820shutdown;
 
 	return 0;
 }

+ 16 - 1
sys/src/9/pc/ethervgbe.c

@@ -12,7 +12,7 @@
  *	- thresholds
  *	- dynamic ring sizing ??
  *	- link status change
- *	- multicast
+ *	- shutdown
  *	- promiscuous
  *	- report error
  *	- Rx/Tx Csum
@@ -1087,6 +1087,18 @@ vgbectl(Ether* edev, void* buf, long n)
 	return n;
 }
 
+static void
+vgbepromiscuous(void* arg, int on)
+{
+	USED(arg, on);
+}
+
+/* multicast already on, don't need to do anything */
+static void
+vgbemulticast(void*, uchar*, int)
+{
+}
+
 static int
 vgbepnp(Ether* edev)
 {
@@ -1122,6 +1134,9 @@ vgbepnp(Ether* edev)
 	edev->transmit = vgbetransmit;
 	edev->interrupt = vgbeinterrupt;
 	edev->ifstat = vgbeifstat;
+//	edev->promiscuous = vgbepromiscuous;
+	edev->multicast = vgbemulticast;
+//	edev->shutdown = vgbeshutdown;
 	edev->ctl = vgbectl;
 
 	edev->arg = edev;

+ 32 - 14
sys/src/cmd/ip/dhcpd/dhcpd.c

@@ -51,14 +51,14 @@ Ipifc	*ipifcs;
 int	debug;
 int	nobootp;
 long	now;
-int	slow;
+int	slowstat, slowdyn;
 char	net[256];
 
 int	pptponly;	// only answer request that came from the pptp server
-int	mute;
+int	mute, mutestat;
 int	minlease = MinLease;
 
-ulong	start;	
+ulong	start;
 
 /* option magic */
 char plan9opt[4] = { 'p', '9', ' ', ' ' };
@@ -231,7 +231,10 @@ main(int argc, char **argv)
 		ndbfile = p;
 		break;
 	case 's':
-		slow = 1;
+		slowstat = 1;
+		break;
+	case 'S':
+		slowdyn = 1;
 		break;
 	case 'n':
 		nobootp = 1;
@@ -239,6 +242,9 @@ main(int argc, char **argv)
 	case 'p':
 		pptponly = 1;
 		break;
+	case 'r':
+		mutestat = 1;
+		break;
 	case 'x':
 		p = ARGF();
 		if(p == nil)
@@ -384,6 +390,13 @@ proto(Req *rp, int n)
 timestamp("done");
 }
 
+static void
+slowdelay(Req *rp)
+{
+	if(slowstat && rp->staticbinding || slowdyn && !rp->staticbinding)
+		sleep(2000);
+}
+
 void
 dhcp(Req *rp)
 {
@@ -391,8 +404,7 @@ dhcp(Req *rp)
 
 	switch(rp->dhcptype){
 	case Discover:
-		if(slow)
-			sleep(500);
+		slowdelay(rp);
 		rcvdiscover(rp);
 		break;
 	case Request:
@@ -491,7 +503,7 @@ rcvrequest(Req *rp)
 				sendnak(rp, "no offer for you");
 			return;
 		}
-	
+
 		/* if not for me, retract offer */
 		if(!forme(rp->server)){
 			b->expoffer = 0;
@@ -684,6 +696,12 @@ setsiaddr(uchar *siaddr, uchar *saddr, uchar *laddr)
 	}
 }
 
+int
+ismuted(Req *rp)
+{
+	return mute || (mutestat && rp->staticbinding);
+}
+
 void
 sendoffer(Req *rp, uchar *ip, int offer)
 {
@@ -740,7 +758,7 @@ sendoffer(Req *rp, uchar *ip, int offer)
 	 *  send
 	 */
 	n = rp->p - rp->buf;
-	if(!mute && write(rp->fd, rp->buf, n) != n)
+	if(!ismuted(rp) && write(rp->fd, rp->buf, n) != n)
 		warning(0, "offer: write failed: %r");
 }
 
@@ -801,7 +819,7 @@ sendack(Req *rp, uchar *ip, int offer, int sendlease)
 	 *  send
 	 */
 	n = rp->p - rp->buf;
-	if(!mute && write(rp->fd, rp->buf, n) != n)
+	if(!ismuted(rp) && write(rp->fd, rp->buf, n) != n)
 		warning(0, "ack: write failed: %r");
 }
 
@@ -854,7 +872,7 @@ sendnak(Req *rp, char *msg)
 	 *  send nak
 	 */
 	n = rp->p - rp->buf;
-	if(!mute && write(rp->fd, rp->buf, n) != n)
+	if(!ismuted(rp) && write(rp->fd, rp->buf, n) != n)
 		warning(0, "nak: write failed: %r");
 }
 
@@ -893,8 +911,8 @@ bootp(Req *rp)
 			warning(0, "bootp for server %s", bp->sname);
 			return;
 		}
-	} else if(slow)
-		sleep(500);
+	} else
+		slowdelay(rp);
 
 	/* ignore if we don't know what file to load */
 	if(*bp->file == 0){
@@ -990,7 +1008,7 @@ bootp(Req *rp)
 	 *  send
 	 */
 	n = rp->p - rp->buf;
-	if(!mute && write(rp->fd, rp->buf, n) != n)
+	if(!ismuted(rp) && write(rp->fd, rp->buf, n) != n)
 		warning(0, "bootp: write failed: %r");
 
 	warning(0, "bootp via %I: file %s xid(%ux)flag(%ux)ci(%V)gi(%V)yi(%V)si(%V) %s",
@@ -1020,7 +1038,7 @@ parseoptions(Req *rp)
 		p += n;
 		if(p > rp->e)
 			return;
-		
+
 		switch(code){
 		case ODipaddr:	/* requested ip address */
 			if(n == IPv4addrlen)