[NET] NETNS: Omit sock->sk_net without CONFIG_NET_NS.
[deliverable/linux.git] / net / ipv6 / icmp.c
index 8f44d49fcee2b474e3fff7b52c45833ed38a2f1e..63309d10df3a1f1ddadd74ae7d0a28a7972a8b76 100644 (file)
@@ -163,6 +163,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
                                     struct flowi *fl)
 {
        struct dst_entry *dst;
+       struct net *net = sock_net(sk);
        int res = 0;
 
        /* Informational messages are not limited. */
@@ -178,7 +179,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
         * XXX: perhaps the expire for routing entries cloned by
         * this lookup should be more aggressive (not longer than timeout).
         */
-       dst = ip6_route_output(sk, fl);
+       dst = ip6_route_output(net, sk, fl);
        if (dst->error) {
                IP6_INC_STATS(ip6_dst_idev(dst),
                              IPSTATS_MIB_OUTNOROUTES);
@@ -186,7 +187,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
                res = 1;
        } else {
                struct rt6_info *rt = (struct rt6_info *)dst;
-               int tmo = init_net.ipv6.sysctl.icmpv6_time;
+               int tmo = net->ipv6.sysctl.icmpv6_time;
 
                /* Give more bandwidth to wider prefixes. */
                if (rt->rt6i_dst.plen < 128)
@@ -305,6 +306,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 = dev_net(skb->dev);
        struct inet6_dev *idev = NULL;
        struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct sock *sk;
@@ -334,7 +336,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
         */
        addr_type = ipv6_addr_type(&hdr->daddr);
 
-       if (ipv6_chk_addr(&init_net, &hdr->daddr, skb->dev, 0))
+       if (ipv6_chk_addr(net, &hdr->daddr, skb->dev, 0))
                saddr = &hdr->daddr;
 
        /*
@@ -391,7 +393,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
        fl.fl_icmp_code = code;
        security_skb_classify_flow(skb, &fl);
 
-       sk = icmpv6_sk(&init_net);
+       sk = icmpv6_sk(net);
        np = inet6_sk(sk);
 
        if (icmpv6_xmit_lock(sk))
@@ -462,9 +464,7 @@ route_done:
        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)
@@ -507,6 +507,7 @@ EXPORT_SYMBOL(icmpv6_send);
 
 static void icmpv6_echo_reply(struct sk_buff *skb)
 {
+       struct net *net = dev_net(skb->dev);
        struct sock *sk;
        struct inet6_dev *idev;
        struct ipv6_pinfo *np;
@@ -537,7 +538,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
        fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
        security_skb_classify_flow(skb, &fl);
 
-       sk = icmpv6_sk(&init_net);
+       sk = icmpv6_sk(net);
        np = inet6_sk(sk);
 
        if (icmpv6_xmit_lock(sk))
@@ -557,9 +558,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)
@@ -777,6 +776,22 @@ drop_no_count:
        return 0;
 }
 
+void icmpv6_flow_init(struct sock *sk, struct flowi *fl,
+                     u8 type,
+                     const struct in6_addr *saddr,
+                     const struct in6_addr *daddr,
+                     int oif)
+{
+       memset(fl, 0, sizeof(*fl));
+       ipv6_addr_copy(&fl->fl6_src, saddr);
+       ipv6_addr_copy(&fl->fl6_dst, daddr);
+       fl->proto               = IPPROTO_ICMPV6;
+       fl->fl_icmp_type        = type;
+       fl->fl_icmp_code        = 0;
+       fl->oif                 = oif;
+       security_sk_classify_flow(sk, fl);
+}
+
 /*
  * Special lock-class for __icmpv6_sk:
  */
@@ -955,6 +970,10 @@ struct ctl_table *ipv6_icmp_sysctl_init(struct net *net)
        table = kmemdup(ipv6_icmp_table_template,
                        sizeof(ipv6_icmp_table_template),
                        GFP_KERNEL);
+
+       if (table)
+               table[0].data = &net->ipv6.sysctl.icmpv6_time;
+
        return table;
 }
 #endif
This page took 0.025508 seconds and 5 git commands to generate.