1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

non-functional cleanup

- remove dead code
- use consistent variable names
- gc unused defines
- whitespace cleanup
This commit is contained in:
Andrew Thompson 2007-06-12 07:29:11 +00:00
parent ff8fbcffcb
commit ec32b37ecd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170599
4 changed files with 108 additions and 142 deletions

View File

@ -216,8 +216,8 @@ static const lacp_timer_func_t lacp_timer_funcs[LACP_NTIMER] = {
void void
lacp_input(struct lagg_port *lgp, struct mbuf *m) lacp_input(struct lagg_port *lgp, struct mbuf *m)
{ {
struct lagg_softc *lgs = lgp->lp_lagg; struct lagg_softc *sc = lgp->lp_softc;
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
uint8_t subtype; uint8_t subtype;
if (m->m_pkthdr.len < sizeof(struct ether_header) + sizeof(subtype)) { if (m->m_pkthdr.len < sizeof(struct ether_header) + sizeof(subtype)) {
@ -247,7 +247,7 @@ static void
lacp_dequeue(void *arg, int pending) lacp_dequeue(void *arg, int pending)
{ {
struct lacp_softc *lsc = (struct lacp_softc *)arg; struct lacp_softc *lsc = (struct lacp_softc *)arg;
struct lagg_softc *sc = lsc->lsc_lagg; struct lagg_softc *sc = lsc->lsc_softc;
struct lagg_port *lgp; struct lagg_port *lgp;
struct mbuf *m; struct mbuf *m;
@ -272,11 +272,7 @@ lacp_pdu_input(struct lagg_port *lgp, struct mbuf *m)
struct lacpdu *du; struct lacpdu *du;
int error = 0; int error = 0;
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
if (__predict_false(lp->lp_flags & LACP_PORT_DETACHING)) {
goto bad;
}
if (m->m_pkthdr.len != sizeof(*du)) { if (m->m_pkthdr.len != sizeof(*du)) {
goto bad; goto bad;
@ -300,16 +296,10 @@ lacp_pdu_input(struct lagg_port *lgp, struct mbuf *m)
goto bad; goto bad;
} }
/* XXX
KASSERT(du->ldu_sph.sph_subtype == SLOWPROTOCOLS_SUBTYPE_LACP,
("a very bad kassert!"));
*/
/* /*
* ignore the version for compatibility with * ignore the version for compatibility with
* the future protocol revisions. * the future protocol revisions.
*/ */
#if 0 #if 0
if (du->ldu_sph.sph_version != 1) { if (du->ldu_sph.sph_version != 1) {
goto bad; goto bad;
@ -320,7 +310,6 @@ lacp_pdu_input(struct lagg_port *lgp, struct mbuf *m)
* ignore tlv types for compatibility with * ignore tlv types for compatibility with
* the future protocol revisions. * the future protocol revisions.
*/ */
if (tlv_check(du, sizeof(*du), &du->ldu_tlv_actor, if (tlv_check(du, sizeof(*du), &du->ldu_tlv_actor,
lacp_info_tlv_template, FALSE)) { lacp_info_tlv_template, FALSE)) {
goto bad; goto bad;
@ -345,11 +334,11 @@ static void
lacp_fill_actorinfo(struct lacp_port *lp, struct lacp_peerinfo *info) lacp_fill_actorinfo(struct lacp_port *lp, struct lacp_peerinfo *info)
{ {
struct lagg_port *lgp = lp->lp_lagg; struct lagg_port *lgp = lp->lp_lagg;
struct lagg_softc *lgs = lgp->lp_lagg; struct lagg_softc *sc = lgp->lp_softc;
info->lip_systemid.lsi_prio = htons(LACP_SYSTEM_PRIO); info->lip_systemid.lsi_prio = htons(LACP_SYSTEM_PRIO);
memcpy(&info->lip_systemid.lsi_mac, memcpy(&info->lip_systemid.lsi_mac,
IF_LLADDR(lgs->sc_ifp), ETHER_ADDR_LEN); IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN);
info->lip_portid.lpi_prio = htons(LACP_PORT_PRIO); info->lip_portid.lpi_prio = htons(LACP_PORT_PRIO);
info->lip_portid.lpi_portno = htons(lp->lp_ifp->if_index); info->lip_portid.lpi_portno = htons(lp->lp_ifp->if_index);
info->lip_state = lp->lp_state; info->lip_state = lp->lp_state;
@ -374,7 +363,7 @@ lacp_xmit_lacpdu(struct lacp_port *lp)
struct lacpdu *du; struct lacpdu *du;
int error; int error;
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
m = m_gethdr(M_DONTWAIT, MT_DATA); m = m_gethdr(M_DONTWAIT, MT_DATA);
if (m == NULL) { if (m == NULL) {
@ -428,7 +417,7 @@ lacp_xmit_marker(struct lacp_port *lp)
struct markerdu *mdu; struct markerdu *mdu;
int error; int error;
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
m = m_gethdr(M_DONTWAIT, MT_DATA); m = m_gethdr(M_DONTWAIT, MT_DATA);
if (m == NULL) { if (m == NULL) {
@ -471,7 +460,7 @@ lacp_linkstate(struct lagg_port *lgp)
uint8_t old_state; uint8_t old_state;
uint16_t old_key; uint16_t old_key;
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
bzero((char *)&ifmr, sizeof(ifmr)); bzero((char *)&ifmr, sizeof(ifmr));
error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr); error = (*ifp->if_ioctl)(ifp, SIOCGIFMEDIA, (caddr_t)&ifmr);
@ -486,7 +475,7 @@ lacp_linkstate(struct lagg_port *lgp)
old_key = lp->lp_key; old_key = lp->lp_key;
lp->lp_media = media; lp->lp_media = media;
/* /*
* If the port is not an active full duplex Ethernet link then it can * If the port is not an active full duplex Ethernet link then it can
* not be aggregated. * not be aggregated.
*/ */
@ -508,7 +497,7 @@ static void
lacp_tick(void *arg) lacp_tick(void *arg)
{ {
struct lacp_softc *lsc = arg; struct lacp_softc *lsc = arg;
struct lagg_softc *sc = lsc->lsc_lagg; struct lagg_softc *sc = lsc->lsc_softc;
struct lacp_port *lp; struct lacp_port *lp;
LAGG_WLOCK(sc); LAGG_WLOCK(sc);
@ -530,8 +519,8 @@ lacp_tick(void *arg)
int int
lacp_port_create(struct lagg_port *lgp) lacp_port_create(struct lagg_port *lgp)
{ {
struct lagg_softc *lgs = lgp->lp_lagg; struct lagg_softc *sc = lgp->lp_softc;
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
struct lacp_port *lp; struct lacp_port *lp;
struct ifnet *ifp = lgp->lp_ifp; struct ifnet *ifp = lgp->lp_ifp;
struct sockaddr_dl sdl; struct sockaddr_dl sdl;
@ -541,7 +530,7 @@ lacp_port_create(struct lagg_port *lgp)
boolean_t active = TRUE; /* XXX should be configurable */ boolean_t active = TRUE; /* XXX should be configurable */
boolean_t fast = FALSE; /* XXX should be configurable */ boolean_t fast = FALSE; /* XXX should be configurable */
LAGG_WLOCK_ASSERT(lgs); LAGG_WLOCK_ASSERT(sc);
bzero((char *)&sdl, sizeof(sdl)); bzero((char *)&sdl, sizeof(sdl));
sdl.sdl_len = sizeof(sdl); sdl.sdl_len = sizeof(sdl);
@ -589,7 +578,7 @@ lacp_port_destroy(struct lagg_port *lgp)
struct lacp_port *lp = LACP_PORT(lgp); struct lacp_port *lp = LACP_PORT(lgp);
int i; int i;
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
for (i = 0; i < LACP_NTIMER; i++) { for (i = 0; i < LACP_NTIMER; i++) {
LACP_TIMER_DISARM(lp, i); LACP_TIMER_DISARM(lp, i);
@ -654,7 +643,7 @@ lacp_disable_distributing(struct lacp_port *lp)
char buf[LACP_LAGIDSTR_MAX+1]; char buf[LACP_LAGIDSTR_MAX+1];
#endif /* defined(LACP_DEBUG) */ #endif /* defined(LACP_DEBUG) */
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
if (la == NULL || (lp->lp_state & LACP_STATE_DISTRIBUTING) == 0) { if (la == NULL || (lp->lp_state & LACP_STATE_DISTRIBUTING) == 0) {
return; return;
@ -692,7 +681,7 @@ lacp_enable_distributing(struct lacp_port *lp)
char buf[LACP_LAGIDSTR_MAX+1]; char buf[LACP_LAGIDSTR_MAX+1];
#endif /* defined(LACP_DEBUG) */ #endif /* defined(LACP_DEBUG) */
LAGG_WLOCK_ASSERT(lgp->lp_lagg); LAGG_WLOCK_ASSERT(lgp->lp_softc);
if ((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0) { if ((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0) {
return; return;
@ -727,19 +716,19 @@ lacp_transit_expire(void *vp)
} }
int int
lacp_attach(struct lagg_softc *lgs) lacp_attach(struct lagg_softc *sc)
{ {
struct lacp_softc *lsc; struct lacp_softc *lsc;
LAGG_WLOCK_ASSERT(lgs); LAGG_WLOCK_ASSERT(sc);
lsc = malloc(sizeof(struct lacp_softc), lsc = malloc(sizeof(struct lacp_softc),
M_DEVBUF, M_NOWAIT|M_ZERO); M_DEVBUF, M_NOWAIT|M_ZERO);
if (lsc == NULL) if (lsc == NULL)
return (ENOMEM); return (ENOMEM);
lgs->sc_psc = (caddr_t)lsc; sc->sc_psc = (caddr_t)lsc;
lsc->lsc_lagg = lgs; lsc->lsc_softc = sc;
lsc->lsc_hashkey = arc4random(); lsc->lsc_hashkey = arc4random();
lsc->lsc_active_aggregator = NULL; lsc->lsc_active_aggregator = NULL;
@ -754,23 +743,23 @@ lacp_attach(struct lagg_softc *lgs)
callout_init(&lsc->lsc_callout, CALLOUT_MPSAFE); callout_init(&lsc->lsc_callout, CALLOUT_MPSAFE);
/* if the lagg is already up then do the same */ /* if the lagg is already up then do the same */
if (lgs->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING)
lacp_init(lgs); lacp_init(sc);
return (0); return (0);
} }
int int
lacp_detach(struct lagg_softc *lgs) lacp_detach(struct lagg_softc *sc)
{ {
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
KASSERT(TAILQ_EMPTY(&lsc->lsc_aggregators), KASSERT(TAILQ_EMPTY(&lsc->lsc_aggregators),
("aggregators still active")); ("aggregators still active"));
KASSERT(lsc->lsc_active_aggregator == NULL, KASSERT(lsc->lsc_active_aggregator == NULL,
("aggregator still attached")); ("aggregator still attached"));
lgs->sc_psc = NULL; sc->sc_psc = NULL;
callout_drain(&lsc->lsc_transit_callout); callout_drain(&lsc->lsc_transit_callout);
callout_drain(&lsc->lsc_callout); callout_drain(&lsc->lsc_callout);
taskqueue_drain(taskqueue_swi, &lsc->lsc_qtask); taskqueue_drain(taskqueue_swi, &lsc->lsc_qtask);
@ -782,32 +771,32 @@ lacp_detach(struct lagg_softc *lgs)
} }
void void
lacp_init(struct lagg_softc *lgs) lacp_init(struct lagg_softc *sc)
{ {
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
callout_reset(&lsc->lsc_callout, hz, lacp_tick, lsc); callout_reset(&lsc->lsc_callout, hz, lacp_tick, lsc);
} }
void void
lacp_stop(struct lagg_softc *lgs) lacp_stop(struct lagg_softc *sc)
{ {
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
callout_stop(&lsc->lsc_transit_callout); callout_stop(&lsc->lsc_transit_callout);
callout_stop(&lsc->lsc_callout); callout_stop(&lsc->lsc_callout);
} }
struct lagg_port * struct lagg_port *
lacp_select_tx_port(struct lagg_softc *lgs, struct mbuf *m) lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m)
{ {
struct lacp_softc *lsc = LACP_SOFTC(lgs); struct lacp_softc *lsc = LACP_SOFTC(sc);
struct lacp_aggregator *la; struct lacp_aggregator *la;
struct lacp_port *lp; struct lacp_port *lp;
uint32_t hash; uint32_t hash;
int nports; int nports;
LAGG_RLOCK_ASSERT(lgs); LAGG_RLOCK_ASSERT(sc);
if (__predict_false(lsc->lsc_suppress_distributing)) { if (__predict_false(lsc->lsc_suppress_distributing)) {
LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__));
@ -981,7 +970,7 @@ static uint16_t
lacp_compose_key(struct lacp_port *lp) lacp_compose_key(struct lacp_port *lp)
{ {
struct lagg_port *lgp = lp->lp_lagg; struct lagg_port *lgp = lp->lp_lagg;
struct lagg_softc *lgs = lgp->lp_lagg; struct lagg_softc *sc = lgp->lp_softc;
u_int media = lp->lp_media; u_int media = lp->lp_media;
uint16_t key; uint16_t key;
@ -1006,7 +995,7 @@ lacp_compose_key(struct lacp_port *lp)
/* bit 0..4: IFM_SUBTYPE */ /* bit 0..4: IFM_SUBTYPE */
key = subtype; key = subtype;
/* bit 5..14: (some bits of) if_index of lagg device */ /* bit 5..14: (some bits of) if_index of lagg device */
key |= 0x7fe0 & ((lgs->sc_ifp->if_index) << 5); key |= 0x7fe0 & ((sc->sc_ifp->if_index) << 5);
/* bit 15: 0 */ /* bit 15: 0 */
} }
return (htons(key)); return (htons(key));
@ -1680,11 +1669,7 @@ lacp_marker_input(struct lagg_port *lgp, struct mbuf *m)
int error = 0; int error = 0;
int pending = 0; int pending = 0;
LAGG_RLOCK_ASSERT(lgp->lp_lagg); LAGG_RLOCK_ASSERT(lgp->lp_softc);
if (__predict_false(lp->lp_flags & LACP_PORT_DETACHING)) {
goto bad;
}
if (m->m_pkthdr.len != sizeof(*mdu)) { if (m->m_pkthdr.len != sizeof(*mdu)) {
goto bad; goto bad;
@ -1708,11 +1693,6 @@ lacp_marker_input(struct lagg_port *lgp, struct mbuf *m)
goto bad; goto bad;
} }
/* XXX
KASSERT(mdu->mdu_sph.sph_subtype == SLOWPROTOCOLS_SUBTYPE_MARKER,
("a very bad kassert!"));
*/
if (mdu->mdu_sph.sph_version != 1) { if (mdu->mdu_sph.sph_version != 1) {
goto bad; goto bad;
} }

View File

@ -61,13 +61,8 @@
#define LACP_STATE_DEFAULTED (1<<6) #define LACP_STATE_DEFAULTED (1<<6)
#define LACP_STATE_EXPIRED (1<<7) #define LACP_STATE_EXPIRED (1<<7)
#define LACP_PORT_NTT 0x00000001 #define LACP_PORT_NTT 0x00000001
#define LACP_PORT_MARK 0x00000002 #define LACP_PORT_MARK 0x00000002
#define LACP_PORT_PROMISC 0x00000004
#define LACP_PORT_LADDRCHANGED 0x00000008
#define LACP_PORT_ATTACHED 0x00000010
#define LACP_PORT_LARVAL 0x00000020
#define LACP_PORT_DETACHING 0x00000040
#define LACP_STATE_BITS \ #define LACP_STATE_BITS \
"\020" \ "\020" \
@ -132,9 +127,9 @@ struct lacp_portid {
} __packed; } __packed;
struct lacp_peerinfo { struct lacp_peerinfo {
struct lacp_systemid lip_systemid; struct lacp_systemid lip_systemid;
uint16_t lip_key; uint16_t lip_key;
struct lacp_portid lip_portid; struct lacp_portid lip_portid;
uint8_t lip_state; uint8_t lip_state;
uint8_t lip_resv[3]; uint8_t lip_resv[3];
} __packed; } __packed;
@ -228,11 +223,11 @@ struct lacp_aggregator {
TAILQ_HEAD(, lacp_port) la_ports; /* distributing ports */ TAILQ_HEAD(, lacp_port) la_ports; /* distributing ports */
struct lacp_peerinfo la_partner; struct lacp_peerinfo la_partner;
struct lacp_peerinfo la_actor; struct lacp_peerinfo la_actor;
int la_pending; /* number of ports which is waiting wait_while */ int la_pending; /* number of ports in wait_while */
}; };
struct lacp_softc { struct lacp_softc {
struct lagg_softc *lsc_lagg; struct lagg_softc *lsc_softc;
struct lacp_aggregator *lsc_active_aggregator; struct lacp_aggregator *lsc_active_aggregator;
TAILQ_HEAD(, lacp_aggregator) lsc_aggregators; TAILQ_HEAD(, lacp_aggregator) lsc_aggregators;
boolean_t lsc_suppress_distributing; boolean_t lsc_suppress_distributing;
@ -257,11 +252,6 @@ struct lacp_softc {
#define LACP_AGGREGATE_WAIT_TIME (2) #define LACP_AGGREGATE_WAIT_TIME (2)
#define LACP_TRANSIT_DELAY 3000 /* in msec */ #define LACP_TRANSIT_DELAY 3000 /* in msec */
/*
int tlv_check(const void *, size_t, const struct tlvhdr *,
const struct tlv_template *, boolean_t);
*/
#define LACP_STATE_EQ(s1, s2, mask) \ #define LACP_STATE_EQ(s1, s2, mask) \
((((s1) ^ (s2)) & (mask)) == 0) ((((s1) ^ (s2)) & (mask)) == 0)

View File

@ -76,7 +76,7 @@ static struct {
}; };
SLIST_HEAD(__trhead, lagg_softc) lagg_list; /* list of laggs */ SLIST_HEAD(__trhead, lagg_softc) lagg_list; /* list of laggs */
static struct mtx lagg_list_mtx; static struct mtx lagg_list_mtx;
eventhandler_tag lagg_detach_cookie = NULL; eventhandler_tag lagg_detach_cookie = NULL;
static int lagg_clone_create(struct if_clone *, int, caddr_t); static int lagg_clone_create(struct if_clone *, int, caddr_t);
@ -331,7 +331,7 @@ lagg_capabilities(struct lagg_softc *sc)
static void static void
lagg_port_lladdr(struct lagg_port *lp, uint8_t *lladdr) lagg_port_lladdr(struct lagg_port *lp, uint8_t *lladdr)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
struct ifnet *ifp = lp->lp_ifp; struct ifnet *ifp = lp->lp_ifp;
struct lagg_llq *llq; struct lagg_llq *llq;
int pending = 0; int pending = 0;
@ -460,7 +460,7 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
ifp->if_output = lagg_port_output; ifp->if_output = lagg_port_output;
lp->lp_ifp = ifp; lp->lp_ifp = ifp;
lp->lp_lagg = sc; lp->lp_softc = sc;
/* Save port link layer address */ /* Save port link layer address */
bcopy(IF_LLADDR(ifp), lp->lp_lladdr, ETHER_ADDR_LEN); bcopy(IF_LLADDR(ifp), lp->lp_lladdr, ETHER_ADDR_LEN);
@ -487,7 +487,7 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
if (sc->sc_port_create != NULL) if (sc->sc_port_create != NULL)
error = (*sc->sc_port_create)(lp); error = (*sc->sc_port_create)(lp);
if (error) { if (error) {
/* remove the port again, without calling sc_port_destroy */ /* remove the port again, without calling sc_port_destroy */
lagg_port_destroy(lp, 0); lagg_port_destroy(lp, 0);
return (error); return (error);
} }
@ -517,7 +517,7 @@ lagg_port_checkstacking(struct lagg_softc *sc)
static int static int
lagg_port_destroy(struct lagg_port *lp, int runpd) lagg_port_destroy(struct lagg_port *lp, int runpd)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
struct lagg_port *lp_ptr; struct lagg_port *lp_ptr;
struct lagg_llq *llq; struct lagg_llq *llq;
struct ifnet *ifp = lp->lp_ifp; struct ifnet *ifp = lp->lp_ifp;
@ -598,7 +598,7 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
/* Should be checked by the caller */ /* Should be checked by the caller */
if (ifp->if_type != IFT_IEEE8023ADLAG || if (ifp->if_type != IFT_IEEE8023ADLAG ||
(lp = ifp->if_lagg) == NULL || (sc = lp->lp_lagg) == NULL) (lp = ifp->if_lagg) == NULL || (sc = lp->lp_softc) == NULL)
goto fallback; goto fallback;
switch (cmd) { switch (cmd) {
@ -610,7 +610,7 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break; break;
} }
if (lp->lp_lagg != sc) { if (lp->lp_softc != sc) {
error = ENOENT; error = ENOENT;
break; break;
} }
@ -670,7 +670,7 @@ lagg_port_ifdetach(void *arg __unused, struct ifnet *ifp)
if ((lp = ifp->if_lagg) == NULL) if ((lp = ifp->if_lagg) == NULL)
return; return;
sc = lp->lp_lagg; sc = lp->lp_softc;
LAGG_WLOCK(sc); LAGG_WLOCK(sc);
lp->lp_detaching = 1; lp->lp_detaching = 1;
@ -681,7 +681,7 @@ lagg_port_ifdetach(void *arg __unused, struct ifnet *ifp)
static void static void
lagg_port2req(struct lagg_port *lp, struct lagg_reqport *rp) lagg_port2req(struct lagg_port *lp, struct lagg_reqport *rp)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
strlcpy(rp->rp_ifname, sc->sc_ifname, sizeof(rp->rp_ifname)); strlcpy(rp->rp_ifname, sc->sc_ifname, sizeof(rp->rp_ifname));
strlcpy(rp->rp_portname, lp->lp_ifp->if_xname, sizeof(rp->rp_portname)); strlcpy(rp->rp_portname, lp->lp_ifp->if_xname, sizeof(rp->rp_portname));
rp->rp_prio = lp->lp_prio; rp->rp_prio = lp->lp_prio;
@ -828,7 +828,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
} }
if ((lp = (struct lagg_port *)tpif->if_lagg) == NULL || if ((lp = (struct lagg_port *)tpif->if_lagg) == NULL ||
lp->lp_lagg != sc) { lp->lp_softc != sc) {
error = ENOENT; error = ENOENT;
break; break;
} }
@ -857,7 +857,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
} }
if ((lp = (struct lagg_port *)tpif->if_lagg) == NULL || if ((lp = (struct lagg_port *)tpif->if_lagg) == NULL ||
lp->lp_lagg != sc) { lp->lp_softc != sc) {
error = ENOENT; error = ENOENT;
break; break;
} }
@ -930,9 +930,9 @@ lagg_ether_setmulti(struct lagg_softc *sc)
static int static int
lagg_ether_cmdmulti(struct lagg_port *lp, int set) lagg_ether_cmdmulti(struct lagg_port *lp, int set)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
struct ifnet *ifp = lp->lp_ifp; struct ifnet *ifp = lp->lp_ifp;
struct ifnet *trifp = sc->sc_ifp; struct ifnet *scifp = sc->sc_ifp;
struct lagg_mc *mc; struct lagg_mc *mc;
struct ifmultiaddr *ifma, *rifma = NULL; struct ifmultiaddr *ifma, *rifma = NULL;
struct sockaddr_dl sdl; struct sockaddr_dl sdl;
@ -948,7 +948,7 @@ lagg_ether_cmdmulti(struct lagg_port *lp, int set)
sdl.sdl_index = ifp->if_index; sdl.sdl_index = ifp->if_index;
if (set) { if (set) {
TAILQ_FOREACH(ifma, &trifp->if_multiaddrs, ifma_link) { TAILQ_FOREACH(ifma, &scifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK) if (ifma->ifma_addr->sa_family != AF_LINK)
continue; continue;
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
@ -978,14 +978,14 @@ static int
lagg_setflag(struct lagg_port *lp, int flag, int status, lagg_setflag(struct lagg_port *lp, int flag, int status,
int (*func)(struct ifnet *, int)) int (*func)(struct ifnet *, int))
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
struct ifnet *trifp = sc->sc_ifp; struct ifnet *scifp = sc->sc_ifp;
struct ifnet *ifp = lp->lp_ifp; struct ifnet *ifp = lp->lp_ifp;
int error; int error;
LAGG_WLOCK_ASSERT(sc); LAGG_WLOCK_ASSERT(sc);
status = status ? (trifp->if_flags & flag) : 0; status = status ? (scifp->if_flags & flag) : 0;
/* Now "status" contains the flag value or 0 */ /* Now "status" contains the flag value or 0 */
/* /*
@ -1016,7 +1016,7 @@ static int
lagg_setflags(struct lagg_port *lp, int status) lagg_setflags(struct lagg_port *lp, int status)
{ {
int error, i; int error, i;
for (i = 0; lagg_pflags[i].flag; i++) { for (i = 0; lagg_pflags[i].flag; i++) {
error = lagg_setflag(lp, lagg_pflags[i].flag, error = lagg_setflag(lp, lagg_pflags[i].flag,
status, lagg_pflags[i].func); status, lagg_pflags[i].func);
@ -1062,10 +1062,10 @@ static struct mbuf *
lagg_input(struct ifnet *ifp, struct mbuf *m) lagg_input(struct ifnet *ifp, struct mbuf *m)
{ {
struct lagg_port *lp = ifp->if_lagg; struct lagg_port *lp = ifp->if_lagg;
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
struct ifnet *trifp = sc->sc_ifp; struct ifnet *scifp = sc->sc_ifp;
if ((trifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || if ((scifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
(lp->lp_flags & LAGG_PORT_DISABLED) || (lp->lp_flags & LAGG_PORT_DISABLED) ||
sc->sc_proto == LAGG_PROTO_NONE) { sc->sc_proto == LAGG_PROTO_NONE) {
m_freem(m); m_freem(m);
@ -1073,13 +1073,13 @@ lagg_input(struct ifnet *ifp, struct mbuf *m)
} }
LAGG_RLOCK(sc); LAGG_RLOCK(sc);
BPF_MTAP(trifp, m); BPF_MTAP(scifp, m);
m = (*sc->sc_input)(sc, lp, m); m = (*sc->sc_input)(sc, lp, m);
if (m != NULL) { if (m != NULL) {
trifp->if_ipackets++; scifp->if_ipackets++;
trifp->if_ibytes += m->m_pkthdr.len; scifp->if_ibytes += m->m_pkthdr.len;
} }
LAGG_RUNLOCK(sc); LAGG_RUNLOCK(sc);
@ -1122,7 +1122,7 @@ lagg_port_state(struct ifnet *ifp, int state)
struct lagg_softc *sc = NULL; struct lagg_softc *sc = NULL;
if (lp != NULL) if (lp != NULL)
sc = lp->lp_lagg; sc = lp->lp_softc;
if (sc == NULL) if (sc == NULL)
return; return;
@ -1228,7 +1228,7 @@ lagg_hashmbuf(struct mbuf *m, uint32_t key)
sizeof(m->m_pkthdr.ether_vtag), p); sizeof(m->m_pkthdr.ether_vtag), p);
} else if (etype == ETHERTYPE_VLAN) { } else if (etype == ETHERTYPE_VLAN) {
vlan = lagg_gethdr(m, off, sizeof(*vlan), &vlanbuf); vlan = lagg_gethdr(m, off, sizeof(*vlan), &vlanbuf);
if (vlan == NULL) if (vlan == NULL)
goto out; goto out;
p = hash32_buf(&vlan->evl_tag, sizeof(vlan->evl_tag), p); p = hash32_buf(&vlan->evl_tag, sizeof(vlan->evl_tag), p);
@ -1305,7 +1305,7 @@ lagg_rr_detach(struct lagg_softc *sc)
static void static void
lagg_rr_port_destroy(struct lagg_port *lp) lagg_rr_port_destroy(struct lagg_port *lp)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
if (lp == (struct lagg_port *)sc->sc_psc) if (lp == (struct lagg_port *)sc->sc_psc)
sc->sc_psc = NULL; sc->sc_psc = NULL;
@ -1467,14 +1467,14 @@ lagg_lb_porttable(struct lagg_softc *sc, struct lagg_port *lp)
static int static int
lagg_lb_port_create(struct lagg_port *lp) lagg_lb_port_create(struct lagg_port *lp)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
return (lagg_lb_porttable(sc, NULL)); return (lagg_lb_porttable(sc, NULL));
} }
static void static void
lagg_lb_port_destroy(struct lagg_port *lp) lagg_lb_port_destroy(struct lagg_port *lp)
{ {
struct lagg_softc *sc = lp->lp_lagg; struct lagg_softc *sc = lp->lp_softc;
lagg_lb_porttable(sc, lp); lagg_lb_porttable(sc, lp);
} }

View File

@ -25,20 +25,19 @@
* Global definitions * Global definitions
*/ */
#define LAGG_MAX_PORTS 32 /* logically */ #define LAGG_MAX_PORTS 32 /* logically */
#define LAGG_MAX_NAMESIZE 32 /* name of a protocol */ #define LAGG_MAX_NAMESIZE 32 /* name of a protocol */
#define LAGG_MAX_STACKING 4 /* maximum number of stacked laggs */ #define LAGG_MAX_STACKING 4 /* maximum number of stacked laggs */
/* Port flags */ /* Port flags */
#define LAGG_PORT_SLAVE 0x00000000 /* normal enslaved port */ #define LAGG_PORT_SLAVE 0x00000000 /* normal enslaved port */
#define LAGG_PORT_MASTER 0x00000001 /* primary port */ #define LAGG_PORT_MASTER 0x00000001 /* primary port */
#define LAGG_PORT_STACK 0x00000002 /* stacked lagg port */ #define LAGG_PORT_STACK 0x00000002 /* stacked lagg port */
#define LAGG_PORT_ACTIVE 0x00000004 /* port is active */ #define LAGG_PORT_ACTIVE 0x00000004 /* port is active */
#define LAGG_PORT_COLLECTING 0x00000008 /* port is receiving frames */ #define LAGG_PORT_COLLECTING 0x00000008 /* port is receiving frames */
#define LAGG_PORT_DISTRIBUTING 0x00000010 /* port is sending frames */ #define LAGG_PORT_DISTRIBUTING 0x00000010 /* port is sending frames */
#define LAGG_PORT_DISABLED 0x00000020 /* port is disabled */ #define LAGG_PORT_DISABLED 0x00000020 /* port is disabled */
#define LAGG_PORT_GLOBAL 0x80000000 /* IOCTL: global flag */ #define LAGG_PORT_BITS "\20\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
#define LAGG_PORT_BITS "\20\01MASTER\02STACK\03ACTIVE\04COLLECTING" \
"\05DISTRIBUTING\06DISABLED" "\05DISTRIBUTING\06DISABLED"
/* Supported lagg PROTOs */ /* Supported lagg PROTOs */
@ -51,8 +50,8 @@
#define LAGG_PROTO_MAX 6 #define LAGG_PROTO_MAX 6
struct lagg_protos { struct lagg_protos {
const char *tpr_name; const char *lpr_name;
int tpr_proto; int lpr_proto;
}; };
#define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER #define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER
@ -78,9 +77,9 @@ struct lagg_reqport {
u_int32_t rp_flags; /* port flags */ u_int32_t rp_flags; /* port flags */
}; };
#define SIOCGLAGGPORT _IOWR('i', 140, struct lagg_reqport) #define SIOCGLAGGPORT _IOWR('i', 140, struct lagg_reqport)
#define SIOCSLAGGPORT _IOW('i', 141, struct lagg_reqport) #define SIOCSLAGGPORT _IOW('i', 141, struct lagg_reqport)
#define SIOCSLAGGDELPORT _IOW('i', 142, struct lagg_reqport) #define SIOCSLAGGDELPORT _IOW('i', 142, struct lagg_reqport)
/* lagg, ports and options */ /* lagg, ports and options */
struct lagg_reqall { struct lagg_reqall {
@ -92,25 +91,23 @@ struct lagg_reqall {
int ra_ports; /* total port count */ int ra_ports; /* total port count */
}; };
#define SIOCGLAGG _IOWR('i', 143, struct lagg_reqall) #define SIOCGLAGG _IOWR('i', 143, struct lagg_reqall)
#define SIOCSLAGG _IOW('i', 144, struct lagg_reqall) #define SIOCSLAGG _IOW('i', 144, struct lagg_reqall)
#ifdef _KERNEL #ifdef _KERNEL
/* /*
* Internal kernel part * Internal kernel part
*/ */
#define lp_ifname lp_ifp->if_xname /* interface name */ #define lp_ifname lp_ifp->if_xname /* interface name */
#define lp_link_state lp_ifp->if_link_state /* link state */ #define lp_link_state lp_ifp->if_link_state /* link state */
#define lp_capabilities lp_ifp->if_capabilities /* capabilities */ #define lp_capabilities lp_ifp->if_capabilities /* capabilities */
#define LAGG_PORTACTIVE(_tp) ( \ #define LAGG_PORTACTIVE(_tp) ( \
((_tp)->lp_link_state == LINK_STATE_UP) && \ ((_tp)->lp_link_state == LINK_STATE_UP) && \
((_tp)->lp_ifp->if_flags & IFF_UP) \ ((_tp)->lp_ifp->if_flags & IFF_UP) \
) )
#define mc_enm mc_u.mcu_enm
struct lagg_ifreq { struct lagg_ifreq {
union { union {
struct ifreq ifreq; struct ifreq ifreq;
@ -121,15 +118,14 @@ struct lagg_ifreq {
} ifreq; } ifreq;
}; };
#define sc_ifflags sc_ifp->if_flags /* flags */ #define sc_ifflags sc_ifp->if_flags /* flags */
#define sc_ifname sc_ifp->if_xname /* name */ #define sc_ifname sc_ifp->if_xname /* name */
#define sc_capabilities sc_ifp->if_capabilities /* capabilities */ #define sc_capabilities sc_ifp->if_capabilities /* capabilities */
#define IFCAP_LAGG_MASK 0xffff0000 /* private capabilities */ #define IFCAP_LAGG_MASK 0xffff0000 /* private capabilities */
#define IFCAP_LAGG_FULLDUPLEX 0x00010000 /* full duplex with >1 ports */ #define IFCAP_LAGG_FULLDUPLEX 0x00010000 /* full duplex with >1 ports */
/* Private data used by the loadbalancing protocol */ /* Private data used by the loadbalancing protocol */
#define LAGG_LB_MAXKEYS 8
struct lagg_lb { struct lagg_lb {
u_int32_t lb_key; u_int32_t lb_key;
struct lagg_port *lb_ports[LAGG_MAX_PORTS]; struct lagg_port *lb_ports[LAGG_MAX_PORTS];
@ -178,7 +174,7 @@ struct lagg_softc {
struct lagg_port { struct lagg_port {
struct ifnet *lp_ifp; /* physical interface */ struct ifnet *lp_ifp; /* physical interface */
struct lagg_softc *lp_lagg; /* parent lagg */ struct lagg_softc *lp_softc; /* parent lagg */
uint8_t lp_lladdr[ETHER_ADDR_LEN]; uint8_t lp_lladdr[ETHER_ADDR_LEN];
u_char lp_iftype; /* interface type */ u_char lp_iftype; /* interface type */
@ -199,14 +195,14 @@ struct lagg_port {
SLIST_ENTRY(lagg_port) lp_entries; SLIST_ENTRY(lagg_port) lp_entries;
}; };
#define LAGG_LOCK_INIT(_sc) rw_init(&(_sc)->sc_mtx, "if_lagg rwlock") #define LAGG_LOCK_INIT(_sc) rw_init(&(_sc)->sc_mtx, "if_lagg rwlock")
#define LAGG_LOCK_DESTROY(_sc) rw_destroy(&(_sc)->sc_mtx) #define LAGG_LOCK_DESTROY(_sc) rw_destroy(&(_sc)->sc_mtx)
#define LAGG_RLOCK(_sc) rw_rlock(&(_sc)->sc_mtx) #define LAGG_RLOCK(_sc) rw_rlock(&(_sc)->sc_mtx)
#define LAGG_WLOCK(_sc) rw_wlock(&(_sc)->sc_mtx) #define LAGG_WLOCK(_sc) rw_wlock(&(_sc)->sc_mtx)
#define LAGG_RUNLOCK(_sc) rw_runlock(&(_sc)->sc_mtx) #define LAGG_RUNLOCK(_sc) rw_runlock(&(_sc)->sc_mtx)
#define LAGG_WUNLOCK(_sc) rw_wunlock(&(_sc)->sc_mtx) #define LAGG_WUNLOCK(_sc) rw_wunlock(&(_sc)->sc_mtx)
#define LAGG_RLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_RLOCKED) #define LAGG_RLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_RLOCKED)
#define LAGG_WLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_WLOCKED) #define LAGG_WLOCK_ASSERT(_sc) rw_assert(&(_sc)->sc_mtx, RA_WLOCKED)
extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *); extern struct mbuf *(*lagg_input_p)(struct ifnet *, struct mbuf *);
extern void (*lagg_linkstate_p)(struct ifnet *, int ); extern void (*lagg_linkstate_p)(struct ifnet *, int );