public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two small mountd IPv6 patches
@ 2010-04-12 19:57 Chuck Lever
       [not found] ` <20100412195538.9839.76495.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2010-04-12 19:57 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Steve-

Two quick clean-ups that prepare for mountd/exportfs IPv6 support.

---

Chuck Lever (2):
      libexport.a: Add helper for populating m_addrlist[]
      libexport.a: Reduce code duplication in client_init()


 support/export/client.c |   41 ++++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 19 deletions(-)

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] libexport.a: Reduce code duplication in client_init()
       [not found] ` <20100412195538.9839.76495.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-04-12 19:57   ` Chuck Lever
  2010-04-12 19:57   ` [PATCH 2/2] libexport.a: Add helper for populating m_addrlist[] Chuck Lever
  2010-04-15 13:00   ` [PATCH 0/2] Two small mountd IPv6 patches Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2010-04-12 19:57 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up:  Most cases in client_init() set clp->m_naddr to zero.  Move
it to the common part of the function, and simplify the logic.  This
will make adding IPv6 support here more straightforward.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 support/export/client.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index aa28fcf..e06c874 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -137,6 +137,7 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp)
 
 	clp->m_exported = 0;
 	clp->m_count = 0;
+	clp->m_naddr = 0;
 
 	if (clp->m_type == MCL_SUBNETWORK) {
 		char	*cp = strchr(clp->m_hostname, '/');
@@ -160,10 +161,10 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp)
 			}
 		}
 		*cp = '/';
-		clp->m_naddr = 0;
-	} else if (!hp) {
-		clp->m_naddr = 0;
-	} else {
+		return;
+	}
+
+	if (hp) {
 		char	**ap = hp->h_addr_list;
 		int	i;
 


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] libexport.a: Add helper for populating m_addrlist[]
       [not found] ` <20100412195538.9839.76495.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-04-12 19:57   ` [PATCH 1/2] libexport.a: Reduce code duplication in client_init() Chuck Lever
@ 2010-04-12 19:57   ` Chuck Lever
  2010-04-15 13:00   ` [PATCH 0/2] Two small mountd IPv6 patches Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2010-04-12 19:57 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up: Move common code that populates an nfs_client record's
m_addrlist to a helper function.  This eliminates a little code
duplication, and makes it simpler to add IPv6 support later.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 support/export/client.c |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index e06c874..6a25928 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -36,6 +36,22 @@ static void	client_init(nfs_client *clp, const char *hname,
 nfs_client	*clientlist[MCL_MAXTYPES] = { NULL, };
 
 
+static void
+init_addrlist(nfs_client *clp, const struct hostent *hp)
+{
+	char **ap;
+	int i;
+
+	if (hp == NULL)
+		return;
+
+	ap = hp->h_addr_list;
+	for (i = 0; *ap != NULL && i < NFSCLNT_ADDRMAX; i++, ap++)
+		clp->m_addrlist[i] = *(struct in_addr *)*ap;
+
+	clp->m_naddr = i;
+}
+
 /* if canonical is set, then we *know* this is already a canonical name
  * so hostname lookup is avoided.
  * This is used when reading /proc/fs/nfs/exports
@@ -96,14 +112,8 @@ client_lookup(char *hname, int canonical)
 		client_add(clp);
 	}
 
-	if (htype == MCL_FQDN && clp->m_naddr == 0 && hp != NULL) {
-		char	**ap = hp->h_addr_list;
-		int	i;
-
-		for (i = 0; *ap && i < NFSCLNT_ADDRMAX; i++, ap++)
-			clp->m_addrlist[i] = *(struct in_addr *)*ap;
-		clp->m_naddr = i;
-	}
+	if (htype == MCL_FQDN && clp->m_naddr == 0)
+		init_addrlist(clp, hp);
 
 	if (hp)
 		free (hp);
@@ -163,16 +173,8 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp)
 		*cp = '/';
 		return;
 	}
-
-	if (hp) {
-		char	**ap = hp->h_addr_list;
-		int	i;
-
-		for (i = 0; *ap && i < NFSCLNT_ADDRMAX; i++, ap++) {
-			clp->m_addrlist[i] = *(struct in_addr *)*ap;
-		}
-		clp->m_naddr = i;
-	}
+	
+	init_addrlist(clp, hp);
 }
 
 void


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Two small mountd IPv6 patches
       [not found] ` <20100412195538.9839.76495.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-04-12 19:57   ` [PATCH 1/2] libexport.a: Reduce code duplication in client_init() Chuck Lever
  2010-04-12 19:57   ` [PATCH 2/2] libexport.a: Add helper for populating m_addrlist[] Chuck Lever
@ 2010-04-15 13:00   ` Steve Dickson
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2010-04-15 13:00 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs



On 04/12/2010 03:57 PM, Chuck Lever wrote:
> Steve-
> 
> Two quick clean-ups that prepare for mountd/exportfs IPv6 support.
> 
> ---
> 
> Chuck Lever (2):
>       libexport.a: Add helper for populating m_addrlist[]
>       libexport.a: Reduce code duplication in client_init()
> 
> 
>  support/export/client.c |   41 ++++++++++++++++++++++-------------------
>  1 files changed, 22 insertions(+), 19 deletions(-)
> 
Committed... 

steved.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-15 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-12 19:57 [PATCH 0/2] Two small mountd IPv6 patches Chuck Lever
     [not found] ` <20100412195538.9839.76495.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-12 19:57   ` [PATCH 1/2] libexport.a: Reduce code duplication in client_init() Chuck Lever
2010-04-12 19:57   ` [PATCH 2/2] libexport.a: Add helper for populating m_addrlist[] Chuck Lever
2010-04-15 13:00   ` [PATCH 0/2] Two small mountd IPv6 patches Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox