Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -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
	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);
+12 −8
Original line number Original line Diff line number Diff line
@@ -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,
	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,
	}
	}
	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;
+7 −3
Original line number Original line Diff line number Diff line
@@ -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;
}
}


+7 −3
Original line number Original line Diff line number Diff line
@@ -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;
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -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 = {
Loading