]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[NETNS][IPV6] af_inet6 - allow socket creation per namespace
authorBenjamin Thery <benjamin.thery@bull.net>
Wed, 5 Mar 2008 18:45:59 +0000 (10:45 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Mar 2008 18:45:59 +0000 (10:45 -0800)
Allow creation of IPv6 raw and datagram sockets in network namespaces
other than init_net.

Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/af_inet6.c

index af5b3078766214d95fac9b3bef55183a06c1084f..430bbd2139c146cdd37b6638b1c11d178029c090 100644 (file)
@@ -92,9 +92,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
        int try_loading_module = 0;
        int err;
 
-       if (net != &init_net)
-               return -EAFNOSUPPORT;
-
        if (sock->type != SOCK_RAW &&
            sock->type != SOCK_DGRAM &&
            !inet_ehash_secret)
@@ -248,6 +245,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        struct sock *sk = sock->sk;
        struct inet_sock *inet = inet_sk(sk);
        struct ipv6_pinfo *np = inet6_sk(sk);
+       struct net *net = sk->sk_net;
        __be32 v4addr = 0;
        unsigned short snum;
        int addr_type = 0;
@@ -278,7 +276,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        /* Check if the address belongs to the host. */
        if (addr_type == IPV6_ADDR_MAPPED) {
                v4addr = addr->sin6_addr.s6_addr32[3];
-               if (inet_addr_type(&init_net, v4addr) != RTN_LOCAL) {
+               if (inet_addr_type(net, v4addr) != RTN_LOCAL) {
                        err = -EADDRNOTAVAIL;
                        goto out;
                }
@@ -300,7 +298,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                                        err = -EINVAL;
                                        goto out;
                                }
-                               dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
+                               dev = dev_get_by_index(net, sk->sk_bound_dev_if);
                                if (!dev) {
                                        err = -ENODEV;
                                        goto out;
@@ -312,7 +310,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                         */
                        v4addr = LOOPBACK4_IPV6;
                        if (!(addr_type & IPV6_ADDR_MULTICAST)) {
-                               if (!ipv6_chk_addr(&init_net, &addr->sin6_addr,
+                               if (!ipv6_chk_addr(net, &addr->sin6_addr,
                                                   dev, 0)) {
                                        if (dev)
                                                dev_put(dev);