Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_fw_private.h
Show First 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | |||||
#define V_autoinc_step VNET(autoinc_step) | #define V_autoinc_step VNET(autoinc_step) | ||||
VNET_DECLARE(unsigned int, fw_tables_max); | VNET_DECLARE(unsigned int, fw_tables_max); | ||||
#define V_fw_tables_max VNET(fw_tables_max) | #define V_fw_tables_max VNET(fw_tables_max) | ||||
VNET_DECLARE(unsigned int, fw_tables_sets); | VNET_DECLARE(unsigned int, fw_tables_sets); | ||||
#define V_fw_tables_sets VNET(fw_tables_sets) | #define V_fw_tables_sets VNET(fw_tables_sets) | ||||
struct nat_priv; | |||||
struct tables_config; | struct tables_config; | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* | /* | ||||
* Here we have the structure representing an ipfw rule. | * Here we have the structure representing an ipfw rule. | ||||
* | * | ||||
* It starts with a general area | * It starts with a general area | ||||
* followed by an array of one or more instructions, which the code | * followed by an array of one or more instructions, which the code | ||||
Show All 36 Lines | struct ip_fw_chain { | ||||
int *idxmap; /* skipto array of rules */ | int *idxmap; /* skipto array of rules */ | ||||
void **srvstate; /* runtime service mappings */ | void **srvstate; /* runtime service mappings */ | ||||
#if defined( __linux__ ) || defined( _WIN32 ) | #if defined( __linux__ ) || defined( _WIN32 ) | ||||
spinlock_t rwmtx; | spinlock_t rwmtx; | ||||
#else | #else | ||||
struct rmlock rwmtx; | struct rmlock rwmtx; | ||||
#endif | #endif | ||||
int static_len; /* total len of static rules (v0) */ | int static_len; /* total len of static rules (v0) */ | ||||
uint32_t gencnt; /* NAT generation count */ | struct nat_priv *nat; /* nat instances */ | ||||
LIST_HEAD(nat_list, cfg_nat) nat; /* list of nat entries */ | |||||
struct ip_fw *default_rule; | struct ip_fw *default_rule; | ||||
struct tables_config *tblcfg; /* tables module data */ | struct tables_config *tblcfg; /* tables module data */ | ||||
void *ifcfg; /* interface module data */ | void *ifcfg; /* interface module data */ | ||||
int *idxmap_back; /* standby skipto array of rules */ | int *idxmap_back; /* standby skipto array of rules */ | ||||
struct namedobj_instance *srvmap; /* cfg name->number mappings */ | struct namedobj_instance *srvmap; /* cfg name->number mappings */ | ||||
#if defined( __linux__ ) || defined( _WIN32 ) | #if defined( __linux__ ) || defined( _WIN32 ) | ||||
spinlock_t uh_lock; | spinlock_t uh_lock; | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | #define IPFW_LOCK_INIT(_chain) do { \ | ||||
rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ | rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ | ||||
} while (0) | } while (0) | ||||
#define IPFW_LOCK_DESTROY(_chain) do { \ | #define IPFW_LOCK_DESTROY(_chain) do { \ | ||||
rw_destroy(&(_chain)->rwmtx); \ | rw_destroy(&(_chain)->rwmtx); \ | ||||
rw_destroy(&(_chain)->uh_lock); \ | rw_destroy(&(_chain)->uh_lock); \ | ||||
} while (0) | } while (0) | ||||
#define IPFW_LOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_LOCKED) | |||||
#define IPFW_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_RLOCKED) | #define IPFW_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_RLOCKED) | ||||
#define IPFW_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_WLOCKED) | #define IPFW_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_WLOCKED) | ||||
#define IPFW_RLOCK_TRACKER | #define IPFW_RLOCK_TRACKER | ||||
#define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx) | #define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx) | ||||
#define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx) | #define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx) | ||||
#define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx) | #define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx) | ||||
#define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx) | #define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx) | ||||
#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) | #define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) | ||||
#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) | #define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) | ||||
#else /* FreeBSD */ | #else /* FreeBSD */ | ||||
#define IPFW_LOCK_INIT(_chain) do { \ | #define IPFW_LOCK_INIT(_chain) do { \ | ||||
rm_init_flags(&(_chain)->rwmtx, "IPFW static rules", RM_RECURSE); \ | rm_init_flags(&(_chain)->rwmtx, "IPFW static rules", RM_RECURSE); \ | ||||
rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ | rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ | ||||
} while (0) | } while (0) | ||||
#define IPFW_LOCK_DESTROY(_chain) do { \ | #define IPFW_LOCK_DESTROY(_chain) do { \ | ||||
rm_destroy(&(_chain)->rwmtx); \ | rm_destroy(&(_chain)->rwmtx); \ | ||||
rw_destroy(&(_chain)->uh_lock); \ | rw_destroy(&(_chain)->uh_lock); \ | ||||
} while (0) | } while (0) | ||||
#define IPFW_LOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_LOCKED) | |||||
#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_RLOCKED) | #define IPFW_RLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_RLOCKED) | ||||
#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_WLOCKED) | #define IPFW_WLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_WLOCKED) | ||||
#define IPFW_RLOCK_TRACKER struct rm_priotracker _tracker | #define IPFW_RLOCK_TRACKER struct rm_priotracker _tracker | ||||
#define IPFW_RLOCK(p) rm_rlock(&(p)->rwmtx, &_tracker) | #define IPFW_RLOCK(p) rm_rlock(&(p)->rwmtx, &_tracker) | ||||
#define IPFW_RUNLOCK(p) rm_runlock(&(p)->rwmtx, &_tracker) | #define IPFW_RUNLOCK(p) rm_runlock(&(p)->rwmtx, &_tracker) | ||||
#define IPFW_WLOCK(p) rm_wlock(&(p)->rwmtx) | #define IPFW_WLOCK(p) rm_wlock(&(p)->rwmtx) | ||||
#define IPFW_WUNLOCK(p) rm_wunlock(&(p)->rwmtx) | #define IPFW_WUNLOCK(p) rm_wunlock(&(p)->rwmtx) | ||||
#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) | #define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) | ||||
#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) | #define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) | ||||
#endif | #endif | ||||
#define IPFW_UH_LOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_LOCKED) | |||||
#define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED) | #define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED) | ||||
#define IPFW_UH_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_WLOCKED) | #define IPFW_UH_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_WLOCKED) | ||||
#define IPFW_UH_UNLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_UNLOCKED) | #define IPFW_UH_UNLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_UNLOCKED) | ||||
#define IPFW_UH_RLOCK(p) rw_rlock(&(p)->uh_lock) | #define IPFW_UH_RLOCK(p) rw_rlock(&(p)->uh_lock) | ||||
#define IPFW_UH_RUNLOCK(p) rw_runlock(&(p)->uh_lock) | #define IPFW_UH_RUNLOCK(p) rw_runlock(&(p)->uh_lock) | ||||
#define IPFW_UH_WLOCK(p) rw_wlock(&(p)->uh_lock) | #define IPFW_UH_WLOCK(p) rw_wlock(&(p)->uh_lock) | ||||
#define IPFW_UH_WUNLOCK(p) rw_wunlock(&(p)->uh_lock) | #define IPFW_UH_WUNLOCK(p) rw_wunlock(&(p)->uh_lock) | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | |||||
void ipfw_unref_table(struct ip_fw_chain *ch, uint16_t kidx); | void ipfw_unref_table(struct ip_fw_chain *ch, uint16_t kidx); | ||||
int ipfw_init_tables(struct ip_fw_chain *ch, int first); | int ipfw_init_tables(struct ip_fw_chain *ch, int first); | ||||
int ipfw_resize_tables(struct ip_fw_chain *ch, unsigned int ntables); | int ipfw_resize_tables(struct ip_fw_chain *ch, unsigned int ntables); | ||||
int ipfw_switch_tables_namespace(struct ip_fw_chain *ch, unsigned int nsets); | int ipfw_switch_tables_namespace(struct ip_fw_chain *ch, unsigned int nsets); | ||||
void ipfw_destroy_tables(struct ip_fw_chain *ch, int last); | void ipfw_destroy_tables(struct ip_fw_chain *ch, int last); | ||||
/* In ip_fw_nat.c -- XXX to be moved to ip_var.h */ | /* In ip_fw_nat.c -- XXX to be moved to ip_var.h */ | ||||
extern struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int); | extern struct cfg_nat *(*lookup_nat_ptr)(struct nat_priv *, uint16_t); | ||||
typedef int ipfw_nat_t(struct ip_fw_args *, struct cfg_nat *, struct mbuf *); | typedef int ipfw_nat_t(struct ip_fw_args *, struct cfg_nat *, struct mbuf *); | ||||
typedef int ipfw_nat_cfg_t(struct sockopt *); | typedef int ipfw_nat_cfg_t(struct sockopt *); | ||||
VNET_DECLARE(int, ipfw_nat_ready); | VNET_DECLARE(int, ipfw_nat_ready); | ||||
#define V_ipfw_nat_ready VNET(ipfw_nat_ready) | #define V_ipfw_nat_ready VNET(ipfw_nat_ready) | ||||
#define IPFW_NAT_LOADED (V_ipfw_nat_ready) | #define IPFW_NAT_LOADED (V_ipfw_nat_ready) | ||||
Show All 25 Lines |