Linux NFS development
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: trond.myklebust@netapp.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 07/24] SUNRPC:  Update RPC server's TCP record marker decoder
Date: Mon, 14 Apr 2008 14:49:59 -0400	[thread overview]
Message-ID: <20080414184959.GJ15950@fieldses.org> (raw)
In-Reply-To: <20080414162730.12741.97124.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>

On Mon, Apr 14, 2008 at 12:27:30PM -0400, Chuck Lever wrote:
> Clean up: Update the RPC server's TCP record marker decoder to match the
> constructs used by the RPC client's TCP socket transport.

Looks good to me.

> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> 
>  include/linux/sunrpc/svcsock.h |    4 ++--
>  net/sunrpc/svcsock.c           |   24 ++++++++++++------------
>  2 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
> index 206f092..8cff696 100644
> --- a/include/linux/sunrpc/svcsock.h
> +++ b/include/linux/sunrpc/svcsock.h
> @@ -26,8 +26,8 @@ struct svc_sock {
>  	void			(*sk_owspace)(struct sock *);
>  
>  	/* private TCP part */
> -	int			sk_reclen;	/* length of record */
> -	int			sk_tcplen;	/* current read length */
> +	u32			sk_reclen;	/* length of record */
> +	u32			sk_tcplen;	/* current read length */
>  };
>  
>  /*
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index de29e7f..51357a3 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -46,6 +46,7 @@
>  #include <linux/sunrpc/types.h>
>  #include <linux/sunrpc/clnt.h>
>  #include <linux/sunrpc/xdr.h>
> +#include <linux/sunrpc/msg_prot.h>
>  #include <linux/sunrpc/svcsock.h>
>  #include <linux/sunrpc/stats.h>
>  
> @@ -829,8 +830,8 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
>  	 * the next four bytes. Otherwise try to gobble up as much as
>  	 * possible up to the complete record length.
>  	 */
> -	if (svsk->sk_tcplen < 4) {
> -		unsigned long	want = 4 - svsk->sk_tcplen;
> +	if (svsk->sk_tcplen < sizeof(rpc_fraghdr)) {
> +		int		want = sizeof(rpc_fraghdr) - svsk->sk_tcplen;
>  		struct kvec	iov;
>  
>  		iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen;
> @@ -840,32 +841,31 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
>  		svsk->sk_tcplen += len;
>  
>  		if (len < want) {
> -			dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
> -				len, want);
> +			dprintk("svc: short recvfrom while reading record "
> +				"length (%d of %d)\n", len, want);
>  			svc_xprt_received(&svsk->sk_xprt);
>  			return -EAGAIN; /* record header not complete */
>  		}
>  
>  		svsk->sk_reclen = ntohl(svsk->sk_reclen);
> -		if (!(svsk->sk_reclen & 0x80000000)) {
> +		if (!(svsk->sk_reclen & RPC_LAST_STREAM_FRAGMENT)) {
>  			/* FIXME: technically, a record can be fragmented,
>  			 *  and non-terminal fragments will not have the top
>  			 *  bit set in the fragment length header.
>  			 *  But apparently no known nfs clients send fragmented
>  			 *  records. */
>  			if (net_ratelimit())
> -				printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
> -				       " (non-terminal)\n",
> -				       (unsigned long) svsk->sk_reclen);
> +				printk(KERN_NOTICE "RPC: multiple fragments "
> +					"per record not supported\n");

Yep, that's helpful documentation, thanks.--b.

>  			goto err_delete;
>  		}
> -		svsk->sk_reclen &= 0x7fffffff;
> +		svsk->sk_reclen &= RPC_FRAGMENT_SIZE_MASK;
>  		dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen);
>  		if (svsk->sk_reclen > serv->sv_max_mesg) {
>  			if (net_ratelimit())
> -				printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
> -				       " (large)\n",
> -				       (unsigned long) svsk->sk_reclen);
> +				printk(KERN_NOTICE "RPC: "
> +					"fragment too large: 0x%08lx\n",
> +					(unsigned long)svsk->sk_reclen);
>  			goto err_delete;
>  		}
>  	}
> 

  parent reply	other threads:[~2008-04-14 18:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14 16:26 [PATCH 00/24] RPC server support rpcbind v4 plus additional clean ups Chuck Lever
     [not found] ` <20080414162108.12741.73233.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 16:26   ` [PATCH 01/24] NFS: Use NFSDBG_FILE for all fops Chuck Lever
2008-04-14 16:26   ` [PATCH 02/24] NFS: Fix trace debugging nits in write.c Chuck Lever
2008-04-14 16:27   ` [PATCH 03/24] SUNRPC: RPC server still uses 2.4 method for disabling TCP Nagle Chuck Lever
     [not found]     ` <20080414162701.12741.10868.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 17:38       ` J. Bruce Fields
2008-04-14 16:27   ` [PATCH 04/24] SUNRPC: Address potential buffer length overflow in svc_sendto Chuck Lever
     [not found]     ` <20080414162708.12741.71691.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 17:48       ` J. Bruce Fields
2008-04-14 19:43         ` Chuck Lever
2008-04-14 20:35           ` J. Bruce Fields
2008-04-14 16:27   ` [PATCH 05/24] SUNRPC: Address potential buffer length overflow in svc_tcp_sendto Chuck Lever
2008-04-14 16:27   ` [PATCH 06/24] SUNRPC: Sanity check incoming UDP datagram lengths properly Chuck Lever
     [not found]     ` <20080414162723.12741.35500.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 18:38       ` J. Bruce Fields
2008-04-14 19:55         ` Chuck Lever
2008-04-14 20:54           ` J. Bruce Fields
2008-04-14 21:38             ` Chuck Lever
2008-04-14 16:27   ` [PATCH 07/24] SUNRPC: Update RPC server's TCP record marker decoder Chuck Lever
     [not found]     ` <20080414162730.12741.97124.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 18:49       ` J. Bruce Fields [this message]
2008-04-14 16:27   ` [PATCH 08/24] SUNRPC: Use unsigned index when looping over arrays Chuck Lever
2008-04-14 16:27   ` [PATCH 09/24] " Chuck Lever
     [not found]     ` <20080414162745.12741.37176.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 18:51       ` J. Bruce Fields
2008-04-14 16:27   ` [PATCH 10/24] SUNRPC: Use unsigned loop and array index in svc_init_buffer() Chuck Lever
     [not found]     ` <20080414162752.12741.15628.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-04-14 18:51       ` J. Bruce Fields
2008-04-14 16:28   ` [PATCH 11/24] SUNRPC: Remove obsolete messages during transport connect Chuck Lever
2008-04-14 16:28   ` [PATCH 12/24] SUNRPC: More useful debugging output for rpcb client Chuck Lever
2008-04-14 16:28   ` [PATCH 13/24] SUNRPC: Document some naked integers in rpcbind client Chuck Lever
2008-04-14 16:28   ` [PATCH 14/24] SUNRPC: Use correct XDR encoding procedure for rpcbind SET/UNSET Chuck Lever
2008-04-14 16:28   ` [PATCH 15/24] SUNRPC: Introduce a specific rpcb_create for contacting localhost Chuck Lever
2008-04-14 16:28   ` [PATCH 16/24] SUNRPC: None of rpcb_create's callers wants a privileged ephemeral port Chuck Lever
2008-04-14 16:28   ` [PATCH 17/24] SUNRPC: Refactor rpcb_register to make rpcbindv4 support easier Chuck Lever
2008-04-14 16:28   ` [PATCH 18/24] SUNRPC: introduce new task flag that fails requests on xprt disconnect Chuck Lever
2008-04-14 16:28   ` [PATCH 19/24] SUNRPC: Quickly detect missing portmapper during RPC service registration Chuck Lever
2008-04-14 16:29   ` [PATCH 20/24] SUNRPC: Support registering IPv6 interfaces with local rpcbind daemon Chuck Lever
2008-04-14 16:29   ` [PATCH 21/24] SUNRPC: Split portmap unregister API into separate function Chuck Lever
2008-04-14 16:29   ` [PATCH 22/24] SUNRPC: Use the new rpcb_v4_register() API in svc_unregister() Chuck Lever
2008-04-14 16:29   ` [PATCH 23/24] SUNRPC: Use new rpcb_v4_register() interface in svc_register() Chuck Lever
2008-04-14 16:29   ` [PATCH 24/24] SUNRPC: Add kernel build option to disable server-side use of rpcbind v3/v4 Chuck Lever
2008-04-14 19:14   ` [PATCH 00/24] RPC server support rpcbind v4 plus additional clean ups J. Bruce Fields
2008-04-14 20:05     ` 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=20080414184959.GJ15950@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@netapp.com \
    /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