We can often specify the UTS namespace to use when starting an RPC client.
However sometimes no UTS namespace is available (specifically during system
shutdown as the last NFS mount in a container is unmounted) so fall
back to the initial UTS namespace.

Signed-off-by: Matt Helsley <matth...@us.ibm.com>
Cc: Cedric Le Goater <c...@fr.ibm.com>
Cc: Linux Kernel Mailing List <linux-ker...@vger.kernel.org>
Cc: linux-...@vger.kernel.org
Cc: Trond Myklebust <trond.mykleb...@fys.uio.no>
Cc: Chuck Lever <chuck.le...@oracle.com>
Cc: Eric W. Biederman <ebied...@xmission.com>
Cc: Linux Containers <contain...@lists.osdl.org>

---
 net/sunrpc/clnt.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6.28/net/sunrpc/clnt.c
===================================================================
--- linux-2.6.28.orig/net/sunrpc/clnt.c
+++ linux-2.6.28/net/sunrpc/clnt.c
@@ -128,6 +128,7 @@ static struct rpc_clnt * rpc_new_client(
        struct rpc_version      *version;
        struct rpc_clnt         *clnt = NULL;
        struct rpc_auth         *auth;
+       struct new_utsname      *uts_ns = init_utsname();
        int err;
        size_t len;
 
@@ -213,10 +214,12 @@ static struct rpc_clnt * rpc_new_client(
        }
 
        /* save the nodename */
-       clnt->cl_nodelen = strlen(init_utsname()->nodename);
+       if (current->nsproxy != NULL)
+               uts_ns = utsname();
+       clnt->cl_nodelen = strlen(uts_ns->nodename);
        if (clnt->cl_nodelen > UNX_MAXNODENAME)
                clnt->cl_nodelen = UNX_MAXNODENAME;
-       memcpy(clnt->cl_nodename, init_utsname()->nodename, clnt->cl_nodelen);
+       memcpy(clnt->cl_nodename, uts_ns->nodename, clnt->cl_nodelen);
        rpc_register_client(clnt);
        return clnt;
 

-- 
_______________________________________________
Containers mailing list
contain...@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Devel mailing list
Devel@openvz.org
https://openvz.org/mailman/listinfo/devel

Reply via email to