Remove "IPFW static rules" rmlock.
Make PFIL's lock global and use it for this purpose. This reduces the number of locks needed to acquire for each packet. Obtained from: Yandex LLC MFC after: 2 weeks Sponsored by: Yandex LLC No objection from: #network Differential Revision: https://reviews.freebsd.org/D10154
This commit is contained in:
parent
3e856909b7
commit
88d950a650
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316461
@ -61,7 +61,6 @@ LIST_HEAD(pfilheadhead, pfil_head);
|
||||
VNET_DEFINE(struct pfilheadhead, pfil_head_list);
|
||||
#define V_pfil_head_list VNET(pfil_head_list)
|
||||
VNET_DEFINE(struct rmlock, pfil_lock);
|
||||
#define V_pfil_lock VNET(pfil_lock)
|
||||
|
||||
#define PFIL_LOCK_INIT_REAL(l, t) \
|
||||
rm_init_flags(l, "PFil " t " rmlock", RM_RECURSE)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <sys/_mutex.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/rmlock.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
struct mbuf;
|
||||
struct ifnet;
|
||||
@ -94,6 +95,9 @@ struct pfil_head {
|
||||
LIST_ENTRY(pfil_head) ph_list;
|
||||
};
|
||||
|
||||
VNET_DECLARE(struct rmlock, pfil_lock);
|
||||
#define V_pfil_lock VNET(pfil_lock)
|
||||
|
||||
/* Public functions for pfil hook management by packet filters. */
|
||||
struct pfil_head *pfil_head_get(int, u_long);
|
||||
int pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *);
|
||||
|
@ -992,7 +992,6 @@ 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 */
|
||||
|
@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <net/ethernet.h> /* for ETHERTYPE_IP */
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/pfil.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/eventhandler.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/pfil.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/pfil.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip_var.h>
|
||||
|
@ -272,8 +272,6 @@ struct ip_fw_chain {
|
||||
void **srvstate; /* runtime service mappings */
|
||||
#if defined( __linux__ ) || defined( _WIN32 )
|
||||
spinlock_t rwmtx;
|
||||
#else
|
||||
struct rmlock rwmtx;
|
||||
#endif
|
||||
int static_len; /* total len of static rules (v0) */
|
||||
uint32_t gencnt; /* NAT generation count */
|
||||
@ -414,25 +412,23 @@ struct ipfw_ifc {
|
||||
#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p)
|
||||
#else /* FreeBSD */
|
||||
#define IPFW_LOCK_INIT(_chain) do { \
|
||||
rm_init_flags(&(_chain)->rwmtx, "IPFW static rules", RM_RECURSE); \
|
||||
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_ASSERT(_chain) rm_assert(&V_pfil_lock, RA_RLOCKED)
|
||||
#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&V_pfil_lock, 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)
|
||||
#define IPFW_RLOCK(p) rm_rlock(&V_pfil_lock, &_tracker)
|
||||
#define IPFW_RUNLOCK(p) rm_runlock(&V_pfil_lock, &_tracker)
|
||||
#define IPFW_WLOCK(p) rm_wlock(&V_pfil_lock)
|
||||
#define IPFW_WUNLOCK(p) rm_wunlock(&V_pfil_lock)
|
||||
#define IPFW_PF_RLOCK(p)
|
||||
#define IPFW_PF_RUNLOCK(p)
|
||||
#endif
|
||||
|
||||
#define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED)
|
||||
|
@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/fnv_hash.h>
|
||||
#include <net/if.h>
|
||||
#include <net/pfil.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
#include <vm/vm.h>
|
||||
|
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/queue.h>
|
||||
#include <net/if.h> /* ip_fw.h requires IFNAMSIZ */
|
||||
#include <net/pfil.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip_var.h> /* struct ipfw_rule_ref */
|
||||
|
@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/queue.h>
|
||||
#include <net/if.h> /* ip_fw.h requires IFNAMSIZ */
|
||||
#include <net/pfil.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip_var.h> /* struct ipfw_rule_ref */
|
||||
|
Loading…
Reference in New Issue
Block a user