- Use more appropriate loop (do { } while()) when generating ethernet address
for bridge interface. - If we found a collision we can break the loop - only one collision is possible and one is exactly enough to need to renegerate. Obtained from: WHEEL Systems MFC after: 1 week
This commit is contained in:
parent
df905a2bd3
commit
5ad9520341
@ -615,7 +615,7 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params)
|
|||||||
*/
|
*/
|
||||||
fb = 0;
|
fb = 0;
|
||||||
getcredhostid(curthread->td_ucred, &hostid);
|
getcredhostid(curthread->td_ucred, &hostid);
|
||||||
for (retry = 1; retry != 0;) {
|
do {
|
||||||
if (fb || hostid == 0) {
|
if (fb || hostid == 0) {
|
||||||
arc4rand(sc->sc_defaddr, ETHER_ADDR_LEN, 1);
|
arc4rand(sc->sc_defaddr, ETHER_ADDR_LEN, 1);
|
||||||
sc->sc_defaddr[0] &= ~1;/* clear multicast bit */
|
sc->sc_defaddr[0] &= ~1;/* clear multicast bit */
|
||||||
@ -635,11 +635,13 @@ bridge_clone_create(struct if_clone *ifc, int unit, caddr_t params)
|
|||||||
LIST_FOREACH(sc2, &bridge_list, sc_list) {
|
LIST_FOREACH(sc2, &bridge_list, sc_list) {
|
||||||
bifp = sc2->sc_ifp;
|
bifp = sc2->sc_ifp;
|
||||||
if (memcmp(sc->sc_defaddr,
|
if (memcmp(sc->sc_defaddr,
|
||||||
IF_LLADDR(bifp), ETHER_ADDR_LEN) == 0)
|
IF_LLADDR(bifp), ETHER_ADDR_LEN) == 0) {
|
||||||
retry = 1;
|
retry = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mtx_unlock(&bridge_list_mtx);
|
mtx_unlock(&bridge_list_mtx);
|
||||||
}
|
} while (retry == 1);
|
||||||
|
|
||||||
bstp_attach(&sc->sc_stp, &bridge_ops);
|
bstp_attach(&sc->sc_stp, &bridge_ops);
|
||||||
ether_ifattach(ifp, sc->sc_defaddr);
|
ether_ifattach(ifp, sc->sc_defaddr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user