[INET]: Consolidate xxx_the secret_rebuild
[safe/jmp/linux-2.6] / net / ipv6 / raw.c
index d6dedc4..ca24ef1 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *     RAW sockets for IPv6
- *     Linux INET6 implementation 
+ *     Linux INET6 implementation
  *
  *     Authors:
- *     Pedro Roque             <roque@di.fc.ul.pt>     
+ *     Pedro Roque             <roque@di.fc.ul.pt>
  *
  *     Adapted from linux/net/ipv4/raw.c
  *
@@ -11,7 +11,7 @@
  *
  *     Fixes:
  *     Hideaki YOSHIFUJI       :       sin6_scope_id support
- *     YOSHIFUJI,H.@USAGI      :       raw checksum (RFC2292(bis) compliance) 
+ *     YOSHIFUJI,H.@USAGI      :       raw checksum (RFC2292(bis) compliance)
  *     Kazunori MIYAZAWA @USAGI:       change process style to use ip6_append_data
  *
  *     This program is free software; you can redistribute it and/or
@@ -24,7 +24,6 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
-#include <linux/sched.h>
 #include <linux/net.h>
 #include <linux/in6.h>
 #include <linux/netdevice.h>
@@ -36,6 +35,7 @@
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 
+#include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/sock.h>
 #include <net/snmp.h>
@@ -50,7 +50,7 @@
 #include <net/udp.h>
 #include <net/inet_common.h>
 #include <net/tcp_states.h>
-#ifdef CONFIG_IPV6_MIP6
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
 #include <net/mip6.h>
 #endif
 
@@ -71,12 +71,12 @@ static void raw_v6_hash(struct sock *sk)
        write_lock_bh(&raw_v6_lock);
        sk_add_node(sk, list);
        sock_prot_inc_use(sk->sk_prot);
-       write_unlock_bh(&raw_v6_lock);
+       write_unlock_bh(&raw_v6_lock);
 }
 
 static void raw_v6_unhash(struct sock *sk)
 {
-       write_lock_bh(&raw_v6_lock);
+       write_lock_bh(&raw_v6_lock);
        if (sk_del_node_init(sk))
                sock_prot_dec_use(sk->sk_prot);
        write_unlock_bh(&raw_v6_lock);
@@ -138,6 +138,28 @@ static __inline__ int icmpv6_filter(struct sock *sk, struct sk_buff *skb)
        return 0;
 }
 
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
+static int (*mh_filter)(struct sock *sock, struct sk_buff *skb);
+
+int rawv6_mh_filter_register(int (*filter)(struct sock *sock,
+                                          struct sk_buff *skb))
+{
+       rcu_assign_pointer(mh_filter, filter);
+       return 0;
+}
+EXPORT_SYMBOL(rawv6_mh_filter_register);
+
+int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock,
+                                            struct sk_buff *skb))
+{
+       rcu_assign_pointer(mh_filter, NULL);
+       synchronize_rcu();
+       return 0;
+}
+EXPORT_SYMBOL(rawv6_mh_filter_unregister);
+
+#endif
+
 /*
  *     demultiplex raw sockets.
  *     (should consider queueing the skb in the sock receive_queue
@@ -153,7 +175,7 @@ int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
        int delivered = 0;
        __u8 hash;
 
-       saddr = &skb->nh.ipv6h->saddr;
+       saddr = &ipv6_hdr(skb)->saddr;
        daddr = saddr + 1;
 
        hash = nexthdr & (MAX_INET_PROTOS - 1);
@@ -179,16 +201,22 @@ int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
                case IPPROTO_ICMPV6:
                        filtered = icmpv6_filter(sk, skb);
                        break;
-#ifdef CONFIG_IPV6_MIP6
+
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
                case IPPROTO_MH:
+               {
                        /* XXX: To validate MH only once for each packet,
                         * this is placed here. It should be after checking
                         * xfrm policy, however it doesn't. The checking xfrm
                         * policy is placed in rawv6_rcv() because it is
                         * required for each socket.
                         */
-                       filtered = mip6_mh_filter(sk, skb);
+                       int (*filter)(struct sock *sock, struct sk_buff *skb);
+
+                       filter = rcu_dereference(mh_filter);
+                       filtered = filter ? filter(sk, skb) : 0;
                        break;
+               }
 #endif
                default:
                        filtered = 0;
@@ -220,7 +248,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
        struct inet_sock *inet = inet_sk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr;
-       __u32 v4addr = 0;
+       __be32 v4addr = 0;
        int addr_type;
        int err;
 
@@ -250,18 +278,18 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                                 */
                                sk->sk_bound_dev_if = addr->sin6_scope_id;
                        }
-                       
+
                        /* Binding to link-local address requires an interface */
                        if (!sk->sk_bound_dev_if)
                                goto out;
 
-                       dev = dev_get_by_index(sk->sk_bound_dev_if);
+                       dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
                        if (!dev) {
                                err = -ENODEV;
                                goto out;
                        }
                }
-               
+
                /* ipv4 addr of the socket is invalid.  Only the
                 * unspecified and mapped address have a v4 equivalent.
                 */
@@ -290,7 +318,7 @@ out:
 
 void rawv6_err(struct sock *sk, struct sk_buff *skb,
               struct inet6_skb_parm *opt,
-              int type, int code, int offset, u32 info)
+              int type, int code, int offset, __be32 info)
 {
        struct inet_sock *inet = inet_sk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -324,7 +352,7 @@ void rawv6_err(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 || sk->sk_filter) && 
+       if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
            skb_checksum_complete(skb)) {
                /* FIXME: increment a raw6 drops counter here */
                kfree_skb(skb);
@@ -342,10 +370,10 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
 }
 
 /*
- *     This is next to useless... 
+ *     This is next to useless...
  *     if we demultiplex in network layer we don't need the extra call
- *     just to queue the skb... 
- *     maybe we could have the network decide upon a hint if it 
+ *     just to queue the skb...
+ *     maybe we could have the network decide upon a hint if it
  *     should call raw_rcv for demultiplexing
  */
 int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
@@ -353,26 +381,27 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
        struct inet_sock *inet = inet_sk(sk);
        struct raw6_sock *rp = raw6_sk(sk);
 
-        if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
-                kfree_skb(skb);
-                return NET_RX_DROP;
-        }
+       if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
+               kfree_skb(skb);
+               return NET_RX_DROP;
+       }
 
        if (!rp->checksum)
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
        if (skb->ip_summed == CHECKSUM_COMPLETE) {
-               skb_postpull_rcsum(skb, skb->nh.raw,
-                                  skb->h.raw - skb->nh.raw);
-               if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                    &skb->nh.ipv6h->daddr,
+               skb_postpull_rcsum(skb, skb_network_header(skb),
+                                  skb_network_header_len(skb));
+               if (!csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
+                                    &ipv6_hdr(skb)->daddr,
                                     skb->len, inet->num, skb->csum))
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
        }
-       if (skb->ip_summed != CHECKSUM_UNNECESSARY)
-               skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                            &skb->nh.ipv6h->daddr,
-                                            skb->len, inet->num, 0);
+       if (!skb_csum_unnecessary(skb))
+               skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
+                                                        &ipv6_hdr(skb)->daddr,
+                                                        skb->len,
+                                                        inet->num, 0));
 
        if (inet->hdrincl) {
                if (skb_checksum_complete(skb)) {
@@ -404,8 +433,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
 
        if (flags & MSG_OOB)
                return -EOPNOTSUPP;
-               
-       if (addr_len) 
+
+       if (addr_len)
                *addr_len=sizeof(*sin6);
 
        if (flags & MSG_ERRQUEUE)
@@ -416,12 +445,12 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
                goto out;
 
        copied = skb->len;
-       if (copied > len) {
-               copied = len;
-               msg->msg_flags |= MSG_TRUNC;
-       }
+       if (copied > len) {
+               copied = len;
+               msg->msg_flags |= MSG_TRUNC;
+       }
 
-       if (skb->ip_summed==CHECKSUM_UNNECESSARY) {
+       if (skb_csum_unnecessary(skb)) {
                err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
        } else if (msg->msg_flags&MSG_TRUNC) {
                if (__skb_checksum_complete(skb))
@@ -439,7 +468,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
        if (sin6) {
                sin6->sin6_family = AF_INET6;
                sin6->sin6_port = 0;
-               ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
+               ipv6_addr_copy(&sin6->sin6_addr, &ipv6_hdr(skb)->saddr);
                sin6->sin6_flowinfo = 0;
                sin6->sin6_scope_id = 0;
                if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
@@ -479,8 +508,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
        int offset;
        int len;
        int total_len;
-       u32 tmp_csum;
-       u16 csum;
+       __wsum tmp_csum;
+       __sum16 csum;
 
        if (!rp->checksum)
                goto send;
@@ -489,7 +518,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
                goto out;
 
        offset = rp->offset;
-       total_len = inet_sk(sk)->cork.length - (skb->nh.raw - skb->data);
+       total_len = inet_sk(sk)->cork.length - (skb_network_header(skb) -
+                                               skb->data);
        if (offset >= total_len - 1) {
                err = -EINVAL;
                ip6_flush_pending_frames(sk);
@@ -512,7 +542,7 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
                        if (csum_skb)
                                continue;
 
-                       len = skb->len - (skb->h.raw - skb->data);
+                       len = skb->len - skb_transport_offset(skb);
                        if (offset >= len) {
                                offset -= len;
                                continue;
@@ -524,22 +554,21 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
                skb = csum_skb;
        }
 
-       offset += skb->h.raw - skb->data;
+       offset += skb_transport_offset(skb);
        if (skb_copy_bits(skb, offset, &csum, 2))
                BUG();
 
        /* in case cksum was not initialized */
        if (unlikely(csum))
-               tmp_csum = csum_sub(tmp_csum, csum);
+               tmp_csum = csum_sub(tmp_csum, csum_unfold(csum));
 
-       tmp_csum = csum_ipv6_magic(&fl->fl6_src,
+       csum = csum_ipv6_magic(&fl->fl6_src,
                                   &fl->fl6_dst,
                                   total_len, fl->proto, tmp_csum);
 
-       if (tmp_csum == 0)
-               tmp_csum = -1;
+       if (csum == 0 && fl->proto == IPPROTO_UDP)
+               csum = CSUM_MANGLED_0;
 
-       csum = tmp_csum;
        if (skb_store_bits(skb, offset, &csum, 2))
                BUG();
 
@@ -550,7 +579,7 @@ out:
 }
 
 static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
-                       struct flowi *fl, struct rt6_info *rt, 
+                       struct flowi *fl, struct rt6_info *rt,
                        unsigned int flags)
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
@@ -571,22 +600,24 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
        skb = sock_alloc_send_skb(sk, length+hh_len+15,
                                  flags&MSG_DONTWAIT, &err);
        if (skb == NULL)
-               goto error; 
+               goto error;
        skb_reserve(skb, hh_len);
 
        skb->priority = sk->sk_priority;
        skb->dst = dst_clone(&rt->u.dst);
 
-       skb->nh.ipv6h = iph = (struct ipv6hdr *)skb_put(skb, length);
+       skb_put(skb, length);
+       skb_reset_network_header(skb);
+       iph = ipv6_hdr(skb);
 
        skb->ip_summed = CHECKSUM_NONE;
 
-       skb->h.raw = skb->nh.raw;
+       skb->transport_header = skb->network_header;
        err = memcpy_fromiovecend((void *)iph, from, 0, length);
        if (err)
                goto error_fault;
 
-       IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS);         
+       IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTREQUESTS);
        err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
                      dst_output);
        if (err > 0)
@@ -600,8 +631,8 @@ error_fault:
        err = -EFAULT;
        kfree_skb(skb);
 error:
-       IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
-       return err; 
+       IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
+       return err;
 }
 
 static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
@@ -609,9 +640,7 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
        struct iovec *iov;
        u8 __user *type = NULL;
        u8 __user *code = NULL;
-#ifdef CONFIG_IPV6_MIP6
        u8 len = 0;
-#endif
        int probed = 0;
        int i;
 
@@ -644,7 +673,6 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
                                probed = 1;
                        }
                        break;
-#ifdef CONFIG_IPV6_MIP6
                case IPPROTO_MH:
                        if (iov->iov_base && iov->iov_len < 1)
                                break;
@@ -658,7 +686,6 @@ static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
                                len += iov->iov_len;
 
                        break;
-#endif
                default:
                        probed = 1;
                        break;
@@ -689,25 +716,25 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        int err;
 
        /* Rough check on arithmetic overflow,
-          better check is made in ip6_build_xmit
+          better check is made in ip6_append_data().
         */
-       if (len < 0)
+       if (len > INT_MAX)
                return -EMSGSIZE;
 
        /* Mirror BSD error message compatibility */
-       if (msg->msg_flags & MSG_OOB)           
+       if (msg->msg_flags & MSG_OOB)
                return -EOPNOTSUPP;
 
        /*
-        *      Get and verify the address. 
+        *      Get and verify the address.
         */
        memset(&fl, 0, sizeof(fl));
 
        if (sin6) {
-               if (addr_len < SIN6_LEN_RFC2133) 
+               if (addr_len < SIN6_LEN_RFC2133)
                        return -EINVAL;
 
-               if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 
+               if (sin6->sin6_family && sin6->sin6_family != AF_INET6)
                        return(-EAFNOSUPPORT);
 
                /* port is the proto value [0..255] carried in nexthdr */
@@ -745,17 +772,17 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                    ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
                        fl.oif = sin6->sin6_scope_id;
        } else {
-               if (sk->sk_state != TCP_ESTABLISHED) 
+               if (sk->sk_state != TCP_ESTABLISHED)
                        return -EDESTADDRREQ;
-               
+
                proto = inet->num;
                daddr = &np->daddr;
                fl.fl6_flowlabel = np->flow_label;
        }
 
        if (ipv6_addr_any(daddr)) {
-               /* 
-                * unspecified destination address 
+               /*
+                * unspecified destination address
                 * treated as error... is this correct ?
                 */
                fl6_sock_release(flowlabel);
@@ -793,7 +820,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        err = rawv6_probe_proto_opt(&fl, msg);
        if (err)
                goto out;
+
        ipv6_addr_copy(&fl.fl6_dst, daddr);
        if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
@@ -816,8 +843,12 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        if (final_p)
                ipv6_addr_copy(&fl.fl6_dst, final_p);
 
-       if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
-               goto out;
+       if ((err = __xfrm_lookup(&dst, &fl, sk, 1)) < 0) {
+               if (err == -EREMOTE)
+                       err = ip6_dst_blackhole(sk, &dst, &fl);
+               if (err < 0)
+                       goto out;
+       }
 
        if (hlimit < 0) {
                if (ipv6_addr_is_multicast(&fl.fl6_dst))
@@ -852,11 +883,11 @@ back_from_confirm:
                        ip6_flush_pending_frames(sk);
                else if (!(msg->msg_flags & MSG_MORE))
                        err = rawv6_push_pending_frames(sk, &fl, rp);
+               release_sock(sk);
        }
 done:
        dst_release(dst);
-       release_sock(sk);
-out:   
+out:
        fl6_sock_release(flowlabel);
        return err<0?err:len;
 do_confirm:
@@ -867,7 +898,7 @@ do_confirm:
        goto done;
 }
 
-static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, 
+static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
                               char __user *optval, int optlen)
 {
        switch (optname) {
@@ -879,12 +910,12 @@ static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
                return 0;
        default:
                return -ENOPROTOOPT;
-       };
+       }
 
        return 0;
 }
 
-static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, 
+static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
                               char __user *optval, int __user *optlen)
 {
        int len;
@@ -904,7 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
                return 0;
        default:
                return -ENOPROTOOPT;
-       };
+       }
 
        return 0;
 }
@@ -916,7 +947,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname,
        struct raw6_sock *rp = raw6_sk(sk);
        int val;
 
-       if (get_user(val, (int __user *)optval))
+       if (get_user(val, (int __user *)optval))
                return -EFAULT;
 
        switch (optname) {
@@ -958,7 +989,8 @@ static int rawv6_setsockopt(struct sock *sk, int level, int optname,
                default:
                        return ipv6_setsockopt(sk, level, optname, optval,
                                               optlen);
-       };
+       }
+
        return do_rawv6_setsockopt(sk, level, optname, optval, optlen);
 }
 
@@ -979,7 +1011,7 @@ static int compat_rawv6_setsockopt(struct sock *sk, int level, int optname,
        default:
                return compat_ipv6_setsockopt(sk, level, optname,
                                              optval, optlen);
-       };
+       }
        return do_rawv6_setsockopt(sk, level, optname, optval, optlen);
 }
 #endif
@@ -1032,7 +1064,8 @@ static int rawv6_getsockopt(struct sock *sk, int level, int optname,
                default:
                        return ipv6_getsockopt(sk, level, optname, optval,
                                               optlen);
-       };
+       }
+
        return do_rawv6_getsockopt(sk, level, optname, optval, optlen);
 }
 
@@ -1053,7 +1086,7 @@ static int compat_rawv6_getsockopt(struct sock *sk, int level, int optname,
        default:
                return compat_ipv6_getsockopt(sk, level, optname,
                                              optval, optlen);
-       };
+       }
        return do_rawv6_getsockopt(sk, level, optname, optval, optlen);
 }
 #endif
@@ -1074,7 +1107,7 @@ static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg)
                        spin_lock_bh(&sk->sk_receive_queue.lock);
                        skb = skb_peek(&sk->sk_receive_queue);
                        if (skb != NULL)
-                               amount = skb->tail - skb->h.raw;
+                               amount = skb->tail - skb->transport_header;
                        spin_unlock_bh(&sk->sk_receive_queue.lock);
                        return put_user(amount, (int __user *)arg);
                }
@@ -1094,10 +1127,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);
 }
@@ -1215,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
                   dest->s6_addr32[0], dest->s6_addr32[1],
                   dest->s6_addr32[2], dest->s6_addr32[3], destp,
-                  sp->sk_state, 
+                  sp->sk_state,
                   atomic_read(&sp->sk_wmem_alloc),
                   atomic_read(&sp->sk_rmem_alloc),
                   0, 0L, 0,
@@ -1238,7 +1280,7 @@ static int raw6_seq_show(struct seq_file *seq, void *v)
        return 0;
 }
 
-static struct seq_operations raw6_seq_ops = {
+static const struct seq_operations raw6_seq_ops = {
        .start =        raw6_seq_start,
        .next =         raw6_seq_next,
        .stop =         raw6_seq_stop,
@@ -1247,24 +1289,11 @@ static struct seq_operations raw6_seq_ops = {
 
 static int raw6_seq_open(struct inode *inode, struct file *file)
 {
-       struct seq_file *seq;
-       int rc = -ENOMEM;
-       struct raw6_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
-       if (!s)
-               goto out;
-       rc = seq_open(file, &raw6_seq_ops);
-       if (rc)
-               goto out_kfree;
-       seq = file->private_data;
-       seq->private = s;
-out:
-       return rc;
-out_kfree:
-       kfree(s);
-       goto out;
+       return seq_open_private(file, &raw6_seq_ops,
+                       sizeof(struct raw6_iter_state));
 }
 
-static struct file_operations raw6_seq_fops = {
+static const struct file_operations raw6_seq_fops = {
        .owner =        THIS_MODULE,
        .open =         raw6_seq_open,
        .read =         seq_read,
@@ -1274,13 +1303,13 @@ static struct file_operations raw6_seq_fops = {
 
 int __init raw6_proc_init(void)
 {
-       if (!proc_net_fops_create("raw6", S_IRUGO, &raw6_seq_fops))
+       if (!proc_net_fops_create(&init_net, "raw6", S_IRUGO, &raw6_seq_fops))
                return -ENOMEM;
        return 0;
 }
 
 void raw6_proc_exit(void)
 {
-       proc_net_remove("raw6");
+       proc_net_remove(&init_net, "raw6");
 }
 #endif /* CONFIG_PROC_FS */