diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-08-22 23:27:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-23 23:43:15 -0400 |
commit | 0eec32ff350348e635b3b8d87b989117ce045d25 (patch) | |
tree | f72ca99d915191d89e3446d599c0937cf6405acf /net | |
parent | 7abac686026ec1af38f6e766369dbfe4007949b6 (diff) |
net_sched: act_csum: coding style cleanup
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/act_csum.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index be41f1cc10ee..67dc7ce9b63a 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c | |||
@@ -42,9 +42,9 @@ static u32 csum_idx_gen; | |||
42 | static DEFINE_RWLOCK(csum_lock); | 42 | static DEFINE_RWLOCK(csum_lock); |
43 | 43 | ||
44 | static struct tcf_hashinfo csum_hash_info = { | 44 | static struct tcf_hashinfo csum_hash_info = { |
45 | .htab = tcf_csum_ht, | 45 | .htab = tcf_csum_ht, |
46 | .hmask = CSUM_TAB_MASK, | 46 | .hmask = CSUM_TAB_MASK, |
47 | .lock = &csum_lock, | 47 | .lock = &csum_lock, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { | 50 | static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { |
@@ -73,7 +73,8 @@ static int tcf_csum_init(struct nlattr *nla, struct nlattr *est, | |||
73 | 73 | ||
74 | pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info); | 74 | pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info); |
75 | if (!pc) { | 75 | if (!pc) { |
76 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, &csum_idx_gen, &csum_hash_info); | 76 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind, |
77 | &csum_idx_gen, &csum_hash_info); | ||
77 | if (IS_ERR(pc)) | 78 | if (IS_ERR(pc)) |
78 | return PTR_ERR(pc); | 79 | return PTR_ERR(pc); |
79 | p = to_tcf_csum(pc); | 80 | p = to_tcf_csum(pc); |
@@ -230,8 +231,9 @@ static int tcf_csum_ipv4_udp(struct sk_buff *skb, struct iphdr *iph, | |||
230 | struct udphdr *udph; | 231 | struct udphdr *udph; |
231 | u16 ul; | 232 | u16 ul; |
232 | 233 | ||
233 | /* Support both UDP and UDPLITE checksum algorithms, | 234 | /* |
234 | * Don't use udph->len to get the real length without any protocol check, | 235 | * Support both UDP and UDPLITE checksum algorithms, Don't use |
236 | * udph->len to get the real length without any protocol check, | ||
235 | * UDPLITE uses udph->len for another thing, | 237 | * UDPLITE uses udph->len for another thing, |
236 | * Use iph->tot_len, or just ipl. | 238 | * Use iph->tot_len, or just ipl. |
237 | */ | 239 | */ |
@@ -249,10 +251,8 @@ static int tcf_csum_ipv4_udp(struct sk_buff *skb, struct iphdr *iph, | |||
249 | if (udplite) { | 251 | if (udplite) { |
250 | if (ul == 0) | 252 | if (ul == 0) |
251 | skb->csum = csum_partial(udph, ipl - ihl, 0); | 253 | skb->csum = csum_partial(udph, ipl - ihl, 0); |
252 | |||
253 | else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl)) | 254 | else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl)) |
254 | skb->csum = csum_partial(udph, ul, 0); | 255 | skb->csum = csum_partial(udph, ul, 0); |
255 | |||
256 | else | 256 | else |
257 | goto ignore_obscure_skb; | 257 | goto ignore_obscure_skb; |
258 | } else { | 258 | } else { |
@@ -282,8 +282,9 @@ static int tcf_csum_ipv6_udp(struct sk_buff *skb, struct ipv6hdr *ip6h, | |||
282 | struct udphdr *udph; | 282 | struct udphdr *udph; |
283 | u16 ul; | 283 | u16 ul; |
284 | 284 | ||
285 | /* Support both UDP and UDPLITE checksum algorithms, | 285 | /* |
286 | * Don't use udph->len to get the real length without any protocol check, | 286 | * Support both UDP and UDPLITE checksum algorithms, Don't use |
287 | * udph->len to get the real length without any protocol check, | ||
287 | * UDPLITE uses udph->len for another thing, | 288 | * UDPLITE uses udph->len for another thing, |
288 | * Use ip6h->payload_len + sizeof(*ip6h) ... , or just ipl. | 289 | * Use ip6h->payload_len + sizeof(*ip6h) ... , or just ipl. |
289 | */ | 290 | */ |
@@ -340,32 +341,32 @@ static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags) | |||
340 | switch (iph->frag_off & htons(IP_OFFSET) ? 0 : iph->protocol) { | 341 | switch (iph->frag_off & htons(IP_OFFSET) ? 0 : iph->protocol) { |
341 | case IPPROTO_ICMP: | 342 | case IPPROTO_ICMP: |
342 | if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP) | 343 | if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP) |
343 | if (!tcf_csum_ipv4_icmp(skb, | 344 | if (!tcf_csum_ipv4_icmp(skb, iph->ihl * 4, |
344 | iph->ihl * 4, ntohs(iph->tot_len))) | 345 | ntohs(iph->tot_len))) |
345 | goto fail; | 346 | goto fail; |
346 | break; | 347 | break; |
347 | case IPPROTO_IGMP: | 348 | case IPPROTO_IGMP: |
348 | if (update_flags & TCA_CSUM_UPDATE_FLAG_IGMP) | 349 | if (update_flags & TCA_CSUM_UPDATE_FLAG_IGMP) |
349 | if (!tcf_csum_ipv4_igmp(skb, | 350 | if (!tcf_csum_ipv4_igmp(skb, iph->ihl * 4, |
350 | iph->ihl * 4, ntohs(iph->tot_len))) | 351 | ntohs(iph->tot_len))) |
351 | goto fail; | 352 | goto fail; |
352 | break; | 353 | break; |
353 | case IPPROTO_TCP: | 354 | case IPPROTO_TCP: |
354 | if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP) | 355 | if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP) |
355 | if (!tcf_csum_ipv4_tcp(skb, iph, | 356 | if (!tcf_csum_ipv4_tcp(skb, iph, iph->ihl * 4, |
356 | iph->ihl * 4, ntohs(iph->tot_len))) | 357 | ntohs(iph->tot_len))) |
357 | goto fail; | 358 | goto fail; |
358 | break; | 359 | break; |
359 | case IPPROTO_UDP: | 360 | case IPPROTO_UDP: |
360 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP) | 361 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP) |
361 | if (!tcf_csum_ipv4_udp(skb, iph, | 362 | if (!tcf_csum_ipv4_udp(skb, iph, iph->ihl * 4, |
362 | iph->ihl * 4, ntohs(iph->tot_len), 0)) | 363 | ntohs(iph->tot_len), 0)) |
363 | goto fail; | 364 | goto fail; |
364 | break; | 365 | break; |
365 | case IPPROTO_UDPLITE: | 366 | case IPPROTO_UDPLITE: |
366 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE) | 367 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE) |
367 | if (!tcf_csum_ipv4_udp(skb, iph, | 368 | if (!tcf_csum_ipv4_udp(skb, iph, iph->ihl * 4, |
368 | iph->ihl * 4, ntohs(iph->tot_len), 1)) | 369 | ntohs(iph->tot_len), 1)) |
369 | goto fail; | 370 | goto fail; |
370 | break; | 371 | break; |
371 | } | 372 | } |
@@ -386,7 +387,7 @@ fail: | |||
386 | } | 387 | } |
387 | 388 | ||
388 | static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, | 389 | static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, |
389 | unsigned int ixhl, unsigned int *pl) | 390 | unsigned int ixhl, unsigned int *pl) |
390 | { | 391 | { |
391 | int off, len, optlen; | 392 | int off, len, optlen; |
392 | unsigned char *xh = (void *)ip6xh; | 393 | unsigned char *xh = (void *)ip6xh; |
@@ -395,8 +396,7 @@ static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, | |||
395 | len = ixhl - off; | 396 | len = ixhl - off; |
396 | 397 | ||
397 | while (len > 1) { | 398 | while (len > 1) { |
398 | switch (xh[off]) | 399 | switch (xh[off]) { |
399 | { | ||
400 | case IPV6_TLV_PAD0: | 400 | case IPV6_TLV_PAD0: |
401 | optlen = 1; | 401 | optlen = 1; |
402 | break; | 402 | break; |
@@ -476,14 +476,14 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) | |||
476 | goto done; | 476 | goto done; |
477 | case IPPROTO_UDP: | 477 | case IPPROTO_UDP: |
478 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP) | 478 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP) |
479 | if (!tcf_csum_ipv6_udp(skb, ip6h, | 479 | if (!tcf_csum_ipv6_udp(skb, ip6h, hl, |
480 | hl, pl + sizeof(*ip6h), 0)) | 480 | pl + sizeof(*ip6h), 0)) |
481 | goto fail; | 481 | goto fail; |
482 | goto done; | 482 | goto done; |
483 | case IPPROTO_UDPLITE: | 483 | case IPPROTO_UDPLITE: |
484 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE) | 484 | if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE) |
485 | if (!tcf_csum_ipv6_udp(skb, ip6h, | 485 | if (!tcf_csum_ipv6_udp(skb, ip6h, hl, |
486 | hl, pl + sizeof(*ip6h), 1)) | 486 | pl + sizeof(*ip6h), 1)) |
487 | goto fail; | 487 | goto fail; |
488 | goto done; | 488 | goto done; |
489 | default: | 489 | default: |
@@ -544,7 +544,6 @@ static int tcf_csum_dump(struct sk_buff *skb, | |||
544 | struct tcf_csum *p = a->priv; | 544 | struct tcf_csum *p = a->priv; |
545 | struct tc_csum opt = { | 545 | struct tc_csum opt = { |
546 | .update_flags = p->update_flags, | 546 | .update_flags = p->update_flags, |
547 | |||
548 | .index = p->tcf_index, | 547 | .index = p->tcf_index, |
549 | .action = p->tcf_action, | 548 | .action = p->tcf_action, |
550 | .refcnt = p->tcf_refcnt - ref, | 549 | .refcnt = p->tcf_refcnt - ref, |
@@ -566,17 +565,17 @@ nla_put_failure: | |||
566 | } | 565 | } |
567 | 566 | ||
568 | static struct tc_action_ops act_csum_ops = { | 567 | static struct tc_action_ops act_csum_ops = { |
569 | .kind = "csum", | 568 | .kind = "csum", |
570 | .hinfo = &csum_hash_info, | 569 | .hinfo = &csum_hash_info, |
571 | .type = TCA_ACT_CSUM, | 570 | .type = TCA_ACT_CSUM, |
572 | .capab = TCA_CAP_NONE, | 571 | .capab = TCA_CAP_NONE, |
573 | .owner = THIS_MODULE, | 572 | .owner = THIS_MODULE, |
574 | .act = tcf_csum, | 573 | .act = tcf_csum, |
575 | .dump = tcf_csum_dump, | 574 | .dump = tcf_csum_dump, |
576 | .cleanup = tcf_csum_cleanup, | 575 | .cleanup = tcf_csum_cleanup, |
577 | .lookup = tcf_hash_search, | 576 | .lookup = tcf_hash_search, |
578 | .init = tcf_csum_init, | 577 | .init = tcf_csum_init, |
579 | .walk = tcf_generic_walker | 578 | .walk = tcf_generic_walker |
580 | }; | 579 | }; |
581 | 580 | ||
582 | MODULE_DESCRIPTION("Checksum updating actions"); | 581 | MODULE_DESCRIPTION("Checksum updating actions"); |