kern_hhook.c (216615) | kern_hhook.c (217248) |
---|---|
1/*- 2 * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> 3 * Copyright (c) 2010 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * This software was developed by Lawrence Stewart while studying at the Centre 7 * for Advanced Internet Architectures, Swinburne University, made possible in 8 * part by grants from the FreeBSD Foundation and Cisco University Research --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org> 3 * Copyright (c) 2010 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * This software was developed by Lawrence Stewart while studying at the Centre 7 * for Advanced Internet Architectures, Swinburne University, made possible in 8 * part by grants from the FreeBSD Foundation and Cisco University Research --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/kern_hhook.c 216615 2010-12-21 13:45:29Z lstewart $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_hhook.c 217248 2011-01-11 00:29:17Z lstewart $"); |
39 40#include <sys/param.h> 41#include <sys/kernel.h> 42#include <sys/hhook.h> 43#include <sys/khelp.h> 44#include <sys/malloc.h> 45#include <sys/module.h> 46#include <sys/module_khelp.h> --- 104 unchanged lines hidden (view full) --- 151 error = EEXIST; 152 break; 153 } 154 } 155 156 if (!error) { 157 STAILQ_INSERT_TAIL(&hhh->hhh_hooks, hhk, hhk_next); 158 hhh->hhh_nhooks++; | 39 40#include <sys/param.h> 41#include <sys/kernel.h> 42#include <sys/hhook.h> 43#include <sys/khelp.h> 44#include <sys/malloc.h> 45#include <sys/module.h> 46#include <sys/module_khelp.h> --- 104 unchanged lines hidden (view full) --- 151 error = EEXIST; 152 break; 153 } 154 } 155 156 if (!error) { 157 STAILQ_INSERT_TAIL(&hhh->hhh_hooks, hhk, hhk_next); 158 hhh->hhh_nhooks++; |
159 } 160 else | 159 } else |
161 free(hhk, M_HHOOK); 162 163 HHH_WUNLOCK(hhh); 164 165 return (error); 166} 167 168/* --- 158 unchanged lines hidden (view full) --- 327 * Remove a helper hook point via a hhook_head lookup. 328 */ 329int 330hhook_head_deregister_lookup(int32_t hhook_type, int32_t hhook_id) 331{ 332 struct hhook_head *hhh; 333 int error; 334 | 160 free(hhk, M_HHOOK); 161 162 HHH_WUNLOCK(hhh); 163 164 return (error); 165} 166 167/* --- 158 unchanged lines hidden (view full) --- 326 * Remove a helper hook point via a hhook_head lookup. 327 */ 328int 329hhook_head_deregister_lookup(int32_t hhook_type, int32_t hhook_id) 330{ 331 struct hhook_head *hhh; 332 int error; 333 |
335 error = 0; | |
336 hhh = hhook_head_get(hhook_type, hhook_id); 337 error = hhook_head_deregister(hhh); 338 339 if (error == EBUSY) 340 hhook_head_release(hhh); 341 342 return (error); 343} --- 7 unchanged lines hidden (view full) --- 351{ 352 struct hhook_head *hhh; 353 354 /* XXXLAS: Pick hhook_head_list based on hhook_head flags. */ 355 HHHLIST_LOCK(); 356 LIST_FOREACH(hhh, &V_hhook_head_list, hhh_next) { 357 if (hhh->hhh_type == hhook_type && hhh->hhh_id == hhook_id) { 358 refcount_acquire(&hhh->hhh_refcount); | 334 hhh = hhook_head_get(hhook_type, hhook_id); 335 error = hhook_head_deregister(hhh); 336 337 if (error == EBUSY) 338 hhook_head_release(hhh); 339 340 return (error); 341} --- 7 unchanged lines hidden (view full) --- 349{ 350 struct hhook_head *hhh; 351 352 /* XXXLAS: Pick hhook_head_list based on hhook_head flags. */ 353 HHHLIST_LOCK(); 354 LIST_FOREACH(hhh, &V_hhook_head_list, hhh_next) { 355 if (hhh->hhh_type == hhook_type && hhh->hhh_id == hhook_id) { 356 refcount_acquire(&hhh->hhh_refcount); |
359 HHHLIST_UNLOCK(); 360 return (hhh); | 357 break; |
361 } 362 } 363 HHHLIST_UNLOCK(); 364 | 358 } 359 } 360 HHHLIST_UNLOCK(); 361 |
365 return (NULL); | 362 return (hhh); |
366} 367 368void 369hhook_head_release(struct hhook_head *hhh) 370{ 371 372 refcount_release(&hhh->hhh_refcount); 373} --- 84 unchanged lines hidden --- | 363} 364 365void 366hhook_head_release(struct hhook_head *hhh) 367{ 368 369 refcount_release(&hhh->hhh_refcount); 370} --- 84 unchanged lines hidden --- |