M pc/devether.c => pc/devether.c +2 -1
@@ 114,7 114,8 @@ etherwloop(Ether *ctlr, Etherpkt *pkt, long len)
int s, different;
different = memcmp(pkt->d, pkt->s, sizeof(pkt->s));
- if(different && memcmp(pkt->d, ctlr->bcast, sizeof(pkt->d)))
+ if(different && memcmp(pkt->d, ctlr->bcast, sizeof(pkt->d))
+ && ctlr->prom==0 && ctlr->all==0)
return 0;
s = splhi();
M port/netif.c => port/netif.c +7 -0
@@ 213,6 213,8 @@ netifwrite(Netif *nif, Chan *c, void *a, long n)
f = nif->f[NETID(c->qid.path)];
if(p = matchtoken(buf, "connect")){
f->type = atoi(p);
+ if(f->type < 0)
+ nif->all++;
} else if(matchtoken(buf, "promiscuous")){
f->prom = 1;
nif->prom++;
@@ 266,6 268,11 @@ netifclose(Netif *nif, Chan *c)
(*nif->promiscuous)(nif->arg, 0);
qunlock(nif);
}
+ if(f->type < 0){
+ qlock(nif);
+ --(nif->all);
+ qunlock(nif);
+ }
f->owner[0] = 0;
f->type = 0;
qclose(f->in);
M port/netif.h => port/netif.h +2 -1
@@ 57,7 57,8 @@ struct Netif
int alen; /* address length */
uchar addr[Nmaxaddr];
uchar bcast[Nmaxaddr];
- int prom;
+ int prom; /* number of promiscuous opens */
+ int all; /* number of -1 multiplexors */
/* statistics */
int misses;