Skip to content

Commit cdeb506

Browse files
Dwyane-Yanintel-lab-lkp
authored andcommitted
mptcp: fix invalid addr occupy 'add_addr_accepted'
This patch fixes an issue where an invalid address is announced as a signal, the 'add_addr_accepted' is incorrectly added twice. If reach the limits, even the invalid connection is removed from conn_list by mptcp_worker, the variable is not updated, so the available address can not be added. When 'ADD_ADDR' adds an invalid address in the LAN, it will trigger the 'tcp_done_with_error' at the TCP level due to 'icmp_unreach'. At this point, 'RETRANS_ADDR' will increment 'add_addr_accepted' again. This patch is also helpful for issue#498. Closes: multipath-tcp/mptcp_net-next#498 Signed-off-by: Gang Yan <[email protected]>
1 parent dabd9bd commit cdeb506

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

net/mptcp/pm_netlink.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,31 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk)
960960
spin_unlock_bh(&msk->pm.lock);
961961
}
962962

963+
void mptcp_pm_subflow_closed_external(struct mptcp_sock *msk,
964+
struct mptcp_subflow_context *subflow)
965+
{
966+
u8 remote_id = READ_ONCE(subflow->remote_id);
967+
s16 local_id = READ_ONCE(subflow->local_id);
968+
struct mptcp_subflow_context *iter;
969+
970+
if (!subflow->request_join || !remote_id)
971+
return;
972+
973+
mptcp_for_each_subflow(msk, iter) {
974+
u8 iter_rmtid = READ_ONCE(iter->remote_id);
975+
s16 iter_locid = READ_ONCE(iter->local_id);
976+
977+
if (remote_id == iter_rmtid && iter->request_join &&
978+
local_id != iter_locid)
979+
return;
980+
}
981+
982+
spin_lock_bh(&msk->pm.lock);
983+
if (--msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk))
984+
WRITE_ONCE(msk->pm.accept_addr, true);
985+
spin_unlock_bh(&msk->pm.lock);
986+
}
987+
963988
static bool address_use_port(struct mptcp_pm_addr_entry *entry)
964989
{
965990
return (entry->flags &

net/mptcp/protocol.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,9 @@ static void __mptcp_close_subflow(struct sock *sk)
24722472
continue;
24732473

24742474
mptcp_close_ssk(sk, ssk, subflow);
2475+
2476+
if (mptcp_pm_is_kernel(msk))
2477+
mptcp_pm_subflow_closed_external(msk, subflow);
24752478
}
24762479

24772480
}

net/mptcp/protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
11461146
unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
11471147
unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk);
11481148
unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk);
1149+
void mptcp_pm_subflow_closed_external(struct mptcp_sock *msk,
1150+
struct mptcp_subflow_context *closed_subflow);
11491151

11501152
/* called under PM lock */
11511153
static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk)

0 commit comments

Comments
 (0)