net_sched: act: move idx_gen into struct tcf_hashinfo
authorWANG Cong <xiyou.wangcong@gmail.com>
Fri, 10 Jan 2014 00:13:59 +0000 (16:13 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Jan 2014 19:50:14 +0000 (11:50 -0800)
There is no need to store the index separatedly
since tcf_hashinfo is allocated statically too.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/act_api.h
net/sched/act_api.c
net/sched/act_csum.c
net/sched/act_gact.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/act_skbedit.c

index d34e1f4d897b44cc5d8dff8bdf0e696b7c68cd5c..268f9e6babd72dc68b4aa7ef0f0dd04adadac333 100644 (file)
@@ -39,6 +39,7 @@ struct tcf_hashinfo {
        struct hlist_head       *htab;
        unsigned int            hmask;
        spinlock_t              lock;
+       u32                     index;
 };
 
 static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
@@ -51,6 +52,7 @@ static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask)
        int i;
 
        spin_lock_init(&hf->lock);
+       hf->index = 0;
        hf->hmask = mask;
        hf->htab = kzalloc((mask + 1) * sizeof(struct hlist_head),
                           GFP_KERNEL);
@@ -105,13 +107,12 @@ struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo);
 void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
 int tcf_hash_release(struct tcf_common *p, int bind,
                     struct tcf_hashinfo *hinfo);
-u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
+u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo);
 struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
                                  int bind, struct tcf_hashinfo *hinfo);
 struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
                                   struct tc_action *a, int size,
-                                  int bind, u32 *idx_gen,
-                                  struct tcf_hashinfo *hinfo);
+                                  int bind, struct tcf_hashinfo *hinfo);
 void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
 
 int tcf_register_action(struct tc_action_ops *a);
index f63e1467cd3a7f4094b292d031f6e5c79f009735..74ae3ff0574771d820f9c32209fb98062cdfd14a 100644 (file)
@@ -173,16 +173,16 @@ struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo)
 }
 EXPORT_SYMBOL(tcf_hash_lookup);
 
-u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo)
+u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo)
 {
-       u32 val = *idx_gen;
+       u32 val = hinfo->index;
 
        do {
                if (++val == 0)
                        val = 1;
        } while (tcf_hash_lookup(val, hinfo));
 
-       *idx_gen = val;
+       hinfo->index = val;
        return val;
 }
 EXPORT_SYMBOL(tcf_hash_new_index);
@@ -215,7 +215,7 @@ EXPORT_SYMBOL(tcf_hash_check);
 
 struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
                                   struct tc_action *a, int size, int bind,
-                                  u32 *idx_gen, struct tcf_hashinfo *hinfo)
+                                  struct tcf_hashinfo *hinfo)
 {
        struct tcf_common *p = kzalloc(size, GFP_KERNEL);
 
@@ -227,7 +227,7 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
 
        spin_lock_init(&p->tcfc_lock);
        INIT_HLIST_NODE(&p->tcfc_head);
-       p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo);
+       p->tcfc_index = index ? index : tcf_hash_new_index(hinfo);
        p->tcfc_tm.install = jiffies;
        p->tcfc_tm.lastuse = jiffies;
        if (est) {
index 8b1d65772a8dfee6345bae94328780ace0384dcd..ee28e1ccbbd5c50e43d57bd0d2feb3ee21e4a7a0 100644 (file)
@@ -37,7 +37,6 @@
 #include <net/tc_act/tc_csum.h>
 
 #define CSUM_TAB_MASK 15
-static u32 csum_idx_gen;
 static struct tcf_hashinfo csum_hash_info;
 
 static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
@@ -67,7 +66,7 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
        pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info);
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
-                                    &csum_idx_gen, &csum_hash_info);
+                                    &csum_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                ret = ACT_P_CREATED;
index af5641c290fa1297543421b0691a7b6e63ae6078..f26e6b890cc7aefb35a4844f994e0a1a2d908fed 100644 (file)
@@ -24,7 +24,6 @@
 #include <net/tc_act/tc_gact.h>
 
 #define GACT_TAB_MASK  15
-static u32 gact_idx_gen;
 static struct tcf_hashinfo gact_hash_info;
 
 #ifdef CONFIG_GACT_PROB
@@ -90,7 +89,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
        pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info);
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
-                                    bind, &gact_idx_gen, &gact_hash_info);
+                                    bind, &gact_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                ret = ACT_P_CREATED;
index 242636950ea5baedf3892cb3f90fb2ecfea00562..484bd19601e36fdaa9df1d4e5c37d1b702ab5be6 100644 (file)
@@ -29,7 +29,6 @@
 
 
 #define IPT_TAB_MASK     15
-static u32 ipt_idx_gen;
 static struct tcf_hashinfo ipt_hash_info;
 
 static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook)
@@ -129,7 +128,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
        pc = tcf_hash_check(index, a, bind, &ipt_hash_info);
        if (!pc) {
                pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind,
-                                    &ipt_idx_gen, &ipt_hash_info);
+                                    &ipt_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                ret = ACT_P_CREATED;
index 9dbb8cd64cb00114d503f9c497fa548ff6de4043..5d05b573a6222fb4142af8120eb1276101101d4f 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/if_arp.h>
 
 #define MIRRED_TAB_MASK     7
-static u32 mirred_idx_gen;
 static LIST_HEAD(mirred_list);
 static struct tcf_hashinfo mirred_hash_info;
 
@@ -107,7 +106,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
                if (dev == NULL)
                        return -EINVAL;
                pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind,
-                                    &mirred_idx_gen, &mirred_hash_info);
+                                    &mirred_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                ret = ACT_P_CREATED;
index 584e65503edb07eddeab334e39853f5534808982..a49fa23b49dd9f45e63dfccc6f64ac5f2077b4f4 100644 (file)
@@ -30,7 +30,6 @@
 
 
 #define NAT_TAB_MASK   15
-static u32 nat_idx_gen;
 
 static struct tcf_hashinfo nat_hash_info;
 
@@ -61,7 +60,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
        pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info);
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
-                                    &nat_idx_gen, &nat_hash_info);
+                                    &nat_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                ret = ACT_P_CREATED;
index 729189341933e7b9035a48ca3e4cdc8c8b6b9cca..f361e4e3c314150e7b9eac377be80540c8a799bb 100644 (file)
@@ -24,7 +24,6 @@
 #include <net/tc_act/tc_pedit.h>
 
 #define PEDIT_TAB_MASK 15
-static u32 pedit_idx_gen;
 
 static struct tcf_hashinfo pedit_hash_info;
 
@@ -63,7 +62,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
                if (!parm->nkeys)
                        return -EINVAL;
                pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
-                                    &pedit_idx_gen, &pedit_hash_info);
+                                    &pedit_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
                p = to_pedit(pc);
index 9295b86d5319f6537157efe75adbd1e3f15eaa84..a719fdff575eaa0917f06ceec76237c50f78175e 100644 (file)
@@ -41,7 +41,6 @@ struct tcf_police {
        container_of(pc, struct tcf_police, common)
 
 #define POL_TAB_MASK     15
-static u32 police_idx_gen;
 static struct tcf_hashinfo police_hash_info;
 
 /* old policer structure from before tc actions */
@@ -251,7 +250,7 @@ override:
 
        police->tcfp_t_c = ktime_to_ns(ktime_get());
        police->tcf_index = parm->index ? parm->index :
-               tcf_hash_new_index(&police_idx_gen, &police_hash_info);
+               tcf_hash_new_index(&police_hash_info);
        h = tcf_hash(police->tcf_index, POL_TAB_MASK);
        spin_lock_bh(&police_hash_info.lock);
        hlist_add_head(&police->tcf_head, &police_hash_info.htab[h]);
index b44491e3ec174bbdf12bb117b72a0630d134639e..f7d5406c1fe27a3b871af63983d10a6f461ce77c 100644 (file)
@@ -25,7 +25,6 @@
 #include <net/tc_act/tc_defact.h>
 
 #define SIMP_TAB_MASK     7
-static u32 simp_idx_gen;
 static struct tcf_hashinfo simp_hash_info;
 
 #define SIMP_MAX_DATA  32
@@ -118,7 +117,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
        pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
-                                    &simp_idx_gen, &simp_hash_info);
+                                    &simp_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
 
index 0fa1aad6e20445f8c1eb3a5fb1c73fce32a5db3d..74af4612706000940f2210e9b01ed53990691844 100644 (file)
@@ -28,7 +28,6 @@
 #include <net/tc_act/tc_skbedit.h>
 
 #define SKBEDIT_TAB_MASK     15
-static u32 skbedit_idx_gen;
 static struct tcf_hashinfo skbedit_hash_info;
 
 static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a,
@@ -104,7 +103,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
        pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info);
        if (!pc) {
                pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind,
-                                    &skbedit_idx_gen, &skbedit_hash_info);
+                                    &skbedit_hash_info);
                if (IS_ERR(pc))
                        return PTR_ERR(pc);
 
This page took 0.031004 seconds and 5 git commands to generate.