OSDN Git Service

Merge tag 'v3.15-rc1' into perf/urgent
[uclinux-h8/linux.git] / net / sched / act_mirred.c
index 0b2c6d3..4f912c0 100644 (file)
 
 #define MIRRED_TAB_MASK     7
 static LIST_HEAD(mirred_list);
-static struct tcf_hashinfo mirred_hash_info;
 
-static int tcf_mirred_release(struct tcf_mirred *m, int bind)
+static void tcf_mirred_release(struct tc_action *a, int bind)
 {
-       if (m) {
-               if (bind)
-                       m->tcf_bindcnt--;
-               m->tcf_refcnt--;
-               if (!m->tcf_bindcnt && m->tcf_refcnt <= 0) {
-                       list_del(&m->tcfm_list);
-                       if (m->tcfm_dev)
-                               dev_put(m->tcfm_dev);
-                       tcf_hash_destroy(&m->common, &mirred_hash_info);
-                       return 1;
-               }
-       }
-       return 0;
+       struct tcf_mirred *m = to_mirred(a);
+       list_del(&m->tcfm_list);
+       if (m->tcfm_dev)
+               dev_put(m->tcfm_dev);
 }
 
 static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
@@ -61,7 +51,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 +90,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_hash_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 +119,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)
 {
@@ -254,12 +233,11 @@ static struct notifier_block mirred_device_notifier = {
 
 static struct tc_action_ops act_mirred_ops = {
        .kind           =       "mirred",
-       .hinfo          =       &mirred_hash_info,
        .type           =       TCA_ACT_MIRRED,
        .owner          =       THIS_MODULE,
        .act            =       tcf_mirred,
        .dump           =       tcf_mirred_dump,
-       .cleanup        =       tcf_mirred_cleanup,
+       .cleanup        =       tcf_mirred_release,
        .init           =       tcf_mirred_init,
 };
 
@@ -273,19 +251,13 @@ static int __init mirred_init_module(void)
        if (err)
                return err;
 
-       err = tcf_hashinfo_init(&mirred_hash_info, MIRRED_TAB_MASK);
-       if (err) {
-               unregister_netdevice_notifier(&mirred_device_notifier);
-               return err;
-       }
        pr_info("Mirror/redirect action on\n");
-       return tcf_register_action(&act_mirred_ops);
+       return tcf_register_action(&act_mirred_ops, MIRRED_TAB_MASK);
 }
 
 static void __exit mirred_cleanup_module(void)
 {
        tcf_unregister_action(&act_mirred_ops);
-       tcf_hashinfo_destroy(&mirred_hash_info);
        unregister_netdevice_notifier(&mirred_device_notifier);
 }