net_sched: move tc_action into tcf_common
[cascardo/linux.git] / net / sched / act_simple.c
index 318328d..289af6f 100644 (file)
 #define SIMP_TAB_MASK     7
 
 static int simp_net_id;
+static struct tc_action_ops act_simp_ops;
 
 #define SIMP_MAX_DATA  32
 static int tcf_simp(struct sk_buff *skb, const struct tc_action *a,
                    struct tcf_result *res)
 {
-       struct tcf_defact *d = a->priv;
+       struct tcf_defact *d = to_defact(a);
 
        spin_lock(&d->tcf_lock);
        tcf_lastuse_update(&d->tcf_tm);
@@ -79,7 +80,7 @@ static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = {
 };
 
 static int tcf_simp_init(struct net *net, struct nlattr *nla,
-                        struct nlattr *est, struct tc_action *a,
+                        struct nlattr *est, struct tc_action **a,
                         int ovr, int bind)
 {
        struct tc_action_net *tn = net_generic(net, simp_net_id);
@@ -100,7 +101,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
        if (tb[TCA_DEF_PARMS] == NULL)
                return -EINVAL;
 
-
        parm = nla_data(tb[TCA_DEF_PARMS]);
        exists = tcf_hash_check(tn, parm->index, a, bind);
        if (exists && bind)
@@ -108,7 +108,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
 
        if (tb[TCA_DEF_DATA] == NULL) {
                if (exists)
-                       tcf_hash_release(a, bind);
+                       tcf_hash_release(*a, bind);
                return -EINVAL;
        }
 
@@ -116,22 +116,22 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
 
        if (!exists) {
                ret = tcf_hash_create(tn, parm->index, est, a,
-                                     sizeof(*d), bind, false);
+                                     &act_simp_ops, bind, false);
                if (ret)
                        return ret;
 
-               d = to_defact(a);
+               d = to_defact(*a);
                ret = alloc_defdata(d, defdata);
                if (ret < 0) {
-                       tcf_hash_cleanup(a, est);
+                       tcf_hash_cleanup(*a, est);
                        return ret;
                }
                d->tcf_action = parm->action;
                ret = ACT_P_CREATED;
        } else {
-               d = to_defact(a);
+               d = to_defact(*a);
 
-               tcf_hash_release(a, bind);
+               tcf_hash_release(*a, bind);
                if (!ovr)
                        return -EEXIST;
 
@@ -139,7 +139,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
        }
 
        if (ret == ACT_P_CREATED)
-               tcf_hash_insert(tn, a);
+               tcf_hash_insert(tn, *a);
        return ret;
 }
 
@@ -147,7 +147,7 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
                         int bind, int ref)
 {
        unsigned char *b = skb_tail_pointer(skb);
-       struct tcf_defact *d = a->priv;
+       struct tcf_defact *d = to_defact(a);
        struct tc_defact opt = {
                .index   = d->tcf_index,
                .refcnt  = d->tcf_refcnt - ref,
@@ -172,14 +172,14 @@ nla_put_failure:
 
 static int tcf_simp_walker(struct net *net, struct sk_buff *skb,
                           struct netlink_callback *cb, int type,
-                          struct tc_action *a)
+                          const struct tc_action_ops *ops)
 {
        struct tc_action_net *tn = net_generic(net, simp_net_id);
 
-       return tcf_generic_walker(tn, skb, cb, type, a);
+       return tcf_generic_walker(tn, skb, cb, type, ops);
 }
 
-static int tcf_simp_search(struct net *net, struct tc_action *a, u32 index)
+static int tcf_simp_search(struct net *net, struct tc_action **a, u32 index)
 {
        struct tc_action_net *tn = net_generic(net, simp_net_id);
 
@@ -196,6 +196,7 @@ static struct tc_action_ops act_simp_ops = {
        .init           =       tcf_simp_init,
        .walk           =       tcf_simp_walker,
        .lookup         =       tcf_simp_search,
+       .size           =       sizeof(struct tcf_defact),
 };
 
 static __net_init int simp_init_net(struct net *net)