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

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

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



This patch does this for target extensions' destroy functions.

Signed-off-by: default avatarJan Engelhardt <jengelh@medozas.de>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent af5d6dc2
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -251,6 +251,12 @@ struct xt_tgchk_param {
	unsigned int hook_mask;
};

/* Target destructor parameters */
struct xt_tgdtor_param {
	const struct xt_target *target;
	void *targinfo;
};

struct xt_match
{
	struct list_head list;
@@ -311,7 +317,7 @@ struct xt_target
	bool (*checkentry)(const struct xt_tgchk_param *);

	/* Called when entry of this type deleted. */
	void (*destroy)(const struct xt_target *target, void *targinfo);
	void (*destroy)(const struct xt_tgdtor_param *);

	/* Called when userspace align differs from kernel space one */
	void (*compat_from_user)(void *dst, void *src);
+13 −6
Original line number Diff line number Diff line
@@ -581,18 +581,23 @@ ebt_cleanup_match(struct ebt_entry_match *m, unsigned int *i)
static inline int
ebt_cleanup_watcher(struct ebt_entry_watcher *w, unsigned int *i)
{
	struct xt_tgdtor_param par;

	if (i && (*i)-- == 0)
		return 1;
	if (w->u.watcher->destroy)
		w->u.watcher->destroy(w->u.watcher, w->data);
	module_put(w->u.watcher->me);

	par.target   = w->u.watcher;
	par.targinfo = w->data;
	if (par.target->destroy != NULL)
		par.target->destroy(&par);
	module_put(par.target->me);
	return 0;
}

static inline int
ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
{
	struct xt_tgdtor_param par;
	struct ebt_entry_target *t;

	if (e->bitmask == 0)
@@ -603,10 +608,12 @@ ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
	EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, NULL);
	EBT_MATCH_ITERATE(e, ebt_cleanup_match, NULL);
	t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
	if (t->u.target->destroy)
		t->u.target->destroy(t->u.target, t->data);
	module_put(t->u.target->me);

	par.target   = t->u.target;
	par.targinfo = t->data;
	if (par.target->destroy != NULL)
		par.target->destroy(&par);
	module_put(par.target->me);
	return 0;
}

+6 −3
Original line number Diff line number Diff line
@@ -557,15 +557,18 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,

static inline int cleanup_entry(struct arpt_entry *e, unsigned int *i)
{
	struct xt_tgdtor_param par;
	struct arpt_entry_target *t;

	if (i && (*i)-- == 0)
		return 1;

	t = arpt_get_target(e);
	if (t->u.kernel.target->destroy)
		t->u.kernel.target->destroy(t->u.kernel.target, t->data);
	module_put(t->u.kernel.target->me);
	par.target   = t->u.kernel.target;
	par.targinfo = t->data;
	if (par.target->destroy != NULL)
		par.target->destroy(&par);
	module_put(par.target->me);
	return 0;
}

+7 −3
Original line number Diff line number Diff line
@@ -768,6 +768,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
static int
cleanup_entry(struct ipt_entry *e, unsigned int *i)
{
	struct xt_tgdtor_param par;
	struct ipt_entry_target *t;

	if (i && (*i)-- == 0)
@@ -776,9 +777,12 @@ cleanup_entry(struct ipt_entry *e, unsigned int *i)
	/* Cleanup all matches */
	IPT_MATCH_ITERATE(e, cleanup_match, NULL);
	t = ipt_get_target(e);
	if (t->u.kernel.target->destroy)
		t->u.kernel.target->destroy(t->u.kernel.target, t->data);
	module_put(t->u.kernel.target->me);

	par.target   = t->u.kernel.target;
	par.targinfo = t->data;
	if (par.target->destroy != NULL)
		par.target->destroy(&par);
	module_put(par.target->me);
	return 0;
}

+3 −3
Original line number Diff line number Diff line
@@ -411,9 +411,9 @@ static bool clusterip_tg_check(const struct xt_tgchk_param *par)
}

/* drop reference count of cluster config when rule is deleted */
static void clusterip_tg_destroy(const struct xt_target *target, void *targinfo)
static void clusterip_tg_destroy(const struct xt_tgdtor_param *par)
{
	const struct ipt_clusterip_tgt_info *cipinfo = targinfo;
	const struct ipt_clusterip_tgt_info *cipinfo = par->targinfo;

	/* if no more entries are referencing the config, remove it
	 * from the list and destroy the proc entry */
@@ -421,7 +421,7 @@ static void clusterip_tg_destroy(const struct xt_target *target, void *targinfo)

	clusterip_config_put(cipinfo->config);

	nf_ct_l3proto_module_put(target->family);
	nf_ct_l3proto_module_put(par->target->family);
}

#ifdef CONFIG_COMPAT
Loading