Skip to content

Commit ad0849a

Browse files
androsadamsonamschuma-ntap
authored andcommitted
NFS test session trunking with exchange id
Use an async exchange id call to test for session trunking To conform with RFC 5661 section 18.35.4, the Non-Update on Existing Clientid case, save the exchange id verifier in cl_confirm and use it for the session trunking exhange id test. Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 04ea1b3 commit ad0849a

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

fs/nfs/nfs4client.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,10 @@ nfs4_check_server_scope(struct nfs41_server_scope *s1,
637637
}
638638

639639
/**
640-
* nfs4_detect_session_trunking - Checks for session trunking called
641-
* after a successful EXCHANGE_ID testing a multi-addr connection to be
642-
* potentially added as a session trunk
640+
* nfs4_detect_session_trunking - Checks for session trunking.
641+
*
642+
* Called after a successful EXCHANGE_ID on a multi-addr connection.
643+
* Upon success, add the transport.
643644
*
644645
* @clp: original mount nfs_client
645646
* @res: result structure from an exchange_id using the original mount
@@ -673,6 +674,9 @@ int nfs4_detect_session_trunking(struct nfs_client *clp,
673674
if (!nfs4_check_server_scope(clp->cl_serverscope, res->server_scope))
674675
goto out_err;
675676

677+
/* Session trunking passed, add the xprt */
678+
rpc_clnt_xprt_switch_add_xprt(clp->cl_rpcclient, xprt);
679+
676680
pr_info("NFS: %s: Session trunking succeeded for %s\n",
677681
clp->cl_hostname,
678682
xprt->address_strings[RPC_DISPLAY_ADDR]);

fs/nfs/nfs4proc.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7107,6 +7107,7 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp,
71077107
struct nfs41_exchange_id_data {
71087108
struct nfs41_exchange_id_res res;
71097109
struct nfs41_exchange_id_args args;
7110+
struct rpc_xprt *xprt;
71107111
int rpc_status;
71117112
};
71127113

@@ -7121,6 +7122,13 @@ static void nfs4_exchange_id_done(struct rpc_task *task, void *data)
71217122

71227123
if (status == 0)
71237124
status = nfs4_check_cl_exchange_flags(cdata->res.flags);
7125+
7126+
if (cdata->xprt && status == 0) {
7127+
status = nfs4_detect_session_trunking(clp, &cdata->res,
7128+
cdata->xprt);
7129+
goto out;
7130+
}
7131+
71247132
if (status == 0)
71257133
status = nfs4_sp4_select_mode(clp, &cdata->res.state_protect);
71267134

@@ -7157,8 +7165,13 @@ static void nfs4_exchange_id_done(struct rpc_task *task, void *data)
71577165
clp->cl_serverscope = cdata->res.server_scope;
71587166
cdata->res.server_scope = NULL;
71597167
}
7168+
/* Save the EXCHANGE_ID verifier session trunk tests */
7169+
memcpy(clp->cl_confirm.data, cdata->args.verifier->data,
7170+
sizeof(clp->cl_confirm.data));
71607171
}
7172+
out:
71617173
cdata->rpc_status = status;
7174+
return;
71627175
}
71637176

71647177
static void nfs4_exchange_id_release(void *data)
@@ -7167,6 +7180,10 @@ static void nfs4_exchange_id_release(void *data)
71677180
(struct nfs41_exchange_id_data *)data;
71687181

71697182
nfs_put_client(cdata->args.client);
7183+
if (cdata->xprt) {
7184+
xprt_put(cdata->xprt);
7185+
rpc_clnt_xprt_switch_put(cdata->args.client->cl_rpcclient);
7186+
}
71707187
kfree(cdata->res.impl_id);
71717188
kfree(cdata->res.server_scope);
71727189
kfree(cdata->res.server_owner);
@@ -7184,7 +7201,7 @@ static const struct rpc_call_ops nfs4_exchange_id_call_ops = {
71847201
* Wrapper for EXCHANGE_ID operation.
71857202
*/
71867203
static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
7187-
u32 sp4_how)
7204+
u32 sp4_how, struct rpc_xprt *xprt)
71887205
{
71897206
nfs4_verifier verifier;
71907207
struct rpc_message msg = {
@@ -7209,7 +7226,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
72097226
if (!calldata)
72107227
goto out;
72117228

7212-
nfs4_init_boot_verifier(clp, &verifier);
7229+
if (!xprt)
7230+
nfs4_init_boot_verifier(clp, &verifier);
72137231

72147232
status = nfs4_init_uniform_client_string(clp);
72157233
if (status)
@@ -7249,8 +7267,15 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
72497267
status = -EINVAL;
72507268
goto out_impl_id;
72517269
}
7252-
7253-
calldata->args.verifier = &verifier;
7270+
if (xprt) {
7271+
calldata->xprt = xprt;
7272+
task_setup_data.rpc_xprt = xprt;
7273+
task_setup_data.flags =
7274+
RPC_TASK_SOFT|RPC_TASK_SOFTCONN|RPC_TASK_ASYNC;
7275+
calldata->args.verifier = &clp->cl_confirm;
7276+
} else {
7277+
calldata->args.verifier = &verifier;
7278+
}
72547279
calldata->args.client = clp;
72557280
#ifdef CONFIG_NFS_V4_1_MIGRATION
72567281
calldata->args.flags = EXCHGID4_FLAG_SUPP_MOVED_REFER |
@@ -7270,9 +7295,13 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
72707295
goto out_impl_id;
72717296
}
72727297

7273-
status = rpc_wait_for_completion_task(task);
7274-
if (!status)
7298+
if (!xprt) {
7299+
status = rpc_wait_for_completion_task(task);
7300+
if (!status)
7301+
status = calldata->rpc_status;
7302+
} else /* session trunking test */
72757303
status = calldata->rpc_status;
7304+
72767305
rpc_put_task(task);
72777306
out:
72787307
if (clp->cl_implid != NULL)
@@ -7315,13 +7344,13 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
73157344
/* try SP4_MACH_CRED if krb5i/p */
73167345
if (authflavor == RPC_AUTH_GSS_KRB5I ||
73177346
authflavor == RPC_AUTH_GSS_KRB5P) {
7318-
status = _nfs4_proc_exchange_id(clp, cred, SP4_MACH_CRED);
7347+
status = _nfs4_proc_exchange_id(clp, cred, SP4_MACH_CRED, NULL);
73197348
if (!status)
73207349
return 0;
73217350
}
73227351

73237352
/* try SP4_NONE */
7324-
return _nfs4_proc_exchange_id(clp, cred, SP4_NONE);
7353+
return _nfs4_proc_exchange_id(clp, cred, SP4_NONE, NULL);
73257354
}
73267355

73277356
static int _nfs4_proc_destroy_clientid(struct nfs_client *clp,

0 commit comments

Comments
 (0)