Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2012 08:06:23 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243669 - head/sys/net
Message-ID:  <201211290806.qAT86NxD022284@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211290806.qAT86NxD022284>