Skip to content

Commit 8ab523c

Browse files
Trond MyklebustAnna Schumaker
authored andcommitted
pnfs: Set transport security policy to RPC_XPRTSEC_NONE unless using TLS
The default setting for the transport security policy must be RPC_XPRTSEC_NONE, when using a TCP or RDMA connection without TLS. Conversely, when using TLS, the security policy needs to be set. Fixes: 6c0a8c5 ("NFS: Have struct nfs_client carry a TLS policy field") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
1 parent 28e1973 commit 8ab523c

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

fs/nfs/nfs3client.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/nfs_fs.h>
33
#include <linux/nfs_mount.h>
44
#include <linux/sunrpc/addr.h>
5+
#include <net/handshake.h>
56
#include "internal.h"
67
#include "nfs3_fs.h"
78
#include "netns.h"
@@ -98,7 +99,11 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
9899
.net = mds_clp->cl_net,
99100
.timeparms = &ds_timeout,
100101
.cred = mds_srv->cred,
101-
.xprtsec = mds_clp->cl_xprtsec,
102+
.xprtsec = {
103+
.policy = RPC_XPRTSEC_NONE,
104+
.cert_serial = TLS_NO_CERT,
105+
.privkey_serial = TLS_NO_PRIVKEY,
106+
},
102107
.connect_timeout = connect_timeout,
103108
.reconnect_timeout = connect_timeout,
104109
};
@@ -111,9 +116,14 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
111116
cl_init.hostname = buf;
112117

113118
switch (ds_proto) {
119+
case XPRT_TRANSPORT_TCP_TLS:
120+
if (mds_clp->cl_xprtsec.policy != RPC_XPRTSEC_NONE)
121+
cl_init.xprtsec = mds_clp->cl_xprtsec;
122+
else
123+
ds_proto = XPRT_TRANSPORT_TCP;
124+
fallthrough;
114125
case XPRT_TRANSPORT_RDMA:
115126
case XPRT_TRANSPORT_TCP:
116-
case XPRT_TRANSPORT_TCP_TLS:
117127
if (mds_clp->cl_nconnect > 1)
118128
cl_init.nconnect = mds_clp->cl_nconnect;
119129
}

fs/nfs/nfs4client.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/sunrpc/xprt.h>
1212
#include <linux/sunrpc/bc_xprt.h>
1313
#include <linux/sunrpc/rpc_pipe_fs.h>
14+
#include <net/handshake.h>
1415
#include "internal.h"
1516
#include "callback.h"
1617
#include "delegation.h"
@@ -983,7 +984,11 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
983984
.net = mds_clp->cl_net,
984985
.timeparms = &ds_timeout,
985986
.cred = mds_srv->cred,
986-
.xprtsec = mds_srv->nfs_client->cl_xprtsec,
987+
.xprtsec = {
988+
.policy = RPC_XPRTSEC_NONE,
989+
.cert_serial = TLS_NO_CERT,
990+
.privkey_serial = TLS_NO_PRIVKEY,
991+
},
987992
};
988993
char buf[INET6_ADDRSTRLEN + 1];
989994

@@ -992,9 +997,14 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
992997
cl_init.hostname = buf;
993998

994999
switch (ds_proto) {
1000+
case XPRT_TRANSPORT_TCP_TLS:
1001+
if (mds_srv->nfs_client->cl_xprtsec.policy != RPC_XPRTSEC_NONE)
1002+
cl_init.xprtsec = mds_srv->nfs_client->cl_xprtsec;
1003+
else
1004+
ds_proto = XPRT_TRANSPORT_TCP;
1005+
fallthrough;
9951006
case XPRT_TRANSPORT_RDMA:
9961007
case XPRT_TRANSPORT_TCP:
997-
case XPRT_TRANSPORT_TCP_TLS:
9981008
if (mds_clp->cl_nconnect > 1) {
9991009
cl_init.nconnect = mds_clp->cl_nconnect;
10001010
cl_init.max_connect = NFS_MAX_TRANSPORTS;

0 commit comments

Comments
 (0)