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

Commit 97a3f84f authored by Cong Wang's avatar Cong Wang Committed by David S. Miller
Browse files

net_sched: remove unnecessary ops->delete()



All ops->delete() wants is getting the tn->idrinfo, but we already
have tc_action before calling ops->delete(), and tc_action has
a pointer ->idrinfo.

More importantly, each type of action does the same thing, that is,
just calling tcf_idr_delete_index().

So it can be just removed.

Fixes: b409074e ("net: sched: add 'delete' function to action ops")
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edfaf94f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ struct tc_action_ops {
	size_t  (*get_fill_size)(const struct tc_action *act);
	struct net_device *(*get_dev)(const struct tc_action *a);
	void	(*put_dev)(struct net_device *dev);
	int     (*delete)(struct net *net, u32 index);
};

struct tc_action_net {
@@ -158,7 +157,6 @@ void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a);
void tcf_idr_cleanup(struct tc_action_net *tn, u32 index);
int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,
			struct tc_action **a, int bind);
int tcf_idr_delete_index(struct tc_action_net *tn, u32 index);
int __tcf_idr_release(struct tc_action *a, bool bind, bool strict);

static inline int tcf_idr_release(struct tc_action *a, bool bind)
+7 −8
Original line number Diff line number Diff line
@@ -337,9 +337,8 @@ bool tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a,
}
EXPORT_SYMBOL(tcf_idr_check);

int tcf_idr_delete_index(struct tc_action_net *tn, u32 index)
static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index)
{
	struct tcf_idrinfo *idrinfo = tn->idrinfo;
	struct tc_action *p;
	int ret = 0;

@@ -370,7 +369,6 @@ int tcf_idr_delete_index(struct tc_action_net *tn, u32 index)
	spin_unlock(&idrinfo->lock);
	return ret;
}
EXPORT_SYMBOL(tcf_idr_delete_index);

int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
		   struct tc_action **a, const struct tc_action_ops *ops,
@@ -1182,24 +1180,25 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
static int tcf_action_delete(struct net *net, struct tc_action *actions[],
			     struct netlink_ext_ack *extack)
{
	u32 act_index;
	int ret, i;
	int i;

	for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) {
		struct tc_action *a = actions[i];
		const struct tc_action_ops *ops = a->ops;

		/* Actions can be deleted concurrently so we must save their
		 * type and id to search again after reference is released.
		 */
		act_index = a->tcfa_index;
		struct tcf_idrinfo *idrinfo = a->idrinfo;
		u32 act_index = a->tcfa_index;

		if (tcf_action_put(a)) {
			/* last reference, action was deleted concurrently */
			module_put(ops->owner);
		} else  {
			int ret;

			/* now do the delete */
			ret = ops->delete(net, act_index);
			ret = tcf_idr_delete_index(idrinfo, act_index);
			if (ret < 0)
				return ret;
		}
+0 −8
Original line number Diff line number Diff line
@@ -395,13 +395,6 @@ static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index,
	return tcf_idr_search(tn, a, index);
}

static int tcf_bpf_delete(struct net *net, u32 index)
{
	struct tc_action_net *tn = net_generic(net, bpf_net_id);

	return tcf_idr_delete_index(tn, index);
}

static struct tc_action_ops act_bpf_ops __read_mostly = {
	.kind		=	"bpf",
	.type		=	TCA_ACT_BPF,
@@ -412,7 +405,6 @@ static struct tc_action_ops act_bpf_ops __read_mostly = {
	.init		=	tcf_bpf_init,
	.walk		=	tcf_bpf_walker,
	.lookup		=	tcf_bpf_search,
	.delete		=	tcf_bpf_delete,
	.size		=	sizeof(struct tcf_bpf),
};

+0 −8
Original line number Diff line number Diff line
@@ -198,13 +198,6 @@ static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index,
	return tcf_idr_search(tn, a, index);
}

static int tcf_connmark_delete(struct net *net, u32 index)
{
	struct tc_action_net *tn = net_generic(net, connmark_net_id);

	return tcf_idr_delete_index(tn, index);
}

static struct tc_action_ops act_connmark_ops = {
	.kind		=	"connmark",
	.type		=	TCA_ACT_CONNMARK,
@@ -214,7 +207,6 @@ static struct tc_action_ops act_connmark_ops = {
	.init		=	tcf_connmark_init,
	.walk		=	tcf_connmark_walker,
	.lookup		=	tcf_connmark_search,
	.delete		=	tcf_connmark_delete,
	.size		=	sizeof(struct tcf_connmark_info),
};

+0 −8
Original line number Diff line number Diff line
@@ -659,13 +659,6 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act)
	return nla_total_size(sizeof(struct tc_csum));
}

static int tcf_csum_delete(struct net *net, u32 index)
{
	struct tc_action_net *tn = net_generic(net, csum_net_id);

	return tcf_idr_delete_index(tn, index);
}

static struct tc_action_ops act_csum_ops = {
	.kind		= "csum",
	.type		= TCA_ACT_CSUM,
@@ -677,7 +670,6 @@ static struct tc_action_ops act_csum_ops = {
	.walk		= tcf_csum_walker,
	.lookup		= tcf_csum_search,
	.get_fill_size  = tcf_csum_get_fill_size,
	.delete		= tcf_csum_delete,
	.size		= sizeof(struct tcf_csum),
};

Loading