From 8a8777f1d2c5b2285910763e5c0ad51efbf11f18 Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 9 Jun 2015 14:50:14 +0000 Subject: [PATCH] Convert trunk(4) to if_input(). ok dlg@ --- sys/net/if_trunk.c | 28 +++++++++------------------- sys/net/trunklacp.c | 7 ++++++- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index 99880efb888..32d23f258c5 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.100 2015/05/26 11:39:07 mpi Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.101 2015/06/09 14:50:14 mpi Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter @@ -16,9 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "bpfilter.h" -#include "trunk.h" - #include #include #include @@ -35,9 +32,6 @@ #include #include #include -#if NBPFILTER > 0 -#include -#endif #include #include @@ -51,6 +45,10 @@ #include #include +#include "bpfilter.h" +#if NBPFILTER > 0 +#include +#endif SLIST_HEAD(__trhead, trunk_softc) trunk_list; /* list of trunks */ @@ -1087,6 +1085,7 @@ trunk_input(struct mbuf *m) struct trunk_port *tp; struct ifnet *trifp = NULL; struct ether_header *eh; + struct mbuf_list ml = MBUF_LIST_INITIALIZER(); int error; ifp = m->m_pkthdr.rcvif; @@ -1113,11 +1112,6 @@ trunk_input(struct mbuf *m) goto bad; } -#if NBPFILTER > 0 - if (trifp->if_bpf && tr->tr_proto != TRUNK_PROTO_FAILOVER) - bpf_mtap_ether(trifp->if_bpf, m, BPF_DIRECTION_IN); -#endif - if ((*tr->tr_input)(tr, tp, m)) { /* * We stop here if the packet has been consumed @@ -1127,9 +1121,10 @@ trunk_input(struct mbuf *m) return (1); } + ml_enqueue(&ml, m); + if_input(trifp, &ml); trifp->if_ipackets++; - m->m_pkthdr.rcvif = trifp; - return (0); + return (1); bad: if (trifp != NULL) @@ -1363,7 +1358,6 @@ trunk_fail_start(struct trunk_softc *tr, struct mbuf *m) int trunk_fail_input(struct trunk_softc *tr, struct trunk_port *tp, struct mbuf *m) { - struct ifnet *ifp = &tr->tr_ac.ac_if; struct trunk_port *tmp_tp; int accept = 0; @@ -1380,10 +1374,6 @@ trunk_fail_input(struct trunk_softc *tr, struct trunk_port *tp, struct mbuf *m) } if (!accept) return (-1); -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif return (0); } diff --git a/sys/net/trunklacp.c b/sys/net/trunklacp.c index 6e707d54dad..da9280a953d 100644 --- a/sys/net/trunklacp.c +++ b/sys/net/trunklacp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trunklacp.c,v 1.21 2015/05/15 10:15:13 mpi Exp $ */ +/* $OpenBSD: trunklacp.c,v 1.22 2015/06/09 14:50:14 mpi 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 $ */ @@ -229,6 +229,11 @@ lacp_input(struct trunk_port *tp, struct mbuf *m) eh = mtod(m, struct ether_header *); if (ntohs(eh->ether_type) == ETHERTYPE_SLOW) { +#if NBPFILTER > 0 + if (ifp->if_bpf) + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); +#endif + if (m->m_pkthdr.len < (sizeof(*eh) + sizeof(subtype))) return (-1); -- 2.20.1