From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 22 11:30:12 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61BA0106566C for ; Sun, 22 Jan 2012 11:30:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3DACB8FC13 for ; Sun, 22 Jan 2012 11:30:12 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q0MBUC6a038400 for ; Sun, 22 Jan 2012 11:30:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0MBUCrP038396; Sun, 22 Jan 2012 11:30:12 GMT (envelope-from gnats) Resent-Date: Sun, 22 Jan 2012 11:30:12 GMT Resent-Message-Id: <201201221130.q0MBUCrP038396@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nikos Vassiliadis Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49A1710656D9 for ; Sun, 22 Jan 2012 11:24:55 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 240978FC17 for ; Sun, 22 Jan 2012 11:24:55 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0MBOsGd024334 for ; Sun, 22 Jan 2012 11:24:54 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q0MBOsZg024333; Sun, 22 Jan 2012 11:24:54 GMT (envelope-from nobody) Message-Id: <201201221124.q0MBOsZg024333@red.freebsd.org> Date: Sun, 22 Jan 2012 11:24:54 GMT From: Nikos Vassiliadis To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/164369: [patch] two STP bridges have the same id X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2012 11:30:12 -0000 >Number: 164369 >Category: kern >Synopsis: [patch] two STP bridges have the same id >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jan 22 11:30:11 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Nikos Vassiliadis >Release: 10.0-CURRENT >Organization: >Environment: FreeBSD lab.local 10.0-CURRENT FreeBSD 10.0-CURRENT #110 r230309M: Wed Jan 18 21:07:24 EET 2012 root@lab.local:/usr/obj/usr/src/sys/LAB i386 >Description: The current code in STP selects the id of a bridge from all available ethernet ifnets regardless if they are part of the said bridge. This is problematic when more than one STP bridges exist, that is, more than one bridges will have the same bridge id. >How-To-Repeat: ifconfig bridge0 create ifconfig bridge1 create ifconfig bridge0 addm em0 addm em1 stp em0 stp em1 ifconfig bridge1 addm em2 addm em3 stp em2 stp em3 The resulting bridges are: bridge0: flags=8802 metric 0 mtu 1500 ether 02:46:61:bb:95:00 nd6 options=29 id 08:00:27:0f:88:a5 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200 root id 08:00:27:0f:88:a5 priority 32768 ifcost 0 port 0 member: em1 flags=1c7 ifmaxaddr 0 port 3 priority 128 path cost 20000 proto rstp role designated state discarding member: em0 flags=1c7 ifmaxaddr 0 port 1 priority 128 path cost 20000 proto rstp role designated state discarding bridge1: flags=8802 metric 0 mtu 1500 ether 02:46:61:bb:95:01 nd6 options=29 id 08:00:27:0f:88:a5 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200 root id 08:00:27:0f:88:a5 priority 32768 ifcost 0 port 0 member: em3 flags=1c7 ifmaxaddr 0 port 5 priority 128 path cost 20000 proto rstp role designated state discarding member: em2 flags=1c7 ifmaxaddr 0 port 4 priority 128 path cost 20000 proto rstp role designated state discarding Both have the same id >Fix: The MAC address candidates for the bridge id should be only from the bridge's members Patch attached with submission follows: Index: sys/net/bridgestp.c =================================================================== --- sys/net/bridgestp.c (revision 230309) +++ sys/net/bridgestp.c (working copy) @@ -2017,20 +2017,27 @@ BSTP_LOCK_ASSERT(bs); mif = NULL; + bp = LIST_FIRST(&bs->bs_bplist); /* * Search through the Ethernet adapters and find the one with the - * lowest value. The adapter which we take the MAC address from does - * not need to be part of the bridge, it just needs to be a unique - * value. + * lowest value. Make sure the adapter which we take the MAC address + * from is part of this bridge, so we can have more than one independent + * bridges in the same STP domain. */ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (ifp->if_type != IFT_ETHER) continue; + if (ifp->if_bridge == NULL || bp == NULL) + continue; + if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0) continue; + if (ifp->if_bridge != bp->bp_ifp->if_bridge) + continue; + if (mif == NULL) { mif = ifp; continue; >Release-Note: >Audit-Trail: >Unformatted: