]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NFSv4: Use the net namespace uniquifier if it is set
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 7 Oct 2020 22:24:18 +0000 (18:24 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Fri, 9 Oct 2020 14:05:06 +0000 (10:05 -0400)
If a container sets a net namespace specific uniquifier, then use that
in the setclientid/exchangeid process.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs4proc.c

index 50a96ca2c3853012a7a474c58c48d6d296ca08da..2e33995691f5a42bb2f4c7c65d334e97c747ea1b 100644 (file)
@@ -63,6 +63,7 @@
 #include "callback.h"
 #include "pnfs.h"
 #include "netns.h"
+#include "sysfs.h"
 #include "nfs4idmap.h"
 #include "nfs4session.h"
 #include "fscache.h"
@@ -6094,11 +6095,23 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
 }
 
 static size_t
-nfs4_get_uniquifier(char *buf, size_t buflen)
+nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
 {
+       struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
+       struct nfs_netns_client *nn_clp = nn->nfs_client;
+       const char *id;
+
        buf[0] = '\0';
 
-       if (nfs4_client_id_uniquifier[0] != '\0')
+       if (nn_clp) {
+               rcu_read_lock();
+               id = rcu_dereference(nn_clp->identifier);
+               if (id)
+                       strscpy(buf, id, buflen);
+               rcu_read_unlock();
+       }
+
+       if (nfs4_client_id_uniquifier[0] != '\0' && buf[0] == '\0')
                strscpy(buf, nfs4_client_id_uniquifier, buflen);
 
        return strlen(buf);
@@ -6123,7 +6136,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
                1;
        rcu_read_unlock();
 
-       buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+       buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
        if (buflen)
                len += buflen + 1;
 
@@ -6170,7 +6183,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
        len = 10 + 10 + 1 + 10 + 1 +
                strlen(clp->cl_rpcclient->cl_nodename) + 1;
 
-       buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+       buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
        if (buflen)
                len += buflen + 1;