Linux NFS development
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Weston Andros Adamson <dros@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] Cleanup XDR parsing for LAYOUTGET, GETDEVICEINFO
Date: Thu, 24 Mar 2011 17:29:08 -0400	[thread overview]
Message-ID: <1301002148.27109.5.camel@lade.trondhjem.org> (raw)
In-Reply-To: <1300999701-2244-1-git-send-email-dros@netapp.com>

On Thu, 2011-03-24 at 16:48 -0400, Weston Andros Adamson wrote:

> diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
> index 433204f..414c7e9 100644
> --- a/fs/nfs/nfs4filelayoutdev.c
> +++ b/fs/nfs/nfs4filelayoutdev.c
> @@ -261,7 +261,7 @@ out:
>   * Currently only support ipv4, and one multi-path address.
>   */
>  static struct nfs4_pnfs_ds *
> -decode_and_add_ds(__be32 **pp, struct inode *inode)
> +decode_and_add_ds(struct xdr_stream *streamp, struct inode *inode)
>  {
>  	struct nfs4_pnfs_ds *ds = NULL;
>  	char *buf;
> @@ -269,25 +269,34 @@ decode_and_add_ds(__be32 **pp, struct inode *inode)
>  	u32 ip_addr, port;
>  	int nlen, rlen, i;
>  	int tmp[2];
> -	__be32 *r_netid, *r_addr, *p = *pp;
> +	__be32 *p;
>  
>  	/* r_netid */
> +	p = xdr_inline_decode(streamp, 4);
> +	if (unlikely(!p))
> +		goto out_err;
>  	nlen = be32_to_cpup(p++);
> -	r_netid = p;
> -	p += XDR_QUADLEN(nlen);
>  
> -	/* r_addr */
> -	rlen = be32_to_cpup(p++);
> -	r_addr = p;
> -	p += XDR_QUADLEN(rlen);
> -	*pp = p;
> +	p = xdr_inline_decode(streamp, nlen);
> +	if (unlikely(!p))
> +		goto out_err;
>  
>  	/* Check that netid is "tcp" */
> -	if (nlen != 3 ||  memcmp((char *)r_netid, "tcp", 3)) {
> +	if (nlen != 3 ||  memcmp((char *)p, "tcp", 3)) {
>  		dprintk("%s: ERROR: non ipv4 TCP r_netid\n", __func__);
>  		goto out_err;
>  	}
>  
> +	/* r_addr */
> +	p = xdr_inline_decode(streamp, 4);
> +	if (unlikely(!p))
> +		goto out_err;
> +	rlen = be32_to_cpup(p);
> +
> +	p = xdr_inline_decode(streamp, rlen);
> +	if (unlikely(!p))
> +		goto out_err;
> +
>  	/* ipv6 length plus port is legal */
>  	if (rlen > INET6_ADDRSTRLEN + 8) {
>  		dprintk("%s: Invalid address, length %d\n", __func__,
> @@ -295,8 +304,10 @@ decode_and_add_ds(__be32 **pp, struct inode *inode)
>  		goto out_err;
>  	}
>  	buf = kmalloc(rlen + 1, GFP_KERNEL);
> +	if (unlikely(!buf))
> +		goto out_err;
>  	buf[rlen] = '\0';
> -	memcpy(buf, r_addr, rlen);
> +	memcpy(buf, p, rlen);
>  
>  	/* replace the port dots with dashes for the in4_pton() delimiter*/
>  	for (i = 0; i < 2; i++) {

I had a small conflict with this last hunk due to an existing patch in
the nfs-for-2.6.39 branch, but I think I've fixed it up correctly.

Please check the nfs-for-2.6.39 branch on
     git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com


  reply	other threads:[~2011-03-24 21:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 20:48 [PATCH] Cleanup XDR parsing for LAYOUTGET, GETDEVICEINFO Weston Andros Adamson
2011-03-24 21:29 ` Trond Myklebust [this message]
     [not found]   ` <1301002148.27109.5.camel-SyLVLa/KEI9HwK5hSS5vWB2eb7JE58TQ@public.gmane.org>
2011-03-25 14:01     ` Dros Adamson

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=1301002148.27109.5.camel@lade.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=dros@netapp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox