Change the callback address in the nfs4_client and nfs4_setclientid
structures to be usable by any transport. Adapt the constants for the XDR
encoding/decodind

Signed-off-by: Aurelien Charbon <aurelien.charbon@ext.bull.net>

 fs/nfs/callback.c         |    5 ++---
 fs/nfs/callback.h         |    4 ++--
 fs/nfs/callback_xdr.c     |    4 ++--
 fs/nfs/nfs4_fs.h          |    2 +-
 fs/nfs/nfs4xdr.c          |    9 +++++----
 include/linux/nfs_fs_sb.h |    2 +-
 include/linux/nfs_xdr.h   |    6 +++---
 net/sunrpc/svcsock.c      |   37 +++++++++++++++++++++++++++++++++----
 8 files changed, 49 insertions(+), 20 deletions(-)
--------
diff -Nru linux-2.6.12-06/fs/nfs/callback.c linux-2.6.12-07/fs/nfs/callback.c
--- linux-2.6.12-06/fs/nfs/callback.c	2005-06-27 09:59:06.000000000 +0200
+++ linux-2.6.12-07/fs/nfs/callback.c	2005-07-01 16:42:13.000000000 +0200
@@ -92,7 +92,6 @@
 	ret = -ENOMEM;
 	if (!serv)
 		goto out_err;
-	/* FIXME: We don't want to register this socket with the portmapper */
 	ret = svc_makesock(serv, IPPROTO_TCP, 0);
 	if (ret < 0)
 		goto out_destroy;
@@ -140,12 +139,12 @@
 
 static int nfs_callback_authenticate(struct svc_rqst *rqstp)
 {
-	struct sockaddr_in *addr = &rqstp->rq_addr;
+	struct sockaddr *addr = (struct sockaddr *)&rqstp->rq_addr;
 	struct nfs4_client *clp;
 	char addr_buf[RPC_BUF_ADDR_MAX_SIZE];
 
 	/* Don't talk to strangers */
-	clp = nfs4_find_client((struct sockaddr *)addr);
+	clp = nfs4_find_client(addr);
 	if (clp == NULL)
 		return SVC_DROP;
 	rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR, addr_buf, sizeof(addr_buf));
diff -Nru linux-2.6.12-06/fs/nfs/callback.h linux-2.6.12-07/fs/nfs/callback.h
--- linux-2.6.12-06/fs/nfs/callback.h	2005-06-22 11:16:43.000000000 +0200
+++ linux-2.6.12-07/fs/nfs/callback.h	2005-06-29 14:55:19.000000000 +0200
@@ -38,7 +38,7 @@
 };
 
 struct cb_getattrargs {
-	struct sockaddr_in *addr;
+	struct sockaddr *addr;
 	struct nfs_fh fh;
 	uint32_t bitmap[2];
 };
@@ -53,7 +53,7 @@
 };
 
 struct cb_recallargs {
-	struct sockaddr_in *addr;
+	struct sockaddr *addr;
 	struct nfs_fh fh;
 	nfs4_stateid stateid;
 	uint32_t truncate;
diff -Nru linux-2.6.12-06/fs/nfs/callback_xdr.c linux-2.6.12-07/fs/nfs/callback_xdr.c
--- linux-2.6.12-06/fs/nfs/callback_xdr.c	2005-06-22 11:17:08.000000000 +0200
+++ linux-2.6.12-07/fs/nfs/callback_xdr.c	2005-06-29 14:15:43.000000000 +0200
@@ -177,7 +177,7 @@
 	status = decode_fh(xdr, &args->fh);
 	if (unlikely(status != 0))
 		goto out;
-	args->addr = &rqstp->rq_addr;
+	args->addr = (struct sockaddr *)&rqstp->rq_addr;
 	status = decode_bitmap(xdr, args->bitmap);
 out:
 	dprintk("%s: exit with status = %d\n", __FUNCTION__, status);
@@ -189,7 +189,7 @@
 	uint32_t *p;
 	unsigned status;
 
-	args->addr = &rqstp->rq_addr;
+	args->addr = (struct sockaddr *)&rqstp->rq_addr;
 	status = decode_stateid(xdr, &args->stateid);
 	if (unlikely(status != 0))
 		goto out;
diff -Nru linux-2.6.12-06/fs/nfs/nfs4_fs.h linux-2.6.12-07/fs/nfs/nfs4_fs.h
--- linux-2.6.12-06/fs/nfs/nfs4_fs.h	2005-06-23 17:35:44.000000000 +0200
+++ linux-2.6.12-07/fs/nfs/nfs4_fs.h	2005-06-29 14:16:50.000000000 +0200
@@ -91,7 +91,7 @@
 	/* Our own IP address, as a null-terminated string.
 	 * This is used to generate the clientid, and the callback address.
 	 */
-	char			cl_ipaddr[16];
+	char			cl_ipaddr[80];
 	unsigned char		cl_id_uniquifier;
 };
 
diff -Nru linux-2.6.12-06/fs/nfs/nfs4xdr.c linux-2.6.12-07/fs/nfs/nfs4xdr.c
--- linux-2.6.12-06/fs/nfs/nfs4xdr.c	2005-06-22 11:17:51.000000000 +0200
+++ linux-2.6.12-07/fs/nfs/nfs4xdr.c	2005-06-29 14:18:04.000000000 +0200
@@ -101,10 +101,11 @@
 #define decode_renew_maxsz	(op_decode_hdr_maxsz)
 #define encode_setclientid_maxsz \
 				(op_encode_hdr_maxsz + \
-				4 /*server->ip_addr*/ + \
-				1 /*Netid*/ + \
-				6 /*uaddr*/ + \
-				6 + (NFS4_VERIFIER_SIZE >> 2))
+				192 /*sc_name*/ + \
+				4 /*Netid*/ + \
+				22 /*uaddr*/ + \
+				2 /*cb_program + cb_ident*/ + \
+				(NFS4_VERIFIER_SIZE >> 2))
 #define decode_setclientid_maxsz \
 				(op_decode_hdr_maxsz + \
 				2 + \
diff -Nru linux-2.6.12-06/include/linux/nfs_fs_sb.h linux-2.6.12-07/include/linux/nfs_fs_sb.h
--- linux-2.6.12-06/include/linux/nfs_fs_sb.h	2005-06-23 11:32:10.000000000 +0200
+++ linux-2.6.12-07/include/linux/nfs_fs_sb.h	2005-06-29 14:22:15.000000000 +0200
@@ -43,7 +43,7 @@
 	/* Our own IP address, as a null-terminated string.
 	 * This is used to generate the clientid, and the callback address.
 	 */
-	char			ip_addr[16];
+	char			ip_addr[80];
 	char *			mnt_path;
 	struct nfs4_client *	nfs4_state;	/* all NFSv4 state starts here */
 	struct list_head	nfs4_siblings;	/* List of other nfs_server structs
diff -Nru linux-2.6.12-06/include/linux/nfs_xdr.h linux-2.6.12-07/include/linux/nfs_xdr.h
--- linux-2.6.12-06/include/linux/nfs_xdr.h	2005-06-22 11:17:51.000000000 +0200
+++ linux-2.6.12-07/include/linux/nfs_xdr.h	2005-06-29 14:23:54.000000000 +0200
@@ -640,12 +640,12 @@
 struct nfs4_setclientid {
 	const nfs4_verifier *		sc_verifier;      /* request */
 	unsigned int			sc_name_len;
-	char				sc_name[32];	  /* request */
+	char				sc_name[80];	  /* request */
 	u32				sc_prog;          /* request */
 	unsigned int			sc_netid_len;
-	char				sc_netid[4];	  /* request */
+	char				sc_netid[12];	  /* request */
 	unsigned int			sc_uaddr_len;
-	char				sc_uaddr[24];     /* request */
+	char				sc_uaddr[80];     /* request */
 	u32				sc_cb_ident;      /* request */
 };
 
diff -Nru linux-2.6.12-06/net/sunrpc/svcsock.c linux-2.6.12-07/net/sunrpc/svcsock.c
--- linux-2.6.12-06/net/sunrpc/svcsock.c	2005-06-28 14:03:49.000000000 +0200
+++ linux-2.6.12-07/net/sunrpc/svcsock.c	2005-06-29 14:28:21.000000000 +0200
@@ -1440,7 +1440,7 @@
  * Create socket for RPC service.
  */
 static int
-svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr *sin)
+svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr *sin, int pmap_reg)
 {
 	struct svc_sock	*svsk;
 	struct socket	*sock;
@@ -1475,8 +1475,8 @@
 		if ((error = sock->ops->listen(sock, 64)) < 0)
 			goto bummer;
 	}
-
-	if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL)
+	
+	if ((svsk = svc_setup_socket(serv, sock, &error, pmap_reg)) != NULL)
 		return 0;
 
 bummer:
@@ -1534,8 +1534,37 @@
 	sin.sin_family      = AF_INET;
 	sin.sin_addr.s_addr = INADDR_ANY;
 	sin.sin_port        = htons(port);
-	return svc_create_socket(serv, protocol, (struct sockaddr *)&sin);
+	return svc_create_socket(serv, protocol, (struct sockaddr *)&sin, 1);
+}
+
+ /*
+ * Make a socket for nfs callback (will be then used by nfsd and lockd)
+ */
+int
+svc_makesock2(struct svc_serv *serv, int protocol, unsigned short port,
+	      int pmap_reg)
+{
+	struct sockaddr_in6     sin6;
+	struct sockaddr_in	sin;
+	int ret;
+
+	dprintk("svc: creating socket proto = %d\n", protocol);
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+	memset(&sin6, '\0', sizeof(struct sockaddr_in6));
+	sin6.sin6_family    = AF_INET6;
+	sin6.sin6_port      = htons(port);
+	ret = svc_create_socket(serv, protocol, (struct sockaddr *)&sin6,
+				pmap_reg);
+	if (ret)
+		return ret;
+#endif
+	sin.sin_family      = AF_INET;
+	sin.sin_addr.s_addr = INADDR_ANY;
+	sin.sin_port        = htons(port);
+	return svc_create_socket(serv, protocol, (struct sockaddr *)&sin,
+				 pmap_reg);
 }
+EXPORT_SYMBOL(svc_makesock2);
 
 /*
  * Handle defer and revisit of requests 

