ref: 2b74e5b514b1c1f318583f55cb2db2e6e3559015
parent: 0df42fec9637aadf77eb242ab57e2fbe80f1a73f
	author: cinap_lenrek <cinap_lenrek@felloff.net>
	date: Fri Sep 28 14:13:01 EDT 2018
	
devip: only add interface route for "on-link" prefixes when a prefix is added with the onlink flag clear, packets towards that prefix needs to be send to the default gateway so we omit adding the interface route. when the on-link flag gets changed to 1 later, we add the interface route. the on-link flag is sticky, so theres no way to clear it back to zero except removing and re-adding the prefix.
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -505,7 +505,14 @@
/* ignore if this is already a local address for this ifc */
 	if((lifc = iplocalonifc(ifc, ip)) != nil){ 		if(lifcp != nil) {- lifc->onlink = lifcp->onlink;
+			if(!lifc->onlink && lifcp->onlink){+ lifc->onlink = 1;
+ addroute(f, lifc->remote, lifc->mask, ip, IPallbits,
+ lifc->remote, lifc->type, ifc, tifc);
+ if(v6addrtype(ip) != linklocalv6)
+ addroute(f, lifc->remote, lifc->mask, ip, IPnoaddr,
+ lifc->remote, lifc->type, ifc, tifc);
+ }
lifc->autoflag = lifcp->autoflag;
lifc->validlt = lifcp->validlt;
lifc->preflt = lifcp->preflt;
@@ -546,9 +553,11 @@
*l = lifc;
/* add route for this logical interface */
- addroute(f, rem, mask, ip, IPallbits, rem, type, ifc, tifc);
- if(v6addrtype(ip) != linklocalv6)
- addroute(f, rem, mask, ip, IPnoaddr, rem, type, ifc, tifc);
+	if(lifc->onlink){+ addroute(f, rem, mask, ip, IPallbits, rem, type, ifc, tifc);
+ if(v6addrtype(ip) != linklocalv6)
+ addroute(f, rem, mask, ip, IPnoaddr, rem, type, ifc, tifc);
+ }
addselfcache(f, ifc, lifc, ip, Runi);
@@ -635,13 +644,15 @@
remselfcache(f, ifc, lifc, lifc->link->self->a);
/* remove the route for this logical interface */
- remroute(f, lifc->remote, lifc->mask,
- lifc->local, IPallbits,
- lifc->remote, lifc->type, ifc, tifc);
- if(v6addrtype(lifc->local) != linklocalv6)
+	if(lifc->onlink){remroute(f, lifc->remote, lifc->mask,
- lifc->local, IPnoaddr,
+ lifc->local, IPallbits,
lifc->remote, lifc->type, ifc, tifc);
+ if(v6addrtype(lifc->local) != linklocalv6)
+ remroute(f, lifc->remote, lifc->mask,
+ lifc->local, IPnoaddr,
+ lifc->remote, lifc->type, ifc, tifc);
+ }
/* unregister proxy */
 	if(lifc->type & Rptpt){--
⑨