[IPV6] ADDRCONF: Convert ipv6_get_saddr() to ipv6_dev_get_saddr().
[deliverable/linux.git] / net / ipv6 / raw.c
index 2663fd1323e4032b4d664698a9b6676c58319d6a..8897ccf8086afacfc643163e89b740cc4a6df13c 100644 (file)
@@ -76,8 +76,9 @@ static void raw_v6_unhash(struct sock *sk)
 }
 
 
-static struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
-               struct in6_addr *loc_addr, struct in6_addr *rmt_addr, int dif)
+static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
+               unsigned short num, struct in6_addr *loc_addr,
+               struct in6_addr *rmt_addr, int dif)
 {
        struct hlist_node *node;
        int is_multicast = ipv6_addr_is_multicast(loc_addr);
@@ -86,6 +87,9 @@ static struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
                if (inet_sk(sk)->num == num) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
 
+                       if (sk->sk_net != net)
+                               continue;
+
                        if (!ipv6_addr_any(&np->daddr) &&
                            !ipv6_addr_equal(&np->daddr, rmt_addr))
                                continue;
@@ -165,6 +169,7 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
        struct sock *sk;
        int delivered = 0;
        __u8 hash;
+       struct net *net;
 
        saddr = &ipv6_hdr(skb)->saddr;
        daddr = saddr + 1;
@@ -182,7 +187,8 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
        if (sk == NULL)
                goto out;
 
-       sk = __raw_v6_lookup(sk, nexthdr, daddr, saddr, IP6CB(skb)->iif);
+       net = skb->dev->nd_net;
+       sk = __raw_v6_lookup(net, sk, nexthdr, daddr, saddr, IP6CB(skb)->iif);
 
        while (sk) {
                int filtered;
@@ -225,7 +231,7 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
                                rawv6_rcv(sk, clone);
                        }
                }
-               sk = __raw_v6_lookup(sk_next(sk), nexthdr, daddr, saddr,
+               sk = __raw_v6_lookup(net, sk_next(sk), nexthdr, daddr, saddr,
                                     IP6CB(skb)->iif);
        }
 out:
@@ -285,7 +291,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                        if (!sk->sk_bound_dev_if)
                                goto out;
 
-                       dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
+                       dev = dev_get_by_index(sk->sk_net, sk->sk_bound_dev_if);
                        if (!dev) {
                                err = -ENODEV;
                                goto out;
@@ -298,7 +304,8 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                v4addr = LOOPBACK4_IPV6;
                if (!(addr_type & IPV6_ADDR_MULTICAST)) {
                        err = -EADDRNOTAVAIL;
-                       if (!ipv6_chk_addr(&addr->sin6_addr, dev, 0)) {
+                       if (!ipv6_chk_addr(sk->sk_net, &addr->sin6_addr,
+                                          dev, 0)) {
                                if (dev)
                                        dev_put(dev);
                                goto out;
@@ -358,6 +365,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
        struct sock *sk;
        int hash;
        struct in6_addr *saddr, *daddr;
+       struct net *net;
 
        hash = nexthdr & (RAW_HTABLE_SIZE - 1);
 
@@ -366,8 +374,9 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
        if (sk != NULL) {
                saddr = &ipv6_hdr(skb)->saddr;
                daddr = &ipv6_hdr(skb)->daddr;
+               net = skb->dev->nd_net;
 
-               while ((sk = __raw_v6_lookup(sk, nexthdr, saddr, daddr,
+               while ((sk = __raw_v6_lookup(net, sk, nexthdr, saddr, daddr,
                                                IP6CB(skb)->iif))) {
                        rawv6_err(sk, skb, NULL, type, code,
                                        inner_offset, info);
@@ -632,6 +641,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
        skb_reserve(skb, hh_len);
 
        skb->priority = sk->sk_priority;
+       skb->mark = sk->sk_mark;
        skb->dst = dst_clone(&rt->u.dst);
 
        skb_put(skb, length);
@@ -758,6 +768,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
         */
        memset(&fl, 0, sizeof(fl));
 
+       fl.mark = sk->sk_mark;
+
        if (sin6) {
                if (addr_len < SIN6_LEN_RFC2133)
                        return -EINVAL;
@@ -1250,7 +1262,7 @@ static const struct seq_operations raw6_seq_ops = {
 
 static int raw6_seq_open(struct inode *inode, struct file *file)
 {
-       return raw_seq_open(file, &raw_v6_hashinfo, PF_INET6);
+       return raw_seq_open(inode, file, &raw_v6_hashinfo, &raw6_seq_ops);
 }
 
 static const struct file_operations raw6_seq_fops = {
@@ -1258,19 +1270,35 @@ static const struct file_operations raw6_seq_fops = {
        .open =         raw6_seq_open,
        .read =         seq_read,
        .llseek =       seq_lseek,
-       .release =      seq_release_private,
+       .release =      seq_release_net,
 };
 
-int __init raw6_proc_init(void)
+static int raw6_init_net(struct net *net)
 {
-       if (!proc_net_fops_create(&init_net, "raw6", S_IRUGO, &raw6_seq_fops))
+       if (!proc_net_fops_create(net, "raw6", S_IRUGO, &raw6_seq_fops))
                return -ENOMEM;
+
        return 0;
 }
 
+static void raw6_exit_net(struct net *net)
+{
+       proc_net_remove(net, "raw6");
+}
+
+static struct pernet_operations raw6_net_ops = {
+       .init = raw6_init_net,
+       .exit = raw6_exit_net,
+};
+
+int __init raw6_proc_init(void)
+{
+       return register_pernet_subsys(&raw6_net_ops);
+}
+
 void raw6_proc_exit(void)
 {
-       proc_net_remove(&init_net, "raw6");
+       unregister_pernet_subsys(&raw6_net_ops);
 }
 #endif /* CONFIG_PROC_FS */
 
@@ -1321,7 +1349,7 @@ out:
        return ret;
 }
 
-void __exit rawv6_exit(void)
+void rawv6_exit(void)
 {
        inet6_unregister_protosw(&rawv6_protosw);
 }
This page took 0.028321 seconds and 5 git commands to generate.