View | Details | Raw Unified | Return to bug 142927
Collapse All | Expand All

(-)sys/net/if.c (+1 lines)
Lines 2341-2346 Link Here
2341
			return (error);
2341
			return (error);
2342
		error = if_setlladdr(ifp,
2342
		error = if_setlladdr(ifp,
2343
		    ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len);
2343
		    ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len);
2344
		EVENTHANDLER_INVOKE(iflladdr_event, ifp);
2344
		break;
2345
		break;
2345
2346
2346
	case SIOCAIFGROUP:
2347
	case SIOCAIFGROUP:
(-)sys/net/if_bridge.c (+2 lines)
Lines 915-920 Link Here
915
			    IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN);
915
			    IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN);
916
			sc->sc_ifaddr = fif;
916
			sc->sc_ifaddr = fif;
917
		}
917
		}
918
		EVENTHANDLER_INVOKE(iflladdr_event, sc->sc_ifp);
918
	}
919
	}
919
920
920
	bridge_mutecaps(sc);	/* recalcuate now this interface is removed */
921
	bridge_mutecaps(sc);	/* recalcuate now this interface is removed */
Lines 1031-1036 Link Here
1031
	    !memcmp(IF_LLADDR(sc->sc_ifp), sc->sc_defaddr, ETHER_ADDR_LEN)) {
1032
	    !memcmp(IF_LLADDR(sc->sc_ifp), sc->sc_defaddr, ETHER_ADDR_LEN)) {
1032
		bcopy(IF_LLADDR(ifs), IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN);
1033
		bcopy(IF_LLADDR(ifs), IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN);
1033
		sc->sc_ifaddr = ifs;
1034
		sc->sc_ifaddr = ifs;
1035
		EVENTHANDLER_INVOKE(iflladdr_event, sc->sc_ifp);
1034
	}
1036
	}
1035
1037
1036
	ifs->if_bridge = sc;
1038
	ifs->if_bridge = sc;
(-)sys/net/if_lagg.c (+1 lines)
Lines 303-308 Link Here
303
	/* Let the protocol know the MAC has changed */
303
	/* Let the protocol know the MAC has changed */
304
	if (sc->sc_lladdr != NULL)
304
	if (sc->sc_lladdr != NULL)
305
		(*sc->sc_lladdr)(sc);
305
		(*sc->sc_lladdr)(sc);
306
	EVENTHANDLER_INVOKE(iflladdr_event, ifp);
306
}
307
}
307
308
308
static void
309
static void
(-)sys/net/if_var.h (+3 lines)
Lines 341-346 Link Here
341
} while(0)
341
} while(0)
342
342
343
#ifdef _KERNEL
343
#ifdef _KERNEL
344
/* interface link layer address change event */
345
typedef void (*iflladdr_event_handler_t)(void *, struct ifnet *);
346
EVENTHANDLER_DECLARE(iflladdr_event, iflladdr_event_handler_t);
344
/* interface address change event */
347
/* interface address change event */
345
typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
348
typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
346
EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
349
EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
(-)sys/net/if_vlan.c (+42 lines)
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;

Return to bug 142927