Skip to content

Commit

Permalink
sunrpc: Fix return value of get_srcport()
Browse files Browse the repository at this point in the history
[ Upstream commit 5d46dd0 ]

Since bc1c56e transport->srcport may by unset, causing
get_srcport() to return 0 when called. Fix this by querying the port
from the underlying socket instead of the transport.

Fixes: bc1c56e (SUNRPC: prevent port reuse on transports which don't request it)
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
amschuma-ntap authored and gregkh committed Sep 18, 2021
1 parent 7787647 commit e519433
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/sunrpc/xprtsock.c
Expand Up @@ -1651,7 +1651,7 @@ static int xs_get_srcport(struct sock_xprt *transport)
unsigned short get_srcport(struct rpc_xprt *xprt)
{
struct sock_xprt *sock = container_of(xprt, struct sock_xprt, xprt);
return sock->srcport;
return xs_sock_getport(sock->sock);
}
EXPORT_SYMBOL(get_srcport);

Expand Down

0 comments on commit e519433

Please sign in to comment.