All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: "Aurélien Charbon" <aurelien.charbon@ext.bull.net>
Cc: Mailing list NFSv4 <nfsv4@linux-nfs.org>,
	netdev ML <netdev@vger.kernel.org>
Subject: Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses
Date: Thu, 06 Sep 2007 12:16:29 -0400	[thread overview]
Message-ID: <46E027DD.4030505@hp.com> (raw)
In-Reply-To: <46DFE4BC.2060406@ext.bull.net>

Hi Aurelien,

More comments.

Aurélien Charbon wrote:
> This is a small part of missing pieces of IPv6 support for the server.
> It deals with the ip_map caching code part.

>  	/* Insert client into hashtable. */
> -	for (i = 0; i < ncp->cl_naddr; i++)
> -		auth_unix_add_addr(ncp->cl_addrlist[i], dom);
> -
> +	for (i = 0; i < ncp->cl_naddr; i++) {
> +		/* Mapping address */
> +		ipv6_addr_v4map(ncp->cl_addrlist[i], addr6);

ipv6_addr_set(&addr6, 0, 0, htonl(0x0000FFFF), ncp->cl_addrlist[i]);
See below.

> @@ -236,7 +237,11 @@ static ssize_t write_getfs(struct file *
>  	res = (struct knfsd_fh*)buf;
>  
>  	exp_readlock();
> -	if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +	/* IPv6 address mapping */
> +	ipv6_addr_v4map(sin->sin_addr, in6);

ipv6_addr_set(&in6, 0, 0, htonl(0x0000FFFF), sin->sin_addr);
See below.

> @@ -271,7 +277,11 @@ static ssize_t write_getfd(struct file *
>  	res = buf;
>  	sin = (struct sockaddr_in *)&data->gd_addr;
>  	exp_readlock();
> -	if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +	/* IPv6 address mapping */
> +	ipv6_addr_v4map(sin->sin_addr, in6);

ipv6_addr_set(&in6, 0, 0, htonl(0x0000FFFF), sin->sin_addr);
See below.

> +#define IS_ADDR_MAPPED(a) \
> +	(((uint32_t *) (a))[0] == 0			\
> +	&& ((uint32_t *) (a))[1] == 0			\
> +	&& (((uint32_t *) (a))[2] == 0			\
> +	|| ((uint32_t *) (a))[2] == htonl(0xffff)))

Can go away, right?

> +static inline void ipv6_addr_v4map(const struct in_addr a1, struct in6_addr a2)
> +{
> +	a2.s6_addr32[0] = 0;
> +	a2.s6_addr32[1] = 0;
> +	a2.s6_addr32[2] = htonl(0xffff);
> +	a2.s6_addr32[3] = (uint32_t)a1.s_addr;
> +}

This can go away.  Looking at other code that does this - TCP, UDP, 
DCCP, they just call ipv6_addr_set() directly.

> +static inline int hash_ip6(struct in6_addr ip)
> +{
> +	return (hash_ip(ip.s6_addr32[0]) ^
> +		hash_ip(ip.s6_addr32[1]) ^
> +		hash_ip(ip.s6_addr32[2]) ^
> +		hash_ip(ip.s6_addr32[3]));
> +}

Should probably use a pointer to the address (*ip), probably doesn't 
matter that much since it's an inline.

> @@ -151,20 +159,22 @@ static void ip_map_request(struct cache_
>  {
>  	char text_addr[20];

This needs to be at least 40 since you're passing that to snprintf() below.

> +	if (ipv6_addr_v4mapped(&(im->m_addr))) {
> +		snprintf(text_addr, 20, NIPQUAD_FMT,
> +				ntohl(im->m_addr.s6_addr32[3]) >> 24 & 0xff,
> +				ntohl(im->m_addr.s6_addr32[3]) >> 16 & 0xff,
> +				ntohl(im->m_addr.s6_addr32[3]) >>  8 & 0xff,
> +				ntohl(im->m_addr.s6_addr32[3]) >>  0 & 0xff);
> +	} else {
> +		snprintf(text_addr, 40, NIP6_FMT, NIP6(im->m_addr));
> +	}

Here -------------------------------^^

> -static struct ip_map *ip_map_lookup(char *class, struct in_addr addr)
> +static struct ip_map *ip_map_lookup(char *class, struct in6_addr addr)

Maybe you should pass a pointer to the address (*addr) to avoid passing 
it on the stack.

> -int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom)
> +int auth_unix_add_addr(struct in6_addr addr, struct auth_domain *dom)

Here too.

> -struct auth_domain *auth_unix_lookup(struct in_addr addr)
> +struct auth_domain *auth_unix_lookup(struct in6_addr addr)

Here too.

> @@ -641,7 +669,19 @@ static int unix_gid_find(uid_t uid, stru
>  int
>  svcauth_unix_set_client(struct svc_rqst *rqstp)
>  {
> -	struct sockaddr_in *sin = svc_addr_in(rqstp);
> +	struct sockaddr_in *sin;
> +	struct sockaddr_in6 *sin6;

Will need change this to something like:

 > +	struct sockaddr_in6 *sin6, sin6_storage;

See below.

> +
> +	switch (rqstp->rq_addr.ss_family) {
> +	default:
> +		BUG();
> +	case AF_INET:
> +		sin = svc_addr_in(rqstp);
> +		ipv6_addr_v4map(sin->sin_addr, sin6->sin6_addr);

sin6 here is uninitialized, and in order to create a mapped address 
you'll need to allocate storage space on the stack to hold it.  New code 
would be:

		sin6 = &sin6_storage;
		ipv6_addr_set(&sin6->sin6_addr, 0, 0, htonl(0x0000FFFF),
				sin->sin_addr);

gcc really should have complained about that...

Maybe in the future rq_addr can just be in the correct form, but there's 
a lot of other code that would need to change for that.

-Brian

  reply	other threads:[~2007-09-06 16:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 13:18 [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses Aurélien Charbon
2007-08-23 15:32 ` Brian Haley
2007-09-06 11:30   ` Aurélien Charbon
2007-09-06 16:16     ` Brian Haley [this message]
2007-08-23 15:39 ` Chuck Lever
  -- strict thread matches above, loose matches on Subject: below --
2007-08-09  7:22 Aurélien Charbon
2007-08-09 12:16 ` Chuck Lever
2007-08-09 15:08   ` Aurélien Charbon
2007-08-09 15:14     ` Chuck Lever
2007-08-10  1:11       ` Neil Brown
2007-08-10  1:06 ` Neil Brown

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=46E027DD.4030505@hp.com \
    --to=brian.haley@hp.com \
    --cc=aurelien.charbon@ext.bull.net \
    --cc=netdev@vger.kernel.org \
    --cc=nfsv4@linux-nfs.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.