Skip to content

Commit 6c0a8c5

Browse files
chuckleverTrond Myklebust
authored andcommitted
NFS: Have struct nfs_client carry a TLS policy field
The new field is used to match struct nfs_clients that have the same TLS policy setting. Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 75eb6af commit 6c0a8c5

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

fs/nfs/client.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
184184
clp->cl_net = get_net(cl_init->net);
185185

186186
clp->cl_principal = "*";
187+
clp->cl_xprtsec = cl_init->xprtsec;
187188
return clp;
188189

189190
error_cleanup:
@@ -326,6 +327,10 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
326327
sap))
327328
continue;
328329

330+
/* Match the xprt security policy */
331+
if (clp->cl_xprtsec.policy != data->xprtsec.policy)
332+
continue;
333+
329334
refcount_inc(&clp->cl_count);
330335
return clp;
331336
}
@@ -675,6 +680,9 @@ static int nfs_init_server(struct nfs_server *server,
675680
.cred = server->cred,
676681
.nconnect = ctx->nfs_server.nconnect,
677682
.init_flags = (1UL << NFS_CS_REUSEPORT),
683+
.xprtsec = {
684+
.policy = RPC_XPRTSEC_NONE,
685+
},
678686
};
679687
struct nfs_client *clp;
680688
int error;

fs/nfs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct nfs_client_initdata {
8181
struct net *net;
8282
const struct rpc_timeout *timeparms;
8383
const struct cred *cred;
84+
struct xprtsec_parms xprtsec;
8485
};
8586

8687
/*

fs/nfs/nfs3client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
9393
.net = mds_clp->cl_net,
9494
.timeparms = &ds_timeout,
9595
.cred = mds_srv->cred,
96+
.xprtsec = mds_clp->cl_xprtsec,
9697
};
9798
struct nfs_client *clp;
9899
char buf[INET6_ADDRSTRLEN + 1];

fs/nfs/nfs4client.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ static int nfs4_set_client(struct nfs_server *server,
896896
int proto, const struct rpc_timeout *timeparms,
897897
u32 minorversion, unsigned int nconnect,
898898
unsigned int max_connect,
899-
struct net *net)
899+
struct net *net,
900+
struct xprtsec_parms *xprtsec)
900901
{
901902
struct nfs_client_initdata cl_init = {
902903
.hostname = hostname,
@@ -909,6 +910,7 @@ static int nfs4_set_client(struct nfs_server *server,
909910
.net = net,
910911
.timeparms = timeparms,
911912
.cred = server->cred,
913+
.xprtsec = *xprtsec,
912914
};
913915
struct nfs_client *clp;
914916

@@ -978,6 +980,7 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
978980
.net = mds_clp->cl_net,
979981
.timeparms = &ds_timeout,
980982
.cred = mds_srv->cred,
983+
.xprtsec = mds_srv->nfs_client->cl_xprtsec,
981984
};
982985
char buf[INET6_ADDRSTRLEN + 1];
983986

@@ -1127,6 +1130,9 @@ static int nfs4_server_common_setup(struct nfs_server *server,
11271130
static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc)
11281131
{
11291132
struct nfs_fs_context *ctx = nfs_fc2context(fc);
1133+
struct xprtsec_parms xprtsec = {
1134+
.policy = RPC_XPRTSEC_NONE,
1135+
};
11301136
struct rpc_timeout timeparms;
11311137
int error;
11321138

@@ -1157,7 +1163,8 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc)
11571163
ctx->minorversion,
11581164
ctx->nfs_server.nconnect,
11591165
ctx->nfs_server.max_connect,
1160-
fc->net_ns);
1166+
fc->net_ns,
1167+
&xprtsec);
11611168
if (error < 0)
11621169
return error;
11631170

@@ -1247,7 +1254,8 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc)
12471254
parent_client->cl_mvops->minor_version,
12481255
parent_client->cl_nconnect,
12491256
parent_client->cl_max_connect,
1250-
parent_client->cl_net);
1257+
parent_client->cl_net,
1258+
&parent_client->cl_xprtsec);
12511259
if (!error)
12521260
goto init_server;
12531261
#endif /* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
@@ -1263,7 +1271,8 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc)
12631271
parent_client->cl_mvops->minor_version,
12641272
parent_client->cl_nconnect,
12651273
parent_client->cl_max_connect,
1266-
parent_client->cl_net);
1274+
parent_client->cl_net,
1275+
&parent_client->cl_xprtsec);
12671276
if (error < 0)
12681277
goto error;
12691278

@@ -1336,7 +1345,8 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,
13361345
error = nfs4_set_client(server, hostname, sap, salen, buf,
13371346
clp->cl_proto, clnt->cl_timeout,
13381347
clp->cl_minorversion,
1339-
clp->cl_nconnect, clp->cl_max_connect, net);
1348+
clp->cl_nconnect, clp->cl_max_connect,
1349+
net, &clp->cl_xprtsec);
13401350
clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status);
13411351
if (error != 0) {
13421352
nfs_server_insert_lists(server);

include/linux/nfs_fs_sb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ struct nfs_client {
6363
u32 cl_minorversion;/* NFSv4 minorversion */
6464
unsigned int cl_nconnect; /* Number of connections */
6565
unsigned int cl_max_connect; /* max number of xprts allowed */
66-
const char * cl_principal; /* used for machine cred */
66+
const char * cl_principal; /* used for machine cred */
67+
struct xprtsec_parms cl_xprtsec; /* xprt security policy */
6768

6869
#if IS_ENABLED(CONFIG_NFS_V4)
6970
struct list_head cl_ds_clients; /* auth flavor data servers */

0 commit comments

Comments
 (0)