diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2008-07-14 16:03:29 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:08:51 -0400 |
commit | babe80eb4994dfdc97d5be19a68b5af66d667585 (patch) | |
tree | 2acdcc7ba99ffed0ab66b21e627f77dd1d3d82bc /net/sunrpc/rpcb_clnt.c | |
parent | 423d8b064771f5cd8b706a4839b18db9bb6c3c59 (diff) |
SUNRPC: Refactor rpcb_register to make rpcbindv4 support easier
rpcbind version 4 registration will reuse part of rpcb_register, so just
split it out into a separate function now.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/rpcb_clnt.c')
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 691bd216f469..8b75c306e661 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -168,6 +168,30 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
168 | return rpc_create(&args); | 168 | return rpc_create(&args); |
169 | } | 169 | } |
170 | 170 | ||
171 | static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | ||
172 | u32 version, struct rpc_message *msg, | ||
173 | int *result) | ||
174 | { | ||
175 | struct rpc_clnt *rpcb_clnt; | ||
176 | int error = 0; | ||
177 | |||
178 | *result = 0; | ||
179 | |||
180 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); | ||
181 | if (!IS_ERR(rpcb_clnt)) { | ||
182 | error = rpc_call_sync(rpcb_clnt, msg, 0); | ||
183 | rpc_shutdown_client(rpcb_clnt); | ||
184 | } else | ||
185 | error = PTR_ERR(rpcb_clnt); | ||
186 | |||
187 | if (error < 0) | ||
188 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " | ||
189 | "server (errno %d).\n", -error); | ||
190 | dprintk("RPC: registration status %d/%d\n", error, *result); | ||
191 | |||
192 | return error; | ||
193 | } | ||
194 | |||
171 | /** | 195 | /** |
172 | * rpcb_register - set or unset a port registration with the local rpcbind svc | 196 | * rpcb_register - set or unset a port registration with the local rpcbind svc |
173 | * @prog: RPC program number to bind | 197 | * @prog: RPC program number to bind |
@@ -189,33 +213,21 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | |||
189 | .r_port = port, | 213 | .r_port = port, |
190 | }; | 214 | }; |
191 | struct rpc_message msg = { | 215 | struct rpc_message msg = { |
192 | .rpc_proc = &rpcb_procedures2[port ? | ||
193 | RPCBPROC_SET : RPCBPROC_UNSET], | ||
194 | .rpc_argp = &map, | 216 | .rpc_argp = &map, |
195 | .rpc_resp = okay, | 217 | .rpc_resp = okay, |
196 | }; | 218 | }; |
197 | struct rpc_clnt *rpcb_clnt; | ||
198 | int error = 0; | ||
199 | 219 | ||
200 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " | 220 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " |
201 | "rpcbind\n", (port ? "" : "un"), | 221 | "rpcbind\n", (port ? "" : "un"), |
202 | prog, vers, prot, port); | 222 | prog, vers, prot, port); |
203 | 223 | ||
204 | rpcb_clnt = rpcb_create_local((struct sockaddr *)&rpcb_inaddr_loopback, | 224 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET]; |
205 | sizeof(rpcb_inaddr_loopback), | 225 | if (port) |
206 | RPCBVERS_2); | 226 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; |
207 | if (!IS_ERR(rpcb_clnt)) { | ||
208 | error = rpc_call_sync(rpcb_clnt, &msg, 0); | ||
209 | rpc_shutdown_client(rpcb_clnt); | ||
210 | } else | ||
211 | error = PTR_ERR(rpcb_clnt); | ||
212 | 227 | ||
213 | if (error < 0) | 228 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, |
214 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " | 229 | sizeof(rpcb_inaddr_loopback), |
215 | "server (errno %d).\n", -error); | 230 | RPCBVERS_2, &msg, okay); |
216 | dprintk("RPC: registration status %d/%d\n", error, *okay); | ||
217 | |||
218 | return error; | ||
219 | } | 231 | } |
220 | 232 | ||
221 | /** | 233 | /** |