ref: fe1eb39db7ae6904924f3ab1f6f9b34416f2eb1b
parent: 2153eb179c21589a991625acba967c69aad1e5d9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 23 18:44:36 EDT 2023
devether: handle bypass outside of ethermux() do it outside of ethermux() as there is a fast-path check for sending like: pkt = (Etherpkt*)bp->rp; if(!(multi = pkt->d[0] & 1)){ tome = memcmp(pkt->d, ether->ea, Eaddrlen) == 0; if(!tome && from != nil && ether->prom == 0) return bp; } else { ...
--- a/sys/src/9/port/devether.c
+++ b/sys/src/9/port/devether.c
@@ -202,7 +202,7 @@
x = nil;
type = (pkt->type[0]<<8)|pkt->type[1];
- dispose = tome || from == nil || port > 0 || (*from)->bypass;
+ dispose = tome || from == nil || port > 0;
for(fp = ether->f; fp < ðer->f[Ntypes]; fp++){
if((f = *fp) == nil)
@@ -211,7 +211,9 @@
continue;
if(!tome && !multi && !f->prom)
continue;
- if(f->bridge || f->bypass){
+ if(f->bypass)
+ continue;
+ if(f->bridge){
if(tome || fp == from)
continue;
if(port >= 0 && port != 1+(fp - ether->f))
@@ -263,6 +265,9 @@
if((*from)->bridge == 0)
memmove(((Etherpkt*)bp->rp)->s, ether->ea, Eaddrlen);
+
+ if((*from)->bypass)
+ from = nil;
bp = ethermux(ether, bp, from);
if(bp == nil)
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -796,7 +796,7 @@
x = nil;
type = (pkt->type[0]<<8)|pkt->type[1];
- dispose = tome || from == nil || port > 0 || from->bypass;
+ dispose = tome || from == nil || port > 0;
for(c = conn; c < &conn[nconn]; c++){
if(!c->used)
@@ -805,7 +805,9 @@
continue;
if(!tome && !multi && !c->prom)
continue;
- if(c->bridge || c->bypass){
+ if(c->bypass)
+ continue;
+ if(c->bridge){
if(tome || c == from)
continue;
if(port >= 0 && port != 1+(c - conn))
@@ -850,6 +852,8 @@
if(!from->bridge)
memmove(((Etherpkt*)bp->rp)->s, macaddr, Eaddrlen);
+ if(from->bypass)
+ from = nil;
bp = ethermux(bp, from);
if(bp == nil)
return;