summaryrefslogtreecommitdiff
path: root/sys/net/trunklacp.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2009-09-09 15:01:19 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2009-09-09 15:01:19 +0000
commit6a766b54611bf2f9582e9e7119ef33e3532d85e6 (patch)
treea1abdc401d852b992c13f4ac90017d5bc3b512d2 /sys/net/trunklacp.c
parentcb686eb47fc128abf85877b7d85d88f23f43b5f4 (diff)
remove inline functions and move some code from the trunk_lacp_input()
API function directly to lacp_input() to simplify the code path. ok mpf@
Diffstat (limited to 'sys/net/trunklacp.c')
-rw-r--r--sys/net/trunklacp.c80
1 files changed, 42 insertions, 38 deletions
diff --git a/sys/net/trunklacp.c b/sys/net/trunklacp.c
index 070da9ca59b..ee17b2972fa 100644
--- a/sys/net/trunklacp.c
+++ b/sys/net/trunklacp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trunklacp.c,v 1.10 2009/07/31 09:21:13 blambert Exp $ */
+/* $OpenBSD: trunklacp.c,v 1.11 2009/09/09 15:01:18 reyk Exp $ */
/* $NetBSD: ieee8023ad_lacp.c,v 1.3 2005/12/11 12:24:54 christos Exp $ */
/* $FreeBSD:ieee8023ad_lacp.c,v 1.15 2008/03/16 19:25:30 thompsa Exp $ */
@@ -224,16 +224,18 @@ struct mbuf *
lacp_input(struct trunk_port *tp, struct ether_header *eh, struct mbuf *m)
{
struct lacp_port *lp = LACP_PORT(tp);
+ struct lacp_softc *lsc = lp->lp_lsc;
+ struct lacp_aggregator *la = lp->lp_aggregator;
u_int8_t subtype;
- if (m->m_pkthdr.len < sizeof(subtype)) {
- m_freem(m);
- return (NULL);
- }
- subtype = *mtod(m, u_int8_t *);
+ if (ntohs(eh->ether_type) == ETHERTYPE_SLOW) {
+ if (m->m_pkthdr.len < sizeof(subtype)) {
+ m_freem(m);
+ return (NULL);
+ }
+ subtype = *mtod(m, u_int8_t *);
- switch (subtype) {
- /* FALLTHROUGH */
+ switch (subtype) {
case SLOWPROTOCOLS_SUBTYPE_LACP:
lacp_pdu_input(lp, eh, m);
return (NULL);
@@ -241,6 +243,18 @@ lacp_input(struct trunk_port *tp, struct ether_header *eh, struct mbuf *m)
case SLOWPROTOCOLS_SUBTYPE_MARKER:
lacp_marker_input(lp, eh, m);
return (NULL);
+ }
+ }
+
+ /*
+ * If the port is not collecting or not in the active aggregator then
+ * free and return.
+ */
+ /* This port is joined to the active aggregator */
+ if ((lp->lp_state & LACP_STATE_COLLECTING) == 0 ||
+ la == NULL || la != lsc->lsc_active_aggregator) {
+ m_freem(m);
+ return (NULL);
}
/* Not a subtype we are interested in */
@@ -303,36 +317,6 @@ bad:
return (EINVAL);
}
-__inline int
-lacp_isactive(struct trunk_port *lgp)
-{
- struct lacp_port *lp = LACP_PORT(lgp);
- struct lacp_softc *lsc = lp->lp_lsc;
- struct lacp_aggregator *la = lp->lp_aggregator;
-
- /* This port is joined to the active aggregator */
- if (la != NULL && la == lsc->lsc_active_aggregator)
- return (1);
-
- return (0);
-}
-
-__inline int
-lacp_iscollecting(struct trunk_port *lgp)
-{
- struct lacp_port *lp = LACP_PORT(lgp);
-
- return ((lp->lp_state & LACP_STATE_COLLECTING) != 0);
-}
-
-__inline int
-lacp_isdistributing(struct trunk_port *lgp)
-{
- struct lacp_port *lp = LACP_PORT(lgp);
-
- return ((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0);
-}
-
void
lacp_fill_actorinfo(struct lacp_port *lp, struct lacp_peerinfo *info)
{
@@ -600,6 +584,26 @@ lacp_req(struct trunk_softc *sc, caddr_t data)
}
}
+u_int
+lacp_port_status(struct trunk_port *lgp)
+{
+ struct lacp_port *lp = LACP_PORT(lgp);
+ struct lacp_softc *lsc = lp->lp_lsc;
+ struct lacp_aggregator *la = lp->lp_aggregator;
+ u_int flags = 0;
+
+ /* This port is joined to the active aggregator */
+ if (la != NULL && la == lsc->lsc_active_aggregator)
+ flags |= TRUNK_PORT_ACTIVE;
+
+ if (lp->lp_state & LACP_STATE_COLLECTING)
+ flags |= TRUNK_PORT_COLLECTING;
+ if (lp->lp_state & LACP_STATE_DISTRIBUTING)
+ flags |= TRUNK_PORT_DISTRIBUTING;
+
+ return (flags);
+}
+
void
lacp_portreq(struct trunk_port *tp, caddr_t data)
{