ref: 4d496b3c7ac69d094e4beb02e6426f47bc357e9a
parent: 21a221129af5d0599023149734ba040fea41719c
parent: de9141bc6d0d0d51abc39cd6b7e199c9ddf18010
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 13 20:08:46 EDT 2018
merge
--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -449,6 +449,7 @@
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 @@
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,10 +468,12 @@
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;
@@ -474,8 +480,8 @@
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));
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -1274,7 +1274,7 @@
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){
@@ -1465,6 +1465,9 @@
Iplifc *lifc;
Ipifc *ifc;
Fs *f;
+
+ if(isv4(ma) != isv4(ia))
+ error("incompatible multicast/interface ip address");
for(l = &c->multi; *l != nil; l = &(*l)->next)
if(ipcmp(ma, (*l)->ma) == 0 && ipcmp(ia, (*l)->ia) == 0)