Merge branch 'master' of github.com:davem330/net
[linux-2.6.git] / net / ipv6 / raw.c
index cc7313b..3486f62 100644 (file)
@@ -130,14 +130,14 @@ static mh_filter_t __rcu *mh_filter __read_mostly;
 
 int rawv6_mh_filter_register(mh_filter_t filter)
 {
-       rcu_assign_pointer(mh_filter, filter);
+       RCU_INIT_POINTER(mh_filter, filter);
        return 0;
 }
 EXPORT_SYMBOL(rawv6_mh_filter_register);
 
 int rawv6_mh_filter_unregister(mh_filter_t filter)
 {
-       rcu_assign_pointer(mh_filter, NULL);
+       RCU_INIT_POINTER(mh_filter, NULL);
        synchronize_rcu();
        return 0;
 }
@@ -372,9 +372,9 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
        read_unlock(&raw_v6_hashinfo.lock);
 }
 
-static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
+static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
 {
-       if ((raw6_sk(sk)->checksum || rcu_dereference_raw(sk->sk_filter)) &&
+       if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
            skb_checksum_complete(skb)) {
                atomic_inc(&sk->sk_drops);
                kfree_skb(skb);
@@ -817,8 +817,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                memset(opt, 0, sizeof(struct ipv6_txoptions));
                opt->tot_len = sizeof(struct ipv6_txoptions);
 
-               err = datagram_send_ctl(sock_net(sk), msg, &fl6, opt, &hlimit,
-                                       &tclass, &dontfrag);
+               err = datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt,
+                                       &hlimit, &tclass, &dontfrag);
                if (err < 0) {
                        fl6_sock_release(flowlabel);
                        return err;
@@ -959,57 +959,54 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname,
                return -EFAULT;
 
        switch (optname) {
-               case IPV6_CHECKSUM:
-                       if (inet_sk(sk)->inet_num == IPPROTO_ICMPV6 &&
-                           level == IPPROTO_IPV6) {
-                               /*
-                                * RFC3542 tells that IPV6_CHECKSUM socket
-                                * option in the IPPROTO_IPV6 level is not
-                                * allowed on ICMPv6 sockets.
-                                * If you want to set it, use IPPROTO_RAW
-                                * level IPV6_CHECKSUM socket option
-                                * (Linux extension).
-                                */
-                               return -EINVAL;
-                       }
+       case IPV6_CHECKSUM:
+               if (inet_sk(sk)->inet_num == IPPROTO_ICMPV6 &&
+                   level == IPPROTO_IPV6) {
+                       /*
+                        * RFC3542 tells that IPV6_CHECKSUM socket
+                        * option in the IPPROTO_IPV6 level is not
+                        * allowed on ICMPv6 sockets.
+                        * If you want to set it, use IPPROTO_RAW
+                        * level IPV6_CHECKSUM socket option
+                        * (Linux extension).
+                        */
+                       return -EINVAL;
+               }
 
-                       /* You may get strange result with a positive odd offset;
-                          RFC2292bis agrees with me. */
-                       if (val > 0 && (val&1))
-                               return -EINVAL;
-                       if (val < 0) {
-                               rp->checksum = 0;
-                       } else {
-                               rp->checksum = 1;
-                               rp->offset = val;
-                       }
+               /* You may get strange result with a positive odd offset;
+                  RFC2292bis agrees with me. */
+               if (val > 0 && (val&1))
+                       return -EINVAL;
+               if (val < 0) {
+                       rp->checksum = 0;
+               } else {
+                       rp->checksum = 1;
+                       rp->offset = val;
+               }
 
-                       return 0;
-                       break;
+               return 0;
 
-               default:
-                       return -ENOPROTOOPT;
+       default:
+               return -ENOPROTOOPT;
        }
 }
 
 static int rawv6_setsockopt(struct sock *sk, int level, int optname,
                          char __user *optval, unsigned int optlen)
 {
-       switch(level) {
-               case SOL_RAW:
-                       break;
+       switch (level) {
+       case SOL_RAW:
+               break;
 
-               case SOL_ICMPV6:
-                       if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
-                               return -EOPNOTSUPP;
-                       return rawv6_seticmpfilter(sk, level, optname, optval,
-                                                  optlen);
-               case SOL_IPV6:
-                       if (optname == IPV6_CHECKSUM)
-                               break;
-               default:
-                       return ipv6_setsockopt(sk, level, optname, optval,
-                                              optlen);
+       case SOL_ICMPV6:
+               if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
+                       return -EOPNOTSUPP;
+               return rawv6_seticmpfilter(sk, level, optname, optval, optlen);
+       case SOL_IPV6:
+               if (optname == IPV6_CHECKSUM)
+                       break;
+       default:
+               return ipv6_setsockopt(sk, level, optname, optval, optlen);
        }
 
        return do_rawv6_setsockopt(sk, level, optname, optval, optlen);
@@ -1075,21 +1072,19 @@ static int do_rawv6_getsockopt(struct sock *sk, int level, int optname,
 static int rawv6_getsockopt(struct sock *sk, int level, int optname,
                          char __user *optval, int __user *optlen)
 {
-       switch(level) {
-               case SOL_RAW:
-                       break;
+       switch (level) {
+       case SOL_RAW:
+               break;
 
-               case SOL_ICMPV6:
-                       if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
-                               return -EOPNOTSUPP;
-                       return rawv6_geticmpfilter(sk, level, optname, optval,
-                                                  optlen);
-               case SOL_IPV6:
-                       if (optname == IPV6_CHECKSUM)
-                               break;
-               default:
-                       return ipv6_getsockopt(sk, level, optname, optval,
-                                              optlen);
+       case SOL_ICMPV6:
+               if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6)
+                       return -EOPNOTSUPP;
+               return rawv6_geticmpfilter(sk, level, optname, optval, optlen);
+       case SOL_IPV6:
+               if (optname == IPV6_CHECKSUM)
+                       break;
+       default:
+               return ipv6_getsockopt(sk, level, optname, optval, optlen);
        }
 
        return do_rawv6_getsockopt(sk, level, optname, optval, optlen);
@@ -1119,31 +1114,29 @@ static int compat_rawv6_getsockopt(struct sock *sk, int level, int optname,
 
 static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg)
 {
-       switch(cmd) {
-               case SIOCOUTQ:
-               {
-                       int amount = sk_wmem_alloc_get(sk);
+       switch (cmd) {
+       case SIOCOUTQ: {
+               int amount = sk_wmem_alloc_get(sk);
 
-                       return put_user(amount, (int __user *)arg);
-               }
-               case SIOCINQ:
-               {
-                       struct sk_buff *skb;
-                       int amount = 0;
-
-                       spin_lock_bh(&sk->sk_receive_queue.lock);
-                       skb = skb_peek(&sk->sk_receive_queue);
-                       if (skb != NULL)
-                               amount = skb->tail - skb->transport_header;
-                       spin_unlock_bh(&sk->sk_receive_queue.lock);
-                       return put_user(amount, (int __user *)arg);
-               }
+               return put_user(amount, (int __user *)arg);
+       }
+       case SIOCINQ: {
+               struct sk_buff *skb;
+               int amount = 0;
+
+               spin_lock_bh(&sk->sk_receive_queue.lock);
+               skb = skb_peek(&sk->sk_receive_queue);
+               if (skb != NULL)
+                       amount = skb->tail - skb->transport_header;
+               spin_unlock_bh(&sk->sk_receive_queue.lock);
+               return put_user(amount, (int __user *)arg);
+       }
 
-               default:
+       default:
 #ifdef CONFIG_IPV6_MROUTE
-                       return ip6mr_ioctl(sk, cmd, (void __user *)arg);
+               return ip6mr_ioctl(sk, cmd, (void __user *)arg);
 #else
-                       return -ENOIOCTLCMD;
+               return -ENOIOCTLCMD;
 #endif
        }
 }