From 86062033feb8a1692f7a3d570c652f1b4a4b4b52 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Tue, 11 Feb 2014 17:07:31 -0800 Subject: net_sched: act: hide struct tcf_common from API Now we can totally hide it from modules. tcf_hash_*() API's will operate on struct tc_action, modules don't need to care about the details. Cc: Jamal Hadi Salim Cc: David S. Miller Signed-off-by: Cong Wang Signed-off-by: Jamal Hadi Salim Signed-off-by: David S. Miller --- net/sched/act_mirred.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'net/sched/act_mirred.c') diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 0b2c6d39d396..3edeecafba2f 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -33,8 +33,9 @@ static LIST_HEAD(mirred_list); static struct tcf_hashinfo mirred_hash_info; -static int tcf_mirred_release(struct tcf_mirred *m, int bind) +static int tcf_mirred_release(struct tc_action *a, int bind) { + struct tcf_mirred *m = to_mirred(a); if (m) { if (bind) m->tcf_bindcnt--; @@ -43,7 +44,7 @@ static int tcf_mirred_release(struct tcf_mirred *m, int bind) list_del(&m->tcfm_list); if (m->tcfm_dev) dev_put(m->tcfm_dev); - tcf_hash_destroy(&m->common, &mirred_hash_info); + tcf_hash_destroy(a); return 1; } } @@ -61,7 +62,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, struct nlattr *tb[TCA_MIRRED_MAX + 1]; struct tc_mirred *parm; struct tcf_mirred *m; - struct tcf_common *pc; struct net_device *dev; int ret, ok_push = 0; @@ -101,21 +101,20 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, dev = NULL; } - pc = tcf_hash_check(parm->index, a, bind); - if (!pc) { + if (!tcf_hash_check(parm->index, a, bind)) { if (dev == NULL) return -EINVAL; - pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind); - if (IS_ERR(pc)) - return PTR_ERR(pc); + ret = tcf_hash_create(parm->index, est, a, sizeof(*m), bind); + if (ret) + return ret; ret = ACT_P_CREATED; } else { if (!ovr) { - tcf_mirred_release(to_mirred(pc), bind); + tcf_mirred_release(a, bind); return -EEXIST; } } - m = to_mirred(pc); + m = to_mirred(a); spin_lock_bh(&m->tcf_lock); m->tcf_action = parm->action; @@ -131,21 +130,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, spin_unlock_bh(&m->tcf_lock); if (ret == ACT_P_CREATED) { list_add(&m->tcfm_list, &mirred_list); - tcf_hash_insert(pc, a->ops->hinfo); + tcf_hash_insert(a); } return ret; } -static int tcf_mirred_cleanup(struct tc_action *a, int bind) -{ - struct tcf_mirred *m = a->priv; - - if (m) - return tcf_mirred_release(m, bind); - return 0; -} - static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res) { @@ -259,7 +249,7 @@ static struct tc_action_ops act_mirred_ops = { .owner = THIS_MODULE, .act = tcf_mirred, .dump = tcf_mirred_dump, - .cleanup = tcf_mirred_cleanup, + .cleanup = tcf_mirred_release, .init = tcf_mirred_init, }; -- cgit v1.2.3-59-g8ed1b