Fix condition and really sort ports. Also add comment describing

the intent of this code.

Reported by:	sbruno
MFC after:	1 week
Sponsored by:	Yandex LLC
This commit is contained in:
ae 2015-01-17 11:32:09 +00:00
parent fa28f09bfa
commit 240f3ae6d2

View File

@ -799,11 +799,16 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
lagg_port_lladdr(lp, IF_LLADDR(sc->sc_ifp));
}
/* Insert into the list of ports. Keep ports sorted by if_index. */
/*
* Insert into the list of ports.
* Keep ports sorted by if_index. It is handy, when configuration
* is predictable and `ifconfig laggN create ...` command
* will lead to the same result each time.
*/
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 <
SLIST_NEXT(tlp, lp_entries)->lp_ifp->if_index >
ifp->if_index))
break;
}