From owner-svn-src-head@FreeBSD.ORG Thu Nov 29 08:06:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0D254B01; Thu, 29 Nov 2012 08:06:24 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E27C48FC08; Thu, 29 Nov 2012 08:06:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAT86Nwb022285; Thu, 29 Nov 2012 08:06:23 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAT86NxD022284; Thu, 29 Nov 2012 08:06:23 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201211290806.qAT86NxD022284@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Thu, 29 Nov 2012 08:06:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243669 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2012 08:06:24 -0000 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);