diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-11 21:32:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-11 21:32:17 -0400 |
commit | 1de9243bbfc451962ab716a3f7a7fda26d91c359 (patch) | |
tree | f1bef0699868905459651a2da61575e6c014b467 /net/ipv4/icmp.c | |
parent | 46d3ceabd8d98ed0ad10f20c595ca784e34786c5 (diff) |
ipv4: Pull icmp socket delivery out into a helper function.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 4a049449305f..18e39d1895d4 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -634,18 +634,31 @@ out:; | |||
634 | EXPORT_SYMBOL(icmp_send); | 634 | EXPORT_SYMBOL(icmp_send); |
635 | 635 | ||
636 | 636 | ||
637 | static void icmp_socket_deliver(struct sk_buff *skb, u32 info) | ||
638 | { | ||
639 | const struct iphdr *iph = (const struct iphdr *) skb->data; | ||
640 | const struct net_protocol *ipprot; | ||
641 | int protocol = iph->protocol; | ||
642 | |||
643 | raw_icmp_error(skb, protocol, info); | ||
644 | |||
645 | rcu_read_lock(); | ||
646 | ipprot = rcu_dereference(inet_protos[protocol]); | ||
647 | if (ipprot && ipprot->err_handler) | ||
648 | ipprot->err_handler(skb, info); | ||
649 | rcu_read_unlock(); | ||
650 | } | ||
651 | |||
637 | /* | 652 | /* |
638 | * Handle ICMP_DEST_UNREACH, ICMP_TIME_EXCEED, and ICMP_QUENCH. | 653 | * Handle ICMP_DEST_UNREACH, ICMP_TIME_EXCEED, and ICMP_QUENCH. |
639 | */ | 654 | */ |
640 | 655 | ||
641 | static void icmp_unreach(struct sk_buff *skb) | 656 | static void icmp_unreach(struct sk_buff *skb) |
642 | { | 657 | { |
643 | const struct net_protocol *ipprot; | ||
644 | const struct iphdr *iph; | 658 | const struct iphdr *iph; |
645 | struct icmphdr *icmph; | 659 | struct icmphdr *icmph; |
646 | struct net *net; | 660 | struct net *net; |
647 | u32 info = 0; | 661 | u32 info = 0; |
648 | int protocol; | ||
649 | 662 | ||
650 | net = dev_net(skb_dst(skb)->dev); | 663 | net = dev_net(skb_dst(skb)->dev); |
651 | 664 | ||
@@ -726,19 +739,7 @@ static void icmp_unreach(struct sk_buff *skb) | |||
726 | if (!pskb_may_pull(skb, iph->ihl * 4 + 8)) | 739 | if (!pskb_may_pull(skb, iph->ihl * 4 + 8)) |
727 | goto out; | 740 | goto out; |
728 | 741 | ||
729 | iph = (const struct iphdr *)skb->data; | 742 | icmp_socket_deliver(skb, info); |
730 | protocol = iph->protocol; | ||
731 | |||
732 | /* | ||
733 | * Deliver ICMP message to raw sockets. Pretty useless feature? | ||
734 | */ | ||
735 | raw_icmp_error(skb, protocol, info); | ||
736 | |||
737 | rcu_read_lock(); | ||
738 | ipprot = rcu_dereference(inet_protos[protocol]); | ||
739 | if (ipprot && ipprot->err_handler) | ||
740 | ipprot->err_handler(skb, info); | ||
741 | rcu_read_unlock(); | ||
742 | 743 | ||
743 | out: | 744 | out: |
744 | return; | 745 | return; |