Commit bbf7c1dd authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Introduce transport switch callout for pluggable rpcbind

Introduce a clean transport switch API for plugging in different types of
rpcbind mechanisms.  For instance, rpcbind can cleanly replace the
existing portmapper client, or a transport can choose to implement RPC
binding any way it likes.

Test plan:
Destructive testing (unplugging the network temporarily).  Connectathon
with UDP and TCP.  NFSv2/3 and NFSv4 mounting should be carefully checked.
Probably need to rig a server where certain services aren't running, or
that returns an error for some typical operation.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 5b1eacbc
...@@ -106,7 +106,7 @@ struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); ...@@ -106,7 +106,7 @@ struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
int rpc_shutdown_client(struct rpc_clnt *); int rpc_shutdown_client(struct rpc_clnt *);
int rpc_destroy_client(struct rpc_clnt *); int rpc_destroy_client(struct rpc_clnt *);
void rpc_release_client(struct rpc_clnt *); void rpc_release_client(struct rpc_clnt *);
void rpc_getport(struct rpc_task *, struct rpc_clnt *); void rpc_getport(struct rpc_task *);
int rpc_register(u32, u32, int, unsigned short, int *); int rpc_register(u32, u32, int, unsigned short, int *);
void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
......
...@@ -105,6 +105,7 @@ struct rpc_xprt_ops { ...@@ -105,6 +105,7 @@ struct rpc_xprt_ops {
void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize); void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize);
int (*reserve_xprt)(struct rpc_task *task); int (*reserve_xprt)(struct rpc_task *task);
void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
void (*rpcbind)(struct rpc_task *task);
void (*set_port)(struct rpc_xprt *xprt, unsigned short port); void (*set_port)(struct rpc_xprt *xprt, unsigned short port);
void (*connect)(struct rpc_task *task); void (*connect)(struct rpc_task *task);
void * (*buf_alloc)(struct rpc_task *task, size_t size); void * (*buf_alloc)(struct rpc_task *task, size_t size);
......
...@@ -774,7 +774,6 @@ call_encode(struct rpc_task *task) ...@@ -774,7 +774,6 @@ call_encode(struct rpc_task *task)
static void static void
call_bind(struct rpc_task *task) call_bind(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client;
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
dprintk("RPC: %4d call_bind (status %d)\n", dprintk("RPC: %4d call_bind (status %d)\n",
...@@ -784,7 +783,7 @@ call_bind(struct rpc_task *task) ...@@ -784,7 +783,7 @@ call_bind(struct rpc_task *task)
if (!xprt_bound(xprt)) { if (!xprt_bound(xprt)) {
task->tk_action = call_bind_status; task->tk_action = call_bind_status;
task->tk_timeout = xprt->bind_timeout; task->tk_timeout = xprt->bind_timeout;
rpc_getport(task, clnt); xprt->ops->rpcbind(task);
} }
} }
......
...@@ -81,13 +81,13 @@ static inline void pmap_wake_portmap_waiters(struct rpc_xprt *xprt) ...@@ -81,13 +81,13 @@ static inline void pmap_wake_portmap_waiters(struct rpc_xprt *xprt)
/** /**
* rpc_getport - obtain the port for a given RPC service on a given host * rpc_getport - obtain the port for a given RPC service on a given host
* @task: task that is waiting for portmapper request * @task: task that is waiting for portmapper request
* @clnt: controlling rpc_clnt
* *
* This one can be called for an ongoing RPC request, and can be used in * This one can be called for an ongoing RPC request, and can be used in
* an async (rpciod) context. * an async (rpciod) context.
*/ */
void rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt) void rpc_getport(struct rpc_task *task)
{ {
struct rpc_clnt *clnt = task->tk_client;
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
struct sockaddr_in *sap = &xprt->addr; struct sockaddr_in *sap = &xprt->addr;
struct portmap_args *map; struct portmap_args *map;
......
...@@ -1262,6 +1262,7 @@ static struct rpc_xprt_ops xs_udp_ops = { ...@@ -1262,6 +1262,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
.set_buffer_size = xs_udp_set_buffer_size, .set_buffer_size = xs_udp_set_buffer_size,
.reserve_xprt = xprt_reserve_xprt_cong, .reserve_xprt = xprt_reserve_xprt_cong,
.release_xprt = xprt_release_xprt_cong, .release_xprt = xprt_release_xprt_cong,
.rpcbind = rpc_getport,
.set_port = xs_set_port, .set_port = xs_set_port,
.connect = xs_connect, .connect = xs_connect,
.buf_alloc = rpc_malloc, .buf_alloc = rpc_malloc,
...@@ -1278,6 +1279,7 @@ static struct rpc_xprt_ops xs_udp_ops = { ...@@ -1278,6 +1279,7 @@ static struct rpc_xprt_ops xs_udp_ops = {
static struct rpc_xprt_ops xs_tcp_ops = { static struct rpc_xprt_ops xs_tcp_ops = {
.reserve_xprt = xprt_reserve_xprt, .reserve_xprt = xprt_reserve_xprt,
.release_xprt = xs_tcp_release_xprt, .release_xprt = xs_tcp_release_xprt,
.rpcbind = rpc_getport,
.set_port = xs_set_port, .set_port = xs_set_port,
.connect = xs_connect, .connect = xs_connect,
.buf_alloc = rpc_malloc, .buf_alloc = rpc_malloc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment