* [PATCH] SUNRPC: prevent port reuse on transports which don't request it.
@ 2021-06-15 1:18 NeilBrown
2021-06-17 3:24 ` NeilBrown
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2021-06-15 1:18 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs
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>
---
net/sunrpc/xprtsock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 316d04945587..3228b7a1836a 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1689,7 +1689,8 @@ static int xs_bind(struct sock_xprt *transport, struct socket *sock)
err = kernel_bind(sock, (struct sockaddr *)&myaddr,
transport->xprt.addrlen);
if (err == 0) {
- transport->srcport = port;
+ if (transport->xprt.reuseport)
+ transport->srcport = port;
break;
}
last = port;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] SUNRPC: prevent port reuse on transports which don't request it.
2021-06-15 1:18 [PATCH] SUNRPC: prevent port reuse on transports which don't request it NeilBrown
@ 2021-06-17 3:24 ` NeilBrown
0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2021-06-17 3:24 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs
On Tue, 15 Jun 2021, someone wrote:
> 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>
I guess this should have
Fixes: e6237b6feb37 ("NFSv4.1: Don't rebind to the same source port when reconnecting to the server")
NeilBrown
> ---
> net/sunrpc/xprtsock.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index 316d04945587..3228b7a1836a 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -1689,7 +1689,8 @@ static int xs_bind(struct sock_xprt *transport, struct socket *sock)
> err = kernel_bind(sock, (struct sockaddr *)&myaddr,
> transport->xprt.addrlen);
> if (err == 0) {
> - transport->srcport = port;
> + if (transport->xprt.reuseport)
> + transport->srcport = port;
> break;
> }
> last = port;
> --
> 2.31.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-17 3:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 1:18 [PATCH] SUNRPC: prevent port reuse on transports which don't request it NeilBrown
2021-06-17 3:24 ` NeilBrown
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.