Skip to content

Commit

Permalink
mptcp: remove multi addresses in PM
Browse files Browse the repository at this point in the history
This patch dropped the member rm_id of struct mptcp_pm_data. Use
rm_list_rx in mptcp_pm_nl_rm_addr_received instead of using rm_id.

In mptcp_pm_nl_rm_addr_received, iterated each address id from
pm.rm_list_rx, then shut down and closed each address id's subsocket.

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
  • Loading branch information
geliangtang authored and jenkins-tessares committed Feb 18, 2021
1 parent 8be112e commit f78ff72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 20 additions & 16 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,36 +575,40 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
{
struct mptcp_subflow_context *subflow, *tmp;
struct sock *sk = (struct sock *)msk;
u8 i;

pr_debug("address rm_id %d", msk->pm.rm_id);
pr_debug("address rm_list_nr %d", msk->pm.rm_list_rx.nr);

msk_owned_by_me(msk);

if (!msk->pm.rm_id)
if (!msk->pm.rm_list_rx.nr)
return;

if (list_empty(&msk->conn_list))
return;

list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
for (i = 0; i < msk->pm.rm_list_rx.nr; i++) {
list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
int how = RCV_SHUTDOWN | SEND_SHUTDOWN;

if (msk->pm.rm_id != subflow->remote_id)
continue;
if (msk->pm.rm_list_rx.ids[i] != subflow->remote_id)
continue;

spin_unlock_bh(&msk->pm.lock);
mptcp_subflow_shutdown(sk, ssk, how);
mptcp_close_ssk(sk, ssk, subflow);
spin_lock_bh(&msk->pm.lock);
pr_debug(" -> address rm_list_ids[%d]=%u", i, msk->pm.rm_list_rx.ids[i]);
spin_unlock_bh(&msk->pm.lock);
mptcp_subflow_shutdown(sk, ssk, how);
mptcp_close_ssk(sk, ssk, subflow);
spin_lock_bh(&msk->pm.lock);

msk->pm.add_addr_accepted--;
msk->pm.subflows--;
WRITE_ONCE(msk->pm.accept_addr, true);
msk->pm.add_addr_accepted--;
msk->pm.subflows--;
WRITE_ONCE(msk->pm.accept_addr, true);

__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);
__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);

break;
break;
}
}
}

Expand Down
1 change: 0 additions & 1 deletion net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ struct mptcp_pm_data {
u8 status;
struct mptcp_rm_list rm_list_tx;
struct mptcp_rm_list rm_list_rx;
u8 rm_id;
};

struct mptcp_data_frag {
Expand Down

0 comments on commit f78ff72

Please sign in to comment.