From 08fc0dcfca09fdd645061044649967673992eb3c Mon Sep 17 00:00:00 2001 From: ae Date: Sun, 25 Jan 2015 16:35:03 +0000 Subject: [PATCH] MFC r277295: Fix condition and really sort ports. Also add comment describing the intent of this code. git-svn-id: svn://svn.freebsd.org/base/stable/10@277707 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/net/if_lagg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 7218e29b3..f2973f64c 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -666,11 +666,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; } -- 2.45.0