Subject: Re: linux-next: nfs build failure

From: Trond Myklebust <[email-masked]>
Date: Wed, 18 Jun 2008 18:18:44 -0400

On Wed, 2008-06-18 at 14:19 -0700, Randy Dunlap wrote:

> > > 
> > > You need the same fix in nfs_parse_ipv6_address().
> > 
> > There is no such printk in nfs_parse_ipv6_address().
> 
> There is such a 'dfprintk()' in that function in today's linux-next tree,
> with the same warning.

Gack, you're right. In fact that shows up another bug: #ifdef
CONFIG_IPV6 isn't sufficient. The reason the above dfprintk wasn't
triggering for me was that you also need to check for
CONFIG_IPV6_MODULE.

Sigh. Revised patch is attached...

  Trond

Subject: NFS: Don't allow IPv6 addresses if CONFIG_IPv6 isn't set
From: Trond Myklebust <[email-masked]>
Date: Wed, 18 Jun 2008 16:04:22 -0400

Fixes a compile failure in fs/nfs/super.c

Also fix the compiler warnings:
  fs/nfs/super.c:721: warning: field width should have type ‘int’, but
  		      argument 2 has type ‘size_t’
  fs/nfs/super.c:776: warning: field width should have type ‘int’, but
  		      argument 2 has type ‘size_t’
  fs/nfs/super.c:809:3: warning: returning void-valued expression
  fs/nfs/super.c:811:3: warning: returning void-valued expression

Signed-off-by: Trond Myklebust <[email-masked]>
---

 fs/nfs/super.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e62820c..1d98e95 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -718,10 +718,10 @@ static void nfs_parse_ipv4_address(char *string, size_t str_len,
 	struct sockaddr_in *sin = (struct sockaddr_in *)sap;
 	u8 *addr = (u8 *)&sin->sin_addr.s_addr;
 
-	dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n",
-			str_len, string);
-
 	if (str_len <= INET_ADDRSTRLEN) {
+		dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n",
+				(int)str_len, string);
+
 		sin->sin_family = AF_INET;
 		*addr_len = sizeof(*sin);
 		if (in4_pton(string, str_len, addr, '\0', NULL))
@@ -732,6 +732,7 @@ static void nfs_parse_ipv4_address(char *string, size_t str_len,
 	*addr_len = 0;
 }
 
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 static void nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
 				    const char *delim,
 				    struct sockaddr_in6 *sin6)
@@ -772,10 +773,10 @@ static void nfs_parse_ipv6_address(char *string, size_t str_len,
 	u8 *addr = (u8 *)&sin6->sin6_addr.in6_u;
 	const char *delim;
 
-	dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n",
-			str_len, string);
-
 	if (str_len <= INET6_ADDRSTRLEN) {
+		dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n",
+				(int)str_len, string);
+
 		sin6->sin6_family = AF_INET6;
 		*addr_len = sizeof(*sin6);
 		if (in6_pton(string, str_len, addr, SCOPE_DELIMITER, &delim)) {
@@ -787,6 +788,14 @@ static void nfs_parse_ipv6_address(char *string, size_t str_len,
 	sap->sa_family = AF_UNSPEC;
 	*addr_len = 0;
 }
+#else
+static void nfs_parse_ipv6_address(char *string, size_t str_len,
+				   struct sockaddr *sap, size_t *addr_len)
+{
+	sap->sa_family = AF_UNSPEC;
+	*addr_len = 0;
+}
+#endif
 
 /*
  * Construct a sockaddr based on the contents of a string that contains
@@ -806,9 +815,9 @@ static void nfs_parse_ip_address(char *string, size_t str_len,
 			colons++;
 
 	if (colons >= 2)
-		return nfs_parse_ipv6_address(string, str_len, sap, addr_len);
+		nfs_parse_ipv6_address(string, str_len, sap, addr_len);
 	else
-		return nfs_parse_ipv4_address(string, str_len, sap, addr_len);
+		nfs_parse_ipv4_address(string, str_len, sap, addr_len);
 }
 
 /*