Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_ioctl.c
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
static struct pf_kpool *pf_get_kpool(const char *, u_int32_t, u_int8_t, | static struct pf_kpool *pf_get_kpool(const char *, u_int32_t, u_int8_t, | ||||
u_int32_t, u_int8_t, u_int8_t, u_int8_t); | u_int32_t, u_int8_t, u_int8_t, u_int8_t); | ||||
static void pf_mv_kpool(struct pf_kpalist *, struct pf_kpalist *); | static void pf_mv_kpool(struct pf_kpalist *, struct pf_kpalist *); | ||||
static void pf_empty_kpool(struct pf_kpalist *); | static void pf_empty_kpool(struct pf_kpalist *); | ||||
static int pfioctl(struct cdev *, u_long, caddr_t, int, | static int pfioctl(struct cdev *, u_long, caddr_t, int, | ||||
struct thread *); | struct thread *); | ||||
static int pf_begin_eth(uint32_t *); | static int pf_begin_eth(uint32_t *); | ||||
static void pf_rollback_eth_cb(struct epoch_context *); | |||||
static int pf_rollback_eth(uint32_t); | static int pf_rollback_eth(uint32_t); | ||||
static int pf_commit_eth(uint32_t); | static int pf_commit_eth(uint32_t); | ||||
static void pf_free_eth_rule(struct pf_keth_rule *); | static void pf_free_eth_rule(struct pf_keth_rule *); | ||||
#ifdef ALTQ | #ifdef ALTQ | ||||
static int pf_begin_altq(u_int32_t *); | static int pf_begin_altq(u_int32_t *); | ||||
static int pf_rollback_altq(u_int32_t); | static int pf_rollback_altq(u_int32_t); | ||||
static int pf_commit_altq(u_int32_t); | static int pf_commit_altq(u_int32_t); | ||||
static int pf_enable_altq(struct pf_altq *); | static int pf_enable_altq(struct pf_altq *); | ||||
▲ Show 20 Lines • Show All 578 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
pf_begin_eth(uint32_t *ticket) | pf_begin_eth(uint32_t *ticket) | ||||
{ | { | ||||
struct pf_keth_rule *rule, *tmp; | struct pf_keth_rule *rule, *tmp; | ||||
PF_RULES_WASSERT(); | PF_RULES_WASSERT(); | ||||
if (V_pf_keth_inactive->open) { | |||||
/* We may be waiting for NET_EPOCH_CALL(pf_rollback_eth_cb) to | |||||
* finish. */ | |||||
return (EBUSY); | |||||
} | |||||
/* Purge old inactive rules. */ | /* Purge old inactive rules. */ | ||||
TAILQ_FOREACH_SAFE(rule, &V_pf_keth_inactive->rules, entries, tmp) { | TAILQ_FOREACH_SAFE(rule, &V_pf_keth_inactive->rules, entries, tmp) { | ||||
TAILQ_REMOVE(&V_pf_keth_inactive->rules, rule, entries); | TAILQ_REMOVE(&V_pf_keth_inactive->rules, rule, entries); | ||||
pf_free_eth_rule(rule); | pf_free_eth_rule(rule); | ||||
} | } | ||||
*ticket = ++V_pf_keth_inactive->ticket; | *ticket = ++V_pf_keth_inactive->ticket; | ||||
V_pf_keth_inactive->open = 1; | V_pf_keth_inactive->open = 1; | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | |||||
pf_rollback_eth_cb(struct epoch_context *ctx) | |||||
{ | |||||
struct pf_keth_settings *settings; | |||||
settings = __containerof(ctx, struct pf_keth_settings, epoch_ctx); | |||||
CURVNET_SET(settings->vnet); | |||||
MPASS(settings == V_pf_keth_inactive); | |||||
PF_RULES_WLOCK(); | |||||
pf_rollback_eth(V_pf_keth_inactive->ticket); | |||||
PF_RULES_WUNLOCK(); | |||||
CURVNET_RESTORE(); | |||||
} | |||||
static int | static int | ||||
pf_rollback_eth(uint32_t ticket) | pf_rollback_eth(uint32_t ticket) | ||||
{ | { | ||||
struct pf_keth_rule *rule, *tmp; | struct pf_keth_rule *rule, *tmp; | ||||
PF_RULES_WASSERT(); | PF_RULES_WASSERT(); | ||||
if (!V_pf_keth_inactive->open || ticket != V_pf_keth_inactive->ticket) | if (!V_pf_keth_inactive->open || ticket != V_pf_keth_inactive->ticket) | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
pf_commit_eth(uint32_t ticket) | pf_commit_eth(uint32_t ticket) | ||||
{ | { | ||||
struct pf_keth_settings *settings; | struct pf_keth_settings *settings; | ||||
if (!V_pf_keth_inactive->open || | if (!V_pf_keth_inactive->open || | ||||
ticket != V_pf_keth_inactive->ticket) | ticket != V_pf_keth_inactive->ticket) | ||||
return (EBUSY); | return (EBUSY); | ||||
PF_RULES_WASSERT(); | |||||
pf_eth_calc_skip_steps(&V_pf_keth_inactive->rules); | pf_eth_calc_skip_steps(&V_pf_keth_inactive->rules); | ||||
settings = V_pf_keth; | settings = V_pf_keth; | ||||
V_pf_keth = V_pf_keth_inactive; | ck_pr_store_ptr(&V_pf_keth, V_pf_keth_inactive); | ||||
V_pf_keth_inactive = settings; | V_pf_keth_inactive = settings; | ||||
V_pf_keth_inactive->ticket = V_pf_keth->ticket; | V_pf_keth_inactive->ticket = V_pf_keth->ticket; | ||||
/* Clean up inactive rules. */ | /* Clean up inactive rules (i.e. previously active rules), only when | ||||
return (pf_rollback_eth(ticket)); | * we're sure they're no longer used. */ | ||||
NET_EPOCH_CALL(pf_rollback_eth_cb, &V_pf_keth_inactive->epoch_ctx); | |||||
return (0); | |||||
} | } | ||||
#ifdef ALTQ | #ifdef ALTQ | ||||
static uint16_t | static uint16_t | ||||
pf_qname2qid(const char *qname) | pf_qname2qid(const char *qname) | ||||
{ | { | ||||
return (tagname2tag(&V_pf_qids, qname)); | return (tagname2tag(&V_pf_qids, qname)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,539 Lines • Show Last 20 Lines |