summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/ipv6.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-03-18 07:50:48 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2018-03-18 07:50:48 +0100
commit71f807873b43a4d2a2e2c9d1acbe1d97b5fdf18c (patch)
treeba144ead649e2321817b0ebafcb6212b2c74e99a /sys/src/9/ip/ipv6.c
parent8ce98a0b32111228827de661fe96efd52ee1b4bf (diff)
devip: more v6 improvements
ipv4local() and ipv6local() now take remote address argument, returning the closest local address to the source. this implements the standartized source address selection rules instead of just returning the first local v4 or v6 address. the source address selection was broken for esp, rudp an udp, blindly assuming ifc->lifc->local being a valid v4 address. use ipv6local() instead. the v6 routing code used to lookup source address route to decide to drop the packet instead of checking the interface on the destination route. factor out the route hint from Conv and put it in Routehint structure. avoiding stack bloat in v4 routing. implement the same trick for v6 avoiding second route lookup in ipoput6. fix memory leak in icmpv6 router solicitation handling. remove old unfinished handling of multiple v6 routers. should implement source specific routes instead. avoid duplication, use common convipvers() function. use isv4() instead of memcmp v4prefix.
Diffstat (limited to 'sys/src/9/ip/ipv6.c')
-rw-r--r--sys/src/9/ip/ipv6.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/src/9/ip/ipv6.c b/sys/src/9/ip/ipv6.c
index 8b50706f4..1fbfedc34 100644
--- a/sys/src/9/ip/ipv6.c
+++ b/sys/src/9/ip/ipv6.c
@@ -28,7 +28,7 @@ static Block* procxtns(IP *ip, Block *bp, int doreasm);
int unfraglen(Block *bp, uchar *nexthdr, int setfh);
int
-ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
+ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
{
int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff;
int morefrags, blklen, rv = 0, tentative;
@@ -74,9 +74,8 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Conv *c)
goto free;
}
- r = v6lookup(f, eh->dst, c);
+ r = v6lookup(f, eh->dst, rh);
if(r == nil){
-// print("no route for %I, src %I free\n", eh->dst, eh->src);
ip->stats[OutNoRoutes]++;
netlog(f, Logip, "no interface %I\n", eh->dst);
rv = -1;
@@ -231,7 +230,6 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp)
IP *ip;
Ip6hdr *h;
Proto *p;
- Route *r, *sr;
ip = f->ip;
ip->stats[InReceives]++;
@@ -274,6 +272,9 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp)
/* route */
if(notforme) {
+ Route *r;
+ Routehint rh;
+
if(!ip->iprouting){
freeblist(bp);
return;
@@ -288,10 +289,9 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp)
}
/* don't forward to source's network */
- sr = v6lookup(f, h->src, nil);
- r = v6lookup(f, h->dst, nil);
-
- if(r == nil || sr == r){
+ rh.r = nil;
+ r = v6lookup(f, h->dst, &rh);
+ if(r == nil || r->ifc == ifc){
ip->stats[OutDiscards]++;
freeblist(bp);
return;
@@ -315,7 +315,7 @@ ipiput6(Fs *f, Ipifc *ifc, Block *bp)
h = (Ip6hdr *)bp->rp;
tos = IPV6CLASS(h);
hop = h->ttl;
- ipoput6(f, bp, 1, hop-1, tos, nil);
+ ipoput6(f, bp, 1, hop-1, tos, &rh);
return;
}