Skip to content

Commit 3ad14f5

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: more accurate MPC endpoint tracking
Currently the id accounting for the ID 0 subflow is not correct: at creation time we mark (correctly) as unavailable the endpoint id corresponding the MPC subflow source address, while at subflow removal time set as available the id 0. With this change we track explicitly the endpoint id corresponding to the MPC subflow so that we can mark it as available at removal time. Additionally this allow deleting the initial subflow via the NL PM specifying the corresponding endpoint id. Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c157bbe commit 3ad14f5

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

net/mptcp/pm_netlink.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
549549
entry = __lookup_addr(pernet, &mpc_addr, false);
550550
if (entry) {
551551
__clear_bit(entry->addr.id, msk->pm.id_avail_bitmap);
552+
msk->mpc_endpoint_id = entry->addr.id;
552553
backup = !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP);
553554
}
554555
rcu_read_unlock();
@@ -764,6 +765,11 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
764765
return -EINVAL;
765766
}
766767

768+
static bool mptcp_local_id_match(const struct mptcp_sock *msk, u8 local_id, u8 id)
769+
{
770+
return local_id == id || (!local_id && msk->mpc_endpoint_id == id);
771+
}
772+
767773
static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
768774
const struct mptcp_rm_list *rm_list,
769775
enum linux_mptcp_mib_field rm_type)
@@ -787,22 +793,23 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
787793
return;
788794

789795
for (i = 0; i < rm_list->nr; i++) {
796+
u8 rm_id = rm_list->ids[i];
790797
bool removed = false;
791798

792799
list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
793800
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
794801
int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
795802
u8 id = subflow->local_id;
796803

797-
if (rm_type == MPTCP_MIB_RMADDR)
798-
id = subflow->remote_id;
799-
800-
if (rm_list->ids[i] != id)
804+
if (rm_type == MPTCP_MIB_RMADDR && subflow->remote_id != rm_id)
805+
continue;
806+
if (rm_type == MPTCP_MIB_RMSUBFLOW && !mptcp_local_id_match(msk, id, rm_id))
801807
continue;
802808

803-
pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
809+
pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u",
804810
rm_type == MPTCP_MIB_RMADDR ? "address" : "subflow",
805-
i, rm_list->ids[i], subflow->local_id, subflow->remote_id);
811+
i, rm_id, subflow->local_id, subflow->remote_id,
812+
msk->mpc_endpoint_id);
806813
spin_unlock_bh(&msk->pm.lock);
807814
mptcp_subflow_shutdown(sk, ssk, how);
808815

@@ -814,7 +821,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
814821
__MPTCP_INC_STATS(sock_net(sk), rm_type);
815822
}
816823
if (rm_type == MPTCP_MIB_RMSUBFLOW)
817-
__set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap);
824+
__set_bit(rm_id ? rm_id : msk->mpc_endpoint_id, msk->pm.id_avail_bitmap);
818825
if (!removed)
819826
continue;
820827

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ struct mptcp_sock {
282282
bool use_64bit_ack; /* Set when we received a 64-bit DSN */
283283
bool csum_enabled;
284284
bool allow_infinite_fallback;
285+
u8 mpc_endpoint_id;
285286
u8 recvmsg_inq:1,
286287
cork:1,
287288
nodelay:1;

0 commit comments

Comments
 (0)