summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/ip.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-10-09 18:26:16 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-10-09 18:26:16 +0000
commit1a6324970d4cb0f0508caa3a685355d500709f1a (patch)
tree4c67be2a637f667f3c603feedf3b2b722a3a5306 /sys/src/9/ip/ip.c
parentd280f411f68cebc5aac71ce8b7cbcfb5b22f1a7c (diff)
devip: cache arp entry in Routehint
Instead of having to do an arp hash table lookup for each outgoing ip packet, forward the Routehint pointer to the medium's bwrite() function and let it cache the arp entry pointer. This avoids route and arp hash table lookups for tcp, il and connection oriented udp. It also allows us to avoid multiple route and arp table lookups for the retransmits once an arp/neighbour solicitation response arrives.
Diffstat (limited to 'sys/src/9/ip/ip.c')
-rw-r--r--sys/src/9/ip/ip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/src/9/ip/ip.c b/sys/src/9/ip/ip.c
index 7f197b22b..284ef0b77 100644
--- a/sys/src/9/ip/ip.c
+++ b/sys/src/9/ip/ip.c
@@ -153,7 +153,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
eh->cksum[1] = 0;
hnputs(eh->cksum, ipcsum(&eh->vihl));
- ipifcoput(ifc, bp, V4, gate);
+ ipifcoput(ifc, bp, V4, gate, rh);
runlock(ifc);
poperror();
return 0;
@@ -237,7 +237,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
feh->cksum[1] = 0;
hnputs(feh->cksum, ipcsum(&feh->vihl));
- ipifcoput(ifc, nb, V4, gate);
+ ipifcoput(ifc, nb, V4, gate, rh);
ip->stats[FragCreates]++;
}
ip->stats[FragOKs]++;
@@ -308,8 +308,8 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
/* route */
v4tov6(v6dst, h->dst);
if(!ipforme(f, v6dst)) {
- Route *r;
Routehint rh;
+ Route *r;
Ipifc *nifc;
if(!ip->iprouting)
@@ -317,6 +317,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
/* don't forward to source's network */
rh.r = nil;
+ rh.a = nil;
r = v4lookup(f, h->dst, h->src, &rh);
if(r == nil || (nifc = r->ifc) == nil
|| (nifc == ifc && !ifc->reflect)){