public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: libtirpc-devel-pyega4qmqnRoyOMFzWx49A@public.gmane.org,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH] rpcbind: set SO_REUSEADDR on NC_TPI_COTS listening sockets (resend)
Date: Wed, 09 Jun 2010 15:58:42 -0400	[thread overview]
Message-ID: <4C0FF272.3010600@oracle.com> (raw)
In-Reply-To: <1276081743-31277-1-git-send-email-jlayton@redhat.com>

For the record, this is an issue for any network service daemon that 
uses a fixed port.  This solution is similar to what sshd does in many 
cases.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>

On 06/ 9/10 07:09 AM, Jeff Layton wrote:
> I previously sent this patch to the libtirpc-devel list but got no
> response. Resending with wider distribution...
>
> If we don't set SO_REUSEADDR, then if there are any sockets on this port
> in TIME_WAIT state when rpcbind is restarted then that will prevent the
> bind() call from succeeding.
>
> Details of the problem are here:
>
>      https://bugzilla.redhat.com/show_bug.cgi?id=597356
>
> Signed-off-by: Jeff Layton<jlayton@redhat.com>
> ---
>   src/rpcbind.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/src/rpcbind.c b/src/rpcbind.c
> index ddf2cfc..c8f0d9f 100644
> --- a/src/rpcbind.c
> +++ b/src/rpcbind.c
> @@ -276,6 +276,7 @@ init_transport(struct netconfig *nconf)
>   	int addrlen = 0;
>   	int nhostsbak;
>   	int checkbind;
> +	int on = 1;
>   	struct sockaddr *sa = NULL;
>   	u_int32_t host_addr[4];  /* IPv4 or IPv6 */
>   	struct sockaddr_un sun;
> @@ -493,6 +494,14 @@ init_transport(struct netconfig *nconf)
>   		}
>   		oldmask = umask(S_IXUSR|S_IXGRP|S_IXOTH);
>   		__rpc_fd2sockinfo(fd,&si);
> +		if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,&on,
> +				sizeof(on)) != 0) {
> +			syslog(LOG_ERR, "cannot set SO_REUSEADDR on %s",
> +				nconf->nc_netid);
> +			if (res != NULL)
> +				freeaddrinfo(res);
> +			return 1;
> +		}
>   		if (bind(fd, sa, addrlen)<  0) {
>   			syslog(LOG_ERR, "cannot bind %s: %m", nconf->nc_netid);
>   			if (res != NULL)


      reply	other threads:[~2010-06-09 19:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09 11:09 [PATCH] rpcbind: set SO_REUSEADDR on NC_TPI_COTS listening sockets (resend) Jeff Layton
2010-06-09 19:58 ` Chuck Lever [this message]

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=4C0FF272.3010600@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=jlayton@redhat.com \
    --cc=libtirpc-devel-pyega4qmqnRoyOMFzWx49A@public.gmane.org \
    --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