netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: nfs@lists.sourceforge.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 13/25] NFS: Distinguish IPv6 addresses in __nfs_find_client
Date: Tue, 13 Nov 2007 13:32:09 -0500	[thread overview]
Message-ID: <20071113183209.5087.28230.stgit@manray.1015granger.net> (raw)

Add support for the AF_INET6 family of IP addresses in __nfs_find_client.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net>
---

 fs/nfs/client.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 8eff0b2..67a5a53 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -34,6 +34,8 @@
 #include <linux/nfs_idmap.h>
 #include <linux/vfs.h>
 #include <linux/inet.h>
+#include <linux/in6.h>
+#include <net/ipv6.h>
 #include <linux/nfs_xdr.h>
 
 #include <asm/system.h>
@@ -213,11 +215,10 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr *addr,
 					    unsigned int nfsversion,
 					    int match_port)
 {
-	struct sockaddr_in *ap = (struct sockaddr_in *)addr;
 	struct nfs_client *clp;
 
 	list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
-		struct sockaddr_in *clap = (struct sockaddr_in *)&clp->cl_addr;
+		struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
 
 		/* Don't match clients that failed to initialise properly */
 		if (clp->cl_cons_state < 0)
@@ -227,14 +228,33 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr *addr,
 		if (clp->rpc_ops->version != nfsversion)
 			continue;
 
-		if (((struct sockaddr *)clap)->sa_family != addr->sa_family)
+		if (clap->sa_family != addr->sa_family)
 			continue;
 
-		if (clap->sin_addr.s_addr != ap->sin_addr.s_addr)
+		switch (addr->sa_family) {
+		case AF_INET: {
+			struct sockaddr_in *sap = (struct sockaddr_in *)clap;
+			struct sockaddr_in *ap = (struct sockaddr_in *)addr;
+			if (sap->sin_addr.s_addr != ap->sin_addr.s_addr)
+				continue;
+			if (!match_port || sap->sin_port == ap->sin_port)
+				goto found;
 			continue;
-
-		if (!match_port || clap->sin_port == ap->sin_port)
-			goto found;
+			}
+		case AF_INET6: {
+			struct sockaddr_in6 *sap = (struct sockaddr_in6 *)clap;
+			struct sockaddr_in6 *ap = (struct sockaddr_in6 *)addr;
+			if (!ipv6_addr_equal(&sap->sin6_addr, &ap->sin6_addr))
+				continue;
+			if (!match_port || sap->sin6_port == ap->sin6_port)
+				goto found;
+			continue;
+			}
+		default:
+			printk(KERN_ERR "%s: address family not supported\n",
+				__FUNCTION__);
+			return NULL;
+		}
 	}
 
 	return NULL;


-------------------------------------------------------------------------
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

                 reply	other threads:[~2007-11-13 18:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20071113183209.5087.28230.stgit@manray.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=netdev@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).