[IPV6] RAW: Add checksum default defines for MH.
authorMasahide NAKAMURA <nakam@linux-ipv6.org>
Wed, 7 Feb 2007 08:07:39 +0000 (00:07 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 8 Feb 2007 20:39:05 +0000 (12:39 -0800)
Add checksum default defines for mobility header(MH) which
goes through raw socket. As the result kernel's behavior is
to handle MH checksum as default.

This patch also removes verifying inbound MH checksum at
mip6_mh_filter() since it did not consider user specified
checksum offset and was redundant check with raw socket code.

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/mip6.c
net/ipv6/raw.c

index be7dd7db65d7684424083b66256703f12d3fb182..681bb077eaccf1ef90fd0f0601c2ad4c7afcac21 100644 (file)
@@ -89,7 +89,6 @@ static int mip6_mh_len(int type)
 int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
 {
        struct ip6_mh *mh;
-       int mhlen;
 
        if (!pskb_may_pull(skb, (skb->h.raw - skb->data) + 8) ||
            !pskb_may_pull(skb, (skb->h.raw - skb->data) + ((skb->h.raw[1] + 1) << 3)))
@@ -103,31 +102,6 @@ int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
                mip6_param_prob(skb, 0, (&mh->ip6mh_hdrlen) - skb->nh.raw);
                return -1;
        }
-       mhlen = (mh->ip6mh_hdrlen + 1) << 3;
-
-       if (skb->ip_summed == CHECKSUM_COMPLETE) {
-               skb->ip_summed = CHECKSUM_UNNECESSARY;
-               if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                   &skb->nh.ipv6h->daddr,
-                                   mhlen, IPPROTO_MH,
-                                   skb->csum)) {
-                       LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH hw checksum failed\n");
-                       skb->ip_summed = CHECKSUM_NONE;
-               }
-       }
-       if (skb->ip_summed == CHECKSUM_NONE) {
-               if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                   &skb->nh.ipv6h->daddr,
-                                   mhlen, IPPROTO_MH,
-                                   skb_checksum(skb, 0, mhlen, 0))) {
-                       LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH checksum failed "
-                                      "[" NIP6_FMT " > " NIP6_FMT "]\n",
-                                      NIP6(skb->nh.ipv6h->saddr),
-                                      NIP6(skb->nh.ipv6h->daddr));
-                       return -1;
-               }
-               skb->ip_summed = CHECKSUM_UNNECESSARY;
-       }
 
        if (mh->ip6mh_proto != IPPROTO_NONE) {
                LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n",
index f2e883c9368a7bbea22537cb87fde2bf2465323e..c2d8059e754e4814bb9131d7800dcb4791e4c2f2 100644 (file)
@@ -1094,10 +1094,19 @@ static void rawv6_close(struct sock *sk, long timeout)
 
 static int rawv6_init_sk(struct sock *sk)
 {
-       if (inet_sk(sk)->num == IPPROTO_ICMPV6) {
-               struct raw6_sock *rp = raw6_sk(sk);
+       struct raw6_sock *rp = raw6_sk(sk);
+
+       switch (inet_sk(sk)->num) {
+       case IPPROTO_ICMPV6:
                rp->checksum = 1;
                rp->offset   = 2;
+               break;
+       case IPPROTO_MH:
+               rp->checksum = 1;
+               rp->offset   = 4;
+               break;
+       default:
+               break;
        }
        return(0);
 }