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@fys.uio.no, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 03/40] SUNRPC: Clean up svc_find_xprt() calling sequence
Date: Wed, 18 Mar 2009 18:55:55 -0400	[thread overview]
Message-ID: <20090318225555.GI18894@fieldses.org> (raw)
In-Reply-To: <20090312160721.16019.89653.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>

On Thu, Mar 12, 2009 at 12:07:21PM -0400, Chuck Lever wrote:
> Clean up: add documentating comment and use appropriate data types for
> svc_find_xprt()'s arguments.
> 
> This also eliminates a mixed sign comparison: @port was an int, while
> the return value of svc_xprt_local_port() is an unsigned short.

Actually, I had second thoughts: the caller is in fact passing in an
int, obtained from sscanf.  Converting to a short introduces some
aliasing that could cause the comparison to succeed in some cases when
it didn't used to, hence catching fewer user errors, right?

So, dropping this one for now.

--b.

> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> 
>  include/linux/sunrpc/svc_xprt.h |    3 ++-
>  net/sunrpc/svc_xprt.c           |   16 +++++++++++-----
>  2 files changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
> index ee21e8a..167e4b5 100644
> --- a/include/linux/sunrpc/svc_xprt.h
> +++ b/include/linux/sunrpc/svc_xprt.h
> @@ -80,7 +80,8 @@ void	svc_close_xprt(struct svc_xprt *xprt);
>  void	svc_delete_xprt(struct svc_xprt *xprt);
>  int	svc_port_is_privileged(struct sockaddr *sin);
>  int	svc_print_xprts(char *buf, int maxlen);
> -struct	svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int);
> +struct	svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name,
> +			const sa_family_t af, const unsigned short port);
>  int	svc_xprt_names(struct svc_serv *serv, char *buf, int buflen);
>  
>  static inline void svc_xprt_get(struct svc_xprt *xprt)
> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> index e588df5..c947c93 100644
> --- a/net/sunrpc/svc_xprt.c
> +++ b/net/sunrpc/svc_xprt.c
> @@ -1033,7 +1033,13 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt)
>  	return dr;
>  }
>  
> -/*
> +/**
> + * svc_find_xprt - find an RPC transport instance
> + * @serv: pointer to svc_serv to search
> + * @xcl_name: C string containing transport's class name
> + * @af: Address family of transport's local address
> + * @port: transport's IP port number
> + *
>   * Return the transport instance pointer for the endpoint accepting
>   * connections/peer traffic from the specified transport class,
>   * address family and port.
> @@ -1042,14 +1048,14 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt)
>   * wild-card, and will result in matching the first transport in the
>   * service's list that has a matching class name.
>   */
> -struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name,
> -			       int af, int port)
> +struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name,
> +			       const sa_family_t af, const unsigned short port)
>  {
>  	struct svc_xprt *xprt;
>  	struct svc_xprt *found = NULL;
>  
>  	/* Sanity check the args */
> -	if (!serv || !xcl_name)
> +	if (serv == NULL || xcl_name == NULL)
>  		return found;
>  
>  	spin_lock_bh(&serv->sv_lock);
> @@ -1058,7 +1064,7 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name,
>  			continue;
>  		if (af != AF_UNSPEC && af != xprt->xpt_local.ss_family)
>  			continue;
> -		if (port && port != svc_xprt_local_port(xprt))
> +		if (port != 0 && port != svc_xprt_local_port(xprt))
>  			continue;
>  		found = xprt;
>  		svc_xprt_get(xprt);
> 

  parent reply	other threads:[~2009-03-18 22:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12 16:06 [PATCH 00/40] Proposed patches for 2.6.30 Chuck Lever
     [not found] ` <20090312155609.16019.86499.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-12 16:07   ` [PATCH 01/40] SUNRPC: Fix return type of svc_addr_len() Chuck Lever
     [not found]     ` <20090312160706.16019.81338.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-18 22:08       ` J. Bruce Fields
2009-03-18 22:40         ` Chuck Lever
2009-03-12 16:07   ` [PATCH 02/40] SUNRPC: Clean up static inline functions in svc_xprt.h Chuck Lever
     [not found]     ` <20090312160713.16019.56290.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-18 22:13       ` J. Bruce Fields
2009-03-12 16:07   ` [PATCH 03/40] SUNRPC: Clean up svc_find_xprt() calling sequence Chuck Lever
     [not found]     ` <20090312160721.16019.89653.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-18 22:34       ` J. Bruce Fields
2009-03-18 22:55       ` J. Bruce Fields [this message]
2009-03-12 16:07   ` [PATCH 04/40] SUNRPC: Pass a family argument to svc_register() Chuck Lever
2009-03-12 16:07   ` [PATCH 05/40] SUNRPC: svc_setup_socket() gets protocol family from socket Chuck Lever
2009-03-12 16:07   ` [PATCH 06/40] SUNRPC: Change svc_create_xprt() to take a @family argument Chuck Lever
2009-03-12 16:07   ` [PATCH 07/40] SUNRPC: Remove @family argument from svc_create() and svc_create_pooled() Chuck Lever
2009-03-12 16:07   ` [PATCH 08/40] NFS: Revert creation of IPv6 listeners for lockd and NFSv4 callbacks Chuck Lever
2009-03-12 16:08   ` [PATCH 09/40] SUNRPC: Set IPV6ONLY flag on PF_INET6 RPC listener sockets Chuck Lever
2009-03-12 16:08   ` [PATCH 10/40] SUNRPC: Use IPv4 loopback for registering AF_INET6 kernel RPC services Chuck Lever
2009-03-12 16:08   ` [PATCH 12/40] SUNRPC: Clean up address type casts in rpcb_v4_register() Chuck Lever
2009-03-12 16:08   ` [PATCH 13/40] SUNRPC: rpcbind actually interprets r_owner string Chuck Lever
2009-03-12 16:08   ` [PATCH 14/40] SUNRPC: Allow callers to pass rpcb_v4_register a NULL address Chuck Lever
2009-03-12 16:08   ` [PATCH 15/40] SUNRPC: Simplify svc_unregister() Chuck Lever
     [not found] ` <20090312161129.16019.26502.stgit@ingres.1015granger.net>
     [not found]   ` <20090312161129.16019.26502.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-03-18 23:54     ` [PATCH 36/40] NFSD: Prevent buffer overflow in write_threads() 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=20090318225555.GI18894@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    /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