SUNRPC: Use proper INADDR_ANY when setting up RPC services on IPv6

Teach svc_create_xprt() to use the correct ANY address for AF_INET6 based
RPC services.

No caller uses AF_INET6 yet.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
Chuck Lever 2008-06-30 18:45:37 -04:00 committed by J. Bruce Fields
parent e851db5b05
commit 5dd248f6f1
1 changed files with 33 additions and 6 deletions

View File

@ -159,15 +159,44 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,
} }
EXPORT_SYMBOL_GPL(svc_xprt_init); EXPORT_SYMBOL_GPL(svc_xprt_init);
int svc_create_xprt(struct svc_serv *serv, char *xprt_name, unsigned short port, static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,
int flags) struct svc_serv *serv,
unsigned short port, int flags)
{ {
struct svc_xprt_class *xcl;
struct sockaddr_in sin = { struct sockaddr_in sin = {
.sin_family = AF_INET, .sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_ANY), .sin_addr.s_addr = htonl(INADDR_ANY),
.sin_port = htons(port), .sin_port = htons(port),
}; };
struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_port = htons(port),
};
struct sockaddr *sap;
size_t len;
switch (serv->sv_family) {
case AF_INET:
sap = (struct sockaddr *)&sin;
len = sizeof(sin);
break;
case AF_INET6:
sap = (struct sockaddr *)&sin6;
len = sizeof(sin6);
break;
default:
return ERR_PTR(-EAFNOSUPPORT);
}
return xcl->xcl_ops->xpo_create(serv, sap, len, flags);
}
int svc_create_xprt(struct svc_serv *serv, char *xprt_name, unsigned short port,
int flags)
{
struct svc_xprt_class *xcl;
dprintk("svc: creating transport %s[%d]\n", xprt_name, port); dprintk("svc: creating transport %s[%d]\n", xprt_name, port);
spin_lock(&svc_xprt_class_lock); spin_lock(&svc_xprt_class_lock);
list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) { list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) {
@ -180,9 +209,7 @@ int svc_create_xprt(struct svc_serv *serv, char *xprt_name, unsigned short port,
goto err; goto err;
spin_unlock(&svc_xprt_class_lock); spin_unlock(&svc_xprt_class_lock);
newxprt = xcl->xcl_ops-> newxprt = __svc_xpo_create(xcl, serv, port, flags);
xpo_create(serv, (struct sockaddr *)&sin, sizeof(sin),
flags);
if (IS_ERR(newxprt)) { if (IS_ERR(newxprt)) {
module_put(xcl->xcl_owner); module_put(xcl->xcl_owner);
return PTR_ERR(newxprt); return PTR_ERR(newxprt);