summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/ip.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-04-08 21:15:00 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-04-08 21:15:00 +0200
commitc2dd9b1da7659c9ac42e7612e5621e9426956c73 (patch)
tree8c191ea02792997669a87965419aac936243104f /sys/src/9/ip/ip.c
parentdc8432d4593c7a4b0a187d0174d4e4e603e456f6 (diff)
devip: implement source specific routing
Diffstat (limited to 'sys/src/9/ip/ip.c')
-rw-r--r--sys/src/9/ip/ip.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/src/9/ip/ip.c b/sys/src/9/ip/ip.c
index 6c4d02992..d296c2ed0 100644
--- a/sys/src/9/ip/ip.c
+++ b/sys/src/9/ip/ip.c
@@ -124,7 +124,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
Block *xp, *nb;
Ip4hdr *eh, *feh;
int lid, len, seglen, chunk, dlen, blklen, offset, medialen;
- Route *r, *sr;
+ Route *r;
IP *ip;
int rv = 0;
@@ -154,25 +154,17 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
goto free;
}
- r = v4lookup(f, eh->dst, rh);
- if(r == nil){
+ r = v4lookup(f, eh->dst, eh->src, rh);
+ if(r == nil || (ifc = r->ifc) == nil){
ip->stats[OutNoRoutes]++;
- netlog(f, Logip, "no interface %V\n", eh->dst);
+ netlog(f, Logip, "no interface %V -> %V\n", eh->src, eh->dst);
rv = -1;
goto free;
}
- ifc = r->ifc;
- if(r->type & (Rifc|Runi))
+ if(r->type & (Rifc|Runi|Rbcast|Rmulti))
gate = eh->dst;
else
- if(r->type & (Rbcast|Rmulti)) {
- gate = eh->dst;
- sr = v4lookup(f, eh->src, nil);
- if(sr != nil && (sr->type & Runi))
- ifc = sr->ifc;
- }
- else
gate = r->v4.gate;
if(!gating)
@@ -380,7 +372,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
/* don't forward to source's network */
rh.r = nil;
- r = v4lookup(f, h->dst, &rh);
+ r = v4lookup(f, h->dst, h->src, &rh);
if(r == nil || r->ifc == ifc){
ip->stats[OutDiscards]++;
freeblist(bp);