Skip to content

Commit 7aca00d

Browse files
Trond MyklebustAnna Schumaker
authored andcommitted
pnfs: Fix TLS logic in _nfs4_pnfs_v3_ds_connect()
Don't try to add an RDMA transport to a client that is already marked as being a TCP/TLS transport. Fixes: 04a1526 ("pnfs/flexfiles: connect to NFSv3 DS using TLS if MDS connection uses TLS") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
1 parent e9a6fb0 commit 7aca00d

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

fs/nfs/pnfs_nfs.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,11 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
809809
unsigned int retrans)
810810
{
811811
struct nfs_client *clp = ERR_PTR(-EIO);
812+
struct nfs_client *mds_clp = mds_srv->nfs_client;
813+
enum xprtsec_policies xprtsec_policy = mds_clp->cl_xprtsec.policy;
812814
struct nfs4_pnfs_ds_addr *da;
813815
unsigned long connect_timeout = timeo * (retrans + 1) * HZ / 10;
816+
int ds_proto;
814817
int status = 0;
815818

816819
dprintk("--> %s DS %s\n", __func__, ds->ds_remotestr);
@@ -834,27 +837,28 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
834837
.xprtsec = clp->cl_xprtsec,
835838
};
836839

837-
if (da->da_transport != clp->cl_proto &&
838-
clp->cl_proto != XPRT_TRANSPORT_TCP_TLS)
839-
continue;
840-
if (da->da_transport == XPRT_TRANSPORT_TCP &&
841-
mds_srv->nfs_client->cl_proto == XPRT_TRANSPORT_TCP_TLS)
840+
if (xprt_args.ident == XPRT_TRANSPORT_TCP &&
841+
clp->cl_proto == XPRT_TRANSPORT_TCP_TLS)
842842
xprt_args.ident = XPRT_TRANSPORT_TCP_TLS;
843843

844-
if (da->da_addr.ss_family != clp->cl_addr.ss_family)
844+
if (xprt_args.ident != clp->cl_proto)
845+
continue;
846+
if (xprt_args.dstaddr->sa_family !=
847+
clp->cl_addr.ss_family)
845848
continue;
846849
/* Add this address as an alias */
847850
rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args,
848-
rpc_clnt_test_and_add_xprt, NULL);
851+
rpc_clnt_test_and_add_xprt, NULL);
849852
continue;
850853
}
851-
if (da->da_transport == XPRT_TRANSPORT_TCP &&
852-
mds_srv->nfs_client->cl_proto == XPRT_TRANSPORT_TCP_TLS)
853-
da->da_transport = XPRT_TRANSPORT_TCP_TLS;
854-
clp = get_v3_ds_connect(mds_srv,
855-
&da->da_addr,
856-
da->da_addrlen, da->da_transport,
857-
timeo, retrans);
854+
855+
ds_proto = da->da_transport;
856+
if (ds_proto == XPRT_TRANSPORT_TCP &&
857+
xprtsec_policy != RPC_XPRTSEC_NONE)
858+
ds_proto = XPRT_TRANSPORT_TCP_TLS;
859+
860+
clp = get_v3_ds_connect(mds_srv, &da->da_addr, da->da_addrlen,
861+
ds_proto, timeo, retrans);
858862
if (IS_ERR(clp))
859863
continue;
860864
clp->cl_rpcclient->cl_softerr = 0;

0 commit comments

Comments
 (0)