aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/rpcb_clnt.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index ebce7a5976c9..44d0732ba874 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -170,7 +170,7 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
170 return rpc_create(&args); 170 return rpc_create(&args);
171} 171}
172 172
173static int rpcb_register_call(u32 version, struct rpc_message *msg) 173static int rpcb_register_call(const u32 version, struct rpc_message *msg)
174{ 174{
175 struct sockaddr *addr = (struct sockaddr *)&rpcb_inaddr_loopback; 175 struct sockaddr *addr = (struct sockaddr *)&rpcb_inaddr_loopback;
176 size_t addrlen = sizeof(rpcb_inaddr_loopback); 176 size_t addrlen = sizeof(rpcb_inaddr_loopback);
@@ -255,17 +255,17 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
255/* 255/*
256 * Fill in AF_INET family-specific arguments to register 256 * Fill in AF_INET family-specific arguments to register
257 */ 257 */
258static int rpcb_register_netid4(struct sockaddr_in *address_to_register, 258static int rpcb_register_netid4(const struct sockaddr *sap,
259 struct rpc_message *msg) 259 struct rpc_message *msg)
260{ 260{
261 const struct sockaddr_in *sin = (const struct sockaddr_in *)sap;
261 struct rpcbind_args *map = msg->rpc_argp; 262 struct rpcbind_args *map = msg->rpc_argp;
262 unsigned short port = ntohs(address_to_register->sin_port); 263 unsigned short port = ntohs(sin->sin_port);
263 char buf[32]; 264 char buf[32];
264 265
265 /* Construct AF_INET universal address */ 266 /* Construct AF_INET universal address */
266 snprintf(buf, sizeof(buf), "%pI4.%u.%u", 267 snprintf(buf, sizeof(buf), "%pI4.%u.%u",
267 &address_to_register->sin_addr.s_addr, 268 &sin->sin_addr.s_addr, port >> 8, port & 0xff);
268 port >> 8, port & 0xff);
269 map->r_addr = buf; 269 map->r_addr = buf;
270 270
271 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " 271 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
@@ -283,21 +283,21 @@ static int rpcb_register_netid4(struct sockaddr_in *address_to_register,
283/* 283/*
284 * Fill in AF_INET6 family-specific arguments to register 284 * Fill in AF_INET6 family-specific arguments to register
285 */ 285 */
286static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, 286static int rpcb_register_netid6(const struct sockaddr *sap,
287 struct rpc_message *msg) 287 struct rpc_message *msg)
288{ 288{
289 const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap;
289 struct rpcbind_args *map = msg->rpc_argp; 290 struct rpcbind_args *map = msg->rpc_argp;
290 unsigned short port = ntohs(address_to_register->sin6_port); 291 unsigned short port = ntohs(sin6->sin6_port);
291 char buf[64]; 292 char buf[64];
292 293
293 /* Construct AF_INET6 universal address */ 294 /* Construct AF_INET6 universal address */
294 if (ipv6_addr_any(&address_to_register->sin6_addr)) 295 if (ipv6_addr_any(&sin6->sin6_addr))
295 snprintf(buf, sizeof(buf), "::.%u.%u", 296 snprintf(buf, sizeof(buf), "::.%u.%u",
296 port >> 8, port & 0xff); 297 port >> 8, port & 0xff);
297 else 298 else
298 snprintf(buf, sizeof(buf), "%pI6.%u.%u", 299 snprintf(buf, sizeof(buf), "%pI6.%u.%u",
299 &address_to_register->sin6_addr, 300 &sin6->sin6_addr, port >> 8, port & 0xff);
300 port >> 8, port & 0xff);
301 map->r_addr = buf; 301 map->r_addr = buf;
302 302
303 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " 303 dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with "
@@ -369,11 +369,9 @@ int rpcb_v4_register(const u32 program, const u32 version,
369 369
370 switch (address->sa_family) { 370 switch (address->sa_family) {
371 case AF_INET: 371 case AF_INET:
372 return rpcb_register_netid4((struct sockaddr_in *)address, 372 return rpcb_register_netid4(address, &msg);
373 &msg);
374 case AF_INET6: 373 case AF_INET6:
375 return rpcb_register_netid6((struct sockaddr_in6 *)address, 374 return rpcb_register_netid6(address, &msg);
376 &msg);
377 } 375 }
378 376
379 return -EAFNOSUPPORT; 377 return -EAFNOSUPPORT;