Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/if_lagg.c
Show First 20 Lines • Show All 634 Lines • ▼ Show 20 Lines | lagg_port_lladdr(struct lagg_port *lp, uint8_t *lladdr) | ||||
primary = (sc->sc_primary->lp_ifp == ifp) ? 1 : 0; | primary = (sc->sc_primary->lp_ifp == ifp) ? 1 : 0; | ||||
if (primary == 0 && (lp->lp_detaching || | if (primary == 0 && (lp->lp_detaching || | ||||
memcmp(lladdr, IF_LLADDR(ifp), ETHER_ADDR_LEN) == 0)) | memcmp(lladdr, IF_LLADDR(ifp), ETHER_ADDR_LEN) == 0)) | ||||
return; | return; | ||||
/* Check to make sure its not already queued to be changed */ | /* Check to make sure its not already queued to be changed */ | ||||
SLIST_FOREACH(llq, &sc->sc_llq_head, llq_entries) { | SLIST_FOREACH(llq, &sc->sc_llq_head, llq_entries) { | ||||
if (llq->llq_ifp == ifp) { | if (llq->llq_ifp == ifp && llq->llq_primary == primary) { | ||||
pending = 1; | pending = 1; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (!pending) { | if (!pending) { | ||||
llq = malloc(sizeof(struct lagg_llq), M_DEVBUF, M_NOWAIT); | llq = malloc(sizeof(struct lagg_llq), M_DEVBUF, M_NOWAIT); | ||||
if (llq == NULL) /* XXX what to do */ | if (llq == NULL) /* XXX what to do */ | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | lagg_port_checkstacking(struct lagg_softc *sc) | ||||
return (m + 1); | return (m + 1); | ||||
} | } | ||||
#endif | #endif | ||||
static int | static int | ||||
lagg_port_destroy(struct lagg_port *lp, int rundelport) | 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; | struct lagg_port *lp_ptr, *lp0; | ||||
struct lagg_llq *llq; | struct lagg_llq *llq; | ||||
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_WLOCK_ASSERT(sc); | LAGG_WLOCK_ASSERT(sc); | ||||
if (rundelport) | if (rundelport) | ||||
Show All 25 Lines | lagg_port_destroy(struct lagg_port *lp, int rundelport) | ||||
/* Finally, remove the port from the lagg */ | /* Finally, remove the port from the lagg */ | ||||
SLIST_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entries); | SLIST_REMOVE(&sc->sc_ports, lp, lagg_port, lp_entries); | ||||
sc->sc_count--; | sc->sc_count--; | ||||
/* 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 ((lp_ptr = SLIST_FIRST(&sc->sc_ports)) == NULL) { | if ((lp0 = SLIST_FIRST(&sc->sc_ports)) == NULL) { | ||||
bzero(&lladdr, ETHER_ADDR_LEN); | bzero(&lladdr, ETHER_ADDR_LEN); | ||||
} else { | } else { | ||||
bcopy(lp_ptr->lp_lladdr, | bcopy(lp0->lp_lladdr, | ||||
lladdr, ETHER_ADDR_LEN); | lladdr, ETHER_ADDR_LEN); | ||||
} | } | ||||
lagg_lladdr(sc, lladdr); | lagg_lladdr(sc, lladdr); | ||||
sc->sc_primary = lp_ptr; | |||||
/* Update link layer address for each port */ | /* | ||||
* Update link layer address for each port. No port is | |||||
* marked as primary at this moment. | |||||
*/ | |||||
SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) | SLIST_FOREACH(lp_ptr, &sc->sc_ports, lp_entries) | ||||
lagg_port_lladdr(lp_ptr, lladdr); | lagg_port_lladdr(lp_ptr, lladdr); | ||||
/* | |||||
* Mark lp0 as the new primary. This invokes an | |||||
* iflladdr_event. | |||||
*/ | |||||
sc->sc_primary = lp0; | |||||
lagg_port_lladdr(lp0, lladdr); | |||||
} | } | ||||
/* Remove any pending lladdr changes from the queue */ | /* Remove any pending lladdr changes from the queue */ | ||||
if (lp->lp_detaching) { | if (lp->lp_detaching) { | ||||
SLIST_FOREACH(llq, &sc->sc_llq_head, llq_entries) { | SLIST_FOREACH(llq, &sc->sc_llq_head, llq_entries) { | ||||
if (llq->llq_ifp == ifp) { | if (llq->llq_ifp == ifp) { | ||||
SLIST_REMOVE(&sc->sc_llq_head, llq, lagg_llq, | SLIST_REMOVE(&sc->sc_llq_head, llq, lagg_llq, | ||||
llq_entries); | llq_entries); | ||||
▲ Show 20 Lines • Show All 1,267 Lines • Show Last 20 Lines |