diff options
author | ae <ae@FreeBSD.org> | 2014-10-07 07:52:47 +0000 |
---|---|---|
committer | ae <ae@FreeBSD.org> | 2014-10-07 07:52:47 +0000 |
commit | f7ad542948836931a687bf9f6d3d5d7e81c7dde0 (patch) | |
tree | 38dd8096a016ea42a8f257074429e39bdf4c7d16 | |
parent | 6b6a0e5b05ab1414054afc77562682367d8856fc (diff) | |
download | FreeBSD-src-f7ad542948836931a687bf9f6d3d5d7e81c7dde0.zip FreeBSD-src-f7ad542948836931a687bf9f6d3d5d7e81c7dde0.tar.gz |
MFC r272176:
Keep list of lagg ports sorted by if_index.
-rw-r--r-- | sys/net/if_lagg.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 4d41e63..92e8dc4 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -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, struct ifnet *ifp) 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 */ |