[NETNS]: Inet control socket should not hold a namespace.
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / af_inet.c
index 7ab0bd64c9d17a73df6605d6289ba5e5dfe1321f..cf766ad15776afa2e4b86d9842b0c0506fdc507c 100644 (file)
@@ -1250,19 +1250,24 @@ out:
        return segs;
 }
 
-int inet_ctl_sock_create(struct socket **sock, unsigned short family,
-                        unsigned short type, unsigned char protocol)
+int inet_ctl_sock_create(struct sock **sk, unsigned short family,
+                        unsigned short type, unsigned char protocol,
+                        struct net *net)
 {
-       int rc = sock_create_kern(family, type, protocol, sock);
+       struct socket *sock;
+       int rc = sock_create_kern(family, type, protocol, &sock);
 
        if (rc == 0) {
-               (*sock)->sk->sk_allocation = GFP_ATOMIC;
-               inet_sk((*sock)->sk)->uc_ttl = -1;
+               *sk = sock->sk;
+               (*sk)->sk_allocation = GFP_ATOMIC;
+               inet_sk(*sk)->uc_ttl = -1;
                /*
                 * Unhash it so that IP input processing does not even see it,
                 * we do not wish this socket to see incoming packets.
                 */
-               (*sock)->sk->sk_prot->unhash((*sock)->sk);
+               (*sk)->sk_prot->unhash(*sk);
+
+               sk_change_net(*sk, net);
        }
        return rc;
 }