All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/7] lockd: Use sockaddr_storage + length for h_addr field
Date: Thu, 4 Sep 2008 13:46:33 -0400	[thread overview]
Message-ID: <20080904174633.GL4536@fieldses.org> (raw)
In-Reply-To: <20080903183539.16867.8416.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>

On Wed, Sep 03, 2008 at 02:35:39PM -0400, Chuck Lever wrote:
> To store larger addresses in the nlm_host structure, make h_addr a
> sockaddr_storage, and add an address length field.

Erps, I just noticed that mail to bfields@citi.umich.edu started getting
shunted off into a mailbox I don't check starting a week or two ago.  If
anyone sent me private mail to that address and hasn't gotten a
response, you might want to resend....  Anyway, thanks, I'll try to look
at this soon.

--b.

> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> 
>  fs/lockd/clntlock.c         |    2 +-
>  fs/lockd/host.c             |   11 ++++++-----
>  include/linux/lockd/lockd.h |   16 +++++++++++++++-
>  3 files changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
> index 0b45fd3..0df5587 100644
> --- a/fs/lockd/clntlock.c
> +++ b/fs/lockd/clntlock.c
> @@ -166,7 +166,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
>  		 */
>  		if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
>  			continue;
> -		if (!nlm_cmp_addr(&block->b_host->h_addr, addr))
> +		if (!nlm_cmp_addr(nlm_addr_in(block->b_host), addr))
>  			continue;
>  		if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
>  			continue;
> diff --git a/fs/lockd/host.c b/fs/lockd/host.c
> index 008e402..8c7022e 100644
> --- a/fs/lockd/host.c
> +++ b/fs/lockd/host.c
> @@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server,
>  	 */
>  	chain = &nlm_hosts[hash];
>  	hlist_for_each_entry(host, pos, chain, h_hash) {
> -		if (!nlm_cmp_addr(&host->h_addr, sin))
> +		if (!nlm_cmp_addr(nlm_addr_in(host), sin))
>  			continue;
>  
>  		/* See if we have an NSM handle for this client */
> @@ -165,8 +165,9 @@ static struct nlm_host *nlm_lookup_host(int server,
>  		goto out;
>  	}
>  	host->h_name	   = nsm->sm_name;
> -	host->h_addr       = *sin;
> -	nlm_clear_port((struct sockaddr *)&host->h_addr);
> +	memcpy(nlm_addr(host), sin, sizeof(*sin));
> +	host->h_addrlen = sizeof(*sin);
> +	nlm_clear_port(nlm_addr(host));
>  	host->h_saddr	   = *ssin;
>  	host->h_version    = version;
>  	host->h_proto      = proto;
> @@ -291,8 +292,8 @@ nlm_bind_host(struct nlm_host *host)
>  		};
>  		struct rpc_create_args args = {
>  			.protocol	= host->h_proto,
> -			.address	= (struct sockaddr *)&host->h_addr,
> -			.addrsize	= sizeof(host->h_addr),
> +			.address	= nlm_addr(host),
> +			.addrsize	= host->h_addrlen,
>  			.saddress	= (struct sockaddr *)&host->h_saddr,
>  			.timeout	= &timeparms,
>  			.servername	= host->h_name,
> diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
> index 0691efb..41d7a8e 100644
> --- a/include/linux/lockd/lockd.h
> +++ b/include/linux/lockd/lockd.h
> @@ -38,7 +38,8 @@
>   */
>  struct nlm_host {
>  	struct hlist_node	h_hash;		/* doubly linked list */
> -	struct sockaddr_in	h_addr;		/* peer address */
> +	struct sockaddr_storage	h_addr;		/* peer address */
> +	size_t			h_addrlen;
>  	struct sockaddr_in	h_saddr;	/* our address (optional) */
>  	struct rpc_clnt	*	h_rpcclnt;	/* RPC client to talk to peer */
>  	char *			h_name;		/* remote hostname */
> @@ -77,6 +78,19 @@ struct nsm_handle {
>  };
>  
>  /*
> + * Rigorous type checking on sockaddr type conversions
> + */
> +static inline struct sockaddr_in *nlm_addr_in(const struct nlm_host *host)
> +{
> +	return (struct sockaddr_in *)&host->h_addr;
> +}
> +
> +static inline struct sockaddr *nlm_addr(const struct nlm_host *host)
> +{
> +	return (struct sockaddr *)&host->h_addr;
> +}
> +
> +/*
>   * Map an fl_owner_t into a unique 32-bit "pid"
>   */
>  struct nlm_lockowner {
> 

  parent reply	other threads:[~2008-09-04 17:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-03 18:35 [PATCH 0/7] More IPv6 support for lockd Chuck Lever
     [not found] ` <20080903183411.16867.33715.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-03 18:35   ` [PATCH 1/7] lockd: Use sockaddr_storage + length for h_addr field Chuck Lever
     [not found]     ` <20080903183539.16867.8416.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-04 17:46       ` J. Bruce Fields [this message]
2008-09-03 18:35   ` [PATCH 2/7] lockd: Use sockaddr_storage for h_saddr field Chuck Lever
     [not found]     ` <20080903183546.16867.90601.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12  1:41       ` J. Bruce Fields
2008-09-12  3:14         ` Chuck Lever
     [not found]           ` <76bd70e30809112014m52af6961ja83522100203300b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-12 22:07             ` J. Bruce Fields
2008-09-03 18:35   ` [PATCH 3/7] NSM: Use sockaddr_storage for sm_addr field Chuck Lever
2008-09-03 18:36   ` [PATCH 4/7] lockd: Teach nlm_cmp_addr() to support AF_INET6 addresses Chuck Lever
2008-09-03 18:36   ` [PATCH 5/7] lockd: Support AF_INET6 when hashing addresses in nlm_lookup_host Chuck Lever
     [not found]     ` <20080903183608.16867.80962.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12 21:59       ` J. Bruce Fields
2008-09-03 18:36   ` [PATCH 6/7] lockd: Combine __nsm_find() and nsm_find() Chuck Lever
     [not found]     ` <20080903183615.16867.58815.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-09-12 21:56       ` J. Bruce Fields
2008-09-03 18:36   ` [PATCH 7/7] lockd: Update nsm_find() to support non-AF_INET addresses Chuck Lever
2008-09-12 22:12   ` [PATCH 0/7] More IPv6 support for lockd J. Bruce Fields

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=20080904174633.GL4536@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.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.