From nobody@FreeBSD.org  Sun Jan 22 11:24:55 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 49A1710656D9
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <nvass@gmx.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] two STP bridges have the same id
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         164369
>Category:       kern
>Synopsis:       [if_bridge] [patch] two STP bridges have the same id
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    adrian
>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:  Sat May 26 08:00:08 UTC 2012
>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<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 02:46:61:bb:95:00
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        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<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
                ifmaxaddr 0 port 3 priority 128 path cost 20000 proto rstp
                role designated state discarding
        member: em0 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 20000 proto rstp
                role designated state discarding

bridge1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 02:46:61:bb:95:01
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        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<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
                ifmaxaddr 0 port 5 priority 128 path cost 20000 proto rstp
                role designated state discarding
        member: em2 flags=1c7<LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP>
                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:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Jan 22 18:35:36 UTC 2012 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=164369 
Responsible-Changed-From-To: freebsd-net->adrian 
Responsible-Changed-By: adrian 
Responsible-Changed-When: Sun Jan 22 19:48:49 UTC 2012 
Responsible-Changed-Why:  
I'll poke this. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=164369 

From: Andrew Thompson <thompsa@FreeBSD.org>
To: bug-followup@FreeBSD.org, nvass@gmx.com, Adrian Chadd <adrian@freebsd.org>
Cc:  
Subject: Re: kern/164369: [if_bridge] [patch] two STP bridges have the same id
Date: Thu, 23 Feb 2012 13:43:28 +1300

 --90e6ba3fd60db7f94504b996ee79
 Content-Type: text/plain; charset=ISO-8859-1
 
 Hi Nikos,
 
 
 I have had a look at this patch. I originally ended up with the same
 change as OpenBSD made but I realised why you did it differently, to
 include all bridge ports and not just those with stp enabled.
 
 Here is a different version of your change, while it is more churn I
 think it ends up with more readable code. If the bridge port list is
 empty we jump straight out and avoid looping when 'bp' is always null.
 
 
 
 regards,
 Andrew
 
 --90e6ba3fd60db7f94504b996ee79
 Content-Type: text/x-patch; charset=US-ASCII; name="bridge-stpmac2.diff"
 Content-Disposition: attachment; filename="bridge-stpmac2.diff"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_gyz2ilxv0
 
 SW5kZXg6IGJyaWRnZXN0cC5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGJyaWRnZXN0cC5jCShyZXZpc2lvbiAy
 MzIwMDQpCisrKyBicmlkZ2VzdHAuYwkod29ya2luZyBjb3B5KQpAQCAtMjAxMiwyNCArMjAxMiwz
 MyBAQCBic3RwX3JlaW5pdChzdHJ1Y3QgYnN0cF9zdGF0ZSAqYnMpCiAJc3RydWN0IGJzdHBfcG9y
 dCAqYnA7CiAJc3RydWN0IGlmbmV0ICppZnAsICptaWY7CiAJdV9jaGFyICplX2FkZHI7CisJdm9p
 ZCAqYnJpZGdlcHRyOwogCXN0YXRpYyBjb25zdCB1X2NoYXIgbGx6ZXJvW0VUSEVSX0FERFJfTEVO
 XTsJLyogMDA6MDA6MDA6MDA6MDA6MDAgKi8KIAogCUJTVFBfTE9DS19BU1NFUlQoYnMpOwogCisJ
 aWYgKExJU1RfRU1QVFkoJmJzLT5ic19icGxpc3QpKQorCQlnb3RvIGRpc2FibGVzdHA7CisKIAlt
 aWYgPSBOVUxMOworCWJyaWRnZXB0ciA9IExJU1RfRklSU1QoJmJzLT5ic19icGxpc3QpLT5icF9p
 ZnAtPmlmX2JyaWRnZTsKKwlLQVNTRVJUKGJyaWRnZXB0ciAhP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D.org>
Cc: bug-followup@FreeBSD.org, Adrian Chadd <adrian@freebsd.org>
Subject: Re: kern/164369: [if_bridge] [patch] two STP bridges have the same
 id
Date: Fri, 24 Feb 2012 12:30:48 +0100

 On 2/23/2012 1:43 AM, Andrew Thompson wrote:
 > Hi Nikos,
 
 Hi Andrew,
 
 > I have had a look at this patch. I originally ended up with the same
 > change as OpenBSD made but I realised why you did it differently, to
 > include all bridge ports and not just those with stp enabled.
 >
 > Here is a different version of your change, while it is more churn I
 > think it ends up with more readable code. If the bridge port list is
 > empty we jump straight out and avoid looping when 'bp' is always null.
 
 I just tested your patch and it works as wanted. Could you please
 commit it?
 
 I would prefer the bridge id to be sticky, that is:
 Get the bridge id from the first ethernet added to
 the bridge and stick to it while it is a member of
 the bridge. This way there is going to be one topology
 change when the bridge enters the STP domain. If
 the said interface leaves the bridge(unlikely), the
 bridge will have to change its ID to another one.
 
 But I don't have time to look at it at the moment:(
 
 Plus the new behavior is good enough for me...
 
 Thanks, Nikos

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/164369: commit references a PR
Date: Fri, 24 Feb 2012 17:51:02 +0000 (UTC)

 Author: thompsa
 Date: Fri Feb 24 17:50:36 2012
 New Revision: 232118
 URL: http://svn.freebsd.org/changeset/base/232118
 
 Log:
   Only look for a usable MAC address for the bridge ID from ports within our
   bridge, this allows us to have more than one independent bridge in the same
   STP domain.
   
   PR:		kern/164369
   Submitted by:	Nikos Vassiliadis (earlier version)
   MFC after:	2 weeks
 
 Modified:
   head/sys/net/bridgestp.c
 
 Modified: head/sys/net/bridgestp.c
 ==============================================================================
 --- head/sys/net/bridgestp.c	Fri Feb 24 17:50:23 2012	(r232117)
 +++ head/sys/net/bridgestp.c	Fri Feb 24 17:50:36 2012	(r232118)
 @@ -2013,24 +2013,33 @@ bstp_reinit(struct bstp_state *bs)
  	struct bstp_port *bp;
  	struct ifnet *ifp, *mif;
  	u_char *e_addr;
 +	void *bridgeptr;
  	static const u_char llzero[ETHER_ADDR_LEN];	/* 00:00:00:00:00:00 */
  
  	BSTP_LOCK_ASSERT(bs);
  
 +	if (LIST_EMPTY(&bs->bs_bplist))
 +		goto disablestp;
 +
  	mif = NULL;
 +	bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
 +	KASSERT(bridgeptr != NULL, ("Invalid bridge pointer"));
  	/*
  	 * 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;
 +			continue;	/* Not Ethernet */
 +
 +		if (ifp->if_bridge != bridgeptr)
 +			continue;	/* Not part of our bridge */
  
  		if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
 -			continue;
 +			continue;	/* No mac address set */
  
  		if (mif == NULL) {
  			mif = ifp;
 @@ -2042,21 +2051,8 @@ bstp_reinit(struct bstp_state *bs)
  		}
  	}
  	IFNET_RUNLOCK_NOSLEEP();
 -
 -	if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
 -		/* Set the bridge and root id (lower bits) to zero */
 -		bs->bs_bridge_pv.pv_dbridge_id =
 -		    ((uint64_t)bs->bs_bridge_priority) << 48;
 -		bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 -		bs->bs_root_pv = bs->bs_bridge_pv;
 -		/* Disable any remaining ports, they will have no MAC address */
 -		LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 -			bp->bp_infois = BSTP_INFO_DISABLED;
 -			bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 -		}
 -		callout_stop(&bs->bs_bstpcallout);
 -		return;
 -	}
 +	if (mif == NULL)
 +		goto disablestp;
  
  	e_addr = IF_LLADDR(mif);
  	bs->bs_bridge_pv.pv_dbridge_id =
 @@ -2084,6 +2080,20 @@ bstp_reinit(struct bstp_state *bs)
  
  	bstp_assign_roles(bs);
  	bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
 +	return;
 +
 +disablestp:
 +	/* Set the bridge and root id (lower bits) to zero */
 +	bs->bs_bridge_pv.pv_dbridge_id =
 +	    ((uint64_t)bs->bs_bridge_priority) << 48;
 +	bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 +	bs->bs_root_pv = bs->bs_bridge_pv;
 +	/* Disable any remaining ports, they will have no MAC address */
 +	LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 +		bp->bp_infois = BSTP_INFO_DISABLED;
 +		bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 +	}
 +	callout_stop(&bs->bs_bstpcallout);
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Nikos Vassiliadis <nvass@gmx.com>
To: bug-followup@FreeBSD.org, nvass@gmx.com
Cc:  
Subject: Re: kern/164369: [if_bridge] [patch] two STP bridges have the same
 id
Date: Fri, 09 Mar 2012 19:55:42 +0100

 Could you close this PR?

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/164369: commit references a PR
Date: Sat, 26 May 2012 07:35:56 +0000 (UTC)

 Author: thompsa
 Date: Sat May 26 07:35:44 2012
 New Revision: 236048
 URL: http://svn.freebsd.org/changeset/base/236048
 
 Log:
   MFC r232118
   
    Only look for a usable MAC address for the bridge ID from ports within our
    bridge, this allows us to have more than one independent bridge in the same
    STP domain.
   
   PR:		kern/164369
   Submitted by:	Nikos Vassiliadis (earlier version)
 
 Modified:
   stable/9/sys/net/bridgestp.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/amd64/include/xen/   (props changed)
   stable/9/sys/boot/   (props changed)
   stable/9/sys/boot/i386/efi/   (props changed)
   stable/9/sys/boot/ia64/efi/   (props changed)
   stable/9/sys/boot/ia64/ski/   (props changed)
   stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
   stable/9/sys/boot/powerpc/ofw/   (props changed)
   stable/9/sys/cddl/contrib/opensolaris/   (props changed)
   stable/9/sys/conf/   (props changed)
   stable/9/sys/contrib/dev/acpica/   (props changed)
   stable/9/sys/contrib/octeon-sdk/   (props changed)
   stable/9/sys/contrib/pf/   (props changed)
   stable/9/sys/contrib/x86emu/   (props changed)
   stable/9/sys/dev/   (props changed)
   stable/9/sys/dev/e1000/   (props changed)
   stable/9/sys/dev/ixgbe/   (props changed)
   stable/9/sys/fs/   (props changed)
   stable/9/sys/fs/ntfs/   (props changed)
   stable/9/sys/modules/   (props changed)
 
 Modified: stable/9/sys/net/bridgestp.c
 ==============================================================================
 --- stable/9/sys/net/bridgestp.c	Sat May 26 07:34:46 2012	(r236047)
 +++ stable/9/sys/net/bridgestp.c	Sat May 26 07:35:44 2012	(r236048)
 @@ -2013,24 +2013,33 @@ bstp_reinit(struct bstp_state *bs)
  	struct bstp_port *bp;
  	struct ifnet *ifp, *mif;
  	u_char *e_addr;
 +	void *bridgeptr;
  	static const u_char llzero[ETHER_ADDR_LEN];	/* 00:00:00:00:00:00 */
  
  	BSTP_LOCK_ASSERT(bs);
  
 +	if (LIST_EMPTY(&bs->bs_bplist))
 +		goto disablestp;
 +
  	mif = NULL;
 +	bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
 +	KASSERT(bridgeptr != NULL, ("Invalid bridge pointer"));
  	/*
  	 * 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;
 +			continue;	/* Not Ethernet */
 +
 +		if (ifp->if_bridge != bridgeptr)
 +			continue;	/* Not part of our bridge */
  
  		if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
 -			continue;
 +			continue;	/* No mac address set */
  
  		if (mif == NULL) {
  			mif = ifp;
 @@ -2042,21 +2051,8 @@ bstp_reinit(struct bstp_state *bs)
  		}
  	}
  	IFNET_RUNLOCK_NOSLEEP();
 -
 -	if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
 -		/* Set the bridge and root id (lower bits) to zero */
 -		bs->bs_bridge_pv.pv_dbridge_id =
 -		    ((uint64_t)bs->bs_bridge_priority) << 48;
 -		bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 -		bs->bs_root_pv = bs->bs_bridge_pv;
 -		/* Disable any remaining ports, they will have no MAC address */
 -		LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 -			bp->bp_infois = BSTP_INFO_DISABLED;
 -			bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 -		}
 -		callout_stop(&bs->bs_bstpcallout);
 -		return;
 -	}
 +	if (mif == NULL)
 +		goto disablestp;
  
  	e_addr = IF_LLADDR(mif);
  	bs->bs_bridge_pv.pv_dbridge_id =
 @@ -2084,6 +2080,20 @@ bstp_reinit(struct bstp_state *bs)
  
  	bstp_assign_roles(bs);
  	bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
 +	return;
 +
 +disablestp:
 +	/* Set the bridge and root id (lower bits) to zero */
 +	bs->bs_bridge_pv.pv_dbridge_id =
 +	    ((uint64_t)bs->bs_bridge_priority) << 48;
 +	bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 +	bs->bs_root_pv = bs->bs_bridge_pv;
 +	/* Disable any remaining ports, they will have no MAC address */
 +	LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 +		bp->bp_infois = BSTP_INFO_DISABLED;
 +		bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 +	}
 +	callout_stop(&bs->bs_bstpcallout);
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/164369: commit references a PR
Date: Sat, 26 May 2012 07:59:32 +0000 (UTC)

 Author: thompsa
 Date: Sat May 26 07:58:58 2012
 New Revision: 236056
 URL: http://svn.freebsd.org/changeset/base/236056
 
 Log:
   MFC r232118
   
    Only look for a usable MAC address for the bridge ID from ports within our
    bridge, this allows us to have more than one independent bridge in the same
    STP domain.
   
   PR:		kern/164369
   Submitted by:	Nikos Vassiliadis (earlier version)
 
 Modified:
   stable/8/sys/net/bridgestp.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/boot/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/e1000/   (props changed)
 
 Modified: stable/8/sys/net/bridgestp.c
 ==============================================================================
 --- stable/8/sys/net/bridgestp.c	Sat May 26 07:58:12 2012	(r236055)
 +++ stable/8/sys/net/bridgestp.c	Sat May 26 07:58:58 2012	(r236056)
 @@ -2013,24 +2013,33 @@ bstp_reinit(struct bstp_state *bs)
  	struct bstp_port *bp;
  	struct ifnet *ifp, *mif;
  	u_char *e_addr;
 +	void *bridgeptr;
  	static const u_char llzero[ETHER_ADDR_LEN];	/* 00:00:00:00:00:00 */
  
  	BSTP_LOCK_ASSERT(bs);
  
 +	if (LIST_EMPTY(&bs->bs_bplist))
 +		goto disablestp;
 +
  	mif = NULL;
 +	bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
 +	KASSERT(bridgeptr != NULL, ("Invalid bridge pointer"));
  	/*
  	 * 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;
 +			continue;	/* Not Ethernet */
 +
 +		if (ifp->if_bridge != bridgeptr)
 +			continue;	/* Not part of our bridge */
  
  		if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
 -			continue;
 +			continue;	/* No mac address set */
  
  		if (mif == NULL) {
  			mif = ifp;
 @@ -2042,21 +2051,8 @@ bstp_reinit(struct bstp_state *bs)
  		}
  	}
  	IFNET_RUNLOCK_NOSLEEP();
 -
 -	if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
 -		/* Set the bridge and root id (lower bits) to zero */
 -		bs->bs_bridge_pv.pv_dbridge_id =
 -		    ((uint64_t)bs->bs_bridge_priority) << 48;
 -		bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 -		bs->bs_root_pv = bs->bs_bridge_pv;
 -		/* Disable any remaining ports, they will have no MAC address */
 -		LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 -			bp->bp_infois = BSTP_INFO_DISABLED;
 -			bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 -		}
 -		callout_stop(&bs->bs_bstpcallout);
 -		return;
 -	}
 +	if (mif == NULL)
 +		goto disablestp;
  
  	e_addr = IF_LLADDR(mif);
  	bs->bs_bridge_pv.pv_dbridge_id =
 @@ -2084,6 +2080,20 @@ bstp_reinit(struct bstp_state *bs)
  
  	bstp_assign_roles(bs);
  	bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
 +	return;
 +
 +disablestp:
 +	/* Set the bridge and root id (lower bits) to zero */
 +	bs->bs_bridge_pv.pv_dbridge_id =
 +	    ((uint64_t)bs->bs_bridge_priority) << 48;
 +	bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
 +	bs->bs_root_pv = bs->bs_bridge_pv;
 +	/* Disable any remaining ports, they will have no MAC address */
 +	LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
 +		bp->bp_infois = BSTP_INFO_DISABLED;
 +		bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
 +	}
 +	callout_stop(&bs->bs_bstpcallout);
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
