summaryrefslogtreecommitdiffstats
path: root/sys/net/ieee8023ad_lacp.c
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2013-07-26 19:41:13 +0000
committeradrian <adrian@FreeBSD.org>2013-07-26 19:41:13 +0000
commit1467e47941ef8cecaa817a96faa46bdab7a79253 (patch)
tree4205f1f1657bf1688ef1232f82b3447d80685761 /sys/net/ieee8023ad_lacp.c
parentc8d343ae8b6bda9a70a4901342a1dfd1f22e5b75 (diff)
downloadFreeBSD-src-1467e47941ef8cecaa817a96faa46bdab7a79253.zip
FreeBSD-src-1467e47941ef8cecaa817a96faa46bdab7a79253.tar.gz
Break out the static, global LACP debug options into a per-lagg unit
sysctl tree. * Create a net.link.lagg.X.lacp node * Add a debug node under that for tx_test and rx_test * Add lacp_strict_mode, defaulting to 1 tx_test and rx_test are still a bitmap of unit numbers for now. At some point it would be nice to create child nodes of the lagg bundle for each sub-interface, and then populate those with various knobs and statistics. Sponsored by: Netflix
Diffstat (limited to 'sys/net/ieee8023ad_lacp.c')
-rw-r--r--sys/net/ieee8023ad_lacp.c72
1 files changed, 54 insertions, 18 deletions
diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c
index 0ba7fde..014140b 100644
--- a/sys/net/ieee8023ad_lacp.c
+++ b/sys/net/ieee8023ad_lacp.c
@@ -193,18 +193,6 @@ SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN,
&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_pdu_input(struct lacp_port *lp, struct mbuf *m)
lacp_dump_lacpdu(du);
}
- if ((1 << lp->lp_ifp->if_dunit) & lacp_rx_test) {
+ if ((1 << lp->lp_ifp->if_dunit) & lp->lp_lsc->lsc_debug.lsc_rx_test) {
LACP_TPRINTF((lp, "Dropping RX PDU\n"));
goto bad;
}
@@ -750,10 +738,48 @@ lacp_transit_expire(void *vp)
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,
+ "Bitmap of if_dunit entries to drop RX frames for");
+ 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,
+ "Bitmap of if_dunit entries to drop TX frames for");
+}
+
int
lacp_attach(struct lagg_softc *sc)
{
struct lacp_softc *lsc;
+ struct sysctl_oid *oid;
lsc = malloc(sizeof(struct lacp_softc),
M_DEVBUF, M_NOWAIT|M_ZERO);
@@ -765,10 +791,19 @@ lacp_attach(struct lagg_softc *sc)
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 +1629,7 @@ lacp_sm_rx_record_pdu(struct lacp_port *lp, const struct lacpdu *du)
}
/* 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 +1657,7 @@ lacp_sm_rx_record_default(struct lacp_port *lp)
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 +1695,7 @@ lacp_sm_rx_update_default_selected(struct lacp_port *lp)
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 +1730,11 @@ lacp_sm_tx(struct lacp_port *lp)
return;
}
- if (((1 << lp->lp_ifp->if_dunit) & lacp_tx_test) == 0)
+ if (((1 << lp->lp_ifp->if_dunit) & lp->lp_lsc->lsc_debug.lsc_tx_test) == 0) {
error = lacp_xmit_lacpdu(lp);
- else
+ } else {
LACP_TPRINTF((lp, "Dropping TX PDU\n"));
+ }
if (error == 0) {
lp->lp_flags &= ~LACP_PORT_NTT;
OpenPOWER on IntegriCloud