svn commit: r192313 - in head/sys: net sys

Sam Leffler sam at FreeBSD.org
Mon May 18 17:18:41 UTC 2009


Author: sam
Date: Mon May 18 17:18:40 2009
New Revision: 192313
URL: http://svn.freebsd.org/changeset/base/192313

Log:
  add bpf_track eventhandler for monitoring bpf taps attached/detached
  
  Reviewed by:	csjp

Modified:
  head/sys/net/bpf.c
  head/sys/sys/eventhandler.h

Modified: head/sys/net/bpf.c
==============================================================================
--- head/sys/net/bpf.c	Mon May 18 17:14:48 2009	(r192312)
+++ head/sys/net/bpf.c	Mon May 18 17:18:40 2009	(r192313)
@@ -534,6 +534,8 @@ bpf_attachd(struct bpf_d *d, struct bpf_
 
 	bpf_bpfd_cnt++;
 	BPFIF_UNLOCK(bp);
+
+	EVENTHANDLER_INVOKE(bpf_track, bp->bif_ifp, 1);
 }
 
 /*
@@ -561,6 +563,8 @@ bpf_detachd(struct bpf_d *d)
 	BPFD_UNLOCK(d);
 	BPFIF_UNLOCK(bp);
 
+	EVENTHANDLER_INVOKE(bpf_track, ifp, 0);
+
 	/*
 	 * Check if this descriptor had requested promiscuous mode.
 	 * If so, turn it off.

Modified: head/sys/sys/eventhandler.h
==============================================================================
--- head/sys/sys/eventhandler.h	Mon May 18 17:14:48 2009	(r192312)
+++ head/sys/sys/eventhandler.h	Mon May 18 17:18:40 2009	(r192313)
@@ -182,6 +182,11 @@ typedef void (*vlan_unconfig_fn)(void *,
 EVENTHANDLER_DECLARE(vlan_config, vlan_config_fn);
 EVENTHANDLER_DECLARE(vlan_unconfig, vlan_unconfig_fn);
 
+/* BPF attach/detach events */
+struct ifnet;
+typedef void (*bpf_track_fn)(void *, struct ifnet *, int /* 1 =>'s attach */);
+EVENTHANDLER_DECLARE(bpf_track, bpf_track_fn);
+
 /*
  * Process events
  * process_fork and exit handlers are called without Giant.


More information about the svn-src-head mailing list