Skip to content

Commit bc19ff5

Browse files
matttbePaolo Abeni
authored andcommitted
mptcp: pm: skip connecting to already established sf
The lookup_subflow_by_daddr() helper checks if there is already a subflow connected to this address. But there could be a subflow that is closing, but taking time due to some reasons: latency, losses, data to process, etc. If an ADD_ADDR is received while the endpoint is being closed, it is better to try connecting to it, instead of rejecting it: the peer which has sent the ADD_ADDR will not be notified that the ADD_ADDR has been rejected for this reason, and the expected subflow will not be created at the end. This helper should then only look for subflows that are established, or going to be, but not the ones being closed. Fixes: d84ad04 ("mptcp: skip connecting the connected address") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent c07cc3e commit bc19ff5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

net/mptcp/pm_netlink.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,15 @@ static bool lookup_subflow_by_daddr(const struct list_head *list,
130130
{
131131
struct mptcp_subflow_context *subflow;
132132
struct mptcp_addr_info cur;
133-
struct sock_common *skc;
134133

135134
list_for_each_entry(subflow, list, node) {
136-
skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow);
135+
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
136+
137+
if (!((1 << inet_sk_state_load(ssk)) &
138+
(TCPF_ESTABLISHED | TCPF_SYN_SENT | TCPF_SYN_RECV)))
139+
continue;
137140

138-
remote_address(skc, &cur);
141+
remote_address((struct sock_common *)ssk, &cur);
139142
if (mptcp_addresses_equal(&cur, daddr, daddr->port))
140143
return true;
141144
}

0 commit comments

Comments
 (0)