Plan 9 from Bell Labs’s /usr/web/sources/extra/changes/2007/0418

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/sys/src/cmd/ndb/cs.c /sys/main/2/ndb /sys/man/6/ndb /sys/man/8/ndb /sys/src/libndb/ndbipinfo.c
% cat >/sys/lib/dist/changes/1176931805.0.txt << EOF
Correctly document the behavior of the @ flag
EOF
 [geoff] --rw-rw-r-- M 44 glenda sys 33123 Apr 18 17:30 sys/src/cmd/ndb/cs.c
	/n/sourcesdump/2007/0418/plan9/sys/src/cmd/ndb/cs.c:1770,1778 - 
	/n/sources/plan9/sys/src/cmd/ndb/cs.c:1770,1778
	  	 */
	  	nresolve = 0;
	  	for(i = 0; i < n; i++)
	- 		if(*list[i] == '@'){
	+ 		if(*list[i] == '@'){		/* @attr=val ? */
	  			list[i]++;
	- 			resolve[i] = 1;
	+ 			resolve[i] = 1;		/* we'll resolve it */
	  			nresolve++;
	  		} else
	  			resolve[i] = 0;
 [geoff] --rw-rw-r-- M 44 glenda sys 9743 Apr 18 17:35 sys/man/2/ndb
	/n/sourcesdump/2007/0418/plan9/sys/man/2/ndb:262,267 - 
	/n/sources/plan9/sys/man/2/ndb:262,276
	  .I n
	  element array
	  .IR attrs .
	+ If any
	+ .I attrs
	+ begin with
	+ .LR @ ,
	+ the
	+ .L @
	+ is excluded from the attribute name,
	+ but causes any corresponding value returned
	+ to be a resolved IP address(es), not a name.
	  For example, consider the following database entries describing a network,
	  a subnetwork, and a system.
	  .IP
 [geoff] --rw-rw-r-- M 44 glenda sys 6671 Apr 18 17:35 sys/man/6/ndb
	/n/sourcesdump/2007/0418/plan9/sys/man/6/ndb:241,249 - 
	/n/sources/plan9/sys/man/6/ndb:241,246
	  .B dns
	  a DNS server to use (for DNS and DHCP)
	  .TP
	- .B @dns
	- a DNS server to forward queries to when running as a resolver (for DNS)
	- .TP
	  .B ntp
	  an NTP server to use (for DHCP)
	  .TP
 [geoff] --rw-rw-r-- M 44 glenda sys 13254 Apr 18 17:35 sys/man/8/ndb
	/n/sourcesdump/2007/0418/plan9/sys/man/8/ndb:297,303 - 
	/n/sources/plan9/sys/man/8/ndb:297,303
	  must be a space-separated list of such DNS servers' IP addresses,
	  otherwise optional
	  .IR ndb (6)
	- .B @dns
	+ .B dns
	  attributes name DNS servers to forward queries to.
	  .TP
	  .B -R

 [geoff] --rw-rw-r-- M 44 glenda sys 5181 Apr 18 17:29 sys/src/libndb/ndbipinfo.c
	/n/sourcesdump/2007/0418/plan9/sys/src/libndb/ndbipinfo.c:34,41 - 
	/n/sources/plan9/sys/src/libndb/ndbipinfo.c:34,41
	  			first = t;
	  		last = t;
	  		p = *argv++;
	- 		if(*p == '@'){
	- 			t->ptr |= Faddr;
	+ 		if(*p == '@'){			/* @attr=val ? */
	+ 			t->ptr |= Faddr;	/* return resolved address(es) */
	  			p++;
	  		}
	  		strncpy(t->attr, p, sizeof(t->attr)-1);

/sys/src/9/ip/icmp6.c
% cat >/sys/lib/dist/changes/1176939006.0.txt << EOF
Code cleanup
• Whitespace / style
• Comments
• Where possible, condense conditionals
EOF
 [geoff] --rw-rw-r-- M 44 presotto sys 17893 Apr 18 19:10 sys/src/9/ip/icmp6.c
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:284,293 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:284,293
	  static void
	  goticmpkt6(Proto *icmp, Block *bp, int muxkey)
	  {
	- 	ushort	recid;
	- 	uchar 	*addr;
	- 	Conv	**c, *s;
	- 	IPICMP	*p = (IPICMP *)bp->rp;
	+ 	ushort recid;
	+ 	uchar *addr;
	+ 	Conv **c, *s;
	+ 	IPICMP *p = (IPICMP *)bp->rp;
	  
	  	if(muxkey == 0) {
	  		recid = nhgets(p->icmpid);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:609,620 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:609,620
	  				goto err;
	  			}
	  
	- 			if(p->type == NbrSolicit)
	- 				if(ipcmp(np->src, v6Unspecified) == 0)
	- 					if(!issmcast(np->dst) || optexsts(np)) {
	- 						ipriv->stats[AddrmxpErrs6]++;
	- 						goto err;
	- 					}
	+ 			if (p->type == NbrSolicit &&
	+ 			    ipcmp(np->src, v6Unspecified) == 0)
	+ 				if(!issmcast(np->dst) || optexsts(np)) {
	+ 					ipriv->stats[AddrmxpErrs6]++;
	+ 					goto err;
	+ 				}
	  
	  			if(p->type == NbrAdvert)
	  				if(isv6mcast(np->dst) &&
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:670,678 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:670,676
	  			goto err;
	  		}
	  	}
	- 
	  	return 1;
	- 
	  err:
	  	ipriv->stats[InErrors6]++;
	  	return 0;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:692,698 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:690,696
	  
	  	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
	  		if(ipcmp(lifc->local, target) == 0) {
	- 			t = (lifc->tentative) ? t_unitent : t_unirany;
	+ 			t = (lifc->tentative)? t_unitent: t_unirany;
	  			runlock(ifc);
	  			return t;
	  		}
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:761,767 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:759,765
	  			}
	  			p = (IPICMP *)bp->rp;
	  			pr = Fsrcvpcolx(icmp->f, p->proto);
	- 			if(pr != nil && pr->advise != nil) {
	+ 			if(pr && pr->advise) {
	  				(*pr->advise)(pr, bp, m2);
	  				return;
	  			}
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/icmp6.c:837,843 - 
	/n/sources/plan9/sys/src/9/ip/icmp6.c:835,840
	  		break;
	  	}
	  	return;
	- 
	  raise:
	  	freeblist(bp);
	  }
 [geoff] --rw-rw-r-- M 44 glenda sys 33863 Apr 18 19:12 sys/src/9/ip/ipifc.c
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:13,27 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:13,24
	  enum {
	  	Maxmedia	= 32,
	  	Nself		= Maxmedia*5,
	- 	NHASH		= (1<<6),
	+ 	NHASH		= 1<<6,
	  	NCACHE		= 256,
	  	QMAX		= 64*1024-1,
	  };
	  
	- Medium *media[Maxmedia] =
	- {
	- 	0
	- };
	+ Medium *media[Maxmedia] = { 0 };
	  
	  /*
	   *  cache of local addresses (addresses we answer to)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:144,158 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:141,155
	  	ifc->maxtu = ifc->m->maxtu;
	  	if(ifc->m->unbindonclose == 0)
	  		ifc->conv->inuse++;
	- 	ifc->rp.mflag = 0;		// default not managed
	+ 	ifc->rp.mflag = 0;		/* default not managed */
	  	ifc->rp.oflag = 0;
	- 	ifc->rp.maxraint = 600000;	// millisecs
	+ 	ifc->rp.maxraint = 600000;	/* millisecs */
	  	ifc->rp.minraint = 200000;
	- 	ifc->rp.linkmtu = 0;		// no mtu sent
	+ 	ifc->rp.linkmtu = 0;		/* no mtu sent */
	  	ifc->rp.reachtime = 0;
	  	ifc->rp.rxmitra = 0;
	  	ifc->rp.ttl = MAXTTL;
	- 	ifc->rp.routerlt = 3*(ifc->rp.maxraint);
	+ 	ifc->rp.routerlt = 3 * ifc->rp.maxraint;
	  
	  	/* any ancillary structures (like routes) no longer pertain */
	  	ifc->ifcid++;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:189,195 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:186,192
	  	ifc->ifcid++;
	  
	  	/* disassociate device */
	- 	if(ifc->m != nil && ifc->m->unbind)
	+ 	if(ifc->m && ifc->m->unbind)
	  		(*ifc->m->unbind)(ifc);
	  	memset(ifc->dev, 0, sizeof(ifc->dev));
	  	ifc->arg = nil;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:213,219 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:210,218
	  	return nil;
	  }
	  
	- char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt %d pktin %lud pktout %lud errin %lud errout %lud\n";
	+ char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
	+ " %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt"
	+ " %d pktin %lud pktout %lud errin %lud errout %lud\n";
	  
	  char slineformat[] = "	%-40I %-10M %-40I %-12lud %-12lud\n";
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:225,231 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:224,229
	  	int m;
	  
	  	ifc = (Ipifc*)c->ptcl;
	- 
	  	m = snprint(state, n, sfixedformat,
	  		ifc->dev, ifc->maxtu, ifc->sendra6, ifc->recvra6,
	  		ifc->rp.mflag, ifc->rp.oflag, ifc->rp.maxraint,
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:235,243 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:233,240
	  
	  	rlock(ifc);
	  	for(lifc = ifc->lifc; lifc && n > m; lifc = lifc->next)
	- 		m += snprint(state+m, n - m, slineformat,
	- 			lifc->local, lifc->mask, lifc->remote,
	- 			lifc->validlt, lifc->preflt);
	+ 		m += snprint(state+m, n - m, slineformat, lifc->local,
	+ 			lifc->mask, lifc->remote, lifc->validlt, lifc->preflt);
	  	if(ifc->lifc == nil)
	  		m += snprint(state+m, n - m, "\n");
	  	runlock(ifc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:253,259 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:250,255
	  	int m;
	  
	  	ifc = (Ipifc*)c->ptcl;
	- 
	  	m = 0;
	  
	  	rlock(ifc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:337,343 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:333,339
	  
	  	ifc = (Ipifc*)c->ptcl;
	  	m = ifc->m;
	- 	if(m != nil && m->unbindonclose)
	+ 	if(m && m->unbindonclose)
	  		ipifcunbind(ifc);
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:349,358 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:345,352
	  {
	  	int mtu;
	  
	- 	if(argc < 2)
	+ 	if(argc < 2 || ifc->m == nil)
	  		return Ebadarg;
	- 	if(ifc->m == nil)
	- 		return Ebadarg;
	  	mtu = strtoul(argv[1], 0, 0);
	  	if(mtu < ifc->m->mintu || mtu > ifc->m->maxtu)
	  		return Ebadarg;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:366,377 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:360,370
	  char*
	  ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
	  {
	+ 	int i, type, mtu, sendnbrdisc = 0;
	  	uchar ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
	  	uchar bcast[IPaddrlen], net[IPaddrlen];
	  	Iplifc *lifc, **l;
	- 	int i, type, mtu;
	  	Fs *f;
	- 	int sendnbrdisc = 0;
	  
	  	if(ifc->m == nil)
	  		return "ipifc not yet bound to device";
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:412,418 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:405,410
	  		break;
	  	default:
	  		return Ebadarg;
	- 		break;
	  	}
	  	if(isv4(ip))
	  		tentative = 0;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:419,425 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:411,417
	  	wlock(ifc);
	  
	  	/* ignore if this is already a local address for this ifc */
	- 	for(lifc = ifc->lifc; lifc; lifc = lifc->next) {
	+ 	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
	  		if(ipcmp(lifc->local, ip) == 0) {
	  			if(lifc->tentative != tentative)
	  				lifc->tentative = tentative;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:432,438 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:424,429
	  			}
	  			goto out;
	  		}
	- 	}
	  
	  	/* add the address to the list of logical ifc's for this ifc */
	  	lifc = smalloc(sizeof(Iplifc));
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:447,459 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:438,449
	  		lifc->validlt = lifcp->validlt;
	  		lifc->preflt = lifcp->preflt;
	  		lifc->origint = lifcp->origint;
	- 	}
	- 	else {		// default values
	+ 	} else {		/* default values */
	  		lifc->onlink = 1;
	  		lifc->autoflag = 1;
	- 		lifc->validlt = 0xffffffff;
	- 		lifc->preflt = 0xffffffff;
	- 		lifc->origint = NOW / 10^3;
	+ 		lifc->validlt = ~0L;
	+ 		lifc->preflt = ~0L;
	+ 		lifc->origint = NOW / 1000;
	  	}
	  	lifc->next = nil;
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:462,468 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:452,458
	  	*l = lifc;
	  
	  	/* check for point-to-point interface */
	- 	if(ipcmp(ip, v6loopback))	/* skip v6 loopback, it's a special address */
	+ 	if(ipcmp(ip, v6loopback)) /* skip v6 loopback, it's a special address */
	  	if(ipcmp(mask, IPallbits) == 0)
	  		type |= Rptpt;
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:503,516 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:493,506
	  		addselfcache(f, ifc, lifc, bcast, Rbcast);
	  
	  		addselfcache(f, ifc, lifc, IPv4bcast, Rbcast);
	- 	}
	- 	else {
	+ 	} else {
	  		if(ipcmp(ip, v6loopback) == 0) {
	  			/* add node-local mcast address */
	  			addselfcache(f, ifc, lifc, v6allnodesN, Rmulti);
	  
	  			/* add route for all node multicast */
	- 			v6addroute(f, tifc, v6allnodesN, v6allnodesNmask, v6allnodesN, Rmulti);
	+ 			v6addroute(f, tifc, v6allnodesN, v6allnodesNmask,
	+ 				v6allnodesN, Rmulti);
	  		}
	  
	  		/* add all nodes multicast address */
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:517,523 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:507,514
	  		addselfcache(f, ifc, lifc, v6allnodesL, Rmulti);
	  
	  		/* add route for all nodes multicast */
	- 		v6addroute(f, tifc, v6allnodesL, v6allnodesLmask, v6allnodesL, Rmulti);
	+ 		v6addroute(f, tifc, v6allnodesL, v6allnodesLmask, v6allnodesL,
	+ 			Rmulti);
	  
	  		/* add solicited-node multicast address */
	  		ipv62smcast(bcast, ip);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:579,585 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:570,575
	  
	  	free(lifc);
	  	return nil;
	- 
	  }
	  
	  /*
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:589,599 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:579,587
	  char*
	  ipifcrem(Ipifc *ifc, char **argv, int argc)
	  {
	- 	uchar ip[IPaddrlen];
	- 	uchar mask[IPaddrlen];
	- 	uchar rem[IPaddrlen];
	- 	Iplifc *lifc;
	  	char *rv;
	+ 	uchar ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
	+ 	Iplifc *lifc;
	  
	  	if(argc < 3)
	  		return Ebadarg;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:612,623 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:600,610
	  	 *  for pt to pt we actually specify the remote address as the
	  	 *  addresss to remove.
	  	 */
	- 	for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next) {
	+ 	for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next)
	  		if (memcmp(ip, lifc->local, IPaddrlen) == 0
	  		&& memcmp(mask, lifc->mask, IPaddrlen) == 0
	  		&& memcmp(rem, lifc->remote, IPaddrlen) == 0)
	  			break;
	- 	}
	  
	  	rv = ipifcremlifc(ifc, lifc);
	  	wunlock(ifc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:636,651 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:623,635
	  	Ipifc *ifc;
	  
	  	e = &f->ipifc->conv[f->ipifc->nc];
	- 	for(cp = f->ipifc->conv; cp < e; cp++){
	+ 	for(cp = f->ipifc->conv; cp < e; cp++)
	  		if(*cp != nil) {
	  			ifc = (Ipifc*)(*cp)->ptcl;
	  			m = ifc->m;
	- 			if(m == nil)
	- 				continue;
	- 			if(m->addroute != nil)
	+ 			if(m && m->addroute)
	  				m->addroute(ifc, vers, addr, mask, gate, type);
	  		}
	- 	}
	  }
	  
	  void
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:656,671 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:640,652
	  	Ipifc *ifc;
	  
	  	e = &f->ipifc->conv[f->ipifc->nc];
	- 	for(cp = f->ipifc->conv; cp < e; cp++){
	+ 	for(cp = f->ipifc->conv; cp < e; cp++)
	  		if(*cp != nil) {
	  			ifc = (Ipifc*)(*cp)->ptcl;
	  			m = ifc->m;
	- 			if(m == nil)
	- 				continue;
	- 			if(m->remroute != nil)
	+ 			if(m && m->remroute)
	  				m->remroute(ifc, vers, addr, mask);
	  		}
	- 	}
	  }
	  
	  /*
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:702,708 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:683,688
	  		return err;
	  
	  	Fsconnected(c, nil);
	- 
	  	return nil;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:718,744 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:698,724
	  		return Ebadarg;
	  
	  	while (argsleft > 1) {
	- 		if(strcmp(argv[i],"recvra")==0)
	+ 		if(strcmp(argv[i], "recvra") == 0)
	  			ifc->recvra6 = (atoi(argv[i+1]) != 0);
	- 		else if(strcmp(argv[i],"sendra")==0)
	+ 		else if(strcmp(argv[i], "sendra") == 0)
	  			ifc->sendra6 = (atoi(argv[i+1]) != 0);
	- 		else if(strcmp(argv[i],"mflag")==0)
	+ 		else if(strcmp(argv[i], "mflag") == 0)
	  			ifc->rp.mflag = (atoi(argv[i+1]) != 0);
	- 		else if(strcmp(argv[i],"oflag")==0)
	+ 		else if(strcmp(argv[i], "oflag") == 0)
	  			ifc->rp.oflag = (atoi(argv[i+1]) != 0);
	- 		else if(strcmp(argv[i],"maxraint")==0)
	+ 		else if(strcmp(argv[i], "maxraint") == 0)
	  			ifc->rp.maxraint = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"minraint")==0)
	+ 		else if(strcmp(argv[i], "minraint") == 0)
	  			ifc->rp.minraint = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"linkmtu")==0)
	+ 		else if(strcmp(argv[i], "linkmtu") == 0)
	  			ifc->rp.linkmtu = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"reachtime")==0)
	+ 		else if(strcmp(argv[i], "reachtime") == 0)
	  			ifc->rp.reachtime = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"rxmitra")==0)
	+ 		else if(strcmp(argv[i], "rxmitra") == 0)
	  			ifc->rp.rxmitra = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"ttl")==0)
	+ 		else if(strcmp(argv[i], "ttl") == 0)
	  			ifc->rp.ttl = atoi(argv[i+1]);
	- 		else if(strcmp(argv[i],"routerlt")==0)
	+ 		else if(strcmp(argv[i], "routerlt") == 0)
	  			ifc->rp.routerlt = atoi(argv[i+1]);
	  		else
	  			return Ebadarg;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:747,759 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:727,738
	  		i += 2;
	  	}
	  
	- 	// consistency check
	+ 	/* consistency check */
	  	if(ifc->rp.maxraint < ifc->rp.minraint) {
	  		ifc->rp.maxraint = vmax;
	  		ifc->rp.minraint = vmin;
	  		return Ebadarg;
	  	}
	- 
	  	return nil;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:760,771 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:739,745
	  char*
	  ipifcsendra6(Ipifc *ifc, char **argv, int argc)
	  {
	- 	int i;
	- 
	- 	i = 0;
	- 	if(argc > 1)
	- 		i = atoi(argv[1]);
	- 	ifc->sendra6 = (i!=0);
	+ 	ifc->sendra6 = ((argc > 1? atoi(argv[1]): 0) != 0);
	  	return nil;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:772,783 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:746,752
	  char*
	  ipifcrecvra6(Ipifc *ifc, char **argv, int argc)
	  {
	- 	int i;
	- 
	- 	i = 0;
	- 	if(argc > 1)
	- 		i = atoi(argv[1]);
	- 	ifc->recvra6 = (i!=0);
	+ 	ifc->recvra6 = ((argc > 1? atoi(argv[1]): 0) != 0);
	  	return nil;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:789,795 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:758,763
	  ipifcctl(Conv* c, char**argv, int argc)
	  {
	  	Ipifc *ifc;
	- 	int i;
	  
	  	ifc = (Ipifc*)c->ptcl;
	  	if(strcmp(argv[0], "add") == 0)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:809,823 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:777,786
	  	else if(strcmp(argv[0], "reassemble") == 0){
	  		ifc->reassemble = 1;
	  		return nil;
	- 	}
	- 	else if(strcmp(argv[0], "iprouting") == 0){
	- 		i = 1;
	- 		if(argc > 1)
	- 			i = atoi(argv[1]);
	- 		iprouting(c->p->f, i);
	+ 	} else if(strcmp(argv[0], "iprouting") == 0){
	+ 		iprouting(c->p->f, (argc > 1? atoi(argv[1]): 1));
	  		return nil;
	- 	}
	- 	else if(strcmp(argv[0], "addpref6") == 0)
	+ 	} else if(strcmp(argv[0], "addpref6") == 0)
	  		return ipifcaddpref6(ifc, argv, argc);
	  	else if(strcmp(argv[0], "setpar6") == 0)
	  		return ipifcsetpar6(ifc, argv, argc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:857,863 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:820,826
	  	ipifc->nc = Maxmedia;
	  	ipifc->ptclsize = sizeof(Ipifc);
	  
	- 	f->ipifc = ipifc;			/* hack for ipifcremroute, findipifc, ... */
	+ 	f->ipifc = ipifc;	/* hack for ipifcremroute, findipifc, ... */
	  	f->self = smalloc(sizeof(Ipselftab));	/* hack for ipforme */
	  
	  	Fsproto(f, ipifc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:913,927 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:876,890
	  
	  		/* add to routing table */
	  		if(isv4(a))
	- 			v4addroute(f, tifc, a+IPv4off, IPallbits+IPv4off, a+IPv4off, type);
	+ 			v4addroute(f, tifc, a+IPv4off, IPallbits+IPv4off,
	+ 				a+IPv4off, type);
	  		else
	  			v6addroute(f, tifc, a, IPallbits, a, type);
	  
	  		if((type & Rmulti) && ifc->m->addmulti != nil)
	  			(*ifc->m->addmulti)(ifc, a, lifc->local);
	- 	} else {
	+ 	} else
	  		lp->ref++;
	- 	}
	  
	  	qunlock(f->self);
	  }
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:950,956 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:913,919
	  		}
	  		l = &np->next;
	  	}
	- 	p->expire = now + 5000;		/* give other threads 5 secs to get out */
	+ 	p->expire = now + 5000;	/* give other threads 5 secs to get out */
	  	p->next = nil;
	  	*l = p;
	  }
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:969,975 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:932,938
	  		}
	  		l = &np->next;
	  	}
	- 	p->expire = now + 5000;		/* give other threads 5 secs to get out */
	+ 	p->expire = now + 5000;	/* give other threads 5 secs to get out */
	  	p->next = nil;
	  	*l = p;
	  }
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1018,1024 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:981,987
	  	 */
	  	l_self = &p->link;
	  	for(link = *l_self; link; link = *l_self){
	- 		if(link == *(l_lifc))
	+ 		if(link == *l_lifc)
	  			break;
	  		l_self = &link->selflink;
	  	}
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1075,1081 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1038,1044
	  	m = 0;
	  	off = offset;
	  	qlock(f->self);
	- 	for(i = 0; i < NHASH && m < n; i++){
	+ 	for(i = 0; i < NHASH && m < n; i++)
	  		for(p = f->self->hash[i]; p != nil && m < n; p = p->next){
	  			nifc = 0;
	  			for(link = p->link; link; link = link->selflink)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1087,1093 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1050,1055
	  				m = 0;
	  			}
	  		}
	- 	}
	  	qunlock(f->self);
	  	return m;
	  }
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1098,1108 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1060,1068
	   	Ipself *p;
	  
	  	p = f->self->hash[hashipa(addr)];
	- 	for(; p; p = p->next){
	- 		if(ipcmp(addr, p->a) == 0) {
	+ 	for(; p; p = p->next)
	+ 		if(ipcmp(addr, p->a) == 0)
	  			return p->link->lifc->tentative;
	- 		}
	- 	}
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1119,1133 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1079,1091
	  	Ipself *p;
	  
	  	p = f->self->hash[hashipa(addr)];
	- 	for(; p; p = p->next){
	+ 	for(; p; p = p->next)
	  		if(ipcmp(addr, p->a) == 0)
	  			return p->type;
	- 	}
	  
	  	/* hack to say accept anything */
	  	if(f->self->acceptall)
	  		return Runi;
	- 
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1141,1150 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1099,1108
	  	Ipifc *ifc, *x;
	  	Iplifc *lifc;
	  	Conv **cp, **e;
	- 	uchar gnet[IPaddrlen];
	- 	uchar xmask[IPaddrlen];
	+ 	uchar gnet[IPaddrlen], xmask[IPaddrlen];
	  
	- 	x = nil; memset(xmask, 0, IPaddrlen);
	+ 	x = nil;
	+ 	memset(xmask, 0, IPaddrlen);
	  
	  	/* find most specific match */
	  	e = &f->ipifc->conv[f->ipifc->nc];
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1151,1167 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1109,1122
	  	for(cp = f->ipifc->conv; cp < e; cp++){
	  		if(*cp == 0)
	  			continue;
	- 
	  		ifc = (Ipifc*)(*cp)->ptcl;
	- 
	  		for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	  			maskip(remote, lifc->mask, gnet);
	- 			if(ipcmp(gnet, lifc->net) == 0){
	+ 			if(ipcmp(gnet, lifc->net) == 0)
	  				if(x == nil || ipcmp(lifc->mask, xmask) > 0){
	  					x = ifc;
	  					ipmove(xmask, lifc->mask);
	  				}
	- 			}
	  		}
	  	}
	  	if(x != nil)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1168,1174 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1123,1129
	  		return x;
	  
	  	/* for now for broadcast and multicast, just use first interface */
	- 	if(type & (Rbcast|Rmulti)){
	+ 	if(type & (Rbcast|Rmulti))
	  		for(cp = f->ipifc->conv; cp < e; cp++){
	  			if(*cp == 0)
	  				continue;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1176,1188 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1131,1141
	  			if(ifc->lifc != nil)
	  				return ifc;
	  		}
	- 	}
	- 
	  	return nil;
	  }
	  
	  enum {
	- 	unknownv6,
	+ 	unknownv6,		/* UGH */
	  	multicastv6,
	  	unspecifiedv6,
	  	linklocalv6,
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1204,1218 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1157,1172
	  	return unknownv6;
	  }
	  
	- #define v6addrcurr(lifc) (( (lifc)->origint + (lifc)->preflt >= (NOW/10^3) ) || ( (lifc)->preflt == 0xffffffff ))
	+ #define v6addrcurr(lifc) ((lifc)->origint + (lifc)->preflt >= NOW/1000 || \
	+ 				(lifc)->preflt == ~0L)
	  
	  static void
	  findprimaryipv6(Fs *f, uchar *local)
	  {
	+ 	int atype, atypel;
	  	Conv **cp, **e;
	  	Ipifc *ifc;
	  	Iplifc *lifc;
	- 	int atype, atypel;
	  
	  	ipmove(local, v6Unspecified);
	  	atype = unspecifiedv6;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1227,1234 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1181,1187
	  		ifc = (Ipifc*)(*cp)->ptcl;
	  		for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	  			atypel = v6addrtype(lifc->local);
	- 			if(atypel > atype)
	- 			if(v6addrcurr(lifc)) {
	+ 			if(atypel > atype && v6addrcurr(lifc)) {
	  				ipmove(local, lifc->local);
	  				atype = atypel;
	  				if(atype == globalv6)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1268,1286 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1221,1237
	  void
	  findlocalip(Fs *f, uchar *local, uchar *remote)
	  {
	+ 	int version, atype = unspecifiedv6, atypel = unknownv6;
	+ 	uchar gate[IPaddrlen], gnet[IPaddrlen];
	  	Ipifc *ifc;
	  	Iplifc *lifc;
	  	Route *r;
	- 	uchar gate[IPaddrlen];
	- 	uchar gnet[IPaddrlen];
	- 	int version;
	- 	int atype = unspecifiedv6, atypel = unknownv6;
	  
	  	USED(atype);
	  	USED(atypel);
	  	qlock(f->ipifc);
	  	r = v6lookup(f, remote, nil);
	-  	version = (memcmp(remote, v4prefix, IPv4off) == 0) ? V4 : V6;
	+  	version = (memcmp(remote, v4prefix, IPv4off) == 0)? V4: V6;
	  
	  	if(r != nil){
	  		ifc = r->ifc;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1306,1314 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1257,1264
	  			for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	  				atypel = v6addrtype(lifc->local);
	  				maskip(gate, lifc->mask, gnet);
	- 				if(ipcmp(gnet, lifc->net) == 0)
	- 				if(atypel > atype)
	- 				if(v6addrcurr(lifc)) {
	+ 				if (ipcmp(gnet, lifc->net) == 0 &&
	+ 				    atypel > atype && v6addrcurr(lifc)) {
	  					ipmove(local, lifc->local);
	  					atype = atypel;
	  					if(atype == globalv6)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1346,1357 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1296,1306
	  {
	  	Iplifc *lifc;
	  
	- 	for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	+ 	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
	  		if(isv4(lifc->local)){
	  			memmove(addr, lifc->local+IPv4off, IPv4addrlen);
	  			return 1;
	  		}
	- 	}
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1363,1374 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1312,1322
	  {
	  	Iplifc *lifc;
	  
	- 	for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	+ 	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
	  		if(!isv4(lifc->local) && !(lifc->tentative)){
	  			ipmove(addr, lifc->local);
	  			return 1;
	  		}
	- 	}
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1377,1388 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1325,1335
	  {
	  	Iplifc *lifc;
	  
	- 	for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	+ 	for(lifc = ifc->lifc; lifc; lifc = lifc->next)
	  		if(!isv4(lifc->local)){
	  			ipmove(addr, lifc->local);
	  			return SRC_UNI;
	  		}
	- 	}
	  	return SRC_UNSPEC;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1413,1422 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1360,1367
	  
	  	/* see if this is a direct connected pt to pt address */
	  	r = v6lookup(f, ip, nil);
	- 	if(r == nil)
	+ 	if(r == nil || (r->type & (Rifc|Rproxy)) != (Rifc|Rproxy))
	  		return 0;
	- 	if((r->type & (Rifc|Rproxy)) != (Rifc|Rproxy))
	- 		return 0;
	  
	  	/* see if this is on the right interface */
	  	for(lifc = ifc->lifc; lifc; lifc = lifc->next){
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1424,1430 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1369,1374
	  		if(ipcmp(net, lifc->remote) == 0)
	  			return 1;
	  	}
	- 
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1437,1460 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1381,1402
	  	if(isv4(ip)){
	  		if(ip[IPv4off] >= 0xe0 && ip[IPv4off] < 0xf0)
	  			return V4;
	- 	} else {
	+ 	} else
	  		if(ip[0] == 0xff)
	  			return V6;
	- 	}
	  	return 0;
	  }
	  int
	  ipisbm(uchar *ip)
	  {
	- 	if(isv4(ip)){
	+ 	if(isv4(ip))
	  		if(ip[IPv4off] >= 0xe0 && ip[IPv4off] < 0xf0)
	  			return V4;
	- 		if(ipcmp(ip, IPv4bcast) == 0)
	+ 		else if(ipcmp(ip, IPv4bcast) == 0)
	  			return V4;
	- 	} else {
	+ 	else
	  		if(ip[0] == 0xff)
	  			return V6;
	- 	}
	  	return 0;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1474,1481 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1416,1422
	  	f = c->p->f;
	  
	  	for(l = &c->multi; *l; l = &(*l)->next)
	- 		if(ipcmp(ma, (*l)->ma) == 0)
	- 		if(ipcmp(ia, (*l)->ia) == 0)
	+ 		if(ipcmp(ma, (*l)->ma) == 0 && ipcmp(ia, (*l)->ia) == 0)
	  			return;		/* it's already there */
	  
	  	multi = *l = smalloc(sizeof(*multi));
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1516,1523 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1457,1463
	  	f = c->p->f;
	  
	  	for(l = &c->multi; *l; l = &(*l)->next)
	- 		if(ipcmp(ma, (*l)->ma) == 0)
	- 		if(ipcmp(ia, (*l)->ia) == 0)
	+ 		if(ipcmp(ma, (*l)->ma) == 0 && ipcmp(ia, (*l)->ia) == 0)
	  			break;
	  
	  	multi = *l;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1575,1588 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1515,1524
	  	/* register the address on any network that will proxy for us */
	  	e = &f->ipifc->conv[f->ipifc->nc];
	  
	- 	if(!isv4(ip)) { // V6
	+ 	if(!isv4(ip))				/* V6 */
	  		for(cp = f->ipifc->conv; cp < e; cp++){
	- 			if(*cp == nil)
	+ 			if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
	  				continue;
	- 			nifc = (Ipifc*)(*cp)->ptcl;
	- 			if(nifc == ifc)
	- 				continue;
	- 
	  			rlock(nifc);
	  			m = nifc->m;
	  			if(m == nil || m->addmulti == nil) {
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1591,1616 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1527,1547
	  			}
	  			for(lifc = nifc->lifc; lifc; lifc = lifc->next){
	  				maskip(ip, lifc->mask, net);
	- 				if(ipcmp(net, lifc->remote) == 0) { /* add solicited-node multicast address */
	+ 				if(ipcmp(net, lifc->remote) == 0) {
	+ 					/* add solicited-node multicast addr */
	  					ipv62smcast(net, ip);
	  					addselfcache(f, nifc, lifc, net, Rmulti);
	  					arpenter(f, V6, ip, nifc->mac, 6, 0);
	- 					//(*m->addmulti)(nifc, net, ip);
	+ 					// (*m->addmulti)(nifc, net, ip);
	  					break;
	  				}
	  			}
	  			runlock(nifc);
	  		}
	- 		return;
	- 	}
	- 	else { // V4
	+ 	else					/* V4 */
	  		for(cp = f->ipifc->conv; cp < e; cp++){
	- 			if(*cp == nil)
	+ 			if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
	  				continue;
	- 			nifc = (Ipifc*)(*cp)->ptcl;
	- 			if(nifc == ifc)
	- 				continue;
	- 
	  			rlock(nifc);
	  			m = nifc->m;
	  			if(m == nil || m->areg == nil){
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1626,1636 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1557,1566
	  			}
	  			runlock(nifc);
	  		}
	- 	}
	  }
	  
	  
	- // added for new v6 mesg types
	+ /* added for new v6 mesg types */
	  static void
	  adddefroute6(Fs *f, uchar *gate, int force)
	  {
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1637,1653 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1567,1584
	  	Route *r;
	  
	  	r = v6lookup(f, v6Unspecified, nil);
	- 	if(r!=nil)
	- 	if(!(force) && (strcmp(r->tag,"ra")!=0))	// route entries generated
	- 		return;			// by all other means take
	- 					// precedence over router annc
	+ 	/*
	+ 	 * route entries generated by all other means take precedence
	+ 	 * over router announcements.
	+ 	 */
	+ 	if (r && !force && strcmp(r->tag, "ra") != 0)
	+ 		return;
	  
	  	v6delroute(f, v6Unspecified, v6Unspecified, 1);
	  	v6addroute(f, "ra", v6Unspecified, v6Unspecified, gate, 0);
	  }
	  
	- enum
	- {
	+ enum {
	  	Ngates = 3,
	  };
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1654,1669 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1585,1597
	  char*
	  ipifcaddpref6(Ipifc *ifc, char**argv, int argc)
	  {
	- 	uchar	onlink = 1;
	- 	uchar	autoflag = 1;
	- 	long 	validlt = 0xffffffff;
	- 	long 	preflt = 0xffffffff;
	- 	long	origint = NOW / 10^3;
	- 	uchar	prefix[IPaddrlen];
	- 	int	plen = 64;
	- 	Iplifc	*lifc;
	- 	char	addr[40], preflen[6];
	- 	char	*params[3];
	+ 	int plen = 64;
	+ 	long origint = NOW / 1000, preflt = ~0L, validlt = ~0L;
	+ 	char addr[40], preflen[6];
	+ 	char *params[3];
	+ 	uchar autoflag = 1, onlink = 1;
	+ 	uchar prefix[IPaddrlen];
	+ 	Iplifc *lifc;
	  
	  	switch(argc) {
	  	case 7:
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1680,1685 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1608,1614
	  		/* fall through */
	  	case 3:
	  		plen = atoi(argv[2]);
	+ 		/* fall through */
	  	case 2:
	  		break;
	  	default:
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1686,1696 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1615,1622
	  		return Ebadarg;
	  	}
	  
	- 	if((parseip(prefix, argv[1])!=6) ||
	- 	 	(validlt < preflt) ||
	- 		(plen < 0) || (plen > 64) ||
	- 		(islinklocal(prefix))
	- 	)
	+ 	if (parseip(prefix, argv[1]) != 6 || validlt < preflt || plen < 0 ||
	+ 	    plen > 64 || islinklocal(prefix))
	  		return Ebadarg;
	  
	  	lifc = smalloc(sizeof(Iplifc));
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1700,1706 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1626,1632
	  	lifc->preflt = preflt;
	  	lifc->origint = origint;
	  
	- 	if(ifc->m->pref2addr!=nil)
	+ 	if(ifc->m->pref2addr)
	  		ifc->m->pref2addr(prefix, ifc->mac);
	  	else
	  		return Ebadarg;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipifc.c:1713,1716 - 
	/n/sources/plan9/sys/src/9/ip/ipifc.c:1639,1641
	  
	  	return ipifcadd(ifc, params, 3, 0, lifc);
	  }
	- 
 [geoff] --rw-rw-r-- M 44 presotto sys 14297 Apr 18 19:13 sys/src/9/ip/ipv6.c
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:16,26 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:16,26
	  	IP_DF		= 0x4000,	/* Don't fragment */
	  	IP_MF		= 0x2000,	/* More fragments */
	  	IP6FHDR		= 8, 		/* sizeof(Fraghdr6) */
	- 	IP_MAX		= (32*1024),	/* Maximum Internet packet size */
	+ 	IP_MAX		= 32*1024,	/* Maximum Internet packet size */
	  };
	  
	- #define IPV6CLASS(hdr) ((hdr->vcf[0]&0x0F)<<2 | (hdr->vcf[1]&0xF0)>>2)
	- #define BLKIPVER(xp)	(((Ip6hdr*)((xp)->rp))->vcf[0]&0xF0)
	+ #define IPV6CLASS(hdr)	(((hdr)->vcf[0]&0x0F)<<2 | ((hdr)->vcf[1]&0xF0)>>2)
	+ #define BLKIPVER(xp)	(((Ip6hdr*)((xp)->rp))->vcf[0] & 0xF0)
	  /*
	   * This sleazy macro is stolen shamelessly from ip.c, see comment there.
	   */
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:32,42 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:32,42
	  typedef struct	Ipfrag	Ipfrag;
	  
	  Block*		ip6reassemble(IP*, int, Block*, Ip6hdr*);
	- void		ipfragfree6(IP*, Fragment6*);
	  Fragment6*	ipfragallo6(IP*);
	- static Block*		procxtns(IP *ip, Block *bp, int doreasm);
	- int		unfraglen(Block *bp, uchar *nexthdr, int setfh);
	+ void		ipfragfree6(IP*, Fragment6*);
	  Block*		procopts(Block *bp);
	+ static Block*	procxtns(IP *ip, Block *bp, int doreasm);
	+ int		unfraglen(Block *bp, uchar *nexthdr, int setfh);
	  
	  /* MIB II counters */
	  enum
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:134,149 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:134,148
	  int
	  ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
	  {
	- 	int tentative;
	- 	Ipifc *ifc;
	+ 	int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff;
	+ 	int morefrags, blklen, rv = 0, tentative;
	  	uchar *gate, nexthdr;
	- 	Ip6hdr *eh;
	- 	int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff, morefrags, blklen;
	- 	Route *r, *sr;
	- 	Fraghdr6 fraghdr;
	  	Block *xp, *nb;
	+ 	Fraghdr6 fraghdr;
	  	IP *ip;
	- 	int rv = 0;
	+ 	Ip6hdr *eh;
	+ 	Ipifc *ifc;
	+ 	Route *r, *sr;
	  
	  	ip = f->ip;
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:154,160 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:153,159
	  
	  	/* Number of uchars in data and ip header to write */
	  	len = blocklen(bp);
	- 	
	+ 
	  	tentative = iptentative(f, eh->src);
	  	if(tentative){
	  		netlog(f, Logip, "reject tx of packet with tentative src address\n");
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:191,204 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:190,201
	  	ifc = r->ifc;
	  	if(r->type & (Rifc|Runi))
	  		gate = eh->dst;
	- 	else
	- 	if(r->type & (Rbcast|Rmulti)) {
	+ 	else if(r->type & (Rbcast|Rmulti)) {
	  		gate = eh->dst;
	  		sr = v6lookup(f, eh->src, nil);
	- 		if(sr != nil && (sr->type & Runi))
	+ 		if(sr && (sr->type & Runi))
	  			ifc = sr->ifc;
	- 	}
	- 	else
	+ 	} else
	  		gate = r->v6.gate;
	  
	  	if(!gating)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:205,217 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:202,213
	  		eh->vcf[0] = IP_VER6;
	  	eh->ttl = ttl;
	  	if(!gating) {
	- 		eh->vcf[0] |= (tos >> 4);
	- 		eh->vcf[1] = (tos << 4);
	+ 		eh->vcf[0] |= tos >> 4;
	+ 		eh->vcf[1]  = tos << 4;
	  	}
	  
	- 	if(!canrlock(ifc)) {
	+ 	if(!canrlock(ifc))
	  		goto free;
	- 	}
	  
	  	if(waserror()){
	  		runlock(ifc);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:218,226 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:214,221
	  		nexterror();
	  	}
	  
	- 	if(ifc->m == nil) {
	+ 	if(ifc->m == nil)
	  		goto raise;
	- 	}
	  
	  	/* If we dont need to fragment just send it */
	  	medialen = ifc->maxtu - ifc->m->hsize;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:232,251 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:227,244
	  		return 0;
	  	}
	  
	- 	if(gating) 
	- 	if(ifc->reassemble <= 0) {
	- 
	- 		/* v6 intermediate nodes are not supposed to fragment pkts;
	- 		   we fragment if ifc->reassemble is turned on; an exception
	- 		   needed for nat.
	+ 	if(gating && ifc->reassemble <= 0) {
	+ 		/*
	+ 		 * v6 intermediate nodes are not supposed to fragment pkts;
	+ 		 * we fragment if ifc->reassemble is turned on; an exception
	+ 		 * needed for nat.
	  		 */
	- 
	  		ip->stats[OutDiscards]++;
	  		icmppkttoobig6(f, ifc, bp);
	  		netlog(f, Logip, "%I: gated pkts not fragmented\n", eh->dst);
	  		goto raise;
	  	}
	- 		
	+ 
	  	/* start v6 fragmentation */
	  	uflen = unfraglen(bp, &nexthdr, 1);
	  	if(uflen > medialen) {
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:271,283 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:264,276
	  
	  	xp = bp;
	  	offset = uflen;
	- 	while (xp != nil && offset && offset >= BLEN(xp)) {
	+ 	while (xp && offset && offset >= BLEN(xp)) {
	  		offset -= BLEN(xp);
	  		xp = xp->next;
	  	}
	  	xp->rp += offset;
	  
	- 	fragoff = 0; 
	+ 	fragoff = 0;
	  	morefrags = 1;
	  
	  	for(; fragoff < flen; fragoff += seglen) {
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:292,298 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:285,291
	  		memmove(nb->wp, eh, uflen);
	  		nb->wp += uflen;
	  
	- 		hnputs(fraghdr.offsetRM, fragoff); // last 3 bits must be 0
	+ 		hnputs(fraghdr.offsetRM, fragoff); /* last 3 bits must be 0 */
	  		fraghdr.offsetRM[1] |= morefrags;
	  		memmove(nb->wp, &fraghdr, IP6FHDR);
	  		nb->wp += IP6FHDR;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:316,322 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:309,315
	  			xp->rp += blklen;
	  			chunk -= blklen;
	  			if(xp->rp == xp->wp)
	- 				xp = xp->next; 
	+ 				xp = xp->next;
	  		}
	  
	  		ifc->m->bwrite(ifc, nb, V6, gate);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:328,334 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:321,327
	  	runlock(ifc);
	  	poperror();
	  free:
	- 	freeblist(bp);	
	+ 	freeblist(bp);
	  	return rv;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:335,349 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:328,339
	  void
	  ipiput6(Fs *f, Ipifc *ifc, Block *bp)
	  {
	- 	int hl;
	- 	int hop, tos;
	+ 	int hl, hop, tos, notforme, tentative;
	  	uchar proto;
	- 	Ip6hdr *h;
	- 	Proto *p;
	- 	int notforme;
	- 	int tentative;
	  	uchar v6dst[IPaddrlen];
	  	IP *ip;
	+ 	Ip6hdr *h;
	+ 	Proto *p;
	  	Route *r, *sr;
	  
	  	ip = f->ip;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:365,377 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:355,367
	  			return;
	  	}
	  
	- 	h = (Ip6hdr *)(bp->rp);
	+ 	h = (Ip6hdr *)bp->rp;
	  
	- 	memmove(&v6dst[0], &(h->dst)[0], IPaddrlen);
	+ 	memmove(&v6dst[0], &h->dst[0], IPaddrlen);
	  	notforme = ipforme(f, v6dst) == 0;
	  	tentative = iptentative(f, v6dst);
	-   
	- 	if(tentative && (h->proto != ICMPv6)) {
	+ 
	+ 	if(tentative && h->proto != ICMPv6) {
	  		print("tentative addr, drop\n");
	  		freeblist(bp);
	  		return;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:393,399 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:383,389
	  		}
	  		/* don't forward to source's network */
	  		sr = v6lookup(f, h->src, nil);
	- 		r = v6lookup(f, h->dst, nil);
	+ 		r  = v6lookup(f, h->dst, nil);
	  
	  		if(r == nil || sr == r){
	  			ip->stats[OutDiscards]++;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:412,423 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:402,412
	  
	  		/* process headers & reassemble if the interface expects it */
	  		bp = procxtns(ip, bp, r->ifc->reassemble);
	- 
	  		if(bp == nil)
	  			return;
	  
	  		ip->stats[ForwDatagrams]++;
	- 		h = (Ip6hdr *) (bp->rp);
	+ 		h = (Ip6hdr *)bp->rp;
	  		tos = IPV6CLASS(h);
	  		hop = h->ttl;
	  		ipoput6(f, bp, 1, hop-1, tos, nil);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:426,432 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:415,420
	  
	  	/* reassemble & process headers if needed */
	  	bp = procxtns(ip, bp, 1);
	- 
	  	if(bp == nil)
	  		return;
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:433,439 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:421,427
	  	h = (Ip6hdr *) (bp->rp);
	  	proto = h->proto;
	  	p = Fsrcvpcol(f, proto);
	- 	if(p != nil && p->rcv != nil) {
	+ 	if(p && p->rcv) {
	  		ip->stats[InDelivers]++;
	  		(*p->rcv)(p, ifc, bp);
	  		return;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:470,476 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:458,463
	  
	  	frag->next = ip->fragfree6;
	  	ip->fragfree6 = frag;
	- 
	  }
	  
	  /*
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:497,529 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:484,515
	  }
	  
	  static Block*
	- procxtns(IP *ip, Block *bp, int doreasm) {
	- 
	+ procxtns(IP *ip, Block *bp, int doreasm)
	+ {
	  	int offset;
	  	uchar proto;
	  	Ip6hdr *h;
	  
	- 	h = (Ip6hdr *) (bp->rp);
	+ 	h = (Ip6hdr *)bp->rp;
	  	offset = unfraglen(bp, &proto, 0);
	  
	- 	if((proto == FH) && (doreasm != 0)) {
	+ 	if(proto == FH && doreasm != 0) {
	  		bp = ip6reassemble(ip, offset, bp, h);
	- 		if(bp == nil) 
	- 			return nil; 
	+ 		if(bp == nil)
	+ 			return nil;
	  		offset = unfraglen(bp, &proto, 0);
	  	}
	  
	- 	if(proto == DOH || offset > IP6HDR) 
	+ 	if(proto == DOH || offset > IP6HDR)
	  		bp = procopts(bp);
	- 
	  	return bp;
	  }
	  
	- 
	- /*	returns length of "Unfragmentable part", i.e., sum of lengths of ipv6 hdr,
	-  *	hop-by-hop & routing headers if present; *nexthdr is set to nexthdr value
	-  *	of the last header in the "Unfragmentable part"; if setfh != 0, nexthdr
	-  *	field of the last header in the "Unfragmentable part" is set to FH.
	+ /*
	+  * returns length of "Unfragmentable part", i.e., sum of lengths of ipv6 hdr,
	+  * hop-by-hop & routing headers if present; *nexthdr is set to nexthdr value
	+  * of the last header in the "Unfragmentable part"; if setfh != 0, nexthdr
	+  * field of the last header in the "Unfragmentable part" is set to FH.
	   */
	  int
	  unfraglen(Block *bp, uchar *nexthdr, int setfh)
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:532,543 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:518,529
	  	int ufl, hs;
	  
	  	p = bp->rp;
	- 	q = p+6;	/* proto, = p+sizeof(Ip6hdr.vcf)+sizeof(Ip6hdr.ploadlen) */
	+ 	q = p+6;   /* proto, = p+sizeof(Ip6hdr.vcf)+sizeof(Ip6hdr.ploadlen) */
	  	*nexthdr = *q;
	  	ufl = IP6HDR;
	  	p += ufl;
	  
	- 	for(;;) {
	+ 	for(;;)
	  		if(*nexthdr == HBH || *nexthdr == RH) {
	  			*nexthdr = *p;
	  			hs = ((int)*(p+1) + 1) * 8;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:544,560 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:530,542
	  			ufl += hs;
	  			q = p;
	  			p += hs;
	- 		}
	- 		else
	+ 		} else
	  			break;
	- 	}
	  
	  	if(*nexthdr == FH)
	  		*q = *p;
	- 
	  	if(setfh)
	  		*q = FH;
	- 
	  	return ufl;
	  }
	  
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:567,582 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:549,562
	  Block*
	  ip6reassemble(IP* ip, int uflen, Block* bp, Ip6hdr* ih)
	  {
	- 
	- 	int fend, offset;
	+ 	int fend, offset, ovlap, len, fragsize, pktposn;
	  	uint id;
	- 	Fragment6 *f, *fnext;
	- 	Fraghdr6 *fraghdr;
	  	uchar src[IPaddrlen], dst[IPaddrlen];
	  	Block *bl, **l, *last, *prev;
	- 	int ovlap, len, fragsize, pktposn;
	+ 	Fraghdr6 *fraghdr;
	+ 	Fragment6 *f, *fnext;
	  
	- 	fraghdr = (Fraghdr6 *) (bp->rp + uflen);
	+ 	fraghdr = (Fraghdr6 *)(bp->rp + uflen);
	  	memmove(src, ih->src, IPaddrlen);
	  	memmove(dst, ih->dst, IPaddrlen);
	  	id = nhgetl(fraghdr->id);
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:587,596 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:567,575
	  	 */
	  	if(bp->next){
	  		bp = pullupblock(bp, blocklen(bp));
	- 		ih = (Ip6hdr *)(bp->rp);
	+ 		ih = (Ip6hdr *)bp->rp;
	  	}
	  
	- 
	  	qlock(&ip->fraglock6);
	  
	  	/*
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:606,619 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:585,597
	  		}
	  	}
	  
	- 
	  	/*
	  	 *  if this isn't a fragmented packet, accept it
	  	 *  and get rid of any fragments that might go
	  	 *  with it.
	  	 */
	- 	if(nhgets(fraghdr->offsetRM)==0) {	// first frag is also the last
	- 		if(f != nil) {
	+ 	if(nhgets(fraghdr->offsetRM) == 0) {	/* 1st frag is also last */
	+ 		if(f) {
	  			ipfragfree6(ip, f);
	  			ip->stats[ReasmFails]++;
	  		}
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:678,689 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:656,665
	  		fend = BKFG(bp)->foff + BKFG(bp)->flen;
	  
	  		/* Take completely covered segments out */
	- 
	  		while(*l) {
	  			ovlap = fend - BKFG(*l)->foff;
	- 
	- 			if(ovlap <= 0) 
	- 				break; 
	+ 			if(ovlap <= 0)
	+ 				break;
	  			if(ovlap < BKFG(*l)->flen) {
	  				BKFG(*l)->flen -= ovlap;
	  				BKFG(*l)->foff += ovlap;
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:704,726 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:680,697
	  	 *  with the trailing bit of fraghdr->offsetRM[1] set, we're done.
	  	 */
	  	pktposn = 0;
	- 	for(bl = f->blist; bl; bl = bl->next) {
	- 		if(BKFG(bl)->foff != pktposn)
	- 			break;
	- 	
	- 		fraghdr = (Fraghdr6 *) (bl->rp + uflen);
	+ 	for(bl = f->blist; bl && BKFG(bl)->foff == pktposn; bl = bl->next) {
	+ 		fraghdr = (Fraghdr6 *)(bl->rp + uflen);
	  		if((fraghdr->offsetRM[1] & 1) == 0) {
	- 
	  			bl = f->blist;
	  
	  			/* get rid of frag header in first fragment */
	- 
	  			memmove(bl->rp + IP6FHDR, bl->rp, uflen);
	  			bl->rp += IP6FHDR;
	- 			len = nhgets(((Ip6hdr*)(bl->rp))->ploadlen) - IP6FHDR;
	+ 			len = nhgets(((Ip6hdr*)bl->rp)->ploadlen) - IP6FHDR;
	  			bl->wp = bl->rp + len + IP6HDR;
	- 
	- 			/* Pullup all the fragment headers and
	+ 			/*
	+ 			 * Pullup all the fragment headers and
	  			 * return a complete packet
	  			 */
	  			for(bl = bl->next; bl; bl = bl->next) {
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:733,743 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:704,714
	  			bl = f->blist;
	  			f->blist = nil;
	  			ipfragfree6(ip, f);
	- 			ih = (Ip6hdr*)(bl->rp);
	+ 			ih = (Ip6hdr*)bl->rp;
	  			hnputs(ih->ploadlen, len);
	  			qunlock(&ip->fraglock6);
	  			ip->stats[ReasmOKs]++;
	- 			return bl;		
	+ 			return bl;
	  		}
	  		pktposn += BKFG(bl)->flen;
	  	}
	/n/sourcesdump/2007/0418/plan9/sys/src/9/ip/ipv6.c:744,747 - 
	/n/sources/plan9/sys/src/9/ip/ipv6.c:715,717
	  	qunlock(&ip->fraglock6);
	  	return nil;
	  }
	- 


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].