On 6/10/08, Jack Vogel <[EMAIL PROTECTED]> wrote:
> This is a small patch that Sam came up with for me, it will allow
> drivers to know
> when a vlan attaches.
>
> It is transparent to any code that doesn't want to change, but this
> will allow my
> drivers to finally utilize the vlan hardware filter (something Linux has had
> for
> ever but we lacked).
>
> My test group has done some basic testing of this and it is working great.
> But we wanted to give any vlan users a chance to see, ask questions, or
> whatever before its committed.
>
> Jack
>

Sigh, sorry, here's the actual patch :)

Jack
--- if_vlan.dist.c	2008-06-04 09:35:05.000000000 -0700
+++ if_vlan.c	2008-06-05 14:48:04.000000000 -0700
@@ -1062,6 +1062,8 @@
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 done:
 	TRUNK_UNLOCK(trunk);
+	if (error == 0)
+		EVENTHANDLER_INVOKE(vlan_config, p, ifv->ifv_tag);
 	VLAN_UNLOCK();
 
 	return (error);
@@ -1084,12 +1086,14 @@
 	struct ifvlantrunk *trunk;
 	struct vlan_mc_entry *mc;
 	struct ifvlan *ifv;
+	struct ifnet  *parent;
 	int error;
 
 	VLAN_LOCK_ASSERT();
 
 	ifv = ifp->if_softc;
 	trunk = ifv->ifv_trunk;
+	parent = PARENT(ifv);
 
 	if (trunk) {
 		struct sockaddr_dl sdl;
@@ -1153,6 +1157,8 @@
 	ifp->if_link_state = LINK_STATE_UNKNOWN;
 	ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
+	EVENTHANDLER_INVOKE(vlan_unconfig, parent, ifv->ifv_tag);
+
 	return (0);
 }
 
--- eventhandler.dist.h	2008-06-05 09:24:16.000000000 -0700
+++ eventhandler.h	2008-06-05 09:27:36.000000000 -0700
@@ -175,6 +175,13 @@
 typedef void (*mountroot_handler_t)(void *);
 EVENTHANDLER_DECLARE(mountroot, mountroot_handler_t);
 
+/* VLAN state change events */
+struct ifnet;
+typedef void (*vlan_config_fn)(void *, struct ifnet *, uint16_t);
+typedef void (*vlan_unconfig_fn)(void *, struct ifnet *, uint16_t);
+EVENTHANDLER_DECLARE(vlan_config, vlan_config_fn);
+EVENTHANDLER_DECLARE(vlan_unconfig, vlan_unconfig_fn);
+
 /*
  * Process events
  * process_fork and exit handlers are called without Giant.
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to