Browse Source

Plan 9 from Bell Labs 2005-05-09

David du Colombier 16 years ago
parent
commit
eb518e987c

+ 7 - 7
dist/replica/_plan9.db

@@ -5771,8 +5771,8 @@ sys/src/9/ip/chandial.c - 664 sys sys 1099020048 2295
 sys/src/9/ip/devip.c - 664 sys sys 1084331653 24164
 sys/src/9/ip/eipconvtest.c - 664 sys sys 1022588098 3135
 sys/src/9/ip/esp.c - 664 sys sys 1047260561 17084
-sys/src/9/ip/ethermedium.c - 664 sys sys 1066514880 15124
-sys/src/9/ip/gre.c - 664 sys sys 1047260562 4684
+sys/src/9/ip/ethermedium.c - 664 sys sys 1115565973 15592
+sys/src/9/ip/gre.c - 664 sys sys 1115566178 5069
 sys/src/9/ip/icmp.c - 664 sys sys 1077376217 9511
 sys/src/9/ip/icmp6.c - 664 sys sys 1047260563 18098
 sys/src/9/ip/igmp.c - 664 sys sys 1055700768 5175
@@ -5781,7 +5781,7 @@ sys/src/9/ip/inferno.c - 664 sys sys 1022588098 517
 sys/src/9/ip/ip.c - 664 sys sys 1101906449 15285
 sys/src/9/ip/ip.h - 664 sys sys 1091904429 15818
 sys/src/9/ip/ipaux.c - 664 sys sys 1079538100 12862
-sys/src/9/ip/ipifc.c - 664 sys sys 1091733773 34267
+sys/src/9/ip/ipifc.c - 664 sys sys 1115566009 34255
 sys/src/9/ip/ipmux.c - 664 sys sys 1047260566 15362
 sys/src/9/ip/iproute.c - 664 sys sys 1049423192 14763
 sys/src/9/ip/ipv6.c - 664 sys sys 1047951328 14433
@@ -5836,7 +5836,7 @@ sys/src/9/pc/archmp.c - 664 sys sys 1084475127 2311
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
 sys/src/9/pc/dat.h - 664 sys sys 1091904418 6281
-sys/src/9/pc/devarch.c - 664 sys sys 1109854210 18553
+sys/src/9/pc/devarch.c - 664 sys sys 1115566123 18554
 sys/src/9/pc/devether.c - 664 sys sys 1078928204 10183
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
 sys/src/9/pc/devi82365.c - 664 sys sys 1099761153 20505
@@ -5859,7 +5859,7 @@ sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
 sys/src/9/pc/ether8139.c - 664 sys sys 1086987324 18362
 sys/src/9/pc/ether8169.c - 664 sys sys 1110882037 22704
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1055689887 32296
-sys/src/9/pc/ether82557.c - 664 sys sys 1098848151 30040
+sys/src/9/pc/ether82557.c - 664 sys sys 1115566440 30076
 sys/src/9/pc/ether83815.c - 664 sys sys 1115476450 23479
 sys/src/9/pc/ether8390.c - 664 sys sys 1112382834 17701
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
@@ -5886,7 +5886,7 @@ sys/src/9/pc/init9.c - 664 sys sys 1040002518 94
 sys/src/9/pc/initcode.s - 664 sys sys 1015014519 282
 sys/src/9/pc/io.h - 664 sys sys 1099761152 8095
 sys/src/9/pc/kbd.c - 664 sys sys 1079617269 11655
-sys/src/9/pc/l.s - 664 sys sys 1113926772 23705
+sys/src/9/pc/l.s - 664 sys sys 1115566067 23833
 sys/src/9/pc/main.c - 664 sys sys 1115352568 14694
 sys/src/9/pc/mem.h - 664 sys sys 1018553448 4573
 sys/src/9/pc/memory.c - 664 sys sys 1071245460 13028
@@ -7004,7 +7004,7 @@ sys/src/boot/pc/ether79c970.c - 664 sys sys 1015007950 11717
 sys/src/boot/pc/ether8003.c - 664 sys sys 1015007950 6446
 sys/src/boot/pc/ether8139.c - 664 sys sys 1102429126 14806
 sys/src/boot/pc/ether8169.c - 664 sys sys 1106018997 18687
-sys/src/boot/pc/ether82557.c - 664 sys sys 1098848150 18911
+sys/src/boot/pc/ether82557.c - 664 sys sys 1115566440 18947
 sys/src/boot/pc/ether83815.c - 664 sys sys 1019537742 19576
 sys/src/boot/pc/ether8390.c - 664 sys sys 1112382847 16209
 sys/src/boot/pc/ether8390.h - 664 sys sys 1015007951 1392

+ 7 - 7
dist/replica/plan9.db

@@ -5771,8 +5771,8 @@ sys/src/9/ip/chandial.c - 664 sys sys 1099020048 2295
 sys/src/9/ip/devip.c - 664 sys sys 1084331653 24164
 sys/src/9/ip/eipconvtest.c - 664 sys sys 1022588098 3135
 sys/src/9/ip/esp.c - 664 sys sys 1047260561 17084
-sys/src/9/ip/ethermedium.c - 664 sys sys 1066514880 15124
-sys/src/9/ip/gre.c - 664 sys sys 1047260562 4684
+sys/src/9/ip/ethermedium.c - 664 sys sys 1115565973 15592
+sys/src/9/ip/gre.c - 664 sys sys 1115566178 5069
 sys/src/9/ip/icmp.c - 664 sys sys 1077376217 9511
 sys/src/9/ip/icmp6.c - 664 sys sys 1047260563 18098
 sys/src/9/ip/igmp.c - 664 sys sys 1055700768 5175
@@ -5781,7 +5781,7 @@ sys/src/9/ip/inferno.c - 664 sys sys 1022588098 517
 sys/src/9/ip/ip.c - 664 sys sys 1101906449 15285
 sys/src/9/ip/ip.h - 664 sys sys 1091904429 15818
 sys/src/9/ip/ipaux.c - 664 sys sys 1079538100 12862
-sys/src/9/ip/ipifc.c - 664 sys sys 1091733773 34267
+sys/src/9/ip/ipifc.c - 664 sys sys 1115566009 34255
 sys/src/9/ip/ipmux.c - 664 sys sys 1047260566 15362
 sys/src/9/ip/iproute.c - 664 sys sys 1049423192 14763
 sys/src/9/ip/ipv6.c - 664 sys sys 1047951328 14433
@@ -5836,7 +5836,7 @@ sys/src/9/pc/archmp.c - 664 sys sys 1084475127 2311
 sys/src/9/pc/audio.h - 664 sys sys 1015014513 343
 sys/src/9/pc/cga.c - 664 sys sys 1015014513 1843
 sys/src/9/pc/dat.h - 664 sys sys 1091904418 6281
-sys/src/9/pc/devarch.c - 664 sys sys 1109854210 18553
+sys/src/9/pc/devarch.c - 664 sys sys 1115566123 18554
 sys/src/9/pc/devether.c - 664 sys sys 1078928204 10183
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
 sys/src/9/pc/devi82365.c - 664 sys sys 1099761153 20505
@@ -5859,7 +5859,7 @@ sys/src/9/pc/ether8003.c - 664 sys sys 1015014516 6665
 sys/src/9/pc/ether8139.c - 664 sys sys 1086987324 18362
 sys/src/9/pc/ether8169.c - 664 sys sys 1110882037 22704
 sys/src/9/pc/ether82543gc.c - 664 sys sys 1055689887 32296
-sys/src/9/pc/ether82557.c - 664 sys sys 1098848151 30040
+sys/src/9/pc/ether82557.c - 664 sys sys 1115566440 30076
 sys/src/9/pc/ether83815.c - 664 sys sys 1115476450 23479
 sys/src/9/pc/ether8390.c - 664 sys sys 1112382834 17701
 sys/src/9/pc/ether8390.h - 664 sys sys 1015014517 1511
@@ -5886,7 +5886,7 @@ sys/src/9/pc/init9.c - 664 sys sys 1040002518 94
 sys/src/9/pc/initcode.s - 664 sys sys 1015014519 282
 sys/src/9/pc/io.h - 664 sys sys 1099761152 8095
 sys/src/9/pc/kbd.c - 664 sys sys 1079617269 11655
-sys/src/9/pc/l.s - 664 sys sys 1113926772 23705
+sys/src/9/pc/l.s - 664 sys sys 1115566067 23833
 sys/src/9/pc/main.c - 664 sys sys 1115352568 14694
 sys/src/9/pc/mem.h - 664 sys sys 1018553448 4573
 sys/src/9/pc/memory.c - 664 sys sys 1071245460 13028
@@ -7004,7 +7004,7 @@ sys/src/boot/pc/ether79c970.c - 664 sys sys 1015007950 11717
 sys/src/boot/pc/ether8003.c - 664 sys sys 1015007950 6446
 sys/src/boot/pc/ether8139.c - 664 sys sys 1102429126 14806
 sys/src/boot/pc/ether8169.c - 664 sys sys 1106018997 18687
-sys/src/boot/pc/ether82557.c - 664 sys sys 1098848150 18911
+sys/src/boot/pc/ether82557.c - 664 sys sys 1115566440 18947
 sys/src/boot/pc/ether83815.c - 664 sys sys 1019537742 19576
 sys/src/boot/pc/ether8390.c - 664 sys sys 1112382847 16209
 sys/src/boot/pc/ether8390.h - 664 sys sys 1015007951 1392

+ 7 - 0
dist/replica/plan9.log

@@ -14881,3 +14881,10 @@
 1115350383 0 c 386/bin/exportfs - 775 sys sys 1115348876 161171
 1115353984 0 c sys/src/9/pc/main.c - 664 sys sys 1115352568 14694
 1115478139 0 c sys/src/9/pc/ether83815.c - 664 sys sys 1115476450 23479
+1115566361 0 c sys/src/9/ip/ethermedium.c - 664 sys sys 1115565973 15592
+1115566361 1 c sys/src/9/ip/gre.c - 664 sys sys 1115566178 5069
+1115566361 2 c sys/src/9/ip/ipifc.c - 664 sys sys 1115566009 34255
+1115566361 3 c sys/src/9/pc/devarch.c - 664 sys sys 1115566123 18554
+1115566361 4 c sys/src/9/pc/l.s - 664 sys sys 1115566067 23833
+1115568160 0 c sys/src/9/pc/ether82557.c - 664 sys sys 1115566440 30076
+1115568160 1 c sys/src/boot/pc/ether82557.c - 664 sys sys 1115566440 18947

+ 17 - 0
sys/src/9/ip/ethermedium.c

@@ -16,6 +16,15 @@ struct Etherhdr
 	uchar	t[2];
 };
 
+static uchar ipbroadcast[IPaddrlen] = {
+	0xff,0xff,0xff,0xff,  
+	0xff,0xff,0xff,0xff,  
+	0xff,0xff,0xff,0xff,  
+	0xff,0xff,0xff,0xff,
+};
+
+static uchar etherbroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
 static void	etherread4(void *a);
 static void	etherread6(void *a);
 static void	etherbind(Ipifc *ifc, int argc, char **argv);
@@ -604,6 +613,14 @@ recvarp(Ipifc *ifc)
 			}
 		}
 
+		/* make sure we're not entering broadcast addresses */
+		if(ipcmp(ip, ipbroadcast) == 0 ||
+			!memcmp(e->sha, etherbroadcast, sizeof(e->sha))){
+			print("arprep: 0x%E/0x%E cannot register broadcast address %I\n",
+				e->s, e->sha, e->spa);
+			break;
+		}
+
 		arpenter(er->f, V4, e->spa, e->sha, sizeof(e->sha), 0);
 		break;
 

+ 35 - 12
sys/src/9/ip/gre.c

@@ -42,6 +42,8 @@ typedef struct GREhdr
 typedef struct GREpriv GREpriv;
 struct GREpriv
 {
+	int		raw;			/* Raw GRE mode */
+
 	/* non-MIB stats */
 	ulong		csumerr;		/* checksum errors */
 	ulong		lenerr;			/* short packet */
@@ -143,18 +145,20 @@ grekick(void *x, Block *bp)
 	ghp = (GREhdr *)(bp->rp);
 	ghp->vihl = IP_VER4;
 
-	v4tov6(raddr, ghp->dst);
-	if(ipcmp(raddr, v4prefix) == 0)
-		memmove(ghp->dst, c->raddr + IPv4off, IPv4addrlen);
-	v4tov6(laddr, ghp->src);
-	if(ipcmp(laddr, v4prefix) == 0){
-		if(ipcmp(c->laddr, IPnoaddr) == 0)
-			findlocalip(c->p->f, c->laddr, raddr); /* pick interface closest to dest */
-		memmove(ghp->src, c->laddr + IPv4off, IPv4addrlen);
+	if(!((GREpriv*)c->p->priv)->raw){
+		v4tov6(raddr, ghp->dst);
+		if(ipcmp(raddr, v4prefix) == 0)
+			memmove(ghp->dst, c->raddr + IPv4off, IPv4addrlen);
+		v4tov6(laddr, ghp->src);
+		if(ipcmp(laddr, v4prefix) == 0){
+			if(ipcmp(c->laddr, IPnoaddr) == 0)
+				findlocalip(c->p->f, c->laddr, raddr); /* pick interface closest to dest */
+			memmove(ghp->src, c->laddr + IPv4off, IPv4addrlen);
+		}
+		hnputs(ghp->eproto, c->rport);
 	}
 
 	ghp->proto = IP_GREPROTO;
-	hnputs(ghp->eproto, c->rport);
 	ghp->frag[0] = 0;
 	ghp->frag[1] = 0;
 
@@ -176,7 +180,6 @@ greiput(Proto *gre, Ipifc*, Block *bp)
 
 	v4tov6(raddr, ghp->src);
 	eproto = nhgets(ghp->eproto);
-
 	qlock(gre);
 
 	/* Look for a conversation structure for this port and address */
@@ -185,7 +188,8 @@ greiput(Proto *gre, Ipifc*, Block *bp)
 		c = *p;
 		if(c->inuse == 0)
 			continue;
-		if(c->rport == eproto && ipcmp(c->raddr, raddr) == 0)
+		if(c->rport == eproto && 
+			(gpriv->raw || ipcmp(c->raddr, raddr) == 0))
 			break;
 	}
 
@@ -234,6 +238,25 @@ grestats(Proto *gre, char *buf, int len)
 	return snprint(buf, len, "gre: len %lud\n", gpriv->lenerr);
 }
 
+char*
+grectl(Conv *c, char **f, int n)
+{
+	GREpriv *gpriv;
+
+	gpriv = c->p->priv;
+	if(n == 1){
+		if(strcmp(f[0], "raw") == 0){
+			gpriv->raw = 1;
+			return nil;
+		}
+		else if(strcmp(f[0], "cooked") == 0){
+			gpriv->raw = 0;
+			return nil;
+		}
+	}
+	return "unknown control request";
+}
+
 void
 greinit(Fs *fs)
 {
@@ -248,7 +271,7 @@ greinit(Fs *fs)
 	gre->create = grecreate;
 	gre->close = greclose;
 	gre->rcv = greiput;
-	gre->ctl = nil;
+	gre->ctl = grectl;
 	gre->advise = nil;
 	gre->stats = grestats;
 	gre->ipproto = IP_GREPROTO;

+ 2 - 2
sys/src/9/ip/ipifc.c

@@ -477,7 +477,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
 
 	addselfcache(f, ifc, lifc, ip, Runi);
 
-	if((type & (Rptpt|Rproxy)) == (Rptpt|Rproxy)){
+	if((type & (Rproxy|Rptpt)) == (Rproxy|Rptpt)){
 		ipifcregisterproxy(f, ifc, rem);
 		goto out;
 	}
@@ -1417,7 +1417,7 @@ ipproxyifc(Fs *f, Ipifc *ifc, uchar *ip)
 	r = v6lookup(f, ip, nil);
 	if(r == nil)
 		return 0;
-	if((r->type & (Rifc|Rptpt|Rproxy)) != (Rifc|Rptpt|Rproxy))
+	if((r->type & (Rifc|Rproxy)) != (Rifc|Rproxy))
 		return 0;
 
 	/* see if this is on the right interface */

+ 2 - 2
sys/src/9/pc/devarch.c

@@ -144,10 +144,10 @@ ioinit(void)
 // This is in particular useful for exchangable cards, such
 // as pcmcia and cardbus cards.
 int
-ioreserve(int port, int size, int align, char *tag)
+ioreserve(int, int size, int align, char *tag)
 {
 	IOMap *m, **l;
-	int i;
+	int i, port;
 
 	lock(&iomap);
 	// find a free port above 0x400 and below 0x1000

+ 1 - 0
sys/src/9/pc/ether82557.c

@@ -925,6 +925,7 @@ i82557pci(void)
 		default:
 			continue;
 		case 0x1031:		/* Intel 82562EM */
+		case 0x1050:		/* Intel 82562EZ */
 		case 0x2449:		/* Intel 82562ET */
 			nop = 1;
 			/*FALLTHROUGH*/

+ 4 - 0
sys/src/9/pc/l.s

@@ -592,6 +592,10 @@ TEXT xchgw(SB), $0
 	RET
 
 TEXT mul64fract(SB), $0
+/*
+ * Multiply two 64-bit number s and keep the middle 64 bits from the 128-bit result
+ * See ../port/tod.c for motivation.
+ */
 	MOVL	r+0(FP), CX
 	XORL	BX, BX				/* BX = 0 */
 

+ 1 - 0
sys/src/boot/pc/ether82557.c

@@ -554,6 +554,7 @@ i82557pci(void)
 		case 0x1209:		/* Intel 82559ER */
 		case 0x1229:		/* Intel 8255[789] */
 		case 0x1031:		/* Intel 82562EM */
+		case 0x1050:		/* Intel 82562EZ */
 		case 0x2449:		/* Intel 82562ET */
 		case 0x1039:		/* Intel 82801BD PRO/100 VE */
 			break;