diff options
author | Rick Macklem <rmacklem@FreeBSD.org> | 2021-04-11 21:34:57 +0000 |
---|---|---|
committer | Rick Macklem <rmacklem@FreeBSD.org> | 2021-04-11 21:34:57 +0000 |
commit | 7763814fc9c27a98fefcbf582d7a936ea43af23a (patch) | |
tree | e3b8fb4cd229928415e55685200f6f2af63b2505 /sys/rpc/clnt_rc.c | |
parent | 70275a6735df8a514f48be77418491f2f8dba817 (diff) | |
download | src-7763814fc9c27a98fefcbf582d7a936ea43af23a.tar.gz src-7763814fc9c27a98fefcbf582d7a936ea43af23a.zip |
nfsv4 client: do the BindConnectionToSession as required
During a recent testing event, it was reported that the NFSv4.1/4.2
server erroneously bound the back channel to a new TCP connection.
RFC5661 specifies that the fore channel is implicitly bound to a
new TCP connection when an RPC with Sequence (almost any of them)
is done on it. For the back channel to be bound to the new TCP
connection, an explicit BindConnectionToSession must be done as
the first RPC on the new connection.
Since new TCP connections are created by the "reconnect" layer
(sys/rpc/clnt_rc.c) of the krpc, this patch adds an optional
upcall done by the krpc whenever a new connection is created.
The patch also adds the specific upcall function that does a
BindConnectionToSession and configures the krpc to call it
when required.
This is necessary for correct interoperability with NFSv4.1/NFSv4.2
servers when the nfscbd daemon is running.
If doing NFSv4.1/NFSv4.2 mounts without this patch, it is
recommended that the nfscbd daemon not be running and that
the "pnfs" mount option not be specified.
PR: 254840
Comments by: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29475
Diffstat (limited to 'sys/rpc/clnt_rc.c')
-rw-r--r-- | sys/rpc/clnt_rc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/rpc/clnt_rc.c b/sys/rpc/clnt_rc.c index 8c204989d0ea..ae3b2985a891 100644 --- a/sys/rpc/clnt_rc.c +++ b/sys/rpc/clnt_rc.c @@ -111,6 +111,8 @@ clnt_reconnect_create( rc->rc_client = NULL; rc->rc_tls = false; rc->rc_tlscertname = NULL; + rc->rc_reconcall = NULL; + rc->rc_reconarg = NULL; cl->cl_refs = 1; cl->cl_ops = &clnt_reconnect_ops; @@ -213,6 +215,9 @@ clnt_reconnect_connect(CLIENT *cl) goto out; } } + if (newclient != NULL && rc->rc_reconcall != NULL) + (*rc->rc_reconcall)(newclient, rc->rc_reconarg, + rc->rc_ucred); } td->td_ucred = oldcred; @@ -408,6 +413,7 @@ clnt_reconnect_control(CLIENT *cl, u_int request, void *info) struct rc_data *rc = (struct rc_data *)cl->cl_private; SVCXPRT *xprt; size_t slen; + struct rpc_reconupcall *upcp; if (info == NULL) { return (FALSE); @@ -513,6 +519,12 @@ clnt_reconnect_control(CLIENT *cl, u_int request, void *info) strlcpy(rc->rc_tlscertname, info, slen); break; + case CLSET_RECONUPCALL: + upcp = (struct rpc_reconupcall *)info; + rc->rc_reconcall = upcp->call; + rc->rc_reconarg = upcp->arg; + break; + default: return (FALSE); } @@ -555,12 +567,15 @@ clnt_reconnect_destroy(CLIENT *cl) CLNT_DESTROY(rc->rc_client); if (rc->rc_backchannel) { xprt = (SVCXPRT *)rc->rc_backchannel; + KASSERT(xprt->xp_socket == NULL, + ("clnt_reconnect_destroy: xp_socket not NULL")); xprt_unregister(xprt); SVC_RELEASE(xprt); } crfree(rc->rc_ucred); mtx_destroy(&rc->rc_lock); mem_free(rc->rc_tlscertname, 0); /* 0 ok, since arg. ignored. */ + mem_free(rc->rc_reconarg, 0); mem_free(rc, sizeof(*rc)); mem_free(cl, sizeof (CLIENT)); } |