From: Tom Tucker <tom@opengridcomputing.com>
To: nfs@lists.sourceforge.net
Cc: neilb@suse.de, bfields@fieldses.org, gnb@sgi.com
Subject: [RFC, PATCH] svc: Modify svc_create_xprt to return local port
Date: Tue, 09 Oct 2007 17:52:53 -0500 [thread overview]
Message-ID: <20071009225253.25816.36183.stgit@dell3.ogc.int> (raw)
Please take this version of the patch. The previous version has a
whitespace issue. Sorry for the inconvenience.
This patch fixes a regression introduced by the svc transport
switch as follows:
- Listening endpoints need to have their local address set properly.
- svc_create_xprt needs to return the local port number since the
the nfs4 callback service uses the return value to determine the
local port elected by the transport when binding to zero.
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---
net/sunrpc/svc_xprt.c | 19 ++++++++++++++++++-
net/sunrpc/svcsock.c | 8 ++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index b580d4c..d35195e 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -159,6 +159,23 @@ void svc_xprt_init(struct svc_xprt_class
}
EXPORT_SYMBOL_GPL(svc_xprt_init);
+static int svc_local_port(struct svc_xprt *xprt)
+{
+ int ret = 0;
+ switch (xprt->xpt_local.ss_family) {
+ case AF_INET:
+ ret = ntohs(((struct sockaddr_in *)
+ &xprt->xpt_local)->sin_port);
+ break;
+ case AF_INET6:
+ ret = ntohs(((struct sockaddr_in6 *)
+ &xprt->xpt_local)->sin6_port);
+ break;
+ }
+ dprintk("svc: local port for xprt %p is %d\n", xprt, ret);
+ return ret;
+}
+
int svc_create_xprt(struct svc_serv *serv, char *xprt_name, unsigned short port,
int flags)
{
@@ -176,7 +193,6 @@ int svc_create_xprt(struct svc_serv *ser
spin_unlock(&svc_xprt_class_lock);
if (try_module_get(xcl->xcl_owner)) {
struct svc_xprt *newxprt;
- ret = 0;
newxprt = xcl->xcl_ops->xpo_create
(serv,
(struct sockaddr *)&sin, sizeof(sin),
@@ -191,6 +207,7 @@ int svc_create_xprt(struct svc_serv *ser
list_add(&newxprt->xpt_list,
&serv->sv_permsocks);
spin_unlock_bh(&serv->sv_lock);
+ ret = svc_local_port(newxprt);
}
}
goto out;
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 7838b27..4bb2d57 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1278,6 +1278,8 @@ svc_create_socket(struct svc_serv *serv,
int error;
int type;
char buf[RPC_MAX_ADDRBUFLEN];
+ struct sockaddr newsin;
+ int newlen;
dprintk("svc: svc_create_socket(%s, %d, %s)\n",
serv->sv_program->pg_name, protocol,
@@ -1302,12 +1304,18 @@ svc_create_socket(struct svc_serv *serv,
if (error < 0)
goto bummer;
+ newlen = len;
+ error = kernel_getsockname(sock, &newsin, &newlen);
+ if (error < 0)
+ goto bummer;
+
if (protocol == IPPROTO_TCP) {
if ((error = kernel_listen(sock, 64)) < 0)
goto bummer;
}
if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) {
+ memcpy(&svsk->sk_xprt.xpt_local, &newsin, newlen);
svc_xprt_received(&svsk->sk_xprt);
return (struct svc_xprt *)svsk;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
next reply other threads:[~2007-10-09 22:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-09 22:52 Tom Tucker [this message]
2007-10-10 2:35 ` [RFC, PATCH] svc: Modify svc_create_xprt to return local port Greg Banks
2007-10-10 2:28 ` Tom Tucker
-- strict thread matches above, loose matches on Subject: below --
2007-10-09 22:47 Tom Tucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071009225253.25816.36183.stgit@dell3.ogc.int \
--to=tom@opengridcomputing.com \
--cc=bfields@fieldses.org \
--cc=gnb@sgi.com \
--cc=neilb@suse.de \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.