diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-11 23:38:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-11 23:38:08 -0400 |
commit | 94206125c4aac32e43c25bfe1b827e7ab993b7dc (patch) | |
tree | 6cfbc21c6b69efd90ccec6575a3a3c91e0bd8cad /net/ipv4/icmp.c | |
parent | d0da720f9f16a5023cc084bed8968702400f6e0f (diff) |
ipv4: Rearrange arguments to ip_rt_redirect()
Pass in the SKB rather than just the IP addresses, so that policy
and other aspects can reside in ip_rt_redirect() rather then
icmp_redirect().
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 588514627aa7..70a793559bb5 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -755,40 +755,16 @@ out_err: | |||
755 | 755 | ||
756 | static void icmp_redirect(struct sk_buff *skb) | 756 | static void icmp_redirect(struct sk_buff *skb) |
757 | { | 757 | { |
758 | const struct iphdr *iph; | 758 | if (skb->len < sizeof(struct iphdr)) { |
759 | 759 | ICMP_INC_STATS_BH(dev_net(skb->dev), ICMP_MIB_INERRORS); | |
760 | if (skb->len < sizeof(struct iphdr)) | 760 | return; |
761 | goto out_err; | 761 | } |
762 | 762 | ||
763 | /* | ||
764 | * Get the copied header of the packet that caused the redirect | ||
765 | */ | ||
766 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) | 763 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) |
767 | goto out; | 764 | return; |
768 | |||
769 | iph = (const struct iphdr *)skb->data; | ||
770 | |||
771 | switch (icmp_hdr(skb)->code & 7) { | ||
772 | case ICMP_REDIR_NET: | ||
773 | case ICMP_REDIR_NETTOS: | ||
774 | /* | ||
775 | * As per RFC recommendations now handle it as a host redirect. | ||
776 | */ | ||
777 | case ICMP_REDIR_HOST: | ||
778 | case ICMP_REDIR_HOSTTOS: | ||
779 | ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr, | ||
780 | icmp_hdr(skb)->un.gateway, | ||
781 | iph->saddr, skb->dev); | ||
782 | break; | ||
783 | } | ||
784 | 765 | ||
766 | ip_rt_redirect(skb, icmp_hdr(skb)->un.gateway); | ||
785 | icmp_socket_deliver(skb, icmp_hdr(skb)->un.gateway); | 767 | icmp_socket_deliver(skb, icmp_hdr(skb)->un.gateway); |
786 | |||
787 | out: | ||
788 | return; | ||
789 | out_err: | ||
790 | ICMP_INC_STATS_BH(dev_net(skb->dev), ICMP_MIB_INERRORS); | ||
791 | goto out; | ||
792 | } | 768 | } |
793 | 769 | ||
794 | /* | 770 | /* |