mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
libpfctl: remove the state getters that do not take a handle
Nothing in the tree calls any of the three. Remove them rather than
fix them: pfctl_get_states_h() does the same with the handle that the
caller has. pfctl_free_states(), struct pfctl_states and the list
entry in struct pfctl_state were there for pfctl_get_states() alone,
and go with it.
Reviewed by: kp
Approved by: kp (mentor)
Fixes: 2a478dfc7f ("libpfctl: retrieve family id only once")
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60248
This commit is contained in:
2 files changed
-77
No files matched your search
@@ -2027,72 +2027,6 @@ out:
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
pfctl_get_states_iter(pfctl_get_state_fn f, void *arg)
|
||||
{
|
||||
struct pfctl_state_filter filter = {};
|
||||
return (pfctl_get_filtered_states_iter(&filter, f, arg));
|
||||
}
|
||||
|
||||
int
|
||||
pfctl_get_filtered_states_iter(struct pfctl_state_filter *filter, pfctl_get_state_fn f, void *arg)
|
||||
{
|
||||
struct pfctl_handle h = {};
|
||||
int error;
|
||||
|
||||
snl_init(&h.ss, NETLINK_GENERIC);
|
||||
error = pfctl_get_states_h(&h, filter, f, arg);
|
||||
snl_free(&h.ss);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
pfctl_append_states(struct pfctl_state *s, void *arg)
|
||||
{
|
||||
struct pfctl_state *new;
|
||||
struct pfctl_states *states = (struct pfctl_states *)arg;
|
||||
|
||||
new = malloc(sizeof(*s));
|
||||
if (new == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
memcpy(new, s, sizeof(*s));
|
||||
|
||||
TAILQ_INSERT_TAIL(&states->states, new, entry);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
pfctl_get_states(int dev __unused, struct pfctl_states *states)
|
||||
{
|
||||
int ret;
|
||||
|
||||
bzero(states, sizeof(*states));
|
||||
TAILQ_INIT(&states->states);
|
||||
|
||||
ret = pfctl_get_states_iter(pfctl_append_states, states);
|
||||
if (ret != 0) {
|
||||
pfctl_free_states(states);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
pfctl_free_states(struct pfctl_states *states)
|
||||
{
|
||||
struct pfctl_state *s, *tmp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(s, &states->states, entry, tmp) {
|
||||
free(s);
|
||||
}
|
||||
|
||||
bzero(states, sizeof(*states));
|
||||
}
|
||||
|
||||
struct pfctl_nl_clear_states {
|
||||
uint32_t killed;
|
||||
};
|
||||
|
||||
@@ -369,8 +369,6 @@ struct pfctl_state_key {
|
||||
};
|
||||
|
||||
struct pfctl_state {
|
||||
TAILQ_ENTRY(pfctl_state) entry;
|
||||
|
||||
uint64_t id;
|
||||
uint32_t creatorid;
|
||||
uint8_t direction;
|
||||
@@ -409,11 +407,6 @@ struct pfctl_state {
|
||||
struct pfctl_rule created_by_rule;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(pfctl_statelist, pfctl_state);
|
||||
struct pfctl_states {
|
||||
struct pfctl_statelist states;
|
||||
};
|
||||
|
||||
enum pfctl_syncookies_mode {
|
||||
PFCTL_SYNCOOKIES_NEVER,
|
||||
PFCTL_SYNCOOKIES_ALWAYS,
|
||||
@@ -508,11 +501,7 @@ struct pfctl_state_filter {
|
||||
bool include_rule;
|
||||
};
|
||||
typedef int (*pfctl_get_state_fn)(struct pfctl_state *, void *);
|
||||
int pfctl_get_states_iter(pfctl_get_state_fn f, void *arg);
|
||||
int pfctl_get_states_h(struct pfctl_handle *h, struct pfctl_state_filter *filter, pfctl_get_state_fn f, void *arg);
|
||||
int pfctl_get_filtered_states_iter(struct pfctl_state_filter *filter, pfctl_get_state_fn f, void *arg);
|
||||
int pfctl_get_states(int dev, struct pfctl_states *states);
|
||||
void pfctl_free_states(struct pfctl_states *states);
|
||||
int pfctl_clear_states(int dev, const struct pfctl_kill *kill,
|
||||
unsigned int *killed);
|
||||
int pfctl_kill_states(int dev, const struct pfctl_kill *kill,
|
||||
|
||||
Reference in new issue
Block a user