]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
SUNRPC: prevent port reuse on transports which don't request it.
authorNeilBrown <neilb@suse.de>
Tue, 15 Jun 2021 01:18:38 +0000 (11:18 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:02:19 +0000 (16:02 +0200)
commitaebe64667664f453572af241bc883a14fac1da59
treead121c77a8324f8872aeb8755bb2e46c35798c8f
parentc1b5b248701ba299248e706dce9f6e6f58bc3506
SUNRPC: prevent port reuse on transports which don't request it.

[ Upstream commit bc1c56e9bbe92766d017efb5f0a0c71f80da5570 ]

If an RPC client is created without RPC_CLNT_CREATE_REUSEPORT, it should
not reuse the source port when a TCP connection is re-established.
This is currently implemented by preventing the source port being
recorded after a successful connection (the call to xs_set_srcport()).

However the source port is also recorded after a successful bind in xs_bind().
This may not be needed at all and certainly is not wanted when
RPC_CLNT_CREATE_REUSEPORT wasn't requested.

So avoid that assignment when xprt.reuseport is not set.

With this change, NFSv4.1 and later mounts use a different port number on
each connection.  This is helpful with some firewalls which don't cope
well with port reuse.

Signed-off-by: NeilBrown <neilb@suse.de>
Fixes: e6237b6feb37 ("NFSv4.1: Don't rebind to the same source port when reconnecting to the server")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/xprtsock.c