Commit 6be3d859 authored by Jan Engelhardt's avatar Jan Engelhardt Committed by Patrick McHardy

netfilter: xtables: move extension arguments into compound structure (3/6)

This patch does this for match extensions' destroy functions.
Signed-off-by: default avatarJan Engelhardt <jengelh@medozas.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent 9b4fce7a
...@@ -212,6 +212,12 @@ struct xt_mtchk_param { ...@@ -212,6 +212,12 @@ struct xt_mtchk_param {
unsigned int hook_mask; unsigned int hook_mask;
}; };
/* Match destructor parameters */
struct xt_mtdtor_param {
const struct xt_match *match;
void *matchinfo;
};
struct xt_match struct xt_match
{ {
struct list_head list; struct list_head list;
...@@ -230,7 +236,7 @@ struct xt_match ...@@ -230,7 +236,7 @@ struct xt_match
bool (*checkentry)(const struct xt_mtchk_param *); bool (*checkentry)(const struct xt_mtchk_param *);
/* Called when entry of this type deleted. */ /* Called when entry of this type deleted. */
void (*destroy)(const struct xt_match *match, void *matchinfo); void (*destroy)(const struct xt_mtdtor_param *);
/* Called when userspace align differs from kernel space one */ /* Called when userspace align differs from kernel space one */
void (*compat_from_user)(void *dst, void *src); void (*compat_from_user)(void *dst, void *src);
......
...@@ -558,12 +558,16 @@ ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo, ...@@ -558,12 +558,16 @@ ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo,
static inline int static inline int
ebt_cleanup_match(struct ebt_entry_match *m, unsigned int *i) ebt_cleanup_match(struct ebt_entry_match *m, unsigned int *i)
{ {
struct xt_mtdtor_param par;
if (i && (*i)-- == 0) if (i && (*i)-- == 0)
return 1; return 1;
if (m->u.match->destroy)
m->u.match->destroy(m->u.match, m->data);
module_put(m->u.match->me);
par.match = m->u.match;
par.matchinfo = m->data;
if (par.match->destroy != NULL)
par.match->destroy(&par);
module_put(par.match->me);
return 0; return 0;
} }
...@@ -609,7 +613,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo, ...@@ -609,7 +613,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
unsigned int i, j, hook = 0, hookmask = 0; unsigned int i, j, hook = 0, hookmask = 0;
size_t gap; size_t gap;
int ret; int ret;
struct xt_mtchk_param par; struct xt_mtchk_param mtpar;
/* don't mess with the struct ebt_entries */ /* don't mess with the struct ebt_entries */
if (e->bitmask == 0) if (e->bitmask == 0)
...@@ -651,10 +655,10 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo, ...@@ -651,10 +655,10 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
} }
i = 0; i = 0;
par.table = name; mtpar.table = name;
par.entryinfo = e; mtpar.entryinfo = e;
par.hook_mask = hookmask; mtpar.hook_mask = hookmask;
ret = EBT_MATCH_ITERATE(e, ebt_check_match, &par, &i); ret = EBT_MATCH_ITERATE(e, ebt_check_match, &mtpar, &i);
if (ret != 0) if (ret != 0)
goto cleanup_matches; goto cleanup_matches;
j = 0; j = 0;
......
...@@ -576,12 +576,16 @@ mark_source_chains(struct xt_table_info *newinfo, ...@@ -576,12 +576,16 @@ mark_source_chains(struct xt_table_info *newinfo,
static int static int
cleanup_match(struct ipt_entry_match *m, unsigned int *i) cleanup_match(struct ipt_entry_match *m, unsigned int *i)
{ {
struct xt_mtdtor_param par;
if (i && (*i)-- == 0) if (i && (*i)-- == 0)
return 1; return 1;
if (m->u.kernel.match->destroy) par.match = m->u.kernel.match;
m->u.kernel.match->destroy(m->u.kernel.match, m->data); par.matchinfo = m->data;
module_put(m->u.kernel.match->me); if (par.match->destroy != NULL)
par.match->destroy(&par);
module_put(par.match->me);
return 0; return 0;
} }
......
...@@ -599,12 +599,16 @@ mark_source_chains(struct xt_table_info *newinfo, ...@@ -599,12 +599,16 @@ mark_source_chains(struct xt_table_info *newinfo,
static int static int
cleanup_match(struct ip6t_entry_match *m, unsigned int *i) cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
{ {
struct xt_mtdtor_param par;
if (i && (*i)-- == 0) if (i && (*i)-- == 0)
return 1; return 1;
if (m->u.kernel.match->destroy) par.match = m->u.kernel.match;
m->u.kernel.match->destroy(m->u.kernel.match, m->data); par.matchinfo = m->data;
module_put(m->u.kernel.match->me); if (par.match->destroy != NULL)
par.match->destroy(&par);
module_put(par.match->me);
return 0; return 0;
} }
......
...@@ -115,9 +115,9 @@ static bool connbytes_mt_check(const struct xt_mtchk_param *par) ...@@ -115,9 +115,9 @@ static bool connbytes_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void connbytes_mt_destroy(const struct xt_match *match, void *matchinfo) static void connbytes_mt_destroy(const struct xt_mtdtor_param *par)
{ {
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
} }
static struct xt_match connbytes_mt_reg[] __read_mostly = { static struct xt_match connbytes_mt_reg[] __read_mostly = {
......
...@@ -246,16 +246,15 @@ static bool connlimit_mt_check(const struct xt_mtchk_param *par) ...@@ -246,16 +246,15 @@ static bool connlimit_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void static void connlimit_mt_destroy(const struct xt_mtdtor_param *par)
connlimit_mt_destroy(const struct xt_match *match, void *matchinfo)
{ {
const struct xt_connlimit_info *info = matchinfo; const struct xt_connlimit_info *info = par->matchinfo;
struct xt_connlimit_conn *conn; struct xt_connlimit_conn *conn;
struct xt_connlimit_conn *tmp; struct xt_connlimit_conn *tmp;
struct list_head *hash = info->data->iphash; struct list_head *hash = info->data->iphash;
unsigned int i; unsigned int i;
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
for (i = 0; i < ARRAY_SIZE(info->data->iphash); ++i) { for (i = 0; i < ARRAY_SIZE(info->data->iphash); ++i) {
list_for_each_entry_safe(conn, tmp, &hash[i], list) { list_for_each_entry_safe(conn, tmp, &hash[i], list) {
......
...@@ -87,10 +87,9 @@ static bool connmark_mt_check(const struct xt_mtchk_param *par) ...@@ -87,10 +87,9 @@ static bool connmark_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void static void connmark_mt_destroy(const struct xt_mtdtor_param *par)
connmark_mt_destroy(const struct xt_match *match, void *matchinfo)
{ {
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
......
...@@ -288,10 +288,9 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par) ...@@ -288,10 +288,9 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void static void conntrack_mt_destroy(const struct xt_mtdtor_param *par)
conntrack_mt_destroy(const struct xt_match *match, void *matchinfo)
{ {
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
......
...@@ -748,17 +748,16 @@ static bool hashlimit_mt_check(const struct xt_mtchk_param *par) ...@@ -748,17 +748,16 @@ static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
} }
static void static void
hashlimit_mt_destroy_v0(const struct xt_match *match, void *matchinfo) hashlimit_mt_destroy_v0(const struct xt_mtdtor_param *par)
{ {
const struct xt_hashlimit_info *r = matchinfo; const struct xt_hashlimit_info *r = par->matchinfo;
htable_put(r->hinfo); htable_put(r->hinfo);
} }
static void static void hashlimit_mt_destroy(const struct xt_mtdtor_param *par)
hashlimit_mt_destroy(const struct xt_match *match, void *matchinfo)
{ {
const struct xt_hashlimit_mtinfo1 *info = matchinfo; const struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
htable_put(info->hinfo); htable_put(info->hinfo);
} }
......
...@@ -67,9 +67,9 @@ static bool helper_mt_check(const struct xt_mtchk_param *par) ...@@ -67,9 +67,9 @@ static bool helper_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void helper_mt_destroy(const struct xt_match *match, void *matchinfo) static void helper_mt_destroy(const struct xt_mtdtor_param *par)
{ {
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
} }
static struct xt_match helper_mt_reg[] __read_mostly = { static struct xt_match helper_mt_reg[] __read_mostly = {
......
...@@ -117,10 +117,9 @@ err1: ...@@ -117,10 +117,9 @@ err1:
return false; return false;
} }
static void xt_rateest_mt_destroy(const struct xt_match *match, static void xt_rateest_mt_destroy(const struct xt_mtdtor_param *par)
void *matchinfo)
{ {
struct xt_rateest_match_info *info = matchinfo; struct xt_rateest_match_info *info = par->matchinfo;
xt_rateest_put(info->est1); xt_rateest_put(info->est1);
if (info->est2) if (info->est2)
......
...@@ -349,9 +349,9 @@ out: ...@@ -349,9 +349,9 @@ out:
return ret; return ret;
} }
static void recent_mt_destroy(const struct xt_match *match, void *matchinfo) static void recent_mt_destroy(const struct xt_mtdtor_param *par)
{ {
const struct xt_recent_mtinfo *info = matchinfo; const struct xt_recent_mtinfo *info = par->matchinfo;
struct recent_table *t; struct recent_table *t;
mutex_lock(&recent_mutex); mutex_lock(&recent_mutex);
......
...@@ -47,9 +47,9 @@ static bool state_mt_check(const struct xt_mtchk_param *par) ...@@ -47,9 +47,9 @@ static bool state_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void state_mt_destroy(const struct xt_match *match, void *matchinfo) static void state_mt_destroy(const struct xt_mtdtor_param *par)
{ {
nf_ct_l3proto_module_put(match->family); nf_ct_l3proto_module_put(par->match->family);
} }
static struct xt_match state_mt_reg[] __read_mostly = { static struct xt_match state_mt_reg[] __read_mostly = {
......
...@@ -70,9 +70,9 @@ static bool string_mt_check(const struct xt_mtchk_param *par) ...@@ -70,9 +70,9 @@ static bool string_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static void string_mt_destroy(const struct xt_match *match, void *matchinfo) static void string_mt_destroy(const struct xt_mtdtor_param *par)
{ {
textsearch_destroy(STRING_TEXT_PRIV(matchinfo)->config); textsearch_destroy(STRING_TEXT_PRIV(par->matchinfo)->config);
} }
static struct xt_match xt_string_mt_reg[] __read_mostly = { static struct xt_match xt_string_mt_reg[] __read_mostly = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment