FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/hhook.h>
#include <sys/khelp.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/module_khelp.h>
#include <sys/osd.h>
#include <sys/queue.h>
#include <sys/refcount.h>
#include <sys/systm.h>
#include <net/vnet.h>
Go to the source code of this file.
Data Structures | |
struct | hhook |
Macros | |
#define | V_hhook_vhead_list VNET(hhook_vhead_list) |
#define | HHHLIST_LOCK() mtx_lock(&hhook_head_list_lock) |
#define | HHHLIST_UNLOCK() mtx_unlock(&hhook_head_list_lock) |
#define | HHHLIST_LOCK_ASSERT() mtx_assert(&hhook_head_list_lock, MA_OWNED) |
#define | HHH_LOCK_INIT(hhh) rm_init(&(hhh)->hhh_lock, "hhook_head rm lock") |
#define | HHH_LOCK_DESTROY(hhh) rm_destroy(&(hhh)->hhh_lock) |
#define | HHH_WLOCK(hhh) rm_wlock(&(hhh)->hhh_lock) |
#define | HHH_WUNLOCK(hhh) rm_wunlock(&(hhh)->hhh_lock) |
#define | HHH_RLOCK(hhh, rmpt) rm_rlock(&(hhh)->hhh_lock, (rmpt)) |
#define | HHH_RUNLOCK(hhh, rmpt) rm_runlock(&(hhh)->hhh_lock, (rmpt)) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_HHOOK, "hhook", "Helper hooks are linked off hhook_head lists") |
LIST_HEAD (hhookheadhead, hhook_head) | |
VNET_DEFINE (struct hhookheadhead, hhook_vhead_list) | |
MTX_SYSINIT (hhookheadlistlock, &hhook_head_list_lock, "hhook_head list lock", MTX_DEF) | |
static void | hhook_head_destroy (struct hhook_head *hhh) |
void | khelp_new_hhook_registered (struct hhook_head *hhh, uint32_t flags) |
void | hhook_run_hooks (struct hhook_head *hhh, void *ctx_data, struct osd *hosd) |
int | hhook_add_hook (struct hhook_head *hhh, struct hookinfo *hki, uint32_t flags) |
int | hhook_add_hook_lookup (struct hookinfo *hki, uint32_t flags) |
int | hhook_remove_hook (struct hhook_head *hhh, struct hookinfo *hki) |
int | hhook_remove_hook_lookup (struct hookinfo *hki) |
int | hhook_head_register (int32_t hhook_type, int32_t hhook_id, struct hhook_head **hhh, uint32_t flags) |
int | hhook_head_deregister (struct hhook_head *hhh) |
int | hhook_head_deregister_lookup (int32_t hhook_type, int32_t hhook_id) |
struct hhook_head * | hhook_head_get (int32_t hhook_type, int32_t hhook_id) |
void | hhook_head_release (struct hhook_head *hhh) |
uint32_t | hhook_head_is_virtualised (struct hhook_head *hhh) |
uint32_t | hhook_head_is_virtualised_lookup (int32_t hook_type, int32_t hook_id) |
static void | hhook_vnet_init (const void *unused __unused) |
static void | hhook_vnet_uninit (const void *unused __unused) |
VNET_SYSINIT (hhook_vnet_init, SI_SUB_INIT_IF, SI_ORDER_FIRST, hhook_vnet_init, NULL) | |
VNET_SYSUNINIT (hhook_vnet_uninit, SI_SUB_INIT_IF, SI_ORDER_FIRST, hhook_vnet_uninit, NULL) | |
Variables | |
struct hhookheadhead | hhook_head_list |
static struct mtx | hhook_head_list_lock |
static uint32_t | n_hhookheads |
#define HHH_LOCK_DESTROY | ( | hhh | ) | rm_destroy(&(hhh)->hhh_lock) |
Definition at line 86 of file kern_hhook.c.
#define HHH_LOCK_INIT | ( | hhh | ) | rm_init(&(hhh)->hhh_lock, "hhook_head rm lock") |
Definition at line 85 of file kern_hhook.c.
#define HHH_RLOCK | ( | hhh, | |
rmpt | |||
) | rm_rlock(&(hhh)->hhh_lock, (rmpt)) |
Definition at line 89 of file kern_hhook.c.
#define HHH_RUNLOCK | ( | hhh, | |
rmpt | |||
) | rm_runlock(&(hhh)->hhh_lock, (rmpt)) |
Definition at line 90 of file kern_hhook.c.
#define HHH_WLOCK | ( | hhh | ) | rm_wlock(&(hhh)->hhh_lock) |
Definition at line 87 of file kern_hhook.c.
#define HHH_WUNLOCK | ( | hhh | ) | rm_wunlock(&(hhh)->hhh_lock) |
Definition at line 88 of file kern_hhook.c.
#define HHHLIST_LOCK | ( | ) | mtx_lock(&hhook_head_list_lock) |
Definition at line 81 of file kern_hhook.c.
#define HHHLIST_LOCK_ASSERT | ( | ) | mtx_assert(&hhook_head_list_lock, MA_OWNED) |
Definition at line 83 of file kern_hhook.c.
#define HHHLIST_UNLOCK | ( | ) | mtx_unlock(&hhook_head_list_lock) |
Definition at line 82 of file kern_hhook.c.
#define V_hhook_vhead_list VNET(hhook_vhead_list) |
Definition at line 68 of file kern_hhook.c.
__FBSDID | ( | "$FreeBSD$" | ) |
int hhook_add_hook | ( | struct hhook_head * | hhh, |
struct hookinfo * | hki, | ||
uint32_t | flags | ||
) |
Definition at line 133 of file kern_hhook.c.
References flags, free(), HHH_WLOCK, HHH_WUNLOCK, hhook::hhk_func, hhook::hhk_helper, hhook::hhk_udata, and malloc().
Referenced by hhook_add_hook_lookup(), and khelp_new_hhook_registered().
int hhook_add_hook_lookup | ( | struct hookinfo * | hki, |
uint32_t | flags | ||
) |
Definition at line 190 of file kern_hhook.c.
References flags, free(), HHHLIST_LOCK, HHHLIST_UNLOCK, hhook_add_hook(), hhook_head_list, malloc(), and n_hhookheads.
Referenced by khelp_add_hhook().
int hhook_head_deregister | ( | struct hhook_head * | hhh | ) |
Definition at line 369 of file kern_hhook.c.
References HHHLIST_LOCK, HHHLIST_UNLOCK, and hhook_head_destroy().
Referenced by hhook_head_deregister_lookup(), and socket_hhook_deregister().
int hhook_head_deregister_lookup | ( | int32_t | hhook_type, |
int32_t | hhook_id | ||
) |
Definition at line 391 of file kern_hhook.c.
References hhook_head_deregister(), hhook_head_get(), and hhook_head_release().
|
static |
Definition at line 344 of file kern_hhook.c.
References free(), HHH_LOCK_DESTROY, HHH_WLOCK, HHH_WUNLOCK, HHHLIST_LOCK_ASSERT, hhook_head_is_virtualised(), and n_hhookheads.
Referenced by hhook_head_deregister(), and hhook_vnet_uninit().
struct hhook_head * hhook_head_get | ( | int32_t | hhook_type, |
int32_t | hhook_id | ||
) |
Definition at line 410 of file kern_hhook.c.
References HHHLIST_LOCK, HHHLIST_UNLOCK, hhook_head_is_virtualised(), and hhook_head_list.
Referenced by hhook_head_deregister_lookup(), hhook_head_is_virtualised_lookup(), and hhook_head_register().
uint32_t hhook_head_is_virtualised | ( | struct hhook_head * | hhh | ) |
Definition at line 448 of file kern_hhook.c.
Referenced by hhook_head_destroy(), hhook_head_get(), and hhook_head_is_virtualised_lookup().
uint32_t hhook_head_is_virtualised_lookup | ( | int32_t | hook_type, |
int32_t | hook_id | ||
) |
Definition at line 463 of file kern_hhook.c.
References hhook_head_get(), hhook_head_is_virtualised(), and hhook_head_release().
int hhook_head_register | ( | int32_t | hhook_type, |
int32_t | hhook_id, | ||
struct hhook_head ** | hhh, | ||
uint32_t | flags | ||
) |
Definition at line 294 of file kern_hhook.c.
References flags, HHH_LOCK_INIT, HHHLIST_LOCK, HHHLIST_UNLOCK, hhook_head_get(), hhook_head_list, hhook_head_release(), khelp_new_hhook_registered(), malloc(), n_hhookheads, and V_hhook_vhead_list.
Referenced by socket_hhook_register().
void hhook_head_release | ( | struct hhook_head * | hhh | ) |
Definition at line 435 of file kern_hhook.c.
Referenced by hhook_head_deregister_lookup(), hhook_head_is_virtualised_lookup(), and hhook_head_register().
int hhook_remove_hook | ( | struct hhook_head * | hhh, |
struct hookinfo * | hki | ||
) |
Definition at line 248 of file kern_hhook.c.
References free(), HHH_WLOCK, HHH_WUNLOCK, hhook::hhk_func, and hhook::hhk_udata.
Referenced by hhook_remove_hook_lookup().
int hhook_remove_hook_lookup | ( | struct hookinfo * | hki | ) |
Definition at line 275 of file kern_hhook.c.
References HHHLIST_LOCK, HHHLIST_UNLOCK, hhook_head_list, and hhook_remove_hook().
Referenced by khelp_deregister_helper(), and khelp_remove_hhook().
void hhook_run_hooks | ( | struct hhook_head * | hhh, |
void * | ctx_data, | ||
struct osd * | hosd | ||
) |
Definition at line 96 of file kern_hhook.c.
References HHH_RLOCK, HHH_RUNLOCK, hhook::hhk_func, hhook::hhk_helper, hhook::hhk_udata, and osd_get().
|
static |
Definition at line 483 of file kern_hhook.c.
References V_hhook_vhead_list.
|
static |
Definition at line 493 of file kern_hhook.c.
References HHHLIST_LOCK, HHHLIST_UNLOCK, hhook_head_destroy(), printf(), and V_hhook_vhead_list.
void khelp_new_hhook_registered | ( | struct hhook_head * | hhh, |
uint32_t | flags | ||
) |
Definition at line 291 of file kern_khelp.c.
References flags, hhook_add_hook(), KHELP_LIST_RLOCK, KHELP_LIST_RUNLOCK, and printf().
Referenced by hhook_head_register().
LIST_HEAD | ( | hhookheadhead | , |
hhook_head | |||
) |
|
static |
MTX_SYSINIT | ( | hhookheadlistlock | , |
& | hhook_head_list_lock, | ||
"hhook_head list lock" | , | ||
MTX_DEF | |||
) |
VNET_DEFINE | ( | struct hhookheadhead | , |
hhook_vhead_list | |||
) |
VNET_SYSINIT | ( | hhook_vnet_init | , |
SI_SUB_INIT_IF | , | ||
SI_ORDER_FIRST | , | ||
hhook_vnet_init | , | ||
NULL | |||
) |
VNET_SYSUNINIT | ( | hhook_vnet_uninit | , |
SI_SUB_INIT_IF | , | ||
SI_ORDER_FIRST | , | ||
hhook_vnet_uninit | , | ||
NULL | |||
) |
struct hhookheadhead hhook_head_list |
Definition at line 66 of file kern_hhook.c.
Referenced by hhook_add_hook_lookup(), hhook_head_get(), hhook_head_register(), and hhook_remove_hook_lookup().
|
static |
Definition at line 70 of file kern_hhook.c.
|
static |
Definition at line 75 of file kern_hhook.c.
Referenced by hhook_add_hook_lookup(), hhook_head_destroy(), and hhook_head_register().