STP and if_epair, ngeth

Nikos Vassiliadis nvass at gmx.com
Sat May 7 14:28:41 UTC 2011


Hi,

The STP code in bridgestp.c uses ifmedia to check duplex status.
if_epair and ng_eiface interfaces commonly used in VIMAGE enabled
jails do not support ifmedia and thus stay forever disabled when
STP is enabled on such interfaces. Could you review the patch?

Thanks, Nikos

-------------- next part --------------
Index: sys/net/bridgestp.c
===================================================================
--- sys/net/bridgestp.c	(revision 221584)
+++ sys/net/bridgestp.c	(working copy)
@@ -1804,12 +1804,19 @@
 	bzero((char *)&ifmr, sizeof(ifmr));
 	error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr);
 
-	if ((error == 0) && (ifp->if_flags & IFF_UP)) {
-		if (ifmr.ifm_status & IFM_ACTIVE) {
+	if (ifp->if_flags & IFF_UP) {
+		if (ifp->if_link_state == LINK_STATE_UP) {
 			/* A full-duplex link is assumed to be point to point */
 			if (bp->bp_flags & BSTP_PORT_AUTOPTP) {
-				bp->bp_ptp_link =
-				    ifmr.ifm_active & IFM_FDX ? 1 : 0;
+				/* Interfaces that do not support ifmedia,
+				 * are assumed to be full-duplex. if_epair
+				 * and ng_eiface fall into this category.
+				 */
+				if (error == 0)
+					bp->bp_ptp_link =
+					    ifmr.ifm_active & IFM_FDX ? 1 : 0;
+				else if (error == EINVAL)
+					bp->bp_ptp_link = 1;
 			}
 
 			/* Calc the cost if the link was down previously */





More information about the freebsd-net mailing list