STP id selection
Nikos Vassiliadis
nvass at gmx.com
Sat Jan 21 13:37:55 UTC 2012
Hi,
The current code in bridgestp.c finds the lower MAC address from all
available ethernets and uses it as the STP id. This is problematic when
more than one STP bridges participate in the same STP domain because
more than one bridges will use the same id. A similar fix was applied
to the OpenBSD version of the code[1]. Could you review the attached
patch?
1.http://www.openbsd.org/cgi-bin/cvsweb/src/sys/net/bridgestp.c?rev=1.33
Thanks, Nikos
-------------- next part --------------
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;
More information about the freebsd-net
mailing list