Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_lagg.c
Show First 20 Lines • Show All 753 Lines • ▼ Show 20 Lines | #endif | ||||
LAGG_RLOCK(); | LAGG_RLOCK(); | ||||
CK_SLIST_FOREACH(tlp, &sc->sc_ports, lp_entries) { | CK_SLIST_FOREACH(tlp, &sc->sc_ports, lp_entries) { | ||||
if (tlp->lp_ifp->if_index < ifp->if_index && ( | if (tlp->lp_ifp->if_index < ifp->if_index && ( | ||||
CK_SLIST_NEXT(tlp, lp_entries) == NULL || | CK_SLIST_NEXT(tlp, lp_entries) == NULL || | ||||
((struct lagg_port*)CK_SLIST_NEXT(tlp, lp_entries))->lp_ifp->if_index > | ((struct lagg_port*)CK_SLIST_NEXT(tlp, lp_entries))->lp_ifp->if_index > | ||||
ifp->if_index)) | ifp->if_index)) | ||||
break; | break; | ||||
} | } | ||||
LAGG_RUNLOCK(); | |||||
if (tlp != NULL) | if (tlp != NULL) | ||||
CK_SLIST_INSERT_AFTER(tlp, lp, lp_entries); | CK_SLIST_INSERT_AFTER(tlp, lp, lp_entries); | ||||
else | else | ||||
CK_SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries); | CK_SLIST_INSERT_HEAD(&sc->sc_ports, lp, lp_entries); | ||||
sc->sc_count++; | sc->sc_count++; | ||||
lagg_setmulti(lp); | lagg_setmulti(lp); | ||||
if ((error = lagg_proto_addport(sc, lp)) != 0) { | if ((error = lagg_proto_addport(sc, lp)) != 0) { | ||||
/* Remove the port, without calling pr_delport. */ | /* Remove the port, without calling pr_delport. */ | ||||
lagg_port_destroy(lp, 0); | lagg_port_destroy(lp, 0); | ||||
if (oldmtu != -1) | if (oldmtu != -1) | ||||
(*ifp->if_ioctl)(ifp, SIOCSIFMTU, (caddr_t)&ifr); | (*ifp->if_ioctl)(ifp, SIOCSIFMTU, (caddr_t)&ifr); | ||||
LAGG_RUNLOCK(); | |||||
return (error); | return (error); | ||||
} | } | ||||
LAGG_RUNLOCK(); | |||||
/* Update lagg capabilities */ | /* Update lagg capabilities */ | ||||
lagg_proto_linkstate(sc, lp); | |||||
lagg_capabilities(sc); | lagg_capabilities(sc); | ||||
lagg_linkstate(sc); | lagg_linkstate(sc); | ||||
return (0); | return (0); | ||||
} | } | ||||
#ifdef LAGG_PORT_STACKING | #ifdef LAGG_PORT_STACKING | ||||
static int | static int | ||||
Show All 34 Lines | lagg_port_destroy(struct lagg_port *lp, int rundelport) | ||||
struct lagg_softc *sc = lp->lp_softc; | struct lagg_softc *sc = lp->lp_softc; | ||||
struct lagg_port *lp_ptr, *lp0; | struct lagg_port *lp_ptr, *lp0; | ||||
struct ifnet *ifp = lp->lp_ifp; | struct ifnet *ifp = lp->lp_ifp; | ||||
uint64_t *pval, vdiff; | uint64_t *pval, vdiff; | ||||
int i; | int i; | ||||
LAGG_XLOCK_ASSERT(sc); | LAGG_XLOCK_ASSERT(sc); | ||||
LAGG_RLOCK(); | |||||
if (rundelport) | if (rundelport) | ||||
lagg_proto_delport(sc, lp); | lagg_proto_delport(sc, lp); | ||||
if (lp->lp_detaching == 0) | if (lp->lp_detaching == 0) | ||||
lagg_clrmulti(lp); | lagg_clrmulti(lp); | ||||
/* Restore interface */ | /* Restore interface */ | ||||
ifp->if_type = lp->lp_iftype; | ifp->if_type = lp->lp_iftype; | ||||
ifp->if_ioctl = lp->lp_ioctl; | ifp->if_ioctl = lp->lp_ioctl; | ||||
ifp->if_output = lp->lp_output; | ifp->if_output = lp->lp_output; | ||||
ifp->if_lagg = NULL; | ifp->if_lagg = NULL; | ||||
/* Update detached port counters */ | /* Update detached port counters */ | ||||
pval = lp->port_counters.val; | pval = lp->port_counters.val; | ||||
for (i = 0; i < IFCOUNTERS; i++, pval++) { | for (i = 0; i < IFCOUNTERS; i++, pval++) { | ||||
vdiff = ifp->if_get_counter(ifp, i) - *pval; | vdiff = ifp->if_get_counter(ifp, i) - *pval; | ||||
sc->detached_counters.val[i] += vdiff; | sc->detached_counters.val[i] += vdiff; | ||||
} | } | ||||
/* Finally, remove the port from the lagg */ | /* Finally, remove the port from the lagg */ | ||||
CK_SLIST_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entries); | CK_SLIST_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entries); | ||||
sc->sc_count--; | sc->sc_count--; | ||||
LAGG_RUNLOCK(); | |||||
/* Update the primary interface */ | /* Update the primary interface */ | ||||
if (lp == sc->sc_primary) { | if (lp == sc->sc_primary) { | ||||
uint8_t lladdr[ETHER_ADDR_LEN]; | uint8_t lladdr[ETHER_ADDR_LEN]; | ||||
if ((lp0 = CK_SLIST_FIRST(&sc->sc_ports)) == NULL) | if ((lp0 = CK_SLIST_FIRST(&sc->sc_ports)) == NULL) | ||||
bzero(&lladdr, ETHER_ADDR_LEN); | bzero(&lladdr, ETHER_ADDR_LEN); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 1,391 Lines • Show Last 20 Lines |