aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/sunrpc/rpcb_clnt.c48
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
171static 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/**