summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-06-14 00:07:45 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-06-14 00:07:45 +0200
commitde9141bc6d0d0d51abc39cd6b7e199c9ddf18010 (patch)
treec4fd6b0370ec23b4fc94560446c10819df8fae03
parent71ce6f53a431962a3dc17947deb1ff8336f37d13 (diff)
devip: don't send arp requests from null address
during dhcp, ipconfig assigns the null address :: which makes ipforme() return Runi for any destination, which can trigger arp resolution when we attempt to reply. so have v4local() skip the null address and have sendarp() check the return status of v4local(), avoing the spurious arp requests.
-rw-r--r--sys/src/9/ip/ethermedium.c14
-rw-r--r--sys/src/9/ip/ipifc.c2
2 files changed, 11 insertions, 5 deletions
diff --git a/sys/src/9/ip/ethermedium.c b/sys/src/9/ip/ethermedium.c
index 3aa74f42f..6471355c1 100644
--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -449,6 +449,7 @@ sendarp(Ipifc *ifc, Arpent *a)
Block *bp;
Etherarp *e;
Etherrock *er = ifc->arg;
+ uchar targ[IPv4addrlen], src[IPv4addrlen];
/* don't do anything if it's been less than a second since the last */
if(NOW - a->ctime < 1000){
@@ -456,6 +457,9 @@ sendarp(Ipifc *ifc, Arpent *a)
return;
}
+ /* try to keep it around for a second more */
+ a->ctime = NOW;
+
/* remove all but the last message */
while((bp = a->hold) != nil){
if(bp == a->last)
@@ -464,18 +468,20 @@ sendarp(Ipifc *ifc, Arpent *a)
freeblist(bp);
}
- /* try to keep it around for a second more */
- a->ctime = NOW;
+ memmove(targ, a->ip+IPv4off, IPv4addrlen);
arprelease(er->f->arp, a);
+ if(!ipv4local(ifc, src, targ))
+ return;
+
n = sizeof(Etherarp);
if(n < ifc->m->mintu)
n = ifc->m->mintu;
bp = allocb(n);
memset(bp->rp, 0, n);
e = (Etherarp*)bp->rp;
- memmove(e->tpa, a->ip+IPv4off, sizeof(e->tpa));
- ipv4local(ifc, e->spa, e->tpa);
+ memmove(e->tpa, targ, sizeof(e->tpa));
+ memmove(e->spa, src, sizeof(e->spa));
memmove(e->sha, ifc->mac, sizeof(e->sha));
memset(e->d, 0xff, sizeof(e->d)); /* ethernet broadcast */
memmove(e->s, ifc->mac, sizeof(e->s));
diff --git a/sys/src/9/ip/ipifc.c b/sys/src/9/ip/ipifc.c
index 4261eac90..302d72df7 100644
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -1274,7 +1274,7 @@ ipv4local(Ipifc *ifc, uchar *local, uchar *remote)
b = -1;
for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next){
- if((lifc->type & Rv4) == 0)
+ if((lifc->type & Rv4) == 0 || ipcmp(lifc->local, IPnoaddr) == 0)
continue;
a = comprefixlen(lifc->local+IPv4off, remote, IPv4addrlen);
if(a > b){