]> err.no Git - linux-2.6/blobdiff - net/ipv6/icmp.c
Merge branch 'davem-next' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6] / net / ipv6 / icmp.c
index 6b5391ab83462437eff92f4a18bb6e733871b53a..abedf95fdf2dd0ca5f8cfa25cdfe0f6504395592 100644 (file)
@@ -5,8 +5,6 @@
  *     Authors:
  *     Pedro Roque             <roque@di.fc.ul.pt>
  *
- *     $Id: icmp.c,v 1.38 2002/02/08 03:57:19 davem Exp $
- *
  *     Based on net/ipv4/icmp.c
  *
  *     RFC 1885
@@ -64,6 +62,7 @@
 #include <net/addrconf.h>
 #include <net/icmp.h>
 #include <net/xfrm.h>
+#include <net/inet_common.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -163,7 +162,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
                                     struct flowi *fl)
 {
        struct dst_entry *dst;
-       struct net *net = sk->sk_net;
+       struct net *net = sock_net(sk);
        int res = 0;
 
        /* Informational messages are not limited. */
@@ -306,7 +305,7 @@ static inline void mip6_addr_swap(struct sk_buff *skb) {}
 void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                 struct net_device *dev)
 {
-       struct net *net = skb->dev->nd_net;
+       struct net *net = dev_net(skb->dev);
        struct inet6_dev *idev = NULL;
        struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct sock *sk;
@@ -440,33 +439,33 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
        }
 
        if (xfrm_decode_session_reverse(skb, &fl2, AF_INET6))
-               goto out;
+               goto relookup_failed;
 
        if (ip6_dst_lookup(sk, &dst2, &fl))
-               goto out;
+               goto relookup_failed;
 
        err = xfrm_lookup(&dst2, &fl, sk, XFRM_LOOKUP_ICMP);
-       if (err == -ENOENT) {
+       switch (err) {
+       case 0:
+               dst_release(dst);
+               dst = dst2;
+               break;
+       case -EPERM:
+               goto out_dst_release;
+       default:
+relookup_failed:
                if (!dst)
                        goto out;
-               goto route_done;
+               break;
        }
 
-       dst_release(dst);
-       dst = dst2;
-
-       if (err)
-               goto out;
-
 route_done:
        if (ipv6_addr_is_multicast(&fl.fl6_dst))
                hlimit = np->mcast_hops;
        else
                hlimit = np->hop_limit;
        if (hlimit < 0)
-               hlimit = dst_metric(dst, RTAX_HOPLIMIT);
-       if (hlimit < 0)
-               hlimit = ipv6_get_hoplimit(dst->dev);
+               hlimit = ip6_dst_hoplimit(dst);
 
        tclass = np->tclass;
        if (tclass < 0)
@@ -509,7 +508,7 @@ EXPORT_SYMBOL(icmpv6_send);
 
 static void icmpv6_echo_reply(struct sk_buff *skb)
 {
-       struct net *net = skb->dev->nd_net;
+       struct net *net = dev_net(skb->dev);
        struct sock *sk;
        struct inet6_dev *idev;
        struct ipv6_pinfo *np;
@@ -560,9 +559,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
        else
                hlimit = np->hop_limit;
        if (hlimit < 0)
-               hlimit = dst_metric(dst, RTAX_HOPLIMIT);
-       if (hlimit < 0)
-               hlimit = ipv6_get_hoplimit(dst->dev);
+               hlimit = ip6_dst_hoplimit(dst);
 
        tclass = np->tclass;
        if (tclass < 0)
@@ -812,9 +809,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
                return -ENOMEM;
 
        for_each_possible_cpu(i) {
-               struct socket *sock;
-               err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
-                                      &sock);
+               err = inet_ctl_sock_create(&sk, PF_INET6,
+                                          SOCK_RAW, IPPROTO_ICMPV6, net);
                if (err < 0) {
                        printk(KERN_ERR
                               "Failed to initialize the ICMP6 control socket "
@@ -823,10 +819,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
                        goto fail;
                }
 
-               net->ipv6.icmp_sk[i] = sk = sock->sk;
-               sk_change_net(sk, net);
+               net->ipv6.icmp_sk[i] = sk;
 
-               sk->sk_allocation = GFP_ATOMIC;
                /*
                 * Split off their lock-class, because sk->sk_dst_lock
                 * gets used from softirqs, which is safe for
@@ -841,14 +835,12 @@ static int __net_init icmpv6_sk_init(struct net *net)
                 */
                sk->sk_sndbuf =
                        (2 * ((64 * 1024) + sizeof(struct sk_buff)));
-
-               sk->sk_prot->unhash(sk);
        }
        return 0;
 
  fail:
        for (j = 0; j < i; j++)
-               sk_release_kernel(net->ipv6.icmp_sk[j]);
+               inet_ctl_sock_destroy(net->ipv6.icmp_sk[j]);
        kfree(net->ipv6.icmp_sk);
        return err;
 }
@@ -858,7 +850,7 @@ static void __net_exit icmpv6_sk_exit(struct net *net)
        int i;
 
        for_each_possible_cpu(i) {
-               sk_release_kernel(net->ipv6.icmp_sk[i]);
+               inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
        }
        kfree(net->ipv6.icmp_sk);
 }
@@ -962,7 +954,8 @@ ctl_table ipv6_icmp_table_template[] = {
                .data           = &init_net.ipv6.sysctl.icmpv6_time,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = &proc_dointvec
+               .proc_handler   = &proc_dointvec_ms_jiffies,
+               .strategy       = &sysctl_ms_jiffies
        },
        { .ctl_name = 0 },
 };