Index: sys/net/ieee8023ad_lacp.c =================================================================== --- sys/net/ieee8023ad_lacp.c (revision 253655) +++ sys/net/ieee8023ad_lacp.c (working copy) @@ -193,18 +193,6 @@ &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); TUNABLE_INT("net.link.lagg.lacp.debug", &lacp_debug); -/* bitmap of ports */ -static int lacp_rx_test = 0; -static int lacp_tx_test = 0; -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, rxtest, CTLFLAG_RW, &lacp_rx_test, 0, - "RXTest"); -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, txtest, CTLFLAG_RW, &lacp_tx_test, 0, - "TXTest"); - -static int lacp_strict = 1; -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, strict, CTLFLAG_RW, &lacp_strict, - 0, "Strict spec compliance"); - #define LACP_DPRINTF(a) if (lacp_debug & 0x01) { lacp_dprintf a ; } #define LACP_TRACE(a) if (lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } #define LACP_TPRINTF(a) if (lacp_debug & 0x04) { lacp_dprintf a ; } @@ -315,7 +303,7 @@ lacp_dump_lacpdu(du); } - if ((1 << lp->lp_ifp->if_dunit) & lacp_rx_test) { + if (lp->lp_lsc->lsc_debug.lsc_rx_test) { LACP_TPRINTF((lp, "Dropping RX PDU\n")); goto bad; } @@ -750,6 +738,43 @@ lsc->lsc_suppress_distributing = FALSE; } +static void +lacp_attach_sysctl(struct lacp_softc *lsc, struct sysctl_oid *p_oid) +{ + struct lagg_softc *sc = lsc->lsc_softc; + + SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(p_oid), OID_AUTO, + "lacp_strict_mode", + CTLFLAG_RW, + &lsc->lsc_strict_mode, + lsc->lsc_strict_mode, + "Enable LACP strict mode"); +} + +static void +lacp_attach_sysctl_debug(struct lacp_softc *lsc, struct sysctl_oid *p_oid) +{ + struct lagg_softc *sc = lsc->lsc_softc; + struct sysctl_oid *oid; + + /* Create a child of the parent lagg interface */ + oid = SYSCTL_ADD_NODE(&sc->ctx, SYSCTL_CHILDREN(p_oid), + OID_AUTO, "debug", CTLFLAG_RD, NULL, "DEBUG"); + + SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, + "rx_test", + CTLFLAG_RW, + &lsc->lsc_debug.lsc_rx_test, + lsc->lsc_debug.lsc_rx_test, + "Drop RX frames"); + SYSCTL_ADD_UINT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, + "tx_test", + CTLFLAG_RW, + &lsc->lsc_debug.lsc_tx_test, + lsc->lsc_debug.lsc_tx_test, + "Drop TX frames"); +} + int lacp_attach(struct lagg_softc *sc) { @@ -765,10 +790,19 @@ lsc->lsc_hashkey = arc4random(); lsc->lsc_active_aggregator = NULL; + lsc->lsc_strict_mode = 1; LACP_LOCK_INIT(lsc); TAILQ_INIT(&lsc->lsc_aggregators); LIST_INIT(&lsc->lsc_ports); + /* Create a child of the parent lagg interface */ + oid = SYSCTL_ADD_NODE(&sc->ctx, SYSCTL_CHILDREN(sc->sc_oid), + OID_AUTO, "lacp", CTLFLAG_RD, NULL, "LACP"); + + /* Attach sysctl nodes */ + lacp_attach_sysctl(lsc, oid); + lacp_attach_sysctl_debug(lsc, oid); + callout_init_mtx(&lsc->lsc_transit_callout, &lsc->lsc_mtx, 0); callout_init_mtx(&lsc->lsc_callout, &lsc->lsc_mtx, 0); @@ -1594,7 +1628,7 @@ } /* XXX Hack, still need to implement 5.4.9 para 2,3,4 */ - if (lacp_strict) + if (lp->lp_lsc->lsc_strict_mode) lp->lp_partner.lip_state |= LACP_STATE_SYNC; lacp_sm_ptx_update_timeout(lp, oldpstate); @@ -1622,7 +1656,7 @@ LACP_TRACE(lp); oldpstate = lp->lp_partner.lip_state; - if (lacp_strict) + if (lp->lp_lsc->lsc_strict_mode) lp->lp_partner = lacp_partner_admin_strict; else lp->lp_partner = lacp_partner_admin_optimistic;; @@ -1660,7 +1694,7 @@ LACP_TRACE(lp); - if (lacp_strict) + if (lp->lp_lsc->lsc_strict_mode) lacp_sm_rx_update_selected_from_peerinfo(lp, &lacp_partner_admin_strict); else @@ -1695,10 +1729,11 @@ return; } - if (((1 << lp->lp_ifp->if_dunit) & lacp_tx_test) == 0) + if (lp->lp_lsc->lsc_debug.lsc_tx_test) { + LACP_TPRINTF((lp, "Dropping TX PDU\n")); + } else { error = lacp_xmit_lacpdu(lp); - else - LACP_TPRINTF((lp, "Dropping TX PDU\n")); + } if (error == 0) { lp->lp_flags &= ~LACP_PORT_NTT; Index: sys/net/ieee8023ad_lacp.h =================================================================== --- sys/net/ieee8023ad_lacp.h (revision 253553) +++ sys/net/ieee8023ad_lacp.h (working copy) @@ -245,6 +245,11 @@ struct lacp_portmap lsc_pmap[2]; volatile u_int lsc_activemap; u_int32_t lsc_hashkey; + struct { + u_int32_t lsc_rx_test; + u_int32_t lsc_tx_test; + } lsc_debug; + u_int32_t lsc_strict_mode; }; #define LACP_TYPE_ACTORINFO 1 Index: sys/net/if_lagg.c =================================================================== --- sys/net/if_lagg.c (revision 253553) +++ sys/net/if_lagg.c (working copy) @@ -291,7 +291,8 @@ sysctl_ctx_init(&sc->ctx); snprintf(num, sizeof(num), "%u", unit); sc->use_flowid = def_use_flowid; - oid = SYSCTL_ADD_NODE(&sc->ctx, &SYSCTL_NODE_CHILDREN(_net_link, lagg), + sc->sc_oid = oid = SYSCTL_ADD_NODE(&sc->ctx, + &SYSCTL_NODE_CHILDREN(_net_link, lagg), OID_AUTO, num, CTLFLAG_RD, NULL, ""); SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "use_flowid", CTLTYPE_INT|CTLFLAG_RW, &sc->use_flowid, sc->use_flowid, Index: sys/net/if_lagg.h =================================================================== --- sys/net/if_lagg.h (revision 253553) +++ sys/net/if_lagg.h (working copy) @@ -228,6 +228,7 @@ eventhandler_tag vlan_detach; struct callout sc_callout; struct sysctl_ctx_list ctx; /* sysctl variables */ + struct sysctl_oid *sc_oid; /* sysctl tree oid */ int use_flowid; /* use M_FLOWID */ };