There's only one "#if NTRUNK" left in the tree, this diff gets rid of it
by overwriting trunk ports' if_output().

ok?

Index: net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.196
diff -u -p -r1.196 if_ethersubr.c
--- net/if_ethersubr.c  11 May 2015 08:41:43 -0000      1.196
+++ net/if_ethersubr.c  12 May 2015 11:29:20 -0000
@@ -87,8 +87,6 @@ didn't get a copy, you may request one f
 #include <sys/syslog.h>
 #include <sys/timeout.h>
 
-#include <crypto/siphash.h>    /* required by if_trunk.h */
-
 #include <net/if.h>
 #include <net/netisr.h>
 #include <net/route.h>
@@ -127,11 +125,6 @@ didn't get a copy, you may request one f
 #include <net/if_pppoe.h>
 #endif
 
-#include "trunk.h"
-#if NTRUNK > 0
-#include <net/if_trunk.h>
-#endif
-
 #ifdef INET6
 #include <netinet6/in6_var.h>
 #include <netinet6/nd6.h>
@@ -273,13 +266,6 @@ ether_output(struct ifnet *ifp0, struct 
                    ifp->if_rdomain, rtable_l2(m->m_pkthdr.ph_rtableid),
                    dst->sa_family);
        }
-#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;
Index: net/if_trunk.c
===================================================================
RCS file: /cvs/src/sys/net/if_trunk.c,v
retrieving revision 1.96
diff -u -p -r1.96 if_trunk.c
--- net/if_trunk.c      11 May 2015 08:41:43 -0000      1.96
+++ net/if_trunk.c      12 May 2015 11:28:39 -0000
@@ -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_s
 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 *);
@@ -354,6 +357,9 @@ trunk_port_create(struct trunk_softc *tr
        trunk_ifih->ifih_input = trunk_input;
        SLIST_INSERT_HEAD(&ifp->if_inputs, trunk_ifih, ifih_next);
 
+       tp->tp_output = ifp->if_output;
+       ifp->if_output = trunk_port_output;
+
        ifp->if_tp = (caddr_t)tp;
        tp->tp_ioctl = ifp->if_ioctl;
        ifp->if_ioctl = trunk_port_ioctl;
@@ -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);
@@ -563,6 +570,20 @@ trunk_port_ioctl(struct ifnet *ifp, u_lo
                error = (*tp->tp_ioctl)(ifp, cmd, 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
Index: net/if_trunk.h
===================================================================
RCS file: /cvs/src/sys/net/if_trunk.h,v
retrieving revision 1.20
diff -u -p -r1.20 if_trunk.h
--- net/if_trunk.h      11 May 2015 08:41:43 -0000      1.20
+++ net/if_trunk.h      12 May 2015 11:28:39 -0000
@@ -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;
 };

Reply via email to