Date: Fri, 26 Jul 2013 19:41:14 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253687 - head/sys/net Message-ID: <201307261941.r6QJfEMO087844@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adrian Date: Fri Jul 26 19:41:13 2013 New Revision: 253687 URL: http://svnweb.freebsd.org/changeset/base/253687 Log: 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 Modified: head/sys/net/ieee8023ad_lacp.c head/sys/net/ieee8023ad_lacp.h head/sys/net/if_lagg.c head/sys/net/if_lagg.h Modified: head/sys/net/ieee8023ad_lacp.c ============================================================================== --- head/sys/net/ieee8023ad_lacp.c Fri Jul 26 19:11:08 2013 (r253686) +++ head/sys/net/ieee8023ad_lacp.c Fri Jul 26 19:41:13 2013 (r253687) @@ -193,18 +193,6 @@ SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO &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, str 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 * } /* 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_po 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(struc 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; Modified: head/sys/net/ieee8023ad_lacp.h ============================================================================== --- head/sys/net/ieee8023ad_lacp.h Fri Jul 26 19:11:08 2013 (r253686) +++ head/sys/net/ieee8023ad_lacp.h Fri Jul 26 19:41:13 2013 (r253687) @@ -245,6 +245,11 @@ struct lacp_softc { 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 Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Fri Jul 26 19:11:08 2013 (r253686) +++ head/sys/net/if_lagg.c Fri Jul 26 19:41:13 2013 (r253687) @@ -291,7 +291,8 @@ lagg_clone_create(struct if_clone *ifc, 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, Modified: head/sys/net/if_lagg.h ============================================================================== --- head/sys/net/if_lagg.h Fri Jul 26 19:11:08 2013 (r253686) +++ head/sys/net/if_lagg.h Fri Jul 26 19:41:13 2013 (r253687) @@ -228,6 +228,7 @@ struct lagg_softc { 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 */ };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307261941.r6QJfEMO087844>