All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@primarydata.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>,
	"hacking@nachtgeist.net" <hacking@nachtgeist.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: It's back! (Re: [REGRESSION] NFS is creating a hidden port (left over from xs_bind() ))
Date: Tue, 6 Feb 2018 19:26:29 +0000	[thread overview]
Message-ID: <1517945183.39096.4.camel@primarydata.com> (raw)
In-Reply-To: <9518bb1f-ad0a-2c33-d3fc-78550be06a0c@nachtgeist.net>

[-- Attachment #1: Type: text/plain, Size: 3799 bytes --]

On Tue, 2018-02-06 at 10:20 +0100, Daniel Reichelt wrote:
> On 02/06/2018 01:24 AM, Trond Myklebust wrote:
> > Does the following fix the issue?
> > 
> > 8<-----------------------------------------------
> > From 9b30889c548a4d45bfe6226e58de32504c1d682f Mon Sep 17 00:00:00
> > 2001
> > From: Trond Myklebust <trond.myklebust@primarydata.com>
> > Date: Mon, 5 Feb 2018 10:20:06 -0500
> > Subject: [PATCH] SUNRPC: Ensure we always close the socket after a
> > connection
> >  shuts down
> > 
> > Ensure that we release the TCP socket once it is in the TCP_CLOSE
> > or
> > TCP_TIME_WAIT state (and only then) so that we don't confuse
> > rkhunter
> > and its ilk.
> > 
> > Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> > ---
> >  net/sunrpc/xprtsock.c | 23 ++++++++++-------------
> >  1 file changed, 10 insertions(+), 13 deletions(-)
> > 
> > diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> > index 18803021f242..5d0108172ed3 100644
> > --- a/net/sunrpc/xprtsock.c
> > +++ b/net/sunrpc/xprtsock.c
> > @@ -807,13 +807,6 @@ static void
> > xs_sock_reset_connection_flags(struct rpc_xprt *xprt)
> >  	smp_mb__after_atomic();
> >  }
> >  
> > -static void xs_sock_mark_closed(struct rpc_xprt *xprt)
> > -{
> > -	xs_sock_reset_connection_flags(xprt);
> > -	/* Mark transport as closed and wake up all pending tasks
> > */
> > -	xprt_disconnect_done(xprt);
> > -}
> > -
> >  /**
> >   * xs_error_report - callback to handle TCP socket state errors
> >   * @sk: socket
> > @@ -833,9 +826,6 @@ static void xs_error_report(struct sock *sk)
> >  	err = -sk->sk_err;
> >  	if (err == 0)
> >  		goto out;
> > -	/* Is this a reset event? */
> > -	if (sk->sk_state == TCP_CLOSE)
> > -		xs_sock_mark_closed(xprt);
> >  	dprintk("RPC:       xs_error_report client %p,
> > error=%d...\n",
> >  			xprt, -err);
> >  	trace_rpc_socket_error(xprt, sk->sk_socket, err);
> > @@ -1655,9 +1645,11 @@ static void xs_tcp_state_change(struct sock
> > *sk)
> >  		if (test_and_clear_bit(XPRT_SOCK_CONNECTING,
> >  					&transport->sock_state))
> >  			xprt_clear_connecting(xprt);
> > +		clear_bit(XPRT_CLOSING, &xprt->state);
> >  		if (sk->sk_err)
> >  			xprt_wake_pending_tasks(xprt, -sk-
> > >sk_err);
> > -		xs_sock_mark_closed(xprt);
> > +		/* Trigger the socket release */
> > +		xs_tcp_force_close(xprt);
> >  	}
> >   out:
> >  	read_unlock_bh(&sk->sk_callback_lock);
> > @@ -2265,14 +2257,19 @@ static void xs_tcp_shutdown(struct rpc_xprt
> > *xprt)
> >  {
> >  	struct sock_xprt *transport = container_of(xprt, struct
> > sock_xprt, xprt);
> >  	struct socket *sock = transport->sock;
> > +	int skst = transport->inet ? transport->inet->sk_state :
> > TCP_CLOSE;
> >  
> >  	if (sock == NULL)
> >  		return;
> > -	if (xprt_connected(xprt)) {
> > +	switch (skst) {
> > +	default:
> >  		kernel_sock_shutdown(sock, SHUT_RDWR);
> >  		trace_rpc_socket_shutdown(xprt, sock);
> > -	} else
> > +		break;
> > +	case TCP_CLOSE:
> > +	case TCP_TIME_WAIT:
> >  		xs_reset_transport(transport);
> > +	}
> >  }
> >  
> >  static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt,
> > 
> 
> 
> Previously, I've seen hidden ports within 5-6 minutes after re-
> starting
> the nfsd and re-mounting nfs-exports on clients.
> 
> With this patch applied, I don't see any hidden ports after 15mins. I
> guess it's a valid fix.

For the record, the intention of the patch is not to adjust or correct
any connection timeout values. Merely to ensure that once the
connection breakage is detected by the socket layer, so that is it no
longer usable by the RPC client, we release the socket.

-- 
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-02-06 19:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 21:31 It's back! (Re: [REGRESSION] NFS is creating a hidden port (left over from xs_bind() )) Daniel Reichelt
2018-02-06  0:24 ` Trond Myklebust
2018-02-06  9:20   ` Daniel Reichelt
2018-02-06 19:26     ` Trond Myklebust [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-06-30 12:59 Steven Rostedt
2016-06-30 12:59 ` Steven Rostedt
2016-06-30 13:17 ` Trond Myklebust
2016-06-30 15:23   ` Steven Rostedt
2016-06-30 16:24     ` Steven Rostedt
2016-06-30 18:30     ` Trond Myklebust
2016-06-30 18:30       ` Trond Myklebust
2016-06-30 20:07       ` Steven Rostedt
2016-06-30 20:07         ` Steven Rostedt
2016-06-30 21:56         ` Steven Rostedt
2015-06-12  3:49 [REGRESSION] NFS is creating a hidden port (left over from xs_bind() ) Steven Rostedt
2015-06-12 14:10 ` Trond Myklebust
2015-06-12 14:40   ` Eric Dumazet
2015-06-12 15:34     ` Steven Rostedt
2015-06-12 15:50       ` Steven Rostedt
2015-06-18  3:08         ` Steven Rostedt
2015-06-18 19:24           ` Trond Myklebust
2015-06-18 19:49             ` Steven Rostedt
2015-06-18 22:50               ` Jeff Layton
2015-06-19  1:08                 ` Steven Rostedt
2015-06-19  1:37                   ` Jeff Layton
2015-06-19 16:25                     ` Steven Rostedt
2015-06-19 17:17                       ` Steven Rostedt
2015-06-19 17:39                         ` Trond Myklebust
2015-06-19 19:52                           ` Jeff Layton
2015-06-19 20:30                             ` Trond Myklebust
2015-06-19 22:14                               ` Steven Rostedt
2015-06-19 23:25                                 ` Trond Myklebust
2015-06-20  1:27                                   ` Steven Rostedt
2016-06-22 16:41                                     ` It's back! (Re: [REGRESSION] NFS is creating a hidden port (left over from xs_bind() )) Steven Rostedt

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=1517945183.39096.4.camel@primarydata.com \
    --to=trondmy@primarydata.com \
    --cc=hacking@nachtgeist.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=rostedt@goodmis.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.