Switch ipfw to use rmlock for runtime locking.
This commit is contained in:
parent
be3cc1b567
commit
ccba94b8fc
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/priv.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -1019,6 +1020,7 @@ ipfw_chk(struct ip_fw_args *args)
|
||||
int is_ipv4 = 0;
|
||||
|
||||
int done = 0; /* flag to exit the outer loop */
|
||||
IPFW_RLOCK_TRACKER;
|
||||
|
||||
if (m->m_flags & M_SKIP_FIREWALL || (! V_ipfw_vnet_ready))
|
||||
return (IP_FW_PASS); /* accept */
|
||||
|
@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD: projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c 267384 2014-06-
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/eventhandler.h>
|
||||
|
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/lock.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
|
||||
#include <netinet/libalias/alias.h>
|
||||
#include <netinet/libalias/alias_local.h>
|
||||
@ -1085,6 +1086,7 @@ ipfw_nat_get_log(struct sockopt *sopt)
|
||||
struct cfg_nat *ptr;
|
||||
int i, size;
|
||||
struct ip_fw_chain *chain;
|
||||
IPFW_RLOCK_TRACKER;
|
||||
|
||||
chain = &V_layer3_chain;
|
||||
|
||||
|
@ -274,7 +274,7 @@ struct ip_fw_chain {
|
||||
#if defined( __linux__ ) || defined( _WIN32 )
|
||||
spinlock_t rwmtx;
|
||||
#else
|
||||
struct rwlock rwmtx;
|
||||
struct rmlock rwmtx;
|
||||
#endif
|
||||
int static_len; /* total len of static rules (v0) */
|
||||
uint32_t gencnt; /* NAT generation count */
|
||||
@ -415,6 +415,7 @@ struct ipfw_ifc {
|
||||
* so the variable and the macros must be here.
|
||||
*/
|
||||
|
||||
#if defined( __linux__ ) || defined( _WIN32 )
|
||||
#define IPFW_LOCK_INIT(_chain) do { \
|
||||
rw_init(&(_chain)->rwmtx, "IPFW static rules"); \
|
||||
rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \
|
||||
@ -428,12 +429,35 @@ struct ipfw_ifc {
|
||||
#define IPFW_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_RLOCKED)
|
||||
#define IPFW_WLOCK_ASSERT(_chain) rw_assert(&(_chain)->rwmtx, RA_WLOCKED)
|
||||
|
||||
#define IPFW_RLOCK_TRACKER
|
||||
#define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx)
|
||||
#define IPFW_RUNLOCK(p) rw_runlock(&(p)->rwmtx)
|
||||
#define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx)
|
||||
#define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx)
|
||||
#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p)
|
||||
#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p)
|
||||
#else /* FreeBSD */
|
||||
#define IPFW_LOCK_INIT(_chain) do { \
|
||||
rm_init(&(_chain)->rwmtx, "IPFW static rules"); \
|
||||
rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \
|
||||
} while (0)
|
||||
|
||||
#define IPFW_LOCK_DESTROY(_chain) do { \
|
||||
rm_destroy(&(_chain)->rwmtx); \
|
||||
rw_destroy(&(_chain)->uh_lock); \
|
||||
} while (0)
|
||||
|
||||
#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_RLOCKED)
|
||||
#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_WLOCKED)
|
||||
|
||||
#define IPFW_RLOCK_TRACKER struct rm_priotracker _tracker
|
||||
#define IPFW_RLOCK(p) rm_rlock(&(p)->rwmtx, &_tracker)
|
||||
#define IPFW_RUNLOCK(p) rm_runlock(&(p)->rwmtx, &_tracker)
|
||||
#define IPFW_WLOCK(p) rm_wlock(&(p)->rwmtx)
|
||||
#define IPFW_WUNLOCK(p) rm_wunlock(&(p)->rwmtx)
|
||||
#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p)
|
||||
#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p)
|
||||
#endif
|
||||
|
||||
#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)
|
||||
|
@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/priv.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -2686,6 +2687,7 @@ ipfw_ctl(struct sockopt *sopt)
|
||||
u_int32_t rulenum[2];
|
||||
uint32_t opt;
|
||||
struct rule_check_info ci;
|
||||
IPFW_RLOCK_TRACKER;
|
||||
|
||||
chain = &V_layer3_chain;
|
||||
error = 0;
|
||||
|
@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/queue.h>
|
||||
|
@ -45,6 +45,7 @@ __FBSDID("$FreeBSD: projects/ipfw/sys/netpfil/ipfw/ip_fw_table.c 270407 2014-08-
|
||||
#include <sys/hash.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/queue.h>
|
||||
|
Loading…
Reference in New Issue
Block a user