diff --git a/sys/man/3/ether b/sys/man/3/ether index e1d534b63..b4f3b37f5 100644 --- a/sys/man/3/ether +++ b/sys/man/3/ether @@ -107,5 +107,17 @@ The interface remains promiscuous until the control file is closed. The extra packets are passed up connections only of types \-1 and \-2. +.PP +Writing packets to the +.B data +file automatically fills the +source address before sending. To allow implementations of +layer 2 bridges like +.IR bridge (3), +connections can be set to bridge mode by writing +.B bridge +to the +.B ctl +file. .SH SOURCE .B /sys/src/9/*/devether.c diff --git a/sys/src/9/kw/devether.c b/sys/src/9/kw/devether.c index ef1f2708f..e6d6fdb21 100644 --- a/sys/src/9/kw/devether.c +++ b/sys/src/9/kw/devether.c @@ -281,7 +281,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/mtx/devether.c b/sys/src/9/mtx/devether.c index 657b22ccf..cdc74061c 100644 --- a/sys/src/9/mtx/devether.c +++ b/sys/src/9/mtx/devether.c @@ -266,7 +266,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/omap/devether.c b/sys/src/9/omap/devether.c index 152be7ef6..096ec39ee 100644 --- a/sys/src/9/omap/devether.c +++ b/sys/src/9/omap/devether.c @@ -279,7 +279,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/pc/devether.c b/sys/src/9/pc/devether.c index 16d9d9e5a..2d2f4ac2e 100644 --- a/sys/src/9/pc/devether.c +++ b/sys/src/9/pc/devether.c @@ -286,7 +286,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/ppc/devether.c b/sys/src/9/ppc/devether.c index 5e1179b43..cacc27f4b 100644 --- a/sys/src/9/ppc/devether.c +++ b/sys/src/9/ppc/devether.c @@ -265,7 +265,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/sgi/devether.c b/sys/src/9/sgi/devether.c index 6339b99ef..b51588304 100644 --- a/sys/src/9/sgi/devether.c +++ b/sys/src/9/sgi/devether.c @@ -285,7 +285,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/teg2/devether.c b/sys/src/9/teg2/devether.c index 6a52d6b56..b6b5ddf2b 100644 --- a/sys/src/9/teg2/devether.c +++ b/sys/src/9/teg2/devether.c @@ -277,7 +277,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/9/zynq/devether.c b/sys/src/9/zynq/devether.c index d3b6e9b64..79d6b4153 100644 --- a/sys/src/9/zynq/devether.c +++ b/sys/src/9/zynq/devether.c @@ -285,7 +285,8 @@ etherwrite(Chan* chan, void* buf, long n, vlong) nexterror(); } memmove(bp->rp, buf, n); - memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); + if(!ether->f[NETID(chan->qid.path)]->bridge) + memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen); poperror(); bp->wp += n; diff --git a/sys/src/cmd/nusb/ether/ether.c b/sys/src/cmd/nusb/ether/ether.c index 5a94387ae..52481899e 100644 --- a/sys/src/cmd/nusb/ether/ether.c +++ b/sys/src/cmd/nusb/ether/ether.c @@ -306,6 +306,11 @@ writeconndata(Req *r) /* copy in the ethernet packet */ memmove(b->wp, p, r->ifcall.count); + + /* fill source mac address if not bridged */ + if(!conn[NUM(r->fid->qid.path)].bridge) + memmove(b->wp+6, macaddr, 6); + b->wp += r->ifcall.count; etheriq(b, 0); diff --git a/sys/src/cmd/vmx/virtio.c b/sys/src/cmd/vmx/virtio.c index 8a7a7d0b3..1dd1b5537 100644 --- a/sys/src/cmd/vmx/virtio.c +++ b/sys/src/cmd/vmx/virtio.c @@ -655,7 +655,10 @@ mkvionet(char *net) }else{ fd = dial(netmkaddr("-1", net, nil), nil, nil, &cfd); if(fd < 0) return -1; - if(cfd >= 0) fprint(cfd, "promiscuous"); + if(cfd >= 0) { + write(cfd, "promiscuous", 11); + write(cfd, "bridge", 6); + } } d = mkviodev(0x1000, 0x020000, 1, 3);