Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139560
b: refs/heads/master
c: cadc0fa
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Mar 28, 2009
1 parent 5e7726a commit b3f5d25
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d5a8620f7c8a5bcade730e2fa1224191f289fb00
refs/heads/master: cadc0fa534e51e20fdffe1623913c163a18d71b1
79 changes: 34 additions & 45 deletions trunk/net/sunrpc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,6 @@ svc_exit_thread(struct svc_rqst *rqstp)
}
EXPORT_SYMBOL_GPL(svc_exit_thread);

#ifdef CONFIG_SUNRPC_REGISTER_V4

/*
* Register an "inet" protocol family netid with the local
* rpcbind daemon via an rpcbind v4 SET request.
Expand All @@ -734,12 +732,13 @@ static int __svc_rpcb_register4(const u32 program, const u32 version,
const unsigned short protocol,
const unsigned short port)
{
struct sockaddr_in sin = {
const struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_ANY),
.sin_port = htons(port),
};
char *netid;
const char *netid;
int error;

switch (protocol) {
case IPPROTO_UDP:
Expand All @@ -752,10 +751,20 @@ static int __svc_rpcb_register4(const u32 program, const u32 version,
return -ENOPROTOOPT;
}

return rpcb_v4_register(program, version,
(struct sockaddr *)&sin, netid);
error = rpcb_v4_register(program, version,
(const struct sockaddr *)&sin, netid);

/*
* User space didn't support rpcbind v4, so retry this
* registration request with the legacy rpcbind v2 protocol.
*/
if (error == -EPROTONOSUPPORT)
error = rpcb_register(program, version, protocol, port);

return error;
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
/*
* Register an "inet6" protocol family netid with the local
* rpcbind daemon via an rpcbind v4 SET request.
Expand All @@ -770,12 +779,13 @@ static int __svc_rpcb_register6(const u32 program, const u32 version,
const unsigned short protocol,
const unsigned short port)
{
struct sockaddr_in6 sin6 = {
const struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_port = htons(port),
};
char *netid;
const char *netid;
int error;

switch (protocol) {
case IPPROTO_UDP:
Expand All @@ -788,9 +798,19 @@ static int __svc_rpcb_register6(const u32 program, const u32 version,
return -ENOPROTOOPT;
}

return rpcb_v4_register(program, version,
(struct sockaddr *)&sin6, netid);
error = rpcb_v4_register(program, version,
(const struct sockaddr *)&sin6, netid);

/*
* User space didn't support rpcbind version 4, so we won't
* use a PF_INET6 listener.
*/
if (error == -EPROTONOSUPPORT)
error = -EAFNOSUPPORT;

return error;
}
#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */

/*
* Register a kernel RPC service via rpcbind version 4.
Expand All @@ -809,48 +829,17 @@ static int __svc_register(const u32 program, const u32 version,
case PF_INET:
return __svc_rpcb_register4(program, version,
protocol, port);
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case PF_INET6:
error = __svc_rpcb_register6(program, version,
return__svc_rpcb_register6(program, version,
protocol, port);
if (error < 0)
return error;

/*
* Work around bug in some versions of Linux rpcbind
* which don't allow registration of both inet and
* inet6 netids.
*
* Error return ignored for now.
*/
__svc_rpcb_register4(program, version,
protocol, port);
return 0;
#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
}

return -EAFNOSUPPORT;
}

#else /* CONFIG_SUNRPC_REGISTER_V4 */

/*
* Register a kernel RPC service via rpcbind version 2.
*
* Returns zero on success; a negative errno value is returned
* if any error occurs.
*/
static int __svc_register(const u32 program, const u32 version,
const int family,
const unsigned short protocol,
const unsigned short port)
{
if (family != PF_INET)
return -EAFNOSUPPORT;

return rpcb_register(program, version, protocol, port);
}

#endif /* CONFIG_SUNRPC_REGISTER_V4 */

/**
* svc_register - register an RPC service with the local portmapper
* @serv: svc_serv struct for the service to register
Expand Down

0 comments on commit b3f5d25

Please sign in to comment.