Browse Source

Plan 9 from Bell Labs 2014-03-19

David du Colombier 10 years ago
parent
commit
dc87839932

+ 25 - 60
rc/bin/ipv6on

@@ -1,25 +1,23 @@
 #!/bin/rc
-# ipv6on [netdir ndbfile [gwv4]] - configure an interface for ipv6,
-#	once ipv4 is configured.  use ipv6 address from ndb if present,
-#	else do stateless-autoconfiguration (SLAC).
+# ipv6on [netdir ndbfile] - configure an interface for ipv6.
+#	use ipv6 address from ndb if present,
+#	else do stateless address autoconfiguration (SLAAC).
 if (! ~ $#* 0 2 3) {
-	echo usage: $0 '[netdir ndbfile [gw-v4-name]]' >[1=2]
+	echo usage: $0 '[netdir ndbfile [obs-gw-v4-name]]' >[1=2]
 	exit usage
 }
 rfork e
+fn ipq {			# attr val rattr
+	ndb/ipquery $* | sed 's/^[a-z0-9]+=//'
+}
+
 if (~ $#* 0) {
 	netdir=/net
 	ndbf=/lib/ndb/local
-	gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
 }
 if not {
 	netdir=$1
 	ndbf=$2
-	if (~ $#* 2)
-		# gw=()
-		gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
-	if not
-		gw=$3
 }
 if (~ $netdir /net) {
 	xsfx=()
@@ -43,65 +41,32 @@ fn nonnil {		# variable
 
 #
 # configure v6 for link-local addresses (fe80::) & multicast (ff02::).
-# accept router advertisements.
+# accept router advertisements, which will contain a default route.
 #
 if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
 	exit 'ipconfig -6 failed'
 ip/ipconfig $xdir ether $netdir/ether? ra6 recvra 1
 
-# lookup any v6 address for me in ndb
-mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
-if (~ $#sysname 0 || ~ $sysname '')
-	mev6=`{ndb/query -f $ndbf sys $sysname ip | grep :}
-
-# for testing
-mylnk=`{ip/linklocal `{cat $netdir/ether?/addr}}
-nonnil mylnk
-
-#
-# have gateway? try to map to a v6 address; get eui-64 of v4's mac
-#
-if (~ $#gw 1) {
-	if (~ $gw [0-9]*.[0-9]*.[0-9]*.[0-9]*)	# is it v4?
-		gwv4 = $gw
-	if (~ $#gwv4 0 || ~ $gwv4 '')
-		gwv4=`{ndb/query -f $ndbf sys $gw ip}
-	gwv6=`{ndb/query -f $ndbf sys $gw ipv6}
-
-	if (! ~ $#gwv4 0) {			# have v4 gateway?
-		# echo ping gw $gwv4...
-		# load arp cache with gw mac
-		ip/ping -qn 3 $netdir/icmp!$gwv4 >/dev/null >[2=1] &
-		sleep 1				# wait briefly for ping
-
-		# get v4 gateway's mac
-		gweth=`{grep '* '^$gwv4^' ' $netdir/arp | awk '{print $4}' }
-		nonnil gweth >[2]/dev/null	# don't frighten users
-		gwlnk=`{ip/linklocal $gweth}	# get mac's eui-64
-		nonnil gwlnk >[2]/dev/null
-	}
+# lookup any v6 address for me in ndb, else use slaac
+myeth=`{cat $netdir/ether?/addr}
+mev6=`{ndb/query -f $ndbf ether $myeth ipv6}
+if (~ $#mev6 0 || ~ $mev6 '')
+	mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
+if (~ $#mev6 0 || ~ $mev6 '') {
+	# slaac: could perhaps get prefix from above RA
+	ipnet=`{ipq ether $myeth ipnet}
+	if (~ $#ipnet 0 || ~ $ipnet '')
+		ipnet=`{ipq sys $sysname ipnet}
+	nonnil ipnet
+	v6pfx=`{ipq ipnet $ipnet ipv6pfx}
+	nonnil v6pfx
+	mev6=`{ip/linklocal $myeth | sed 's/^fe80:/'$v6pfx'/'}
 }
 nonnil mev6
+
 #
 # configure my global v6 addresses
 #
-v6mask=`{ndb/ipquery ip $mev6 ipmask}
+v6mask=`{ipq ip $mev6 ipmask}
 ip/ipconfig $xdir ether $netdir/ether?	add $mev6 $v6mask
 ip/ipconfig $xdir loopback /dev/null	add $mev6 /128
-
-#
-# have gateway? find its v6 address and make it our default route
-#
-if (~ $#gw 1) {
-	if (~ $#gwv6 0 || ~ $gwv6 '') {
-		if (~ $#gwlnk 0 || ~ $gwlnk '')
-			gwv6=`{ip/linklocal $gweth}
-		if not
-			gwv6=$gwlnk
-	}
-	nonnil gwv6
-
-	# add default v6 route to v6 addr of v4 gw
-	echo add :: /0 $gwv6 >$netdir/iproute	# need not be link-local
-}
-exit ''

+ 3 - 2
rc/bin/ssh

@@ -1,3 +1,4 @@
 #!/bin/rc
-# ssh host arg... - invoke ssh v1
-exec /$cputype/bin/ssh1 $*
+# ssh host arg... - invoke ssh v1.  if it fails, try v2.
+if (! /$cputype/bin/ssh1 $* >[2]/dev/null)
+	exec /$cputype/bin/ssh2 $*

+ 2 - 0
sys/games/lib/fortunes

@@ -4320,3 +4320,5 @@ The custom error module does not recognize this error.
 The U.S. government has to get out of the business of fucking with encryption standards.  - Richard Clarke
 How do you tell a bad standard?  If it begins with "I", e.g, I2O, IPMI.  If it ends with "I", e.g., ACPI, EFI, IPMI, etc.  If it has the word "intelligent" in it, e.g., I2O, IPMI.  Or, the best, if it has all three, e.g., IPMI. - Ron Minnich
 It's frequently easier to read disassembled glibc object code than the glibc source. - Ron Minnich
+Most of your set-top box issues can be resolved by rebooting the device. Please select this option to reboot your device. This will NOT erase the settings. - FiOS set-top box troubleshooter.
+There is no avoiding war, it can only be postponed to the advantage of the enemy. - Niccolò Machiavelli

+ 4 - 0
sys/lib/kbmap/uk

@@ -6,3 +6,7 @@
 0	86	'\
 4	86	^\
 1	86	'|
+
+2	86	'\
+5	86	^\
+6	86	'|

+ 2 - 2
sys/man/8/dhcpd

@@ -203,11 +203,11 @@ just log them and what
 would have done.
 .TP
 .B s
-Sleep 2 seconds before answering requests for static addresses.
+Sleep roughly 1 to 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.
+Sleep roughly 1 to 2 seconds before answering requests for dynamic addresses.
 .TP
 .B x
 The IP stack to use is mounted at 

+ 17 - 9
sys/man/8/ipconfig

@@ -55,9 +55,7 @@ ipconfig, rip, linklocal, ipv6on \- Internet configuration and routing
 [
 .I netmtpt
 .I ndbfile
-[
-.I gwipv4
-]\|]
+]
 .SH DESCRIPTION
 .I Ipconfig
 binds a device interface (default
@@ -321,12 +319,15 @@ uses the network database at
 .I ndbfile
 to configure the network mounted on
 .I netmtpt
-with a link-local address (derived from its MAC address)
-and attempts to add a default IPv6 route to the local
-IPv4 gateway's IPv6 address.
-If
-.I gwipv4
-is supplied, it will be used as the gateway's IPv4 address.
+with an IPv6 link-local address (derived from its MAC address)
+and an IPv6 global address, either from an
+.B ipv6
+attribute for
+.B $sysname
+or the interface's MAC address,
+if present,
+or via stateless address autoconfiguration.
+It also attempts to add a default IPv6 route from a router advertisement.
 .SH EXAMPLES
 Configure Ethernet 0 as the primary IP interface.
 Get all addresses via DHCP.  Start up a connection server
@@ -393,3 +394,10 @@ ip/ipconfig ra6 recvra 1
 .br
 .B /lib/rfc/rfc2373
 for IPv6's modified EUI-64
+.SH BUGS
+Currently, SLAAC relies on each
+.B ipnet
+declaration containing an
+.B ipv6pfx
+attribute.
+This should be replaced by a router advertisement prefix.

+ 1 - 1
sys/src/9/ip/ip.h

@@ -38,7 +38,7 @@ enum
 	Addrlen=	64,
 	Maxproto=	20,
 	Nhash=		64,
-	Maxincall=	32,	/* max. conn.s in listen q not accepted yet */
+	Maxincall=	64,	/* max. conn.s in listen q not accepted yet */
 	Nchans=		1024,
 	MAClen=		16,		/* longest mac address */
 

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

@@ -219,8 +219,9 @@ enum {					/* General Descriptor control */
 /*
  */
 enum {					/* Ring sizes  (<= 1024) */
-	Ntd		= 64,		/* Transmit Ring */
-	Nrd		= 1024,		/* Receive Ring */
+	/* were 1024 & 64, but 253 and 9 are ample. */
+	Nrd		= 256,		/* Receive Ring */
+	Ntd		= 32,		/* Transmit Ring */
 
 	Mtu		= ETHERMAXTU,
 	Mps		= ROUNDUP(ETHERMAXTU+4, 128),
@@ -297,7 +298,7 @@ typedef struct Ctlr {
 	int	rcr;			/* receive configuration register */
 	int	imr;
 
-	Watermark wmrb;
+//	Watermark wmrb;
 	Watermark wmrd;
 	Watermark wmtd;
 
@@ -513,8 +514,10 @@ rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
 		nexterror();
 	}
 
+	dtcc = ctlr->dtcc;
+	assert(dtcc);
 	csr32w(ctlr, Dtccr+4, 0);
-	csr32w(ctlr, Dtccr, PCIWADDR(ctlr->dtcc)|Cmd);
+	csr32w(ctlr, Dtccr, PCIWADDR(dtcc)|Cmd);
 	for(timeo = 0; timeo < 1000; timeo++){
 		if(!(csr32r(ctlr, Dtccr) & Cmd))
 			break;
@@ -523,8 +526,6 @@ rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
 	if(csr32r(ctlr, Dtccr) & Cmd)
 		error(Eio);
 
-	dtcc = ctlr->dtcc;
-
 	edev->oerrs = dtcc->txer;
 	edev->crcs = dtcc->rxer;
 	edev->frames = dtcc->fae;
@@ -859,9 +860,8 @@ rtl8169attach(Ether* edev)
 			qunlock(&ctlr->alock);
 			error(Enomem);
 		}
-		memset(ctlr->dtcc, 0, sizeof(Dtcc));	/* paranoia */
 		rtl8169init(edev);
-		initmark(&ctlr->wmrb, Nrd, "rcv bufs unprocessed");
+//		initmark(&ctlr->wmrb, Nrb, "rcv bufs unprocessed");
 		initmark(&ctlr->wmrd, Nrd-1, "rcv descrs processed at once");
 		initmark(&ctlr->wmtd, Ntd-1, "xmit descr queue len");
 		ctlr->init = 1;

+ 6 - 2
sys/src/9/pc/ether82557.c

@@ -20,8 +20,12 @@
 #include "etherif.h"
 
 enum {
-	Nrfd		= 64,		/* receive frame area */
-	Ncb		= 64,		/* maximum control blocks queued */
+	/*
+	 * these were both 64.  increased them to try to improve lookout's
+	 * reliability as a pxe booter.
+	 */
+	Nrfd		= 128,		/* receive frame area */
+	Ncb		= 128,		/* maximum control blocks queued */
 
 	NullPointer	= 0xFFFFFFFF,	/* 82557 NULL pointer */
 };

+ 4 - 4
sys/src/9/pc/ether82563.c

@@ -414,10 +414,10 @@ enum {
 };
 
 enum {
-	Nrd		= 512,		/* power of two */
-	Ntd		= 64,		/* power of two */
-	/* 1024 buffers can be filled in 12 ms. at full line rate */
-	Nrb		= 1024,		/* private receive buffers per Ctlr */
+	/* were 512, 1024 & 64, but 52, 253 and 9 are ample. */
+	Nrd		= 128,		/* power of two */
+	Nrb		= 256,		/* private receive buffers per Ctlr */
+	Ntd		= 32,		/* power of two */
 };
 
 enum {

+ 4 - 3
sys/src/9/pc/ether82598.c

@@ -22,10 +22,11 @@ enum {
 	Descalign= 128,		/* 599 manual needs 128-byte alignment */
 
 	/* tunable parameters */
-	Nrd	= 256,		/* multiple of 8, power of 2 for NEXTPOW2 */
-	Nrb	= 1024,
-	Ntd	= 64,		/* multiple of 8, power of 2 for NEXTPOW2 */
 	Goslow	= 0,		/* flag: go slow by throttling intrs, etc. */
+	/* were 256, 1024 & 64, but 30, 47 and 1 are ample. */
+	Nrd	= 64,		/* multiple of 8, power of 2 for NEXTPOW2 */
+	Nrb	= 128,
+	Ntd	= 32,		/* multiple of 8, power of 2 for NEXTPOW2 */
 };
 
 enum {

+ 4 - 3
sys/src/9/pc/etherdp83820.c

@@ -335,10 +335,11 @@ enum {					/* extsts bits */
 };
 
 enum {
-	Nrd		= 256,
-	Nrb		= 4*Nrd,
 	Rbsz		= ROUNDUP(sizeof(Etherpkt)+8, 8),
-	Ntd		= 64,
+	/* were 256, 4*Nrd & 64, but 52, 253 and 9 are ample. */
+	Nrd		= 128,
+	Nrb		= 256,
+	Ntd		= 32,
 };
 
 typedef struct Ctlr Ctlr;

+ 4 - 3
sys/src/9/pc/etherigbe.c

@@ -443,10 +443,11 @@ enum {					/* Td status */
 };
 
 enum {
-	Nrd		= 256,		/* multiple of 8 */
-	Ntd		= 64,		/* multiple of 8 */
-	Nrb		= 1024,		/* private receive buffers per Ctlr */
 	Rbsz		= 2048,
+	/* were 256, 1024 & 64, but 52, 253 and 9 are ample. */
+	Nrd		= 128,		/* multiple of 8 */
+	Nrb		= 256,		/* private receive buffers per Ctlr */
+	Ntd		= 32,		/* multiple of 8 */
 };
 
 typedef struct Ctlr Ctlr;

+ 9 - 3
sys/src/cmd/acme/cols.c

@@ -111,7 +111,7 @@ void
 colclose(Column *c, Window *w, int dofree)
 {
 	Rectangle r;
-	int i;
+	int i, didmouse, up;
 
 	/* w is locked */
 	if(!c->safe)
@@ -125,7 +125,7 @@ colclose(Column *c, Window *w, int dofree)
 	w->tag.col = nil;
 	w->body.col = nil;
 	w->col = nil;
-	restoremouse(w);
+	didmouse = restoremouse(w);
 	if(dofree){
 		windelete(w);
 		winclose(w);
@@ -137,6 +137,7 @@ colclose(Column *c, Window *w, int dofree)
 		draw(screen, r, display->white, nil, ZP);
 		return;
 	}
+	up = 0;
 	if(i == c->nw){		/* extend last window down */
 		w = c->w[i-1];
 		r.min.y = w->r.min.y;
@@ -144,10 +145,15 @@ colclose(Column *c, Window *w, int dofree)
 	}else{			/* extend next window up */
 		w = c->w[i];
 		r.max.y = w->r.max.y;
+		up = 1;
 	}
 	draw(screen, r, textcols[BACK], nil, ZP);
-	if(c->safe)
+	if(c->safe){
 		winresize(w, r, FALSE);
+		USED(up);
+		if(!didmouse)
+			movetodel(w);
+	}
 }
 
 void

+ 2 - 1
sys/src/cmd/acme/fns.h

@@ -19,10 +19,11 @@ void	undo(Text*, Text*, Text*, int, int, Rune*, int);
 char*	getname(Text*, Text*, Rune*, int, int);
 void	scrsleep(uint);
 void	savemouse(Window*);
-void	restoremouse(Window*);
+int	restoremouse(Window*);
 void	clearmouse(void);
 void	allwindows(void(*)(Window*, void*), void*);
 uint loadfile(int, uint, int*, int(*)(void*, uint, Rune*, int), void*);
+void	movetodel(Window*);
 
 Window*	errorwin(Mntdir*, int);
 Window*	errorwinforwin(Window*);

+ 8 - 2
sys/src/cmd/acme/util.c

@@ -366,12 +366,18 @@ savemouse(Window *w)
 	mousew = w;
 }
 
-void
+int
 restoremouse(Window *w)
 {
-	if(mousew!=nil && mousew==w)
+	int did;
+
+	did = 0;
+	if(mousew!=nil && mousew==w){
 		moveto(mousectl, prevmouse);
+		did = 1;
+	}
 	mousew = nil;
+	return did;
 }
 
 void

+ 28 - 0
sys/src/cmd/acme/wind.c

@@ -83,6 +83,34 @@ wininit(Window *w, Window *clone, Rectangle r)
 	}
 }
 
+int
+delrunepos(Window *w)
+{
+	int n;
+	Rune rune;
+	
+	for(n=0; n<w->tag.file->nc; n++) {
+		bufread(w->tag.file, n, &rune, 1);
+		if(rune == ' ')
+			break;
+	}
+	n += 2;
+	if(n >= w->tag.file->nc)
+		return -1;
+	return n;
+}
+
+void
+movetodel(Window *w)
+{
+	int n;
+	
+	n = delrunepos(w);
+	if(n < 0)
+		return;
+	moveto(mousectl, addpt(frptofchar(&w->tag, n), Pt(4, w->tag.font->height-4)));
+}
+
 int
 winresize(Window *w, Rectangle r, int safe)
 {

+ 1 - 1
sys/src/cmd/db/main.c

@@ -103,7 +103,7 @@ main(int argc, char **argv)
 	setsym();
 	dotmap = dumbmap(-1);
 	if (name && machbyname(name) == 0)
-			dprint ("unknown machine %s", name);
+		dprint("unknown machine %s\n", name);
 	dprint("%s binary\n", mach->name);
 	if(setjmp(env) == 0){
 		if (corfil) {

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

@@ -409,13 +409,13 @@ proto(Req *rp, int n)
 
 /*
  * since we are single-threaded, this causes us to effectively
- * stop listening for two seconds.
+ * stop listening while we sleep.
  */
 static void
 slowdelay(Req *rp)
 {
 	if(slowstat && rp->staticbinding || slowdyn && !rp->staticbinding)
-		sleep(2000);
+		sleep(1000);
 }
 
 void

+ 10 - 1
sys/src/cmd/rx.c

@@ -24,6 +24,12 @@ usage(void)
 	exits("usage");
 }
 
+static int
+catch(void *, char *s)
+{
+	return strstr(s, "alarm") != nil;
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -58,6 +64,7 @@ main(int argc, char *argv[])
 		usage();
 	host = argv[0];
 	args = buildargs(&argv[1]);
+	atnotify(catch, 1);
 
 	/* try rexexec p9any then dial again with p9sk2 */
 	fd = call(0, host, "rexexec", &addr);
@@ -97,10 +104,12 @@ void
 rex(int fd, char *cmd, char *proto)
 {
 	char buf[4096];
-	int kid, n;
+	int kid, n, oalarm;
 	AuthInfo *ai;
 
+	oalarm = alarm(2 * 60 * 1000);		/* don't hang forever */
 	ai = auth_proxy(fd, auth_getkey, "proto=%s role=client %s", proto, key);
+	alarm(oalarm);
 	if(ai == nil){
 		if(strcmp(proto, "p9any") == 0)
 			return;

+ 15 - 5
sys/src/cmd/venti/srv/arenas.c

@@ -15,7 +15,8 @@ struct AHash
 
 enum
 {
-	AHashSize	= 512
+	AHashSize	= 512,
+	Emergency	= 0,		/* flag: performing emergency surgery */
 };
 
 static AHash	*ahash[AHashSize];
@@ -142,8 +143,11 @@ initarenapart(Part *part)
 	ap->narenas = amn.n;
 	ap->map = amn.map;
 	if(okamap(ap->map, ap->narenas, ap->arenabase, ap->size, "arena table") < 0){
-		freearenapart(ap, 0);
-		return nil;
+		if(!Emergency){
+			freearenapart(ap, 0);
+			return nil;
+		}
+		/* else keep on, for emergency use */
 	}
 
 	ap->arenas = MKNZ(Arena*, ap->narenas);
@@ -152,8 +156,14 @@ initarenapart(Part *part)
 		ap->arenas[i] = initarena(part, ap->map[i].start, ap->map[i].stop - ap->map[i].start, ap->blocksize);
 		if(ap->arenas[i] == nil){
 			seterr(ECorrupt, "%s: %r", ap->map[i].name);
-			freearenapart(ap, 1);
-			return nil;
+			if(!Emergency){
+				freearenapart(ap, 1);
+				return nil;
+			}else{
+				/* keep on, for emergency use */
+				ap->narenas = i;
+				break;
+			}
 		}
 		if(namecmp(ap->map[i].name, ap->arenas[i]->name) != 0){
 			seterr(ECorrupt, "arena name mismatches with expected name: %s vs. %s",