diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-01-09 19:13:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-13 14:50:14 -0500 |
commit | ddafd34f419546f1eb7c343178685f059c3cf127 (patch) | |
tree | 56eacb6abe0c856904632e437baf6cef62cbb39c /net/sched | |
parent | 600adc18eba823f9fd8ed5fec8b04f11dddf3884 (diff) |
net_sched: act: move idx_gen into struct tcf_hashinfo
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>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/act_api.c | 10 | ||||
-rw-r--r-- | net/sched/act_csum.c | 3 | ||||
-rw-r--r-- | net/sched/act_gact.c | 3 | ||||
-rw-r--r-- | net/sched/act_ipt.c | 3 | ||||
-rw-r--r-- | net/sched/act_mirred.c | 3 | ||||
-rw-r--r-- | net/sched/act_nat.c | 3 | ||||
-rw-r--r-- | net/sched/act_pedit.c | 3 | ||||
-rw-r--r-- | net/sched/act_police.c | 3 | ||||
-rw-r--r-- | net/sched/act_simple.c | 3 | ||||
-rw-r--r-- | net/sched/act_skbedit.c | 3 |
10 files changed, 14 insertions, 23 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index f63e1467cd3a..74ae3ff05747 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -173,16 +173,16 @@ struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo) | |||
173 | } | 173 | } |
174 | EXPORT_SYMBOL(tcf_hash_lookup); | 174 | EXPORT_SYMBOL(tcf_hash_lookup); |
175 | 175 | ||
176 | u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo) | 176 | u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo) |
177 | { | 177 | { |
178 | u32 val = *idx_gen; | 178 | u32 val = hinfo->index; |
179 | 179 | ||
180 | do { | 180 | do { |
181 | if (++val == 0) | 181 | if (++val == 0) |
182 | val = 1; | 182 | val = 1; |
183 | } while (tcf_hash_lookup(val, hinfo)); | 183 | } while (tcf_hash_lookup(val, hinfo)); |
184 | 184 | ||
185 | *idx_gen = val; | 185 | hinfo->index = val; |
186 | return val; | 186 | return val; |
187 | } | 187 | } |
188 | EXPORT_SYMBOL(tcf_hash_new_index); | 188 | EXPORT_SYMBOL(tcf_hash_new_index); |
@@ -215,7 +215,7 @@ EXPORT_SYMBOL(tcf_hash_check); | |||
215 | 215 | ||
216 | struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, | 216 | struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, |
217 | struct tc_action *a, int size, int bind, | 217 | struct tc_action *a, int size, int bind, |
218 | u32 *idx_gen, struct tcf_hashinfo *hinfo) | 218 | struct tcf_hashinfo *hinfo) |
219 | { | 219 | { |
220 | struct tcf_common *p = kzalloc(size, GFP_KERNEL); | 220 | struct tcf_common *p = kzalloc(size, GFP_KERNEL); |
221 | 221 | ||
@@ -227,7 +227,7 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, | |||
227 | 227 | ||
228 | spin_lock_init(&p->tcfc_lock); | 228 | spin_lock_init(&p->tcfc_lock); |
229 | INIT_HLIST_NODE(&p->tcfc_head); | 229 | INIT_HLIST_NODE(&p->tcfc_head); |
230 | p->tcfc_index = index ? index : tcf_hash_new_index(idx_gen, hinfo); | 230 | p->tcfc_index = index ? index : tcf_hash_new_index(hinfo); |
231 | p->tcfc_tm.install = jiffies; | 231 | p->tcfc_tm.install = jiffies; |
232 | p->tcfc_tm.lastuse = jiffies; | 232 | p->tcfc_tm.lastuse = jiffies; |
233 | if (est) { | 233 | if (est) { |
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index 8b1d65772a8d..ee28e1ccbbd5 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <net/tc_act/tc_csum.h> | 37 | #include <net/tc_act/tc_csum.h> |
38 | 38 | ||
39 | #define CSUM_TAB_MASK 15 | 39 | #define CSUM_TAB_MASK 15 |
40 | static u32 csum_idx_gen; | ||
41 | static struct tcf_hashinfo csum_hash_info; | 40 | static struct tcf_hashinfo csum_hash_info; |
42 | 41 | ||
43 | static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { | 42 | 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, | |||
67 | pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info); | 66 | pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info); |
68 | if (!pc) { | 67 | if (!pc) { |
69 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, | 68 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, |
70 | &csum_idx_gen, &csum_hash_info); | 69 | &csum_hash_info); |
71 | if (IS_ERR(pc)) | 70 | if (IS_ERR(pc)) |
72 | return PTR_ERR(pc); | 71 | return PTR_ERR(pc); |
73 | ret = ACT_P_CREATED; | 72 | ret = ACT_P_CREATED; |
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index af5641c290fa..f26e6b890cc7 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <net/tc_act/tc_gact.h> | 24 | #include <net/tc_act/tc_gact.h> |
25 | 25 | ||
26 | #define GACT_TAB_MASK 15 | 26 | #define GACT_TAB_MASK 15 |
27 | static u32 gact_idx_gen; | ||
28 | static struct tcf_hashinfo gact_hash_info; | 27 | static struct tcf_hashinfo gact_hash_info; |
29 | 28 | ||
30 | #ifdef CONFIG_GACT_PROB | 29 | #ifdef CONFIG_GACT_PROB |
@@ -90,7 +89,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
90 | pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info); | 89 | pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info); |
91 | if (!pc) { | 90 | if (!pc) { |
92 | pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), | 91 | pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), |
93 | bind, &gact_idx_gen, &gact_hash_info); | 92 | bind, &gact_hash_info); |
94 | if (IS_ERR(pc)) | 93 | if (IS_ERR(pc)) |
95 | return PTR_ERR(pc); | 94 | return PTR_ERR(pc); |
96 | ret = ACT_P_CREATED; | 95 | ret = ACT_P_CREATED; |
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 242636950ea5..484bd19601e3 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | #define IPT_TAB_MASK 15 | 31 | #define IPT_TAB_MASK 15 |
32 | static u32 ipt_idx_gen; | ||
33 | static struct tcf_hashinfo ipt_hash_info; | 32 | static struct tcf_hashinfo ipt_hash_info; |
34 | 33 | ||
35 | static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook) | 34 | 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, | |||
129 | pc = tcf_hash_check(index, a, bind, &ipt_hash_info); | 128 | pc = tcf_hash_check(index, a, bind, &ipt_hash_info); |
130 | if (!pc) { | 129 | if (!pc) { |
131 | pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind, | 130 | pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind, |
132 | &ipt_idx_gen, &ipt_hash_info); | 131 | &ipt_hash_info); |
133 | if (IS_ERR(pc)) | 132 | if (IS_ERR(pc)) |
134 | return PTR_ERR(pc); | 133 | return PTR_ERR(pc); |
135 | ret = ACT_P_CREATED; | 134 | ret = ACT_P_CREATED; |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 9dbb8cd64cb0..5d05b573a622 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/if_arp.h> | 30 | #include <linux/if_arp.h> |
31 | 31 | ||
32 | #define MIRRED_TAB_MASK 7 | 32 | #define MIRRED_TAB_MASK 7 |
33 | static u32 mirred_idx_gen; | ||
34 | static LIST_HEAD(mirred_list); | 33 | static LIST_HEAD(mirred_list); |
35 | static struct tcf_hashinfo mirred_hash_info; | 34 | static struct tcf_hashinfo mirred_hash_info; |
36 | 35 | ||
@@ -107,7 +106,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, | |||
107 | if (dev == NULL) | 106 | if (dev == NULL) |
108 | return -EINVAL; | 107 | return -EINVAL; |
109 | pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind, | 108 | pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind, |
110 | &mirred_idx_gen, &mirred_hash_info); | 109 | &mirred_hash_info); |
111 | if (IS_ERR(pc)) | 110 | if (IS_ERR(pc)) |
112 | return PTR_ERR(pc); | 111 | return PTR_ERR(pc); |
113 | ret = ACT_P_CREATED; | 112 | ret = ACT_P_CREATED; |
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 584e65503edb..a49fa23b49dd 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | #define NAT_TAB_MASK 15 | 32 | #define NAT_TAB_MASK 15 |
33 | static u32 nat_idx_gen; | ||
34 | 33 | ||
35 | static struct tcf_hashinfo nat_hash_info; | 34 | static struct tcf_hashinfo nat_hash_info; |
36 | 35 | ||
@@ -61,7 +60,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
61 | pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info); | 60 | pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info); |
62 | if (!pc) { | 61 | if (!pc) { |
63 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, | 62 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, |
64 | &nat_idx_gen, &nat_hash_info); | 63 | &nat_hash_info); |
65 | if (IS_ERR(pc)) | 64 | if (IS_ERR(pc)) |
66 | return PTR_ERR(pc); | 65 | return PTR_ERR(pc); |
67 | ret = ACT_P_CREATED; | 66 | ret = ACT_P_CREATED; |
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 729189341933..f361e4e3c314 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <net/tc_act/tc_pedit.h> | 24 | #include <net/tc_act/tc_pedit.h> |
25 | 25 | ||
26 | #define PEDIT_TAB_MASK 15 | 26 | #define PEDIT_TAB_MASK 15 |
27 | static u32 pedit_idx_gen; | ||
28 | 27 | ||
29 | static struct tcf_hashinfo pedit_hash_info; | 28 | static struct tcf_hashinfo pedit_hash_info; |
30 | 29 | ||
@@ -63,7 +62,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
63 | if (!parm->nkeys) | 62 | if (!parm->nkeys) |
64 | return -EINVAL; | 63 | return -EINVAL; |
65 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, | 64 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, |
66 | &pedit_idx_gen, &pedit_hash_info); | 65 | &pedit_hash_info); |
67 | if (IS_ERR(pc)) | 66 | if (IS_ERR(pc)) |
68 | return PTR_ERR(pc); | 67 | return PTR_ERR(pc); |
69 | p = to_pedit(pc); | 68 | p = to_pedit(pc); |
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 9295b86d5319..a719fdff575e 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
@@ -41,7 +41,6 @@ struct tcf_police { | |||
41 | container_of(pc, struct tcf_police, common) | 41 | container_of(pc, struct tcf_police, common) |
42 | 42 | ||
43 | #define POL_TAB_MASK 15 | 43 | #define POL_TAB_MASK 15 |
44 | static u32 police_idx_gen; | ||
45 | static struct tcf_hashinfo police_hash_info; | 44 | static struct tcf_hashinfo police_hash_info; |
46 | 45 | ||
47 | /* old policer structure from before tc actions */ | 46 | /* old policer structure from before tc actions */ |
@@ -251,7 +250,7 @@ override: | |||
251 | 250 | ||
252 | police->tcfp_t_c = ktime_to_ns(ktime_get()); | 251 | police->tcfp_t_c = ktime_to_ns(ktime_get()); |
253 | police->tcf_index = parm->index ? parm->index : | 252 | police->tcf_index = parm->index ? parm->index : |
254 | tcf_hash_new_index(&police_idx_gen, &police_hash_info); | 253 | tcf_hash_new_index(&police_hash_info); |
255 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); | 254 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); |
256 | spin_lock_bh(&police_hash_info.lock); | 255 | spin_lock_bh(&police_hash_info.lock); |
257 | hlist_add_head(&police->tcf_head, &police_hash_info.htab[h]); | 256 | hlist_add_head(&police->tcf_head, &police_hash_info.htab[h]); |
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index b44491e3ec17..f7d5406c1fe2 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <net/tc_act/tc_defact.h> | 25 | #include <net/tc_act/tc_defact.h> |
26 | 26 | ||
27 | #define SIMP_TAB_MASK 7 | 27 | #define SIMP_TAB_MASK 7 |
28 | static u32 simp_idx_gen; | ||
29 | static struct tcf_hashinfo simp_hash_info; | 28 | static struct tcf_hashinfo simp_hash_info; |
30 | 29 | ||
31 | #define SIMP_MAX_DATA 32 | 30 | #define SIMP_MAX_DATA 32 |
@@ -118,7 +117,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
118 | pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); | 117 | pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); |
119 | if (!pc) { | 118 | if (!pc) { |
120 | pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, | 119 | pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, |
121 | &simp_idx_gen, &simp_hash_info); | 120 | &simp_hash_info); |
122 | if (IS_ERR(pc)) | 121 | if (IS_ERR(pc)) |
123 | return PTR_ERR(pc); | 122 | return PTR_ERR(pc); |
124 | 123 | ||
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index 0fa1aad6e204..74af46127060 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <net/tc_act/tc_skbedit.h> | 28 | #include <net/tc_act/tc_skbedit.h> |
29 | 29 | ||
30 | #define SKBEDIT_TAB_MASK 15 | 30 | #define SKBEDIT_TAB_MASK 15 |
31 | static u32 skbedit_idx_gen; | ||
32 | static struct tcf_hashinfo skbedit_hash_info; | 31 | static struct tcf_hashinfo skbedit_hash_info; |
33 | 32 | ||
34 | static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a, | 33 | 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, | |||
104 | pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info); | 103 | pc = tcf_hash_check(parm->index, a, bind, &skbedit_hash_info); |
105 | if (!pc) { | 104 | if (!pc) { |
106 | pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, | 105 | pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind, |
107 | &skbedit_idx_gen, &skbedit_hash_info); | 106 | &skbedit_hash_info); |
108 | if (IS_ERR(pc)) | 107 | if (IS_ERR(pc)) |
109 | return PTR_ERR(pc); | 108 | return PTR_ERR(pc); |
110 | 109 | ||