diff options
| author | Oleg Bulyzhin <oleg@FreeBSD.org> | 2010-12-27 18:55:16 +0000 |
|---|---|---|
| committer | Oleg Bulyzhin <oleg@FreeBSD.org> | 2010-12-27 18:55:16 +0000 |
| commit | 127e3f3f482b6564c05ab6db22e7de7ce35eef14 (patch) | |
| tree | e0002f1463bdc626e52ffda53c2d6aba498dc9d9 /sys | |
| parent | 83a7e8d5f174d1df0cd0b797270b8162c6ace0d3 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/net/if_lagg.c | 57 | ||||
| -rw-r--r-- | sys/net/if_lagg.h | 4 |
2 files changed, 61 insertions, 0 deletions
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 1abcf08da0ef..c00c4193c25d 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/rwlock.h> #include <sys/taskqueue.h> +#include <sys/eventhandler.h> #include <net/ethernet.h> #include <net/if.h> @@ -204,6 +205,50 @@ static moduledata_t lagg_mod = { DECLARE_MODULE(if_lagg, lagg_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); +#if __FreeBSD_version >= 800000 +/* + * This routine is run via an vlan + * config EVENT + */ +static void +lagg_register_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag) +{ + struct lagg_softc *sc = ifp->if_softc; + struct lagg_port *lp; + + if (ifp->if_softc != arg) /* Not our event */ + return; + + LAGG_RLOCK(sc); + if (!SLIST_EMPTY(&sc->sc_ports)) { + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) + EVENTHANDLER_INVOKE(vlan_config, lp->lp_ifp, vtag); + } + LAGG_RUNLOCK(sc); +} + +/* + * This routine is run via an vlan + * unconfig EVENT + */ +static void +lagg_unregister_vlan(void *arg, struct ifnet *ifp, u_int16_t vtag) +{ + struct lagg_softc *sc = ifp->if_softc; + struct lagg_port *lp; + + if (ifp->if_softc != arg) /* Not our event */ + return; + + LAGG_RLOCK(sc); + if (!SLIST_EMPTY(&sc->sc_ports)) { + SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) + EVENTHANDLER_INVOKE(vlan_unconfig, lp->lp_ifp, vtag); + } + LAGG_RUNLOCK(sc); +} +#endif + static int lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) { @@ -259,6 +304,13 @@ lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) */ ether_ifattach(ifp, eaddr); +#if __FreeBSD_version >= 800000 + sc->vlan_attach = EVENTHANDLER_REGISTER(vlan_config, + lagg_register_vlan, sc, EVENTHANDLER_PRI_FIRST); + sc->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, + lagg_unregister_vlan, sc, EVENTHANDLER_PRI_FIRST); +#endif + /* Insert into the global list of laggs */ mtx_lock(&lagg_list_mtx); SLIST_INSERT_HEAD(&lagg_list, sc, sc_entries); @@ -278,6 +330,11 @@ lagg_clone_destroy(struct ifnet *ifp) lagg_stop(sc); ifp->if_flags &= ~IFF_UP; +#if __FreeBSD_version >= 800000 + EVENTHANDLER_DEREGISTER(vlan_config, sc->vlan_attach); + EVENTHANDLER_DEREGISTER(vlan_unconfig, sc->vlan_detach); +#endif + /* Shutdown and remove lagg ports */ while ((lp = SLIST_FIRST(&sc->sc_ports)) != NULL) lagg_port_destroy(lp, 1); diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index 896f5b310801..0034c61799b1 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -198,6 +198,10 @@ struct lagg_softc { void (*sc_lladdr)(struct lagg_softc *); void (*sc_req)(struct lagg_softc *, caddr_t); void (*sc_portreq)(struct lagg_port *, caddr_t); +#if __FreeBSD_version >= 800000 + eventhandler_tag vlan_attach; + eventhandler_tag vlan_detach; +#endif }; struct lagg_port { |
