Skip to content

Commit f7d6a23

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: fix per socket endpoint accounting
Since full-mesh endpoint support, the reception of a single ADD_ADDR option can cause multiple subflows creation. When such option is accepted we increment 'add_addr_accepted' by one. When we received a paired RM_ADDR option, we deleted all the relevant subflows, decrementing 'add_addr_accepted' by one for each of them. We have a similar issue for 'local_addr_used' Fix them moving the pm endpoint accounting outside the subflow traversal. Fixes: 1a0d613 ("mptcp: local addresses fullmesh") Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 05be5e2 commit f7d6a23

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/mptcp/pm_netlink.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
711711
return;
712712

713713
for (i = 0; i < rm_list->nr; i++) {
714+
bool removed = false;
715+
714716
list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
715717
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
716718
int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
@@ -730,15 +732,19 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
730732
mptcp_close_ssk(sk, ssk, subflow);
731733
spin_lock_bh(&msk->pm.lock);
732734

733-
if (rm_type == MPTCP_MIB_RMADDR) {
734-
msk->pm.add_addr_accepted--;
735-
WRITE_ONCE(msk->pm.accept_addr, true);
736-
} else if (rm_type == MPTCP_MIB_RMSUBFLOW) {
737-
msk->pm.local_addr_used--;
738-
}
735+
removed = true;
739736
msk->pm.subflows--;
740737
__MPTCP_INC_STATS(sock_net(sk), rm_type);
741738
}
739+
if (!removed)
740+
continue;
741+
742+
if (rm_type == MPTCP_MIB_RMADDR) {
743+
msk->pm.add_addr_accepted--;
744+
WRITE_ONCE(msk->pm.accept_addr, true);
745+
} else if (rm_type == MPTCP_MIB_RMSUBFLOW) {
746+
msk->pm.local_addr_used--;
747+
}
742748
}
743749
}
744750

0 commit comments

Comments
 (0)