diff options
Diffstat (limited to 'net/sched/act_gact.c')
-rw-r--r-- | net/sched/act_gact.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index eb9ba60ebab4..a0eed30d5811 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -24,20 +24,12 @@ | |||
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 struct tcf_common *tcf_gact_ht[GACT_TAB_MASK + 1]; | 27 | static struct tcf_hashinfo gact_hash_info; |
28 | static u32 gact_idx_gen; | ||
29 | static DEFINE_RWLOCK(gact_lock); | ||
30 | |||
31 | static struct tcf_hashinfo gact_hash_info = { | ||
32 | .htab = tcf_gact_ht, | ||
33 | .hmask = GACT_TAB_MASK, | ||
34 | .lock = &gact_lock, | ||
35 | }; | ||
36 | 28 | ||
37 | #ifdef CONFIG_GACT_PROB | 29 | #ifdef CONFIG_GACT_PROB |
38 | static int gact_net_rand(struct tcf_gact *gact) | 30 | static int gact_net_rand(struct tcf_gact *gact) |
39 | { | 31 | { |
40 | if (!gact->tcfg_pval || net_random() % gact->tcfg_pval) | 32 | if (!gact->tcfg_pval || prandom_u32() % gact->tcfg_pval) |
41 | return gact->tcf_action; | 33 | return gact->tcf_action; |
42 | return gact->tcfg_paction; | 34 | return gact->tcfg_paction; |
43 | } | 35 | } |
@@ -94,17 +86,16 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
94 | } | 86 | } |
95 | #endif | 87 | #endif |
96 | 88 | ||
97 | pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info); | 89 | pc = tcf_hash_check(parm->index, a, bind); |
98 | if (!pc) { | 90 | if (!pc) { |
99 | pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), | 91 | pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), bind); |
100 | bind, &gact_idx_gen, &gact_hash_info); | ||
101 | if (IS_ERR(pc)) | 92 | if (IS_ERR(pc)) |
102 | return PTR_ERR(pc); | 93 | return PTR_ERR(pc); |
103 | ret = ACT_P_CREATED; | 94 | ret = ACT_P_CREATED; |
104 | } else { | 95 | } else { |
105 | if (bind)/* dont override defaults */ | 96 | if (bind)/* dont override defaults */ |
106 | return 0; | 97 | return 0; |
107 | tcf_hash_release(pc, bind, &gact_hash_info); | 98 | tcf_hash_release(pc, bind, a->ops->hinfo); |
108 | if (!ovr) | 99 | if (!ovr) |
109 | return -EEXIST; | 100 | return -EEXIST; |
110 | } | 101 | } |
@@ -122,7 +113,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
122 | #endif | 113 | #endif |
123 | spin_unlock_bh(&gact->tcf_lock); | 114 | spin_unlock_bh(&gact->tcf_lock); |
124 | if (ret == ACT_P_CREATED) | 115 | if (ret == ACT_P_CREATED) |
125 | tcf_hash_insert(pc, &gact_hash_info); | 116 | tcf_hash_insert(pc, a->ops->hinfo); |
126 | return ret; | 117 | return ret; |
127 | } | 118 | } |
128 | 119 | ||
@@ -131,7 +122,7 @@ static int tcf_gact_cleanup(struct tc_action *a, int bind) | |||
131 | struct tcf_gact *gact = a->priv; | 122 | struct tcf_gact *gact = a->priv; |
132 | 123 | ||
133 | if (gact) | 124 | if (gact) |
134 | return tcf_hash_release(&gact->common, bind, &gact_hash_info); | 125 | return tcf_hash_release(&gact->common, bind, a->ops->hinfo); |
135 | return 0; | 126 | return 0; |
136 | } | 127 | } |
137 | 128 | ||
@@ -202,7 +193,6 @@ static struct tc_action_ops act_gact_ops = { | |||
202 | .kind = "gact", | 193 | .kind = "gact", |
203 | .hinfo = &gact_hash_info, | 194 | .hinfo = &gact_hash_info, |
204 | .type = TCA_ACT_GACT, | 195 | .type = TCA_ACT_GACT, |
205 | .capab = TCA_CAP_NONE, | ||
206 | .owner = THIS_MODULE, | 196 | .owner = THIS_MODULE, |
207 | .act = tcf_gact, | 197 | .act = tcf_gact, |
208 | .dump = tcf_gact_dump, | 198 | .dump = tcf_gact_dump, |
@@ -216,6 +206,9 @@ MODULE_LICENSE("GPL"); | |||
216 | 206 | ||
217 | static int __init gact_init_module(void) | 207 | static int __init gact_init_module(void) |
218 | { | 208 | { |
209 | int err = tcf_hashinfo_init(&gact_hash_info, GACT_TAB_MASK); | ||
210 | if (err) | ||
211 | return err; | ||
219 | #ifdef CONFIG_GACT_PROB | 212 | #ifdef CONFIG_GACT_PROB |
220 | pr_info("GACT probability on\n"); | 213 | pr_info("GACT probability on\n"); |
221 | #else | 214 | #else |
@@ -227,6 +220,7 @@ static int __init gact_init_module(void) | |||
227 | static void __exit gact_cleanup_module(void) | 220 | static void __exit gact_cleanup_module(void) |
228 | { | 221 | { |
229 | tcf_unregister_action(&act_gact_ops); | 222 | tcf_unregister_action(&act_gact_ops); |
223 | tcf_hashinfo_destroy(&gact_hash_info); | ||
230 | } | 224 | } |
231 | 225 | ||
232 | module_init(gact_init_module); | 226 | module_init(gact_init_module); |