Skip to content

Commit

Permalink
mptcp: change add_addr_signal type
Browse files Browse the repository at this point in the history
This patch changed the 'add_addr_signal' type from bool to char, so that
we could encode the addr type there.

Suggested-by: Paolo Abeni <[email protected]>
Acked-by: Paolo Abeni <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and jenkins-tessares committed Nov 20, 2020
1 parent 0493cf3 commit 8ef3c33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
15 changes: 9 additions & 6 deletions net/mptcp/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr,
bool echo)
{
u8 add_addr = READ_ONCE(msk->pm.add_addr_signal);

pr_debug("msk=%p, local_id=%d", msk, addr->id);

msk->pm.local = *addr;
WRITE_ONCE(msk->pm.add_addr_echo, echo);
WRITE_ONCE(msk->pm.add_addr_signal, true);
add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL);
if (echo)
add_addr |= BIT(MPTCP_ADD_ADDR_ECHO);
WRITE_ONCE(msk->pm.add_addr_signal, add_addr);
return 0;
}

Expand Down Expand Up @@ -182,13 +186,13 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
if (!mptcp_pm_should_add_signal(msk))
goto out_unlock;

*echo = READ_ONCE(msk->pm.add_addr_echo);
*echo = mptcp_pm_should_add_signal_echo(msk);

if (remaining < mptcp_add_addr_len(msk->pm.local.family, *echo))
goto out_unlock;

*saddr = msk->pm.local;
WRITE_ONCE(msk->pm.add_addr_signal, false);
WRITE_ONCE(msk->pm.add_addr_signal, 0);
ret = true;

out_unlock:
Expand Down Expand Up @@ -232,11 +236,10 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
msk->pm.subflows = 0;
msk->pm.rm_id = 0;
WRITE_ONCE(msk->pm.work_pending, false);
WRITE_ONCE(msk->pm.add_addr_signal, false);
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_subflow, false);
WRITE_ONCE(msk->pm.add_addr_echo, false);
msk->pm.status = 0;

spin_lock_init(&msk->pm.lock);
Expand Down
15 changes: 12 additions & 3 deletions net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,24 @@ enum mptcp_pm_status {
MPTCP_PM_SUBFLOW_ESTABLISHED,
};

enum mptcp_add_addr_status {
MPTCP_ADD_ADDR_SIGNAL,
MPTCP_ADD_ADDR_ECHO,
};

struct mptcp_pm_data {
struct mptcp_addr_info local;
struct mptcp_addr_info remote;
struct list_head anno_list;

spinlock_t lock; /*protects the whole PM data */

bool add_addr_signal;
u8 add_addr_signal;
bool rm_addr_signal;
bool server_side;
bool work_pending;
bool accept_addr;
bool accept_subflow;
bool add_addr_echo;
u8 add_addr_signaled;
u8 add_addr_accepted;
u8 local_addr_used;
Expand Down Expand Up @@ -516,7 +520,12 @@ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id);

static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
{
return READ_ONCE(msk->pm.add_addr_signal);
return READ_ONCE(msk->pm.add_addr_signal) & BIT(MPTCP_ADD_ADDR_SIGNAL);
}

static inline bool mptcp_pm_should_add_signal_echo(struct mptcp_sock *msk)
{
return READ_ONCE(msk->pm.add_addr_signal) & BIT(MPTCP_ADD_ADDR_ECHO);
}

static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
Expand Down

0 comments on commit 8ef3c33

Please sign in to comment.