svc: Modify svc_create_xprt to return local port
Subsystems (3)
RFC PATCH 1/1 svc: Modify svc_create_xprt to return local port
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.
---
net/sunrpc/svc_xprt.c | 19 ++++++++++++++++++- net/sunrpc/svcsock.c | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletions(-)
net/sunrpc/svc_xprt.c +18 -1
@@ -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 *serspin_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 *serlist_add (&newxprt->xpt_list, &serv->sv_permsocks);spin_unlock_bh (&serv->sv_lock); + ret =svc_local_port (newxprt); } } goto out;
net/sunrpc/svcsock.c +8 -0
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 17 lines · Tom Tucker
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_xprtneeds 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.[...]
net/sunrpc/svcsock.c svc_create_socket(struct svc_serv *serv, · line 1282
Quoted 5 lines
net/sunrpc/svcsock.c +2
-0@@ -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;
Struct sockaddr isn't big enough for this to work with ipv6, use struct sockaddr_storage. Or do the kernel_getsockname() driectly into xprt->xpt_local.
Greg.
Signature · 12 lines
Greg Banks, R&D Software Engineer, SGI Australian Software Group. Apparently, I'm Bedevere. Which MPHG character are you? I don't speak for SGI. ------------------------------------------------------------------------- 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 - [email protected] https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 14 lines · Greg Banks
Quoted 13 lines · Tom Tucker
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_xprtneeds 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.
Quoted 13 lines
net/sunrpc/svcsock.c svc_create_socket(struct svc_serv *serv, · line 1282
Quoted 9 lines
[...]
net/sunrpc/svcsock.c +2
-0@@ -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;Struct sockaddr isn't big enough for this to work with ipv6, use struct
sockaddr_storage. Or do thekernel_getsockname()driectly intoxprt->xpt_local.
I think this is preferred. Thanks Greg.
Quoted 2 lines
Greg.
-------------------------------------------------------------------------
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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs