Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jun 2008 10:30:35 -0700
From:      "Jack Vogel" <jfvogel@gmail.com>
To:        "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>,  "FreeBSD Current" <freebsd-current@freebsd.org>,  "FreeBSD Stable List" <freebsd-stable@freebsd.org>,  "Sam Leffler" <sam@errno.com>
Subject:   Re: Vlan EVENT patch
Message-ID:  <2a41acea0806101030xa9f0689k663709a4595b1771@mail.gmail.com>
In-Reply-To: <2a41acea0806100951x1142edc6qc872d3810c2bd467@mail.gmail.com>
References:  <2a41acea0806100951x1142edc6qc872d3810c2bd467@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 6/10/08, Jack Vogel <jfvogel@gmail.com> 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

[-- Attachment #2 --]
--- 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.

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2a41acea0806101030xa9f0689k663709a4595b1771>