diff options
| author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-28 18:13:01 +0200 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-28 18:13:01 +0200 |
| commit | 02b867f01eca1fefbe8b29205c8a8d4c13d2ffd0 (patch) | |
| tree | f29c39c46df8f932ecac61e5c2dfc872797a214d | |
| parent | 03bcc1520a54573c7149233cf51975e0fe077399 (diff) | |
| download | plan9front-02b867f01eca1fefbe8b29205c8a8d4c13d2ffd0.tar.xz | |
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.
| -rw-r--r-- | sys/src/9/ip/ipifc.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/src/9/ip/ipifc.c b/sys/src/9/ip/ipifc.c index 0a078077f..c72a55971 100644 --- a/sys/src/9/ip/ipifc.c +++ b/sys/src/9/ip/ipifc.c @@ -505,7 +505,14 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) /* 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 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp) *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 @@ ipifcremlifc(Ipifc *ifc, Iplifc **l) 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){ |
