Commit cbde2787 authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

mptcp: add rm_list_tx in mptcp_pm_data

This patch added a new member rm_list_tx for struct mptcp_pm_data as the
removing address list on the outgoing direction. Initialize its nr field
to zero in mptcp_pm_data_init.

In mptcp_pm_remove_anno_addr, put the single address id into an removing
list, and passed it to mptcp_pm_remove_addr.

In mptcp_pm_remove_addr, save the input rm_list to rm_list_tx in struct
mptcp_pm_data.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6445e17a
...@@ -39,18 +39,18 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, ...@@ -39,18 +39,18 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
return 0; return 0;
} }
int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id) int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
{ {
u8 rm_addr = READ_ONCE(msk->pm.addr_signal); u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
pr_debug("msk=%p, local_id=%d", msk, local_id); pr_debug("msk=%p, rm_list_nr=%d", msk, rm_list->nr);
if (rm_addr) { if (rm_addr) {
pr_warn("addr_signal error, rm_addr=%d", rm_addr); pr_warn("addr_signal error, rm_addr=%d", rm_addr);
return -EINVAL; return -EINVAL;
} }
msk->pm.rm_id = local_id; msk->pm.rm_list_tx = *rm_list;
rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL); rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
WRITE_ONCE(msk->pm.addr_signal, rm_addr); WRITE_ONCE(msk->pm.addr_signal, rm_addr);
return 0; return 0;
...@@ -260,7 +260,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining, ...@@ -260,7 +260,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
struct mptcp_rm_list *rm_list) struct mptcp_rm_list *rm_list)
{ {
int ret = false; int ret = false, len;
spin_lock_bh(&msk->pm.lock); spin_lock_bh(&msk->pm.lock);
...@@ -268,11 +268,15 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, ...@@ -268,11 +268,15 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
if (!mptcp_pm_should_rm_signal(msk)) if (!mptcp_pm_should_rm_signal(msk))
goto out_unlock; goto out_unlock;
if (remaining < TCPOLEN_MPTCP_RM_ADDR_BASE) len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
if (len < 0) {
WRITE_ONCE(msk->pm.addr_signal, 0);
goto out_unlock;
}
if (remaining < len)
goto out_unlock; goto out_unlock;
rm_list->ids[0] = msk->pm.rm_id; *rm_list = msk->pm.rm_list_tx;
rm_list->nr = 1;
WRITE_ONCE(msk->pm.addr_signal, 0); WRITE_ONCE(msk->pm.addr_signal, 0);
ret = true; ret = true;
...@@ -292,7 +296,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) ...@@ -292,7 +296,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
msk->pm.add_addr_accepted = 0; msk->pm.add_addr_accepted = 0;
msk->pm.local_addr_used = 0; msk->pm.local_addr_used = 0;
msk->pm.subflows = 0; msk->pm.subflows = 0;
msk->pm.rm_id = 0; msk->pm.rm_list_tx.nr = 0;
WRITE_ONCE(msk->pm.work_pending, false); WRITE_ONCE(msk->pm.work_pending, false);
WRITE_ONCE(msk->pm.addr_signal, 0); WRITE_ONCE(msk->pm.addr_signal, 0);
WRITE_ONCE(msk->pm.accept_addr, false); WRITE_ONCE(msk->pm.accept_addr, false);
......
...@@ -1071,12 +1071,15 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, ...@@ -1071,12 +1071,15 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
struct mptcp_addr_info *addr, struct mptcp_addr_info *addr,
bool force) bool force)
{ {
struct mptcp_rm_list list = { .nr = 0 };
bool ret; bool ret;
list.ids[list.nr++] = addr->id;
ret = remove_anno_list_by_saddr(msk, addr); ret = remove_anno_list_by_saddr(msk, addr);
if (ret || force) { if (ret || force) {
spin_lock_bh(&msk->pm.lock); spin_lock_bh(&msk->pm.lock);
mptcp_pm_remove_addr(msk, addr->id); mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock); spin_unlock_bh(&msk->pm.lock);
} }
return ret; return ret;
......
...@@ -207,6 +207,7 @@ struct mptcp_pm_data { ...@@ -207,6 +207,7 @@ struct mptcp_pm_data {
u8 local_addr_used; u8 local_addr_used;
u8 subflows; u8 subflows;
u8 status; u8 status;
struct mptcp_rm_list rm_list_tx;
u8 rm_id; u8 rm_id;
}; };
...@@ -661,7 +662,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk, ...@@ -661,7 +662,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
int mptcp_pm_announce_addr(struct mptcp_sock *msk, int mptcp_pm_announce_addr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr, const struct mptcp_addr_info *addr,
bool echo, bool port); bool echo, bool port);
int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id); int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list);
int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id); int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id);
void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment