SUNRPC: Pass a family argument to svc_register()

The sv_family field is going away.  Instead of using sv_family, have
the svc_register() function take a protocol family argument.

Since this argument represents a protocol family, and not an address
family, this argument takes an int, as this is what is passed to
sock_create_kern().  Also make sure svc_register's helpers are
checking for PF_FOO instead of AF_FOO.  The value of [AP]F_FOO are
equivalent; this is simply a symbolic change to reflect the semantics
of the value stored in that variable.

sock_create_kern() should return EPFNOSUPPORT if the passed-in
protocol family isn't supported, but it uses EAFNOSUPPORT for this
case.  We will stick with that tradition here, as svc_register()
is called by the RPC server in the same path as sock_create_kern().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Chuck Lever 2009-03-18 20:46:06 -04:00 committed by Trond Myklebust
parent 156e62094a
commit 4b62e58ccc
3 changed files with 14 additions and 13 deletions

View File

@ -396,8 +396,8 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
void svc_destroy(struct svc_serv *); void svc_destroy(struct svc_serv *);
int svc_process(struct svc_rqst *); int svc_process(struct svc_rqst *);
int svc_register(const struct svc_serv *, const unsigned short, int svc_register(const struct svc_serv *, const int,
const unsigned short); const unsigned short, const unsigned short);
void svc_wake_up(struct svc_serv *); void svc_wake_up(struct svc_serv *);
void svc_reserve(struct svc_rqst *rqstp, int space); void svc_reserve(struct svc_rqst *rqstp, int space);

View File

@ -800,17 +800,17 @@ static int __svc_rpcb_register6(const u32 program, const u32 version,
* if any error occurs. * if any error occurs.
*/ */
static int __svc_register(const u32 program, const u32 version, static int __svc_register(const u32 program, const u32 version,
const sa_family_t family, const int family,
const unsigned short protocol, const unsigned short protocol,
const unsigned short port) const unsigned short port)
{ {
int error; int error;
switch (family) { switch (family) {
case AF_INET: case PF_INET:
return __svc_rpcb_register4(program, version, return __svc_rpcb_register4(program, version,
protocol, port); protocol, port);
case AF_INET6: case PF_INET6:
error = __svc_rpcb_register6(program, version, error = __svc_rpcb_register6(program, version,
protocol, port); protocol, port);
if (error < 0) if (error < 0)
@ -840,11 +840,11 @@ static int __svc_register(const u32 program, const u32 version,
* if any error occurs. * if any error occurs.
*/ */
static int __svc_register(const u32 program, const u32 version, static int __svc_register(const u32 program, const u32 version,
sa_family_t family, const int family,
const unsigned short protocol, const unsigned short protocol,
const unsigned short port) const unsigned short port)
{ {
if (family != AF_INET) if (family != PF_INET)
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
return rpcb_register(program, version, protocol, port); return rpcb_register(program, version, protocol, port);
@ -855,13 +855,14 @@ static int __svc_register(const u32 program, const u32 version,
/** /**
* svc_register - register an RPC service with the local portmapper * svc_register - register an RPC service with the local portmapper
* @serv: svc_serv struct for the service to register * @serv: svc_serv struct for the service to register
* @family: protocol family of service's listener socket
* @proto: transport protocol number to advertise * @proto: transport protocol number to advertise
* @port: port to advertise * @port: port to advertise
* *
* Service is registered for any address in serv's address family * Service is registered for any address in the passed-in protocol family
*/ */
int svc_register(const struct svc_serv *serv, const unsigned short proto, int svc_register(const struct svc_serv *serv, const int family,
const unsigned short port) const unsigned short proto, const unsigned short port)
{ {
struct svc_program *progp; struct svc_program *progp;
unsigned int i; unsigned int i;
@ -879,7 +880,7 @@ int svc_register(const struct svc_serv *serv, const unsigned short proto,
i, i,
proto == IPPROTO_UDP? "udp" : "tcp", proto == IPPROTO_UDP? "udp" : "tcp",
port, port,
serv->sv_family, family,
progp->pg_vers[i]->vs_hidden? progp->pg_vers[i]->vs_hidden?
" (but not telling portmap)" : ""); " (but not telling portmap)" : "");
@ -887,7 +888,7 @@ int svc_register(const struct svc_serv *serv, const unsigned short proto,
continue; continue;
error = __svc_register(progp->pg_prog, i, error = __svc_register(progp->pg_prog, i,
serv->sv_family, proto, port); family, proto, port);
if (error < 0) if (error < 0)
break; break;
} }

View File

@ -1122,7 +1122,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
/* Register socket with portmapper */ /* Register socket with portmapper */
if (*errp >= 0 && pmap_register) if (*errp >= 0 && pmap_register)
*errp = svc_register(serv, inet->sk_protocol, *errp = svc_register(serv, serv->sv_family, inet->sk_protocol,
ntohs(inet_sk(inet)->sport)); ntohs(inet_sk(inet)->sport));
if (*errp < 0) { if (*errp < 0) {