Skip to content

Commit 6be3d85

Browse files
Jan Engelhardtkaber
authored andcommitted
netfilter: xtables: move extension arguments into compound structure (3/6)
This patch does this for match extensions' destroy functions. Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 9b4fce7 commit 6be3d85

14 files changed

Lines changed: 56 additions & 43 deletions

File tree

‎include/linux/netfilter/x_tables.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ struct xt_mtchk_param {
212212
unsigned int hook_mask;
213213
};
214214

215+
/* Match destructor parameters */
216+
struct xt_mtdtor_param {
217+
const struct xt_match *match;
218+
void *matchinfo;
219+
};
220+
215221
struct xt_match
216222
{
217223
struct list_head list;
@@ -230,7 +236,7 @@ struct xt_match
230236
bool (*checkentry)(const struct xt_mtchk_param *);
231237

232238
/* Called when entry of this type deleted. */
233-
void (*destroy)(const struct xt_match *match, void *matchinfo);
239+
void (*destroy)(const struct xt_mtdtor_param *);
234240

235241
/* Called when userspace align differs from kernel space one */
236242
void (*compat_from_user)(void *dst, void *src);

‎net/bridge/netfilter/ebtables.c‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,16 @@ ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo,
558558
static inline int
559559
ebt_cleanup_match(struct ebt_entry_match *m, unsigned int *i)
560560
{
561+
struct xt_mtdtor_param par;
562+
561563
if (i && (*i)-- == 0)
562564
return 1;
563-
if (m->u.match->destroy)
564-
m->u.match->destroy(m->u.match, m->data);
565-
module_put(m->u.match->me);
566565

566+
par.match = m->u.match;
567+
par.matchinfo = m->data;
568+
if (par.match->destroy != NULL)
569+
par.match->destroy(&par);
570+
module_put(par.match->me);
567571
return 0;
568572
}
569573

@@ -609,7 +613,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
609613
unsigned int i, j, hook = 0, hookmask = 0;
610614
size_t gap;
611615
int ret;
612-
struct xt_mtchk_param par;
616+
struct xt_mtchk_param mtpar;
613617

614618
/* don't mess with the struct ebt_entries */
615619
if (e->bitmask == 0)
@@ -651,10 +655,10 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
651655
}
652656
i = 0;
653657

654-
par.table = name;
655-
par.entryinfo = e;
656-
par.hook_mask = hookmask;
657-
ret = EBT_MATCH_ITERATE(e, ebt_check_match, &par, &i);
658+
mtpar.table = name;
659+
mtpar.entryinfo = e;
660+
mtpar.hook_mask = hookmask;
661+
ret = EBT_MATCH_ITERATE(e, ebt_check_match, &mtpar, &i);
658662
if (ret != 0)
659663
goto cleanup_matches;
660664
j = 0;

‎net/ipv4/netfilter/ip_tables.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,16 @@ mark_source_chains(struct xt_table_info *newinfo,
576576
static int
577577
cleanup_match(struct ipt_entry_match *m, unsigned int *i)
578578
{
579+
struct xt_mtdtor_param par;
580+
579581
if (i && (*i)-- == 0)
580582
return 1;
581583

582-
if (m->u.kernel.match->destroy)
583-
m->u.kernel.match->destroy(m->u.kernel.match, m->data);
584-
module_put(m->u.kernel.match->me);
584+
par.match = m->u.kernel.match;
585+
par.matchinfo = m->data;
586+
if (par.match->destroy != NULL)
587+
par.match->destroy(&par);
588+
module_put(par.match->me);
585589
return 0;
586590
}
587591

‎net/ipv6/netfilter/ip6_tables.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,16 @@ mark_source_chains(struct xt_table_info *newinfo,
599599
static int
600600
cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
601601
{
602+
struct xt_mtdtor_param par;
603+
602604
if (i && (*i)-- == 0)
603605
return 1;
604606

605-
if (m->u.kernel.match->destroy)
606-
m->u.kernel.match->destroy(m->u.kernel.match, m->data);
607-
module_put(m->u.kernel.match->me);
607+
par.match = m->u.kernel.match;
608+
par.matchinfo = m->data;
609+
if (par.match->destroy != NULL)
610+
par.match->destroy(&par);
611+
module_put(par.match->me);
608612
return 0;
609613
}
610614

‎net/netfilter/xt_connbytes.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ static bool connbytes_mt_check(const struct xt_mtchk_param *par)
115115
return true;
116116
}
117117

118-
static void connbytes_mt_destroy(const struct xt_match *match, void *matchinfo)
118+
static void connbytes_mt_destroy(const struct xt_mtdtor_param *par)
119119
{
120-
nf_ct_l3proto_module_put(match->family);
120+
nf_ct_l3proto_module_put(par->match->family);
121121
}
122122

123123
static struct xt_match connbytes_mt_reg[] __read_mostly = {

‎net/netfilter/xt_connlimit.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,15 @@ static bool connlimit_mt_check(const struct xt_mtchk_param *par)
246246
return true;
247247
}
248248

249-
static void
250-
connlimit_mt_destroy(const struct xt_match *match, void *matchinfo)
249+
static void connlimit_mt_destroy(const struct xt_mtdtor_param *par)
251250
{
252-
const struct xt_connlimit_info *info = matchinfo;
251+
const struct xt_connlimit_info *info = par->matchinfo;
253252
struct xt_connlimit_conn *conn;
254253
struct xt_connlimit_conn *tmp;
255254
struct list_head *hash = info->data->iphash;
256255
unsigned int i;
257256

258-
nf_ct_l3proto_module_put(match->family);
257+
nf_ct_l3proto_module_put(par->match->family);
259258

260259
for (i = 0; i < ARRAY_SIZE(info->data->iphash); ++i) {
261260
list_for_each_entry_safe(conn, tmp, &hash[i], list) {

‎net/netfilter/xt_connmark.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ static bool connmark_mt_check(const struct xt_mtchk_param *par)
8787
return true;
8888
}
8989

90-
static void
91-
connmark_mt_destroy(const struct xt_match *match, void *matchinfo)
90+
static void connmark_mt_destroy(const struct xt_mtdtor_param *par)
9291
{
93-
nf_ct_l3proto_module_put(match->family);
92+
nf_ct_l3proto_module_put(par->match->family);
9493
}
9594

9695
#ifdef CONFIG_COMPAT

‎net/netfilter/xt_conntrack.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,9 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par)
288288
return true;
289289
}
290290

291-
static void
292-
conntrack_mt_destroy(const struct xt_match *match, void *matchinfo)
291+
static void conntrack_mt_destroy(const struct xt_mtdtor_param *par)
293292
{
294-
nf_ct_l3proto_module_put(match->family);
293+
nf_ct_l3proto_module_put(par->match->family);
295294
}
296295

297296
#ifdef CONFIG_COMPAT

‎net/netfilter/xt_hashlimit.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,17 +748,16 @@ static bool hashlimit_mt_check(const struct xt_mtchk_param *par)
748748
}
749749

750750
static void
751-
hashlimit_mt_destroy_v0(const struct xt_match *match, void *matchinfo)
751+
hashlimit_mt_destroy_v0(const struct xt_mtdtor_param *par)
752752
{
753-
const struct xt_hashlimit_info *r = matchinfo;
753+
const struct xt_hashlimit_info *r = par->matchinfo;
754754

755755
htable_put(r->hinfo);
756756
}
757757

758-
static void
759-
hashlimit_mt_destroy(const struct xt_match *match, void *matchinfo)
758+
static void hashlimit_mt_destroy(const struct xt_mtdtor_param *par)
760759
{
761-
const struct xt_hashlimit_mtinfo1 *info = matchinfo;
760+
const struct xt_hashlimit_mtinfo1 *info = par->matchinfo;
762761

763762
htable_put(info->hinfo);
764763
}

‎net/netfilter/xt_helper.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ static bool helper_mt_check(const struct xt_mtchk_param *par)
6767
return true;
6868
}
6969

70-
static void helper_mt_destroy(const struct xt_match *match, void *matchinfo)
70+
static void helper_mt_destroy(const struct xt_mtdtor_param *par)
7171
{
72-
nf_ct_l3proto_module_put(match->family);
72+
nf_ct_l3proto_module_put(par->match->family);
7373
}
7474

7575
static struct xt_match helper_mt_reg[] __read_mostly = {

0 commit comments

Comments
 (0)