Lines 138-143
Link Here
|
138 |
static MALLOC_DEFINE(M_VLAN, VLANNAME, "802.1Q Virtual LAN Interface"); |
138 |
static MALLOC_DEFINE(M_VLAN, VLANNAME, "802.1Q Virtual LAN Interface"); |
139 |
|
139 |
|
140 |
static eventhandler_tag ifdetach_tag; |
140 |
static eventhandler_tag ifdetach_tag; |
|
|
141 |
static eventhandler_tag iflladdr_tag; |
141 |
|
142 |
|
142 |
/* |
143 |
/* |
143 |
* We have a global mutex, that is used to serialize configuration |
144 |
* We have a global mutex, that is used to serialize configuration |
Lines 199-204
Link Here
|
199 |
static int vlan_clone_destroy(struct if_clone *, struct ifnet *); |
200 |
static int vlan_clone_destroy(struct if_clone *, struct ifnet *); |
200 |
|
201 |
|
201 |
static void vlan_ifdetach(void *arg, struct ifnet *ifp); |
202 |
static void vlan_ifdetach(void *arg, struct ifnet *ifp); |
|
|
203 |
static void vlan_iflladdr(void *arg, struct ifnet *ifp); |
202 |
|
204 |
|
203 |
static struct if_clone vlan_cloner = IFC_CLONE_INITIALIZER(VLANNAME, NULL, |
205 |
static struct if_clone vlan_cloner = IFC_CLONE_INITIALIZER(VLANNAME, NULL, |
204 |
IF_MAXUNIT, NULL, vlan_clone_match, vlan_clone_create, vlan_clone_destroy); |
206 |
IF_MAXUNIT, NULL, vlan_clone_match, vlan_clone_create, vlan_clone_destroy); |
Lines 463-468
Link Here
|
463 |
} |
465 |
} |
464 |
|
466 |
|
465 |
/* |
467 |
/* |
|
|
468 |
* A handler for parent interface link layer address changes. |
469 |
* If the parent interface link layer address is changed we |
470 |
* should also change it on all children vlans. |
471 |
*/ |
472 |
static void |
473 |
vlan_iflladdr(void *arg __unused, struct ifnet *ifp) |
474 |
{ |
475 |
struct ifvlan *ifv; |
476 |
int i; |
477 |
|
478 |
/* |
479 |
* Check if it's a trunk interface first of all |
480 |
* to avoid needless locking. |
481 |
*/ |
482 |
if (ifp->if_vlantrunk == NULL) |
483 |
return; |
484 |
|
485 |
VLAN_LOCK(); |
486 |
/* |
487 |
* OK, it's a trunk. Loop over and change all vlan's lladdrs on it. |
488 |
*/ |
489 |
#ifdef VLAN_ARRAY |
490 |
for (i = 0; i < VLAN_ARRAY_SIZE; i++) |
491 |
if ((ifv = ifp->if_vlantrunk->vlans[i])) |
492 |
if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp), ETHER_ADDR_LEN); |
493 |
#else /* VLAN_ARRAY */ |
494 |
for (i = 0; i < (1 << ifp->if_vlantrunk->hwidth); i++) |
495 |
LIST_FOREACH(ifv, &ifp->if_vlantrunk->hash[i], ifv_list) |
496 |
if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp), ETHER_ADDR_LEN); |
497 |
#endif /* VLAN_ARRAY */ |
498 |
VLAN_UNLOCK(); |
499 |
|
500 |
} |
501 |
|
502 |
/* |
466 |
* A handler for network interface departure events. |
503 |
* A handler for network interface departure events. |
467 |
* Track departure of trunks here so that we don't access invalid |
504 |
* Track departure of trunks here so that we don't access invalid |
468 |
* pointers or whatever if a trunk is ripped from under us, e.g., |
505 |
* pointers or whatever if a trunk is ripped from under us, e.g., |
Lines 537-542
Link Here
|
537 |
vlan_ifdetach, NULL, EVENTHANDLER_PRI_ANY); |
574 |
vlan_ifdetach, NULL, EVENTHANDLER_PRI_ANY); |
538 |
if (ifdetach_tag == NULL) |
575 |
if (ifdetach_tag == NULL) |
539 |
return (ENOMEM); |
576 |
return (ENOMEM); |
|
|
577 |
iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, |
578 |
vlan_iflladdr, NULL, EVENTHANDLER_PRI_ANY); |
579 |
if (iflladdr_tag == NULL) |
580 |
return (ENOMEM); |
540 |
VLAN_LOCK_INIT(); |
581 |
VLAN_LOCK_INIT(); |
541 |
vlan_input_p = vlan_input; |
582 |
vlan_input_p = vlan_input; |
542 |
vlan_link_state_p = vlan_link_state; |
583 |
vlan_link_state_p = vlan_link_state; |
Lines 555-560
Link Here
|
555 |
case MOD_UNLOAD: |
596 |
case MOD_UNLOAD: |
556 |
if_clone_detach(&vlan_cloner); |
597 |
if_clone_detach(&vlan_cloner); |
557 |
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag); |
598 |
EVENTHANDLER_DEREGISTER(ifnet_departure_event, ifdetach_tag); |
|
|
599 |
EVENTHANDLER_DEREGISTER(iflladdr_event, iflladdr_tag); |
558 |
vlan_input_p = NULL; |
600 |
vlan_input_p = NULL; |
559 |
vlan_link_state_p = NULL; |
601 |
vlan_link_state_p = NULL; |
560 |
vlan_trunk_cap_p = NULL; |
602 |
vlan_trunk_cap_p = NULL; |