From 1527ed55d1025f2ff030a673ac5e8251e76c09af Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 13 May 2015 08:16:01 +0000 Subject: [PATCH] Get rid of the last "#if NTRUNK" by overwriting trunk ports' output function. ok claudio@, reyk@ --- sys/net/if_ethersubr.c | 16 +--------------- sys/net/if_trunk.c | 23 ++++++++++++++++++++++- sys/net/if_trunk.h | 4 +++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index dd9edad20d2..4262c49e6d7 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.196 2015/05/11 08:41:43 mpi Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.197 2015/05/13 08:16:01 mpi Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -87,8 +87,6 @@ didn't get a copy, you may request one from . #include #include -#include /* required by if_trunk.h */ - #include #include #include @@ -127,11 +125,6 @@ didn't get a copy, you may request one from . #include #endif -#include "trunk.h" -#if NTRUNK > 0 -#include -#endif - #ifdef INET6 #include #include @@ -275,13 +268,6 @@ ether_output(struct ifnet *ifp0, struct mbuf *m0, struct sockaddr *dst, } #endif -#if NTRUNK > 0 - /* restrict transmission on trunk members to bpf only */ - if (ifp->if_type == IFT_IEEE8023ADLAG && - (m_tag_find(m, PACKET_TAG_DLT, NULL) == NULL)) - senderr(EBUSY); -#endif - esrc = ac->ac_enaddr; #if NCARP > 0 diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index e786b274e7d..4bdc88100c3 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.96 2015/05/11 08:41:43 mpi Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.97 2015/05/13 08:16:01 mpi Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter @@ -66,6 +66,8 @@ void trunk_port_watchdog(struct ifnet *); void trunk_port_state(void *); void trunk_port_ifdetach(void *); int trunk_port_ioctl(struct ifnet *, u_long, caddr_t); +int trunk_port_output(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); struct trunk_port *trunk_port_get(struct trunk_softc *, struct ifnet *); int trunk_port_checkstacking(struct trunk_softc *); void trunk_port2req(struct trunk_port *, struct trunk_reqport *); @@ -75,6 +77,7 @@ int trunk_ether_delmulti(struct trunk_softc *, struct ifreq *); void trunk_ether_purgemulti(struct trunk_softc *); int trunk_ether_cmdmulti(struct trunk_port *, u_long); int trunk_ioctl_allports(struct trunk_softc *, u_long, caddr_t); +int trunk_input(struct mbuf *, void *); void trunk_start(struct ifnet *); void trunk_init(struct ifnet *); void trunk_stop(struct ifnet *); @@ -362,6 +365,9 @@ trunk_port_create(struct trunk_softc *tr, struct ifnet *ifp) tp->tp_watchdog = ifp->if_watchdog; ifp->if_watchdog = trunk_port_watchdog; + tp->tp_output = ifp->if_output; + ifp->if_output = trunk_port_output; + tp->tp_if = ifp; tp->tp_trunk = tr; @@ -450,6 +456,7 @@ trunk_port_destroy(struct trunk_port *tp) ifp->if_watchdog = tp->tp_watchdog; ifp->if_ioctl = tp->tp_ioctl; + ifp->if_output = tp->tp_output; ifp->if_tp = NULL; hook_disestablish(ifp->if_linkstatehooks, tp->lh_cookie); @@ -565,6 +572,20 @@ trunk_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return (error); } +int +trunk_port_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + /* restrict transmission on trunk members to bpf only */ + if (ifp->if_type == IFT_IEEE8023ADLAG && + (m_tag_find(m, PACKET_TAG_DLT, NULL) == NULL)) { + m_freem(m); + return (EBUSY); + } + + return (ether_output(ifp, m, dst, rt)); +} + void trunk_port_ifdetach(void *arg) { diff --git a/sys/net/if_trunk.h b/sys/net/if_trunk.h index 91000813b89..b335d2360b0 100644 --- a/sys/net/if_trunk.h +++ b/sys/net/if_trunk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.h,v 1.20 2015/05/11 08:41:43 mpi Exp $ */ +/* $OpenBSD: if_trunk.h,v 1.21 2015/05/13 08:16:01 mpi Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter @@ -141,6 +141,8 @@ struct trunk_port { /* Redirected callbacks */ void (*tp_watchdog)(struct ifnet *); int (*tp_ioctl)(struct ifnet *, u_long, caddr_t); + int (*tp_output)(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); SLIST_ENTRY(trunk_port) tp_entries; }; -- 2.20.1