Skip to content

Commit 6f757c9

Browse files
Greg Jumpervijay-suman
authored andcommitted
net/rds: Use proper peer port number even when not connected
The function rds_tcp_get_peer_sport() should return the peer port of a socket, even when the socket is not currently connected, so that RDS can reliably determine the MPRDS "lane" corresponding to the port. rds_tcp_get_peer_sport() calls kernel_getpeername() to get the port number; however, when paths between endpoints frequently drop and reconnect, kernel_getpeername() can return -ENOTCONN, causing rds_tcp_get_peer_sport() to return an error, and ultimately causing RDS to use the wrong lane for a port when reconnecting to a peer. This patch modifies rds_tcp_get_peer_sport() to directly call the socket-specific get-name function (inet_getname() in this case) that kernel_getpeername() also calls. The socket-specific function offers an additional argument which, when set to a value greater than 1, causes the function to return the socket's peer name even when the socket is not connected, which in turn allows rds_tcp_get_peer_sport() to return the correct port number. Orabug: 35896264 Suggested-by: Gerd Rausch <[email protected]> Signed-off-by: Greg Jumper <[email protected]> Reviewed-by: Håkon Bugge <[email protected]>
1 parent 930c491 commit 6f757c9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/rds/tcp_listen.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ rds_tcp_get_peer_sport(struct socket *sock)
6868
} saddr;
6969
int sport;
7070

71-
if (kernel_getpeername(sock, &saddr.addr) >= 0) {
71+
/* Call the socket's getname() function (inet_getname() in this case)
72+
* with a final argument greater than 1 to get the peer's port
73+
* regardless of whether the socket is currently connected.
74+
*/
75+
if (sock->ops->getname(sock, &saddr.addr, 2) >= 0) {
7276
switch (saddr.addr.sa_family) {
7377
case AF_INET:
7478
sport = ntohs(saddr.sin.sin_port);

0 commit comments

Comments
 (0)