diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-02-11 20:07:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-12 19:23:32 -0500 |
commit | 86062033feb8a1692f7a3d570c652f1b4a4b4b52 (patch) | |
tree | 1f17c34b7d610f666ffd9e20adbe998d846c7b9b /net/sched/act_ipt.c | |
parent | 7282ec8cb4f82287c2aef20a24328b42c630f7cb (diff) |
net_sched: act: hide struct tcf_common from API
Now we can totally hide it from modules. tcf_hash_*() API's
will operate on struct tc_action, modules don't need to care about
the details.
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/act_ipt.c')
-rw-r--r-- | net/sched/act_ipt.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 0a6d62174027..f5e69782d400 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
@@ -69,8 +69,9 @@ static void ipt_destroy_target(struct xt_entry_target *t) | |||
69 | module_put(par.target->me); | 69 | module_put(par.target->me); |
70 | } | 70 | } |
71 | 71 | ||
72 | static int tcf_ipt_release(struct tcf_ipt *ipt, int bind) | 72 | static int tcf_ipt_release(struct tc_action *a, int bind) |
73 | { | 73 | { |
74 | struct tcf_ipt *ipt = to_ipt(a); | ||
74 | int ret = 0; | 75 | int ret = 0; |
75 | if (ipt) { | 76 | if (ipt) { |
76 | if (bind) | 77 | if (bind) |
@@ -80,7 +81,7 @@ static int tcf_ipt_release(struct tcf_ipt *ipt, int bind) | |||
80 | ipt_destroy_target(ipt->tcfi_t); | 81 | ipt_destroy_target(ipt->tcfi_t); |
81 | kfree(ipt->tcfi_tname); | 82 | kfree(ipt->tcfi_tname); |
82 | kfree(ipt->tcfi_t); | 83 | kfree(ipt->tcfi_t); |
83 | tcf_hash_destroy(&ipt->common, &ipt_hash_info); | 84 | tcf_hash_destroy(a); |
84 | ret = ACT_P_DELETED; | 85 | ret = ACT_P_DELETED; |
85 | } | 86 | } |
86 | } | 87 | } |
@@ -99,7 +100,6 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
99 | { | 100 | { |
100 | struct nlattr *tb[TCA_IPT_MAX + 1]; | 101 | struct nlattr *tb[TCA_IPT_MAX + 1]; |
101 | struct tcf_ipt *ipt; | 102 | struct tcf_ipt *ipt; |
102 | struct tcf_common *pc; | ||
103 | struct xt_entry_target *td, *t; | 103 | struct xt_entry_target *td, *t; |
104 | char *tname; | 104 | char *tname; |
105 | int ret = 0, err; | 105 | int ret = 0, err; |
@@ -125,21 +125,20 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
125 | if (tb[TCA_IPT_INDEX] != NULL) | 125 | if (tb[TCA_IPT_INDEX] != NULL) |
126 | index = nla_get_u32(tb[TCA_IPT_INDEX]); | 126 | index = nla_get_u32(tb[TCA_IPT_INDEX]); |
127 | 127 | ||
128 | pc = tcf_hash_check(index, a, bind); | 128 | if (!tcf_hash_check(index, a, bind) ) { |
129 | if (!pc) { | 129 | ret = tcf_hash_create(index, est, a, sizeof(*ipt), bind); |
130 | pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind); | 130 | if (ret) |
131 | if (IS_ERR(pc)) | 131 | return ret; |
132 | return PTR_ERR(pc); | ||
133 | ret = ACT_P_CREATED; | 132 | ret = ACT_P_CREATED; |
134 | } else { | 133 | } else { |
135 | if (bind)/* dont override defaults */ | 134 | if (bind)/* dont override defaults */ |
136 | return 0; | 135 | return 0; |
137 | tcf_ipt_release(to_ipt(pc), bind); | 136 | tcf_ipt_release(a, bind); |
138 | 137 | ||
139 | if (!ovr) | 138 | if (!ovr) |
140 | return -EEXIST; | 139 | return -EEXIST; |
141 | } | 140 | } |
142 | ipt = to_ipt(pc); | 141 | ipt = to_ipt(a); |
143 | 142 | ||
144 | hook = nla_get_u32(tb[TCA_IPT_HOOK]); | 143 | hook = nla_get_u32(tb[TCA_IPT_HOOK]); |
145 | 144 | ||
@@ -170,7 +169,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
170 | ipt->tcfi_hook = hook; | 169 | ipt->tcfi_hook = hook; |
171 | spin_unlock_bh(&ipt->tcf_lock); | 170 | spin_unlock_bh(&ipt->tcf_lock); |
172 | if (ret == ACT_P_CREATED) | 171 | if (ret == ACT_P_CREATED) |
173 | tcf_hash_insert(pc, a->ops->hinfo); | 172 | tcf_hash_insert(a); |
174 | return ret; | 173 | return ret; |
175 | 174 | ||
176 | err3: | 175 | err3: |
@@ -178,21 +177,11 @@ err3: | |||
178 | err2: | 177 | err2: |
179 | kfree(tname); | 178 | kfree(tname); |
180 | err1: | 179 | err1: |
181 | if (ret == ACT_P_CREATED) { | 180 | if (ret == ACT_P_CREATED) |
182 | if (est) | 181 | tcf_hash_cleanup(a, est); |
183 | gen_kill_estimator(&pc->tcfc_bstats, | ||
184 | &pc->tcfc_rate_est); | ||
185 | kfree_rcu(pc, tcfc_rcu); | ||
186 | } | ||
187 | return err; | 182 | return err; |
188 | } | 183 | } |
189 | 184 | ||
190 | static int tcf_ipt_cleanup(struct tc_action *a, int bind) | ||
191 | { | ||
192 | struct tcf_ipt *ipt = a->priv; | ||
193 | return tcf_ipt_release(ipt, bind); | ||
194 | } | ||
195 | |||
196 | static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, | 185 | static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, |
197 | struct tcf_result *res) | 186 | struct tcf_result *res) |
198 | { | 187 | { |
@@ -289,7 +278,7 @@ static struct tc_action_ops act_ipt_ops = { | |||
289 | .owner = THIS_MODULE, | 278 | .owner = THIS_MODULE, |
290 | .act = tcf_ipt, | 279 | .act = tcf_ipt, |
291 | .dump = tcf_ipt_dump, | 280 | .dump = tcf_ipt_dump, |
292 | .cleanup = tcf_ipt_cleanup, | 281 | .cleanup = tcf_ipt_release, |
293 | .init = tcf_ipt_init, | 282 | .init = tcf_ipt_init, |
294 | }; | 283 | }; |
295 | 284 | ||
@@ -300,7 +289,7 @@ static struct tc_action_ops act_xt_ops = { | |||
300 | .owner = THIS_MODULE, | 289 | .owner = THIS_MODULE, |
301 | .act = tcf_ipt, | 290 | .act = tcf_ipt, |
302 | .dump = tcf_ipt_dump, | 291 | .dump = tcf_ipt_dump, |
303 | .cleanup = tcf_ipt_cleanup, | 292 | .cleanup = tcf_ipt_release, |
304 | .init = tcf_ipt_init, | 293 | .init = tcf_ipt_init, |
305 | }; | 294 | }; |
306 | 295 | ||