[NETNS][RAW]: Make /proc/net/raw(6) show per-namespace socket list.
[deliverable/linux.git] / net / ipv6 / raw.c
index 45a580e843dcca7f295d206a86aa37a83eadb0b1..026fa910cb7032f70c70037c98d5cebc67d11d1f 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:
@@ -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(&init_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);
@@ -1250,7 +1259,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, PF_INET6);
 }
 
 static const struct file_operations raw6_seq_fops = {
@@ -1258,7 +1267,7 @@ 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)
This page took 0.026896 seconds and 5 git commands to generate.