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

mptcp: drop rm_addr_signal flag

This patch reused add_addr_signal for the RM_ADDR announcing signal, by
defining a new ADD_ADDR status named MPTCP_RM_ADDR_SIGNAL. Then the flag
rm_addr_signal in PM could be dropped.
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 90a4aea8
...@@ -20,6 +20,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, ...@@ -20,6 +20,11 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
pr_debug("msk=%p, local_id=%d", msk, addr->id); pr_debug("msk=%p, local_id=%d", msk, addr->id);
if (add_addr) {
pr_warn("addr_signal error, add_addr=%d", add_addr);
return -EINVAL;
}
msk->pm.local = *addr; msk->pm.local = *addr;
add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL); add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL);
if (echo) if (echo)
...@@ -34,10 +39,18 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, ...@@ -34,10 +39,18 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id) int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id)
{ {
u8 rm_addr = READ_ONCE(msk->pm.add_addr_signal);
pr_debug("msk=%p, local_id=%d", msk, local_id); pr_debug("msk=%p, local_id=%d", msk, local_id);
if (rm_addr) {
pr_warn("addr_signal error, rm_addr=%d", rm_addr);
return -EINVAL;
}
msk->pm.rm_id = local_id; msk->pm.rm_id = local_id;
WRITE_ONCE(msk->pm.rm_addr_signal, true); rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
WRITE_ONCE(msk->pm.add_addr_signal, rm_addr);
return 0; return 0;
} }
...@@ -231,7 +244,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, ...@@ -231,7 +244,7 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
goto out_unlock; goto out_unlock;
*rm_id = msk->pm.rm_id; *rm_id = msk->pm.rm_id;
WRITE_ONCE(msk->pm.rm_addr_signal, false); WRITE_ONCE(msk->pm.add_addr_signal, 0);
ret = true; ret = true;
out_unlock: out_unlock:
...@@ -253,7 +266,6 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) ...@@ -253,7 +266,6 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
msk->pm.rm_id = 0; msk->pm.rm_id = 0;
WRITE_ONCE(msk->pm.work_pending, false); WRITE_ONCE(msk->pm.work_pending, false);
WRITE_ONCE(msk->pm.add_addr_signal, 0); WRITE_ONCE(msk->pm.add_addr_signal, 0);
WRITE_ONCE(msk->pm.rm_addr_signal, false);
WRITE_ONCE(msk->pm.accept_addr, false); WRITE_ONCE(msk->pm.accept_addr, false);
WRITE_ONCE(msk->pm.accept_subflow, false); WRITE_ONCE(msk->pm.accept_subflow, false);
msk->pm.status = 0; msk->pm.status = 0;
......
...@@ -173,6 +173,7 @@ enum mptcp_add_addr_status { ...@@ -173,6 +173,7 @@ enum mptcp_add_addr_status {
MPTCP_ADD_ADDR_ECHO, MPTCP_ADD_ADDR_ECHO,
MPTCP_ADD_ADDR_IPV6, MPTCP_ADD_ADDR_IPV6,
MPTCP_ADD_ADDR_PORT, MPTCP_ADD_ADDR_PORT,
MPTCP_RM_ADDR_SIGNAL,
}; };
struct mptcp_pm_data { struct mptcp_pm_data {
...@@ -183,7 +184,6 @@ struct mptcp_pm_data { ...@@ -183,7 +184,6 @@ struct mptcp_pm_data {
spinlock_t lock; /*protects the whole PM data */ spinlock_t lock; /*protects the whole PM data */
u8 add_addr_signal; u8 add_addr_signal;
bool rm_addr_signal;
bool server_side; bool server_side;
bool work_pending; bool work_pending;
bool accept_addr; bool accept_addr;
...@@ -578,7 +578,7 @@ static inline bool mptcp_pm_should_add_signal_port(struct mptcp_sock *msk) ...@@ -578,7 +578,7 @@ static inline bool mptcp_pm_should_add_signal_port(struct mptcp_sock *msk)
static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk) static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
{ {
return READ_ONCE(msk->pm.rm_addr_signal); return READ_ONCE(msk->pm.add_addr_signal) & BIT(MPTCP_RM_ADDR_SIGNAL);
} }
static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port) static inline unsigned int mptcp_add_addr_len(int family, bool echo, bool port)
......
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