2007-11-29 19:41:04

by Chuck Lever

[permalink] [raw]
Subject: [NFS] [PATCH 01/29] SUNRPC: Use default address length based on address family

If the address length passed to rpc_create is zero, have it use a default
length based on the address family of the passed in address.

Signed-off-by: Chuck Lever <[email protected]>
---

net/sunrpc/clnt.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 76be83e..efa7890 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -30,6 +30,7 @@
#include <linux/smp_lock.h>
#include <linux/utsname.h>
#include <linux/workqueue.h>
+#include <linux/in6.h>

#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
@@ -249,6 +250,21 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
};
char servername[20];

+ if (args->addrsize == 0) {
+ switch (args->address->sa_family) {
+ case AF_INET:
+ xprtargs.addrlen = sizeof(struct sockaddr_in);
+ break;
+ case AF_INET6:
+ xprtargs.addrlen = sizeof(struct sockaddr_in6);
+ break;
+ default:
+ /* caller wants default address length, but
+ * address family isn't recognized. */
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
xprt = xprt_create_transport(&xprtargs);
if (IS_ERR(xprt))
return (struct rpc_clnt *)xprt;


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
_______________________________________________
Please note that [email protected] is being discontinued.
Please subscribe to [email protected] instead.
http://vger.kernel.org/vger-lists.html#linux-nfs