Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-drm-fsl-dcu.git] / net / ipv6 / icmp.c
index 4ec876066b3fd1f860882b7601e110cc2db2aa2e..9377fea026824ca61ff7fe716c6957d62e86a8cf 100644 (file)
@@ -107,7 +107,7 @@ static __inline__ void icmpv6_xmit_unlock(void)
        spin_unlock_bh(&icmpv6_socket->sk->sk_lock.slock);
 }
 
-/* 
+/*
  * Slightly more convenient version of icmpv6_send.
  */
 void icmpv6_param_prob(struct sk_buff *skb, int code, int pos)
@@ -153,8 +153,8 @@ static int is_ineligible(struct sk_buff *skb)
 
 static int sysctl_icmpv6_time __read_mostly = 1*HZ;
 
-/* 
- * Check the ICMP output rate limit 
+/*
+ * Check the ICMP output rate limit
  */
 static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
                                     struct flowi *fl)
@@ -170,14 +170,15 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
        if (type == ICMPV6_PKT_TOOBIG)
                return 1;
 
-       /* 
+       /*
         * Look up the output route.
         * 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);
        if (dst->error) {
-               IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES);
+               IP6_INC_STATS(ip6_dst_idev(dst),
+                             IPSTATS_MIB_OUTNOROUTES);
        } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) {
                res = 1;
        } else {
@@ -197,7 +198,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
 /*
  *     an inline helper for the "simple" if statement below
  *     checks if parameter problem report is caused by an
- *     unrecognized IPv6 option that has the Option Type 
+ *     unrecognized IPv6 option that has the Option Type
  *     highest-order two bits set to 10
  */
 
@@ -233,7 +234,7 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
                                                      len, fl->proto,
                                                      skb->csum);
        } else {
-               u32 tmp_csum = 0;
+               __wsum tmp_csum = 0;
 
                skb_queue_walk(&sk->sk_write_queue, skb) {
                        tmp_csum = csum_add(tmp_csum, skb->csum);
@@ -241,13 +242,11 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
 
                tmp_csum = csum_partial((char *)icmp6h,
                                        sizeof(struct icmp6hdr), tmp_csum);
-               tmp_csum = csum_ipv6_magic(&fl->fl6_src,
-                                          &fl->fl6_dst,
-                                          len, fl->proto, tmp_csum);
-               icmp6h->icmp6_cksum = tmp_csum;
+               icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src,
+                                                     &fl->fl6_dst,
+                                                     len, fl->proto,
+                                                     tmp_csum);
        }
-       if (icmp6h->icmp6_cksum == 0)
-               icmp6h->icmp6_cksum = -1;
        ip6_push_pending_frames(sk);
 out:
        return err;
@@ -263,7 +262,7 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st
 {
        struct icmpv6_msg *msg = (struct icmpv6_msg *) from;
        struct sk_buff *org_skb = msg->skb;
-       __u32 csum = 0;
+       __wsum csum = 0;
 
        csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
                                      to, len, csum);
@@ -299,7 +298,7 @@ static inline void mip6_addr_swap(struct sk_buff *skb) {}
 /*
  *     Send an ICMP message in response to a packet in error
  */
-void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, 
+void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                 struct net_device *dev)
 {
        struct inet6_dev *idev = NULL;
@@ -321,7 +320,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                return;
 
        /*
-        *      Make sure we respect the rules 
+        *      Make sure we respect the rules
         *      i.e. RFC 1885 2.4(e)
         *      Rule (e.1) is enforced by not using icmpv6_send
         *      in any code that processes icmp errors.
@@ -337,8 +336,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
 
        if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
                if (type != ICMPV6_PKT_TOOBIG &&
-                   !(type == ICMPV6_PARAMPROB && 
-                     code == ICMPV6_UNK_OPTION && 
+                   !(type == ICMPV6_PARAMPROB &&
+                     code == ICMPV6_UNK_OPTION &&
                      (opt_unrec(skb, info))))
                        return;
 
@@ -365,7 +364,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
                return;
        }
 
-       /* 
+       /*
         *      Never answer to a ICMP packet.
         */
        if (is_ineligible(skb)) {
@@ -544,18 +543,18 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
        }
        err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));
 
-        ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
-        ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
+       ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
+       ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
 
-out_put: 
+out_put:
        if (likely(idev != NULL))
                in6_dev_put(idev);
        dst_release(dst);
-out: 
+out:
        icmpv6_xmit_unlock();
 }
 
-static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
+static void icmpv6_notify(struct sk_buff *skb, int type, int code, __be32 info)
 {
        struct in6_addr *saddr, *daddr;
        struct inet6_protocol *ipprot;
@@ -609,7 +608,7 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
        }
        read_unlock(&raw_v6_lock);
 }
-  
+
 /*
  *     Handle icmp messages
  */
@@ -637,8 +636,8 @@ static int icmpv6_rcv(struct sk_buff **pskb)
                        break;
                /* fall through */
        case CHECKSUM_NONE:
-               skb->csum = ~csum_ipv6_magic(saddr, daddr, skb->len,
-                                            IPPROTO_ICMPV6, 0);
+               skb->csum = ~csum_unfold(csum_ipv6_magic(saddr, daddr, skb->len,
+                                            IPPROTO_ICMPV6, 0));
                if (__skb_checksum_complete(skb)) {
                        LIMIT_NETDEBUG(KERN_DEBUG "ICMPv6 checksum failed [" NIP6_FMT " > " NIP6_FMT "]\n",
                                       NIP6(*saddr), NIP6(*daddr));
@@ -723,9 +722,9 @@ static int icmpv6_rcv(struct sk_buff **pskb)
                if (type & ICMPV6_INFOMSG_MASK)
                        break;
 
-               /* 
-                * error of unknown type. 
-                * must pass to upper level 
+               /*
+                * error of unknown type.
+                * must pass to upper level
                 */
 
                icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu);
@@ -853,7 +852,7 @@ int icmpv6_err_convert(int type, int code, int *err)
        case ICMPV6_PKT_TOOBIG:
                *err = EMSGSIZE;
                break;
-               
+
        case ICMPV6_PARAMPROB:
                *err = EPROTO;
                fatal = 1;