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 of Technology, 8 * made possible in part by grants from the FreeBSD Foundation and Cisco --- 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 251752 2013-06-14 18:11:21Z 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> --- 215 unchanged lines hidden (view full) --- 262 refcount_init(&tmphhh->hhh_refcount, 1); 263 *hhh = tmphhh; 264 } else 265 refcount_init(&tmphhh->hhh_refcount, 0); 266 267 HHHLIST_LOCK(); 268 if (flags & HHOOK_HEADISINVNET) { 269 tmphhh->hhh_flags |= HHH_ISINVNET; |
270#ifdef VIMAGE |
271 KASSERT(curvnet != NULL, ("curvnet is NULL")); 272 tmphhh->hhh_vid = (uintptr_t)curvnet; 273 LIST_INSERT_HEAD(&V_hhook_vhead_list, tmphhh, hhh_vnext); |
274#endif |
275 } 276 LIST_INSERT_HEAD(&hhook_head_list, tmphhh, hhh_next); 277 HHHLIST_UNLOCK(); 278 279 return (0); 280} 281 282static void 283hhook_head_destroy(struct hhook_head *hhh) 284{ 285 struct hhook *tmp, *tmp2; 286 287 HHHLIST_LOCK_ASSERT(); 288 289 LIST_REMOVE(hhh, hhh_next); |
290#ifdef VIMAGE |
291 if (hhook_head_is_virtualised(hhh) == HHOOK_HEADISINVNET) 292 LIST_REMOVE(hhh, hhh_vnext); |
293#endif |
294 HHH_WLOCK(hhh); 295 STAILQ_FOREACH_SAFE(tmp, &hhh->hhh_hooks, hhk_next, tmp2) 296 free(tmp, M_HHOOK); 297 HHH_WUNLOCK(hhh); 298 HHH_LOCK_DESTROY(hhh); 299 free(hhh, M_HHOOK); 300} 301 --- 44 unchanged lines hidden (view full) --- 346struct hhook_head * 347hhook_head_get(int32_t hhook_type, int32_t hhook_id) 348{ 349 struct hhook_head *hhh; 350 351 HHHLIST_LOCK(); 352 LIST_FOREACH(hhh, &hhook_head_list, hhh_next) { 353 if (hhh->hhh_type == hhook_type && hhh->hhh_id == hhook_id) { |
354#ifdef VIMAGE |
355 if (hhook_head_is_virtualised(hhh) == 356 HHOOK_HEADISINVNET) { 357 KASSERT(curvnet != NULL, ("curvnet is NULL")); 358 if (hhh->hhh_vid != (uintptr_t)curvnet) 359 continue; 360 } |
361#endif |
362 refcount_acquire(&hhh->hhh_refcount); 363 break; 364 } 365 } 366 HHHLIST_UNLOCK(); 367 368 return (hhh); 369} --- 92 unchanged lines hidden --- |