svn commit: r272680 - stable/10/sys/net

Andrey V. Elsukov ae at FreeBSD.org
Tue Oct 7 07:52:48 UTC 2014


Author: ae
Date: Tue Oct  7 07:52:47 2014
New Revision: 272680
URL: https://svnweb.freebsd.org/changeset/base/272680

Log:
  MFC r272176:
    Keep list of lagg ports sorted by if_index.

Modified:
  stable/10/sys/net/if_lagg.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/if_lagg.c
==============================================================================
--- stable/10/sys/net/if_lagg.c	Tue Oct  7 06:34:05 2014	(r272679)
+++ stable/10/sys/net/if_lagg.c	Tue Oct  7 07:52:47 2014	(r272680)
@@ -565,7 +565,7 @@ static int
 lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
 {
 	struct lagg_softc *sc_ptr;
-	struct lagg_port *lp;
+	struct lagg_port *lp, *tlp;
 	int error = 0;
 
 	LAGG_WLOCK_ASSERT(sc);
@@ -672,8 +672,18 @@ lagg_port_create(struct lagg_softc *sc, 
 		lagg_port_lladdr(lp, IF_LLADDR(sc->sc_ifp));
 	}
 
-	/* Insert into the list of ports */
-	SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries);
+	/* Insert into the list of ports. Keep ports sorted by if_index. */
+	SLIST_FOREACH(tlp, &sc->sc_ports, lp_entries) {
+		if (tlp->lp_ifp->if_index < ifp->if_index && (
+		    SLIST_NEXT(tlp, lp_entries) == NULL ||
+		    SLIST_NEXT(tlp, lp_entries)->lp_ifp->if_index <
+		    ifp->if_index))
+			break;
+	}
+	if (tlp != NULL)
+		SLIST_INSERT_AFTER(tlp, lp, lp_entries);
+	else
+		SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries);
 	sc->sc_count++;
 
 	/* Update lagg capabilities */


More information about the svn-src-all mailing list