Changeset View
Changeset View
Standalone View
Standalone View
sbin/pfctl/pfctl_optimize.c
Show All 32 Lines | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "pfctl_ioctl.h" | |||||
#include "pfctl_parser.h" | #include "pfctl_parser.h" | ||||
#include "pfctl.h" | #include "pfctl.h" | ||||
/* The size at which a table becomes faster than individual rules */ | /* The size at which a table becomes faster than individual rules */ | ||||
#define TABLE_THRESHOLD 6 | #define TABLE_THRESHOLD 6 | ||||
/* #define OPT_DEBUG 1 */ | /* #define OPT_DEBUG 1 */ | ||||
▲ Show 20 Lines • Show All 855 Lines • ▼ Show 20 Lines | load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) | ||||
DEBUG("Loading %d active rules for a feedback profile", mnr); | DEBUG("Loading %d active rules for a feedback profile", mnr); | ||||
for (nr = 0; nr < mnr; ++nr) { | for (nr = 0; nr < mnr; ++nr) { | ||||
struct pf_ruleset *rs; | struct pf_ruleset *rs; | ||||
if ((por = calloc(1, sizeof(*por))) == NULL) { | if ((por = calloc(1, sizeof(*por))) == NULL) { | ||||
warn("calloc"); | warn("calloc"); | ||||
return (1); | return (1); | ||||
} | } | ||||
pr.nr = nr; | pr.nr = nr; | ||||
if (ioctl(pf->dev, DIOCGETRULE, &pr)) { | |||||
warn("DIOCGETRULES"); | if (pfctl_get_rule(pf->dev, nr, pr.ticket, "", PF_PASS, | ||||
&pr.rule, pr.anchor_call)) { | |||||
warn("DIOCGETRULENV"); | |||||
return (1); | return (1); | ||||
} | } | ||||
memcpy(&por->por_rule, &pr.rule, sizeof(por->por_rule)); | memcpy(&por->por_rule, &pr.rule, sizeof(por->por_rule)); | ||||
rs = pf_find_or_create_ruleset(pr.anchor_call); | rs = pf_find_or_create_ruleset(pr.anchor_call); | ||||
por->por_rule.anchor = rs->anchor; | por->por_rule.anchor = rs->anchor; | ||||
if (TAILQ_EMPTY(&por->por_rule.rpool.list)) | if (TAILQ_EMPTY(&por->por_rule.rpool.list)) | ||||
memset(&por->por_rule.rpool, 0, | memset(&por->por_rule.rpool, 0, | ||||
sizeof(por->por_rule.rpool)); | sizeof(por->por_rule.rpool)); | ||||
▲ Show 20 Lines • Show All 745 Lines • Show Last 20 Lines |