diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-09-09 15:01:19 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-09-09 15:01:19 +0000 |
commit | 6a766b54611bf2f9582e9e7119ef33e3532d85e6 (patch) | |
tree | a1abdc401d852b992c13f4ac90017d5bc3b512d2 /sys | |
parent | cb686eb47fc128abf85877b7d85d88f23f43b5f4 (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')
-rw-r--r-- | sys/net/if_trunk.c | 29 | ||||
-rw-r--r-- | sys/net/trunklacp.c | 80 | ||||
-rw-r--r-- | sys/net/trunklacp.h | 7 |
3 files changed, 48 insertions, 68 deletions
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index a070d4fb53d..b212d6e1082 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.67 2009/07/16 22:58:45 thib Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.68 2009/09/09 15:01:18 reyk Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -609,14 +609,8 @@ trunk_port2req(struct trunk_port *tp, struct trunk_reqport *rp) break; case TRUNK_PROTO_LACP: - rp->rp_flags = 0; /* LACP has a different definition of active */ - if (lacp_isactive(tp)) - rp->rp_flags |= TRUNK_PORT_ACTIVE; - if (lacp_iscollecting(tp)) - rp->rp_flags |= TRUNK_PORT_COLLECTING; - if (lacp_isdistributing(tp)) - rp->rp_flags |= TRUNK_PORT_DISTRIBUTING; + rp->rp_flags = lacp_port_status(tp); break; default: break; @@ -1631,25 +1625,10 @@ trunk_lacp_input(struct trunk_softc *tr, struct trunk_port *tp, struct ether_header *eh, struct mbuf *m) { struct ifnet *ifp = &tr->tr_ac.ac_if; - u_short etype; - - etype = ntohs(eh->ether_type); - - /* Tap off LACP control messages */ - if (etype == ETHERTYPE_SLOW) { - m = lacp_input(tp, eh, m); - if (m == NULL) - return (-1); - } - /* - * If the port is not collecting or not in the active aggregator then - * free and return. - */ - if (lacp_iscollecting(tp) == 0 || lacp_isactive(tp) == 0) { - m_freem(m); + m = lacp_input(tp, eh, m); + if (m == NULL) return (-1); - } m->m_pkthdr.rcvif = ifp; return (0); 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) { diff --git a/sys/net/trunklacp.h b/sys/net/trunklacp.h index 19618cf1d4b..927f6c59b93 100644 --- a/sys/net/trunklacp.h +++ b/sys/net/trunklacp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: trunklacp.h,v 1.4 2008/11/08 01:00:01 mpf Exp $ */ +/* $OpenBSD: trunklacp.h,v 1.5 2009/09/09 15:01:18 reyk Exp $ */ /* $NetBSD: ieee8023ad_impl.h,v 1.2 2005/12/10 23:21:39 elad Exp $ */ /* @@ -267,10 +267,7 @@ void lacp_port_destroy(struct trunk_port *); void lacp_linkstate(struct trunk_port *); void lacp_req(struct trunk_softc *, caddr_t); void lacp_portreq(struct trunk_port *, caddr_t); - -int lacp_isactive(struct trunk_port *); -int lacp_iscollecting(struct trunk_port *); -int lacp_isdistributing(struct trunk_port *); +u_int lacp_port_status(struct trunk_port *); /* following constants don't include terminating NUL */ #define LACP_MACSTR_MAX (2*6 + 5) |