diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-01-19 14:26:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-20 02:31:12 -0500 |
commit | cc7ec456f82da7f89a5b376e613b3ac4311b3e9a (patch) | |
tree | 534729db08c10f40c090261cdc191dd2303dfc5c /net/sched/ematch.c | |
parent | 7180a03118cac7256fb04f929fe34d0aeee92c40 (diff) |
net_sched: cleanups
Cleanup net/sched code to current CodingStyle and practices.
Reduce inline abuse
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/ematch.c')
-rw-r--r-- | net/sched/ematch.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index 5e37da961f80..88d93eb92507 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -93,7 +93,7 @@ | |||
93 | static LIST_HEAD(ematch_ops); | 93 | static LIST_HEAD(ematch_ops); |
94 | static DEFINE_RWLOCK(ematch_mod_lock); | 94 | static DEFINE_RWLOCK(ematch_mod_lock); |
95 | 95 | ||
96 | static inline struct tcf_ematch_ops * tcf_em_lookup(u16 kind) | 96 | static struct tcf_ematch_ops *tcf_em_lookup(u16 kind) |
97 | { | 97 | { |
98 | struct tcf_ematch_ops *e = NULL; | 98 | struct tcf_ematch_ops *e = NULL; |
99 | 99 | ||
@@ -163,8 +163,8 @@ void tcf_em_unregister(struct tcf_ematch_ops *ops) | |||
163 | } | 163 | } |
164 | EXPORT_SYMBOL(tcf_em_unregister); | 164 | EXPORT_SYMBOL(tcf_em_unregister); |
165 | 165 | ||
166 | static inline struct tcf_ematch * tcf_em_get_match(struct tcf_ematch_tree *tree, | 166 | static inline struct tcf_ematch *tcf_em_get_match(struct tcf_ematch_tree *tree, |
167 | int index) | 167 | int index) |
168 | { | 168 | { |
169 | return &tree->matches[index]; | 169 | return &tree->matches[index]; |
170 | } | 170 | } |
@@ -184,7 +184,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
184 | 184 | ||
185 | if (em_hdr->kind == TCF_EM_CONTAINER) { | 185 | if (em_hdr->kind == TCF_EM_CONTAINER) { |
186 | /* Special ematch called "container", carries an index | 186 | /* Special ematch called "container", carries an index |
187 | * referencing an external ematch sequence. */ | 187 | * referencing an external ematch sequence. |
188 | */ | ||
188 | u32 ref; | 189 | u32 ref; |
189 | 190 | ||
190 | if (data_len < sizeof(ref)) | 191 | if (data_len < sizeof(ref)) |
@@ -195,7 +196,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
195 | goto errout; | 196 | goto errout; |
196 | 197 | ||
197 | /* We do not allow backward jumps to avoid loops and jumps | 198 | /* We do not allow backward jumps to avoid loops and jumps |
198 | * to our own position are of course illegal. */ | 199 | * to our own position are of course illegal. |
200 | */ | ||
199 | if (ref <= idx) | 201 | if (ref <= idx) |
200 | goto errout; | 202 | goto errout; |
201 | 203 | ||
@@ -208,7 +210,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
208 | * which automatically releases the reference again, therefore | 210 | * which automatically releases the reference again, therefore |
209 | * the module MUST not be given back under any circumstances | 211 | * the module MUST not be given back under any circumstances |
210 | * here. Be aware, the destroy function assumes that the | 212 | * here. Be aware, the destroy function assumes that the |
211 | * module is held if the ops field is non zero. */ | 213 | * module is held if the ops field is non zero. |
214 | */ | ||
212 | em->ops = tcf_em_lookup(em_hdr->kind); | 215 | em->ops = tcf_em_lookup(em_hdr->kind); |
213 | 216 | ||
214 | if (em->ops == NULL) { | 217 | if (em->ops == NULL) { |
@@ -221,7 +224,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
221 | if (em->ops) { | 224 | if (em->ops) { |
222 | /* We dropped the RTNL mutex in order to | 225 | /* We dropped the RTNL mutex in order to |
223 | * perform the module load. Tell the caller | 226 | * perform the module load. Tell the caller |
224 | * to replay the request. */ | 227 | * to replay the request. |
228 | */ | ||
225 | module_put(em->ops->owner); | 229 | module_put(em->ops->owner); |
226 | err = -EAGAIN; | 230 | err = -EAGAIN; |
227 | } | 231 | } |
@@ -230,7 +234,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
230 | } | 234 | } |
231 | 235 | ||
232 | /* ematch module provides expected length of data, so we | 236 | /* ematch module provides expected length of data, so we |
233 | * can do a basic sanity check. */ | 237 | * can do a basic sanity check. |
238 | */ | ||
234 | if (em->ops->datalen && data_len < em->ops->datalen) | 239 | if (em->ops->datalen && data_len < em->ops->datalen) |
235 | goto errout; | 240 | goto errout; |
236 | 241 | ||
@@ -246,7 +251,8 @@ static int tcf_em_validate(struct tcf_proto *tp, | |||
246 | * TCF_EM_SIMPLE may be specified stating that the | 251 | * TCF_EM_SIMPLE may be specified stating that the |
247 | * data only consists of a u32 integer and the module | 252 | * data only consists of a u32 integer and the module |
248 | * does not expected a memory reference but rather | 253 | * does not expected a memory reference but rather |
249 | * the value carried. */ | 254 | * the value carried. |
255 | */ | ||
250 | if (em_hdr->flags & TCF_EM_SIMPLE) { | 256 | if (em_hdr->flags & TCF_EM_SIMPLE) { |
251 | if (data_len < sizeof(u32)) | 257 | if (data_len < sizeof(u32)) |
252 | goto errout; | 258 | goto errout; |
@@ -334,7 +340,8 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
334 | * The array of rt attributes is parsed in the order as they are | 340 | * The array of rt attributes is parsed in the order as they are |
335 | * provided, their type must be incremental from 1 to n. Even | 341 | * provided, their type must be incremental from 1 to n. Even |
336 | * if it does not serve any real purpose, a failure of sticking | 342 | * if it does not serve any real purpose, a failure of sticking |
337 | * to this policy will result in parsing failure. */ | 343 | * to this policy will result in parsing failure. |
344 | */ | ||
338 | for (idx = 0; nla_ok(rt_match, list_len); idx++) { | 345 | for (idx = 0; nla_ok(rt_match, list_len); idx++) { |
339 | err = -EINVAL; | 346 | err = -EINVAL; |
340 | 347 | ||
@@ -359,7 +366,8 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, | |||
359 | /* Check if the number of matches provided by userspace actually | 366 | /* Check if the number of matches provided by userspace actually |
360 | * complies with the array of matches. The number was used for | 367 | * complies with the array of matches. The number was used for |
361 | * the validation of references and a mismatch could lead to | 368 | * the validation of references and a mismatch could lead to |
362 | * undefined references during the matching process. */ | 369 | * undefined references during the matching process. |
370 | */ | ||
363 | if (idx != tree_hdr->nmatches) { | 371 | if (idx != tree_hdr->nmatches) { |
364 | err = -EINVAL; | 372 | err = -EINVAL; |
365 | goto errout_abort; | 373 | goto errout_abort; |
@@ -449,7 +457,7 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) | |||
449 | .flags = em->flags | 457 | .flags = em->flags |
450 | }; | 458 | }; |
451 | 459 | ||
452 | NLA_PUT(skb, i+1, sizeof(em_hdr), &em_hdr); | 460 | NLA_PUT(skb, i + 1, sizeof(em_hdr), &em_hdr); |
453 | 461 | ||
454 | if (em->ops && em->ops->dump) { | 462 | if (em->ops && em->ops->dump) { |
455 | if (em->ops->dump(skb, em) < 0) | 463 | if (em->ops->dump(skb, em) < 0) |
@@ -478,6 +486,7 @@ static inline int tcf_em_match(struct sk_buff *skb, struct tcf_ematch *em, | |||
478 | struct tcf_pkt_info *info) | 486 | struct tcf_pkt_info *info) |
479 | { | 487 | { |
480 | int r = em->ops->match(skb, em, info); | 488 | int r = em->ops->match(skb, em, info); |
489 | |||
481 | return tcf_em_is_inverted(em) ? !r : r; | 490 | return tcf_em_is_inverted(em) ? !r : r; |
482 | } | 491 | } |
483 | 492 | ||
@@ -527,8 +536,8 @@ pop_stack: | |||
527 | 536 | ||
528 | stack_overflow: | 537 | stack_overflow: |
529 | if (net_ratelimit()) | 538 | if (net_ratelimit()) |
530 | printk(KERN_WARNING "tc ematch: local stack overflow," | 539 | pr_warning("tc ematch: local stack overflow," |
531 | " increase NET_EMATCH_STACK\n"); | 540 | " increase NET_EMATCH_STACK\n"); |
532 | return -1; | 541 | return -1; |
533 | } | 542 | } |
534 | EXPORT_SYMBOL(__tcf_em_tree_match); | 543 | EXPORT_SYMBOL(__tcf_em_tree_match); |