svn commit: r243669 - head/sys/net
Pawel Jakub Dawidek
pjd at FreeBSD.org
Thu Nov 29 08:06:24 UTC 2012
Author: pjd
Date: Thu Nov 29 08:06:23 2012
New Revision: 243669
URL: http://svnweb.freebsd.org/changeset/base/243669
Log:
- 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
Modified:
head/sys/net/if_bridge.c
Modified: head/sys/net/if_bridge.c
==============================================================================
--- head/sys/net/if_bridge.c Thu Nov 29 07:30:42 2012 (r243668)
+++ head/sys/net/if_bridge.c Thu Nov 29 08:06:23 2012 (r243669)
@@ -615,7 +615,7 @@ bridge_clone_create(struct if_clone *ifc
*/
fb = 0;
getcredhostid(curthread->td_ucred, &hostid);
- for (retry = 1; retry != 0;) {
+ do {
if (fb || hostid == 0) {
arc4rand(sc->sc_defaddr, ETHER_ADDR_LEN, 1);
sc->sc_defaddr[0] &= ~1;/* clear multicast bit */
@@ -635,11 +635,13 @@ bridge_clone_create(struct if_clone *ifc
LIST_FOREACH(sc2, &bridge_list, sc_list) {
bifp = sc2->sc_ifp;
if (memcmp(sc->sc_defaddr,
- IF_LLADDR(bifp), ETHER_ADDR_LEN) == 0)
+ IF_LLADDR(bifp), ETHER_ADDR_LEN) == 0) {
retry = 1;
+ break;
+ }
}
mtx_unlock(&bridge_list_mtx);
- }
+ } while (retry == 1);
bstp_attach(&sc->sc_stp, &bridge_ops);
ether_ifattach(ifp, sc->sc_defaddr);
More information about the svn-src-all
mailing list