Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vlan.c
Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | |||||
VNET_DECLARE(int, vlan_mtag_pcp); | VNET_DECLARE(int, vlan_mtag_pcp); | ||||
#define V_vlan_mtag_pcp VNET(vlan_mtag_pcp) | #define V_vlan_mtag_pcp VNET(vlan_mtag_pcp) | ||||
static const char vlanname[] = "vlan"; | static const char vlanname[] = "vlan"; | ||||
static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN Interface"); | static MALLOC_DEFINE(M_VLAN, vlanname, "802.1Q Virtual LAN Interface"); | ||||
static eventhandler_tag ifdetach_tag; | static eventhandler_tag ifdetach_tag; | ||||
static eventhandler_tag iflladdr_tag; | static eventhandler_tag iflladdr_tag; | ||||
static eventhandler_tag ifevent_tag; | |||||
/* | /* | ||||
* if_vlan uses two module-level synchronizations primitives to allow concurrent | * if_vlan uses two module-level synchronizations primitives to allow concurrent | ||||
* modification of vlan interfaces and (mostly) allow for vlans to be destroyed | * modification of vlan interfaces and (mostly) allow for vlans to be destroyed | ||||
* while they are being used for tx/rx. To accomplish this in a way that has | * while they are being used for tx/rx. To accomplish this in a way that has | ||||
* acceptable performance and cooperation with other parts of the network stack | * acceptable performance and cooperation with other parts of the network stack | ||||
* there is a non-sleepable epoch(9) and an sx(9). | * there is a non-sleepable epoch(9) and an sx(9). | ||||
* | * | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
static struct ifnet *vlan_clone_match_ethervid(const char *, int *); | static struct ifnet *vlan_clone_match_ethervid(const char *, int *); | ||||
static int vlan_clone_match(struct if_clone *, const char *); | static int vlan_clone_match(struct if_clone *, const char *); | ||||
static int vlan_clone_create(struct if_clone *, char *, size_t, caddr_t); | static int vlan_clone_create(struct if_clone *, char *, size_t, caddr_t); | ||||
static int vlan_clone_destroy(struct if_clone *, struct ifnet *); | static int vlan_clone_destroy(struct if_clone *, struct ifnet *); | ||||
static void vlan_ifdetach(void *arg, struct ifnet *ifp); | static void vlan_ifdetach(void *arg, struct ifnet *ifp); | ||||
static void vlan_iflladdr(void *arg, struct ifnet *ifp); | static void vlan_iflladdr(void *arg, struct ifnet *ifp); | ||||
static void vlan_ifevent(void *arg, struct ifnet *ifp, int event); | |||||
static void vlan_lladdr_fn(void *arg, int pending); | static void vlan_lladdr_fn(void *arg, int pending); | ||||
static struct if_clone *vlan_cloner; | static struct if_clone *vlan_cloner; | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
VNET_DEFINE_STATIC(struct if_clone *, vlan_cloner); | VNET_DEFINE_STATIC(struct if_clone *, vlan_cloner); | ||||
#define V_vlan_cloner VNET(vlan_cloner) | #define V_vlan_cloner VNET(vlan_cloner) | ||||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | CK_SLIST_FOREACH (mc, &sc->vlan_mc_listhead, mc_entries) { | ||||
} | } | ||||
} | } | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* A handler for interface ifnet events. | |||||
*/ | |||||
static void | |||||
vlan_ifevent(void *arg __unused, struct ifnet *ifp, int event) | |||||
{ | |||||
struct epoch_tracker et; | |||||
struct ifvlan *ifv; | |||||
struct ifvlantrunk *trunk; | |||||
if (event != IFNET_EVENT_UPDATE_BAUDRATE) | |||||
return; | |||||
NET_EPOCH_ENTER(et); | |||||
trunk = ifp->if_vlantrunk; | |||||
if (trunk == NULL) { | |||||
NET_EPOCH_EXIT(et); | |||||
return; | |||||
} | |||||
TRUNK_WLOCK(trunk); | |||||
VLAN_FOREACH(ifv, trunk) { | |||||
ifv->ifv_ifp->if_baudrate = ifp->if_baudrate; | |||||
} | |||||
TRUNK_WUNLOCK(trunk); | |||||
NET_EPOCH_EXIT(et); | |||||
} | |||||
/* | |||||
* A handler for parent interface link layer address changes. | * A handler for parent interface link layer address changes. | ||||
* If the parent interface link layer address is changed we | * If the parent interface link layer address is changed we | ||||
* should also change it on all children vlans. | * should also change it on all children vlans. | ||||
*/ | */ | ||||
static void | static void | ||||
vlan_iflladdr(void *arg __unused, struct ifnet *ifp) | vlan_iflladdr(void *arg __unused, struct ifnet *ifp) | ||||
{ | { | ||||
struct epoch_tracker et; | struct epoch_tracker et; | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | case MOD_LOAD: | ||||
ifdetach_tag = EVENTHANDLER_REGISTER(ifnet_departure_event, | ifdetach_tag = EVENTHANDLER_REGISTER(ifnet_departure_event, | ||||
vlan_ifdetach, NULL, EVENTHANDLER_PRI_ANY); | vlan_ifdetach, NULL, EVENTHANDLER_PRI_ANY); | ||||
if (ifdetach_tag == NULL) | if (ifdetach_tag == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, | iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, | ||||
vlan_iflladdr, NULL, EVENTHANDLER_PRI_ANY); | vlan_iflladdr, NULL, EVENTHANDLER_PRI_ANY); | ||||
if (iflladdr_tag == NULL) | if (iflladdr_tag == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
ifevent_tag = EVENTHANDLER_REGISTER(ifnet_event, | |||||
vlan_ifevent, NULL, EVENTHANDLER_PRI_ANY); | |||||
if (ifevent_tag == NULL) | |||||
return (ENOMEM); | |||||
VLAN_LOCKING_INIT(); | VLAN_LOCKING_INIT(); | ||||
vlan_input_p = vlan_input; | vlan_input_p = vlan_input; | ||||
vlan_link_state_p = vlan_link_state; | vlan_link_state_p = vlan_link_state; | ||||
vlan_trunk_cap_p = vlan_trunk_capabilities; | vlan_trunk_cap_p = vlan_trunk_capabilities; | ||||
vlan_trunkdev_p = vlan_trunkdev; | vlan_trunkdev_p = vlan_trunkdev; | ||||
vlan_cookie_p = vlan_cookie; | vlan_cookie_p = vlan_cookie; | ||||
vlan_setcookie_p = vlan_setcookie; | vlan_setcookie_p = vlan_setcookie; | ||||
vlan_tag_p = vlan_tag; | vlan_tag_p = vlan_tag; | ||||
Show All 14 Lines | #endif | ||||
"\n"); | "\n"); | ||||
break; | break; | ||||
case MOD_UNLOAD: | case MOD_UNLOAD: | ||||
#ifndef VIMAGE | #ifndef VIMAGE | ||||
if_clone_detach(vlan_cloner); | if_clone_detach(vlan_cloner); | ||||
#endif | #endif | ||||
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag); | EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag); | ||||
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag); | EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag); | ||||
EVENTHANDLER_DEREGISTER(ifnet_event, ifevent_tag); | |||||
vlan_input_p = NULL; | vlan_input_p = NULL; | ||||
vlan_link_state_p = NULL; | vlan_link_state_p = NULL; | ||||
vlan_trunk_cap_p = NULL; | vlan_trunk_cap_p = NULL; | ||||
vlan_trunkdev_p = NULL; | vlan_trunkdev_p = NULL; | ||||
vlan_tag_p = NULL; | vlan_tag_p = NULL; | ||||
vlan_cookie_p = NULL; | vlan_cookie_p = NULL; | ||||
vlan_setcookie_p = NULL; | vlan_setcookie_p = NULL; | ||||
vlan_devat_p = NULL; | vlan_devat_p = NULL; | ||||
▲ Show 20 Lines • Show All 1,357 Lines • Show Last 20 Lines |