diff options
author | stephen hemminger <shemminger@vyatta.com> | 2012-09-24 14:12:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-27 18:12:37 -0400 |
commit | 0c5794a66c7c6443759e6098841767958a031187 (patch) | |
tree | bc5206b2ce2fa58fc47f6d94fabc7c1bb9fa6f78 /net | |
parent | d208328765a0ab425e36b5b828285f3337a85451 (diff) |
gre: remove unnecessary rcu_read_lock/unlock
The gre function pointers for receive and error handling are
always called (from gre.c) with rcu_read_lock already held.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/ip_gre.c | 21 | ||||
-rw-r--r-- | net/ipv6/ip6_gre.c | 14 |
2 files changed, 10 insertions, 25 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 0d4c3832d490..1c012cb2cb94 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -557,37 +557,34 @@ static void ipgre_err(struct sk_buff *skb, u32 info) | |||
557 | break; | 557 | break; |
558 | } | 558 | } |
559 | 559 | ||
560 | rcu_read_lock(); | ||
561 | t = ipgre_tunnel_lookup(skb->dev, iph->daddr, iph->saddr, | 560 | t = ipgre_tunnel_lookup(skb->dev, iph->daddr, iph->saddr, |
562 | flags, key, p[1]); | 561 | flags, key, p[1]); |
563 | 562 | ||
564 | if (t == NULL) | 563 | if (t == NULL) |
565 | goto out; | 564 | return; |
566 | 565 | ||
567 | if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { | 566 | if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { |
568 | ipv4_update_pmtu(skb, dev_net(skb->dev), info, | 567 | ipv4_update_pmtu(skb, dev_net(skb->dev), info, |
569 | t->parms.link, 0, IPPROTO_GRE, 0); | 568 | t->parms.link, 0, IPPROTO_GRE, 0); |
570 | goto out; | 569 | return; |
571 | } | 570 | } |
572 | if (type == ICMP_REDIRECT) { | 571 | if (type == ICMP_REDIRECT) { |
573 | ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, | 572 | ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, |
574 | IPPROTO_GRE, 0); | 573 | IPPROTO_GRE, 0); |
575 | goto out; | 574 | return; |
576 | } | 575 | } |
577 | if (t->parms.iph.daddr == 0 || | 576 | if (t->parms.iph.daddr == 0 || |
578 | ipv4_is_multicast(t->parms.iph.daddr)) | 577 | ipv4_is_multicast(t->parms.iph.daddr)) |
579 | goto out; | 578 | return; |
580 | 579 | ||
581 | if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) | 580 | if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) |
582 | goto out; | 581 | return; |
583 | 582 | ||
584 | if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO)) | 583 | if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO)) |
585 | t->err_count++; | 584 | t->err_count++; |
586 | else | 585 | else |
587 | t->err_count = 1; | 586 | t->err_count = 1; |
588 | t->err_time = jiffies; | 587 | t->err_time = jiffies; |
589 | out: | ||
590 | rcu_read_unlock(); | ||
591 | } | 588 | } |
592 | 589 | ||
593 | static inline void ipgre_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb) | 590 | static inline void ipgre_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb) |
@@ -625,7 +622,7 @@ static int ipgre_rcv(struct sk_buff *skb) | |||
625 | __be16 gre_proto; | 622 | __be16 gre_proto; |
626 | 623 | ||
627 | if (!pskb_may_pull(skb, 16)) | 624 | if (!pskb_may_pull(skb, 16)) |
628 | goto drop_nolock; | 625 | goto drop; |
629 | 626 | ||
630 | iph = ip_hdr(skb); | 627 | iph = ip_hdr(skb); |
631 | h = skb->data; | 628 | h = skb->data; |
@@ -636,7 +633,7 @@ static int ipgre_rcv(struct sk_buff *skb) | |||
636 | - We do not support routing headers. | 633 | - We do not support routing headers. |
637 | */ | 634 | */ |
638 | if (flags&(GRE_VERSION|GRE_ROUTING)) | 635 | if (flags&(GRE_VERSION|GRE_ROUTING)) |
639 | goto drop_nolock; | 636 | goto drop; |
640 | 637 | ||
641 | if (flags&GRE_CSUM) { | 638 | if (flags&GRE_CSUM) { |
642 | switch (skb->ip_summed) { | 639 | switch (skb->ip_summed) { |
@@ -664,7 +661,6 @@ static int ipgre_rcv(struct sk_buff *skb) | |||
664 | 661 | ||
665 | gre_proto = *(__be16 *)(h + 2); | 662 | gre_proto = *(__be16 *)(h + 2); |
666 | 663 | ||
667 | rcu_read_lock(); | ||
668 | tunnel = ipgre_tunnel_lookup(skb->dev, | 664 | tunnel = ipgre_tunnel_lookup(skb->dev, |
669 | iph->saddr, iph->daddr, flags, key, | 665 | iph->saddr, iph->daddr, flags, key, |
670 | gre_proto); | 666 | gre_proto); |
@@ -740,14 +736,11 @@ static int ipgre_rcv(struct sk_buff *skb) | |||
740 | 736 | ||
741 | netif_rx(skb); | 737 | netif_rx(skb); |
742 | 738 | ||
743 | rcu_read_unlock(); | ||
744 | return 0; | 739 | return 0; |
745 | } | 740 | } |
746 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); | 741 | icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); |
747 | 742 | ||
748 | drop: | 743 | drop: |
749 | rcu_read_unlock(); | ||
750 | drop_nolock: | ||
751 | kfree_skb(skb); | 744 | kfree_skb(skb); |
752 | return 0; | 745 | return 0; |
753 | } | 746 | } |
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 424d11a4e7ff..b987d4db790f 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -437,14 +437,12 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
437 | ipv6h = (const struct ipv6hdr *)skb->data; | 437 | ipv6h = (const struct ipv6hdr *)skb->data; |
438 | p = (__be16 *)(skb->data + offset); | 438 | p = (__be16 *)(skb->data + offset); |
439 | 439 | ||
440 | rcu_read_lock(); | ||
441 | |||
442 | t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, | 440 | t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, |
443 | flags & GRE_KEY ? | 441 | flags & GRE_KEY ? |
444 | *(((__be32 *)p) + (grehlen / 4) - 1) : 0, | 442 | *(((__be32 *)p) + (grehlen / 4) - 1) : 0, |
445 | p[1]); | 443 | p[1]); |
446 | if (t == NULL) | 444 | if (t == NULL) |
447 | goto out; | 445 | return; |
448 | 446 | ||
449 | switch (type) { | 447 | switch (type) { |
450 | __u32 teli; | 448 | __u32 teli; |
@@ -489,8 +487,6 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
489 | else | 487 | else |
490 | t->err_count = 1; | 488 | t->err_count = 1; |
491 | t->err_time = jiffies; | 489 | t->err_time = jiffies; |
492 | out: | ||
493 | rcu_read_unlock(); | ||
494 | } | 490 | } |
495 | 491 | ||
496 | static inline void ip6gre_ecn_decapsulate_ipv4(const struct ip6_tnl *t, | 492 | static inline void ip6gre_ecn_decapsulate_ipv4(const struct ip6_tnl *t, |
@@ -528,7 +524,7 @@ static int ip6gre_rcv(struct sk_buff *skb) | |||
528 | __be16 gre_proto; | 524 | __be16 gre_proto; |
529 | 525 | ||
530 | if (!pskb_may_pull(skb, sizeof(struct in6_addr))) | 526 | if (!pskb_may_pull(skb, sizeof(struct in6_addr))) |
531 | goto drop_nolock; | 527 | goto drop; |
532 | 528 | ||
533 | ipv6h = ipv6_hdr(skb); | 529 | ipv6h = ipv6_hdr(skb); |
534 | h = skb->data; | 530 | h = skb->data; |
@@ -539,7 +535,7 @@ static int ip6gre_rcv(struct sk_buff *skb) | |||
539 | - We do not support routing headers. | 535 | - We do not support routing headers. |
540 | */ | 536 | */ |
541 | if (flags&(GRE_VERSION|GRE_ROUTING)) | 537 | if (flags&(GRE_VERSION|GRE_ROUTING)) |
542 | goto drop_nolock; | 538 | goto drop; |
543 | 539 | ||
544 | if (flags&GRE_CSUM) { | 540 | if (flags&GRE_CSUM) { |
545 | switch (skb->ip_summed) { | 541 | switch (skb->ip_summed) { |
@@ -567,7 +563,6 @@ static int ip6gre_rcv(struct sk_buff *skb) | |||
567 | 563 | ||
568 | gre_proto = *(__be16 *)(h + 2); | 564 | gre_proto = *(__be16 *)(h + 2); |
569 | 565 | ||
570 | rcu_read_lock(); | ||
571 | tunnel = ip6gre_tunnel_lookup(skb->dev, | 566 | tunnel = ip6gre_tunnel_lookup(skb->dev, |
572 | &ipv6h->saddr, &ipv6h->daddr, key, | 567 | &ipv6h->saddr, &ipv6h->daddr, key, |
573 | gre_proto); | 568 | gre_proto); |
@@ -646,14 +641,11 @@ static int ip6gre_rcv(struct sk_buff *skb) | |||
646 | 641 | ||
647 | netif_rx(skb); | 642 | netif_rx(skb); |
648 | 643 | ||
649 | rcu_read_unlock(); | ||
650 | return 0; | 644 | return 0; |
651 | } | 645 | } |
652 | icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0); | 646 | icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0); |
653 | 647 | ||
654 | drop: | 648 | drop: |
655 | rcu_read_unlock(); | ||
656 | drop_nolock: | ||
657 | kfree_skb(skb); | 649 | kfree_skb(skb); |
658 | return 0; | 650 | return 0; |
659 | } | 651 | } |