linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Neil Brown <neilb@suse.de>
Cc: Chuck Lever <chuck.lever@oracle.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/3] Give hostname.c more support for IPv6
Date: Mon, 27 Sep 2010 07:44:45 -0400	[thread overview]
Message-ID: <4CA083AD.2090306@RedHat.com> (raw)
In-Reply-To: <20100804064945.16641.71097.stgit@localhost.localdomain>



On 08/04/2010 02:49 AM, Neil Brown wrote:
> Allow host_pton,  host_addrinfo, and all functions that use
> sockaddr_size to work correctly with IPv6 addresses.
> 
> This means host_addrinfo can now return IPv6 addresses, but I think
> all code is ready for that.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  support/export/hostname.c |   26 ++++++++++++++++++--------
>  1 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/support/export/hostname.c b/support/export/hostname.c
> index f6a59f1..46ddfe2 100644
> --- a/support/export/hostname.c
> +++ b/support/export/hostname.c
> @@ -38,9 +38,11 @@
>  static socklen_t
>  sockaddr_size(const struct sockaddr *sap)
>  {
> -	if (sap->sa_family != AF_INET)
> -		return 0;
> -	return (socklen_t)sizeof(struct sockaddr_in);
> +	if (sap->sa_family == AF_INET)
> +		return (socklen_t)sizeof(struct sockaddr_in);
> +	if (sap->sa_family == AF_INET6)
> +		return (socklen_t)sizeof(struct sockaddr_in6);
> +	return 0;
>  }
>  #endif	/* HAVE_GETNAMEINFO */
This routine was eliminated with commit 63afb9

>  
> @@ -126,10 +128,12 @@ host_pton(const char *paddr)
>  	 * addresses that end with a blank.
>  	 *
>  	 * inet_pton(3) is much stricter.  Use it to be certain we
> -	 * have a real AF_INET presentation address, before invoking
> -	 * getaddrinfo(3) to generate the full addrinfo list.
> +	 * have a real AF_INET or AF_INET6 presentation address,
> +	 * before invoking getaddrinfo(3) to generate the full
> +	 * addrinfo list.
>  	 */
> -	if (inet_pton(AF_INET, paddr, &sin.sin_addr) == 0)
> +	if (inet_pton(AF_INET, paddr, &sin.sin_addr) == 0 &&
> +	    inet_pton(AF_INET6, paddr, &sin.sin_addr) == 0)
>  		return NULL;
This error case is  already handled in the current version of
of host_pton, but I must say, the above approved is much clear
than the existing code... but I'm going to leave things as-is..

>  
>  	error = getaddrinfo(paddr, NULL, &hint, &ai);
> @@ -168,7 +172,7 @@ host_addrinfo(const char *hostname)
>  {
>  	struct addrinfo *ai = NULL;
>  	struct addrinfo hint = {
> -		.ai_family	= AF_INET,
> +		.ai_family	= AF_UNSPEC,
>  		/* don't return duplicates */
>  		.ai_protocol	= (int)IPPROTO_UDP,
>  		.ai_flags	= AI_ADDRCONFIG | AI_CANONNAME,
> @@ -178,7 +182,13 @@ host_addrinfo(const char *hostname)
>  	error = getaddrinfo(hostname, NULL, &hint, &ai);
>  	switch (error) {
>  	case 0:
> -		return ai;
> +		if (ai->ai_family == AF_INET ||
> +		    ai->ai_family == AF_INET6)
> +			return ai;
> +		freeaddrinfo(ai);
> +		xlog(D_GENERAL, "%s: resolved to neither IPv4 nor IPv6 address.",
> +				hostname);
> +		break;
I think I'm going to try and blend this in with Chuck's recent patches
since I do like the idea of logging unsupported address families...

steved.

>  	case EAI_SYSTEM:
>  		xlog(D_GENERAL, "%s: failed to resolve %s: (%d) %m",
>  				__func__, hostname, errno);
> 
> 

  parent reply	other threads:[~2010-09-27 11:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04  6:49 [PATCH 0/3] Some IPv6 enhancements for nfs-utils Neil Brown
2010-08-04  6:49 ` [PATCH 1/3] Make buffers large enough for IPv6 addresses Neil Brown
2010-09-27 11:33   ` Steve Dickson
2010-08-04  6:49 ` [PATCH 2/3] Give hostname.c more support for IPv6 Neil Brown
2010-08-04 11:57   ` Jim Rees
2010-09-27 11:44   ` Steve Dickson [this message]
2010-08-04  6:49 ` [PATCH 3/3] Allow check_fqdn to compare IPv6 addresses Neil Brown
2010-09-27 11:46   ` Steve Dickson
2010-08-04 15:08 ` [PATCH 0/3] Some IPv6 enhancements for nfs-utils Chuck Lever

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=4CA083AD.2090306@RedHat.com \
    --to=steved@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    /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).