From owner-svn-src-all@FreeBSD.ORG Fri Sep 26 12:42:07 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7B091741; Fri, 26 Sep 2014 12:42:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 66A75648; Fri, 26 Sep 2014 12:42:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8QCg7XU049085; Fri, 26 Sep 2014 12:42:07 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8QCg7Ax049084; Fri, 26 Sep 2014 12:42:07 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201409261242.s8QCg7Ax049084@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Fri, 26 Sep 2014 12:42:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272176 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Sep 2014 12:42:07 -0000 Author: ae Date: Fri Sep 26 12:42:06 2014 New Revision: 272176 URL: http://svnweb.freebsd.org/changeset/base/272176 Log: Keep list of lagg ports sorted by if_index. Obtained from: Yandex LLC MFC after: 1 week Sponsored by: Yandex LLC Modified: head/sys/net/if_lagg.c Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Fri Sep 26 12:35:58 2014 (r272175) +++ head/sys/net/if_lagg.c Fri Sep 26 12:42:06 2014 (r272176) @@ -601,7 +601,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); @@ -708,8 +708,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 */