ether: allow spoofing of source mac address for bridges; used by vmx
to implement layer 2 bridges in userspace, we disable to auto filling of the source mac address when bridge mode is enabled on the connection.
This commit is contained in:
parent
4ad70e6055
commit
9fd8894fec
11 changed files with 37 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -281,6 +281,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -266,6 +266,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -279,6 +279,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -286,6 +286,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -265,6 +265,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -285,6 +285,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -277,6 +277,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -285,6 +285,7 @@ etherwrite(Chan* chan, void* buf, long n, vlong)
|
|||
nexterror();
|
||||
}
|
||||
memmove(bp->rp, buf, n);
|
||||
if(!ether->f[NETID(chan->qid.path)]->bridge)
|
||||
memmove(bp->rp+Eaddrlen, ether->ea, Eaddrlen);
|
||||
poperror();
|
||||
bp->wp += n;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue