Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: Rename tw_lock to mpcb_list_lock
Browse files Browse the repository at this point in the history
The lock is going to cover more than just the tw-list.
Namely, the subflow-list stored in the mpcb.

Signed-off-by: Christoph Paasch <[email protected]>
Signed-off-by: Matthieu Baerts <[email protected]>
  • Loading branch information
cpaasch authored and matttbe committed May 2, 2018
1 parent 773f0e5 commit 411ffb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion include/net/mptcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ struct mptcp_cb {
/* list of sockets that need a call to release_cb */
struct hlist_head callback_list;

/* Lock used for protecting the different rcu-lists of mptcp_cb */
spinlock_t mpcb_list_lock;

/* High-order bits of 64-bit sequence numbers */
u32 snd_high_order[2];
u32 rcv_high_order[2];
Expand Down Expand Up @@ -292,7 +295,6 @@ struct mptcp_cb {
u64 infinite_rcv_seq;

/***** Start of fields, used for connection closure */
spinlock_t tw_lock;
unsigned char mptw_state;
u8 dfin_path_index;

Expand Down
14 changes: 7 additions & 7 deletions net/mptcp/mptcp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,14 @@ void mptcp_sock_destruct(struct sock *sk)
* update to the rcv_nxt of the time-wait-sock and remove
* its reference to the mpcb.
*/
spin_lock_bh(&mpcb->tw_lock);
spin_lock_bh(&mpcb->mpcb_list_lock);
list_for_each_entry_rcu(mptw, &mpcb->tw_list, list) {
list_del_rcu(&mptw->list);
mptw->in_list = 0;
mptcp_mpcb_put(mpcb);
rcu_assign_pointer(mptw->mpcb, NULL);
}
spin_unlock_bh(&mpcb->tw_lock);
spin_unlock_bh(&mpcb->mpcb_list_lock);

mptcp_debug("%s destroying meta-sk token %#x\n", __func__,
tcp_sk(sk)->mpcb->mptcp_loc_token);
Expand Down Expand Up @@ -1279,9 +1279,9 @@ static int mptcp_alloc_mpcb(struct sock *meta_sk, __u64 remote_key,

/* Init time-wait stuff */
INIT_LIST_HEAD(&mpcb->tw_list);
spin_lock_init(&mpcb->tw_lock);

INIT_HLIST_HEAD(&mpcb->callback_list);
spin_lock_init(&mpcb->mpcb_list_lock);

mptcp_mpcb_inherit_sockopts(meta_sk, master_sk);

Expand Down Expand Up @@ -2252,10 +2252,10 @@ int mptcp_init_tw_sock(struct sock *sk, struct tcp_timewait_sock *tw)
mptw->rcv_nxt++;
rcu_assign_pointer(mptw->mpcb, mpcb);

spin_lock_bh(&mpcb->tw_lock);
spin_lock_bh(&mpcb->mpcb_list_lock);
list_add_rcu(&mptw->list, &tp->mpcb->tw_list);
mptw->in_list = 1;
spin_unlock_bh(&mpcb->tw_lock);
spin_unlock_bh(&mpcb->mpcb_list_lock);

return 0;
}
Expand All @@ -2271,12 +2271,12 @@ void mptcp_twsk_destructor(struct tcp_timewait_sock *tw)
* from the list and drop the ref properly.
*/
if (mpcb && refcount_inc_not_zero(&mpcb->mpcb_refcnt)) {
spin_lock_bh(&mpcb->tw_lock);
spin_lock_bh(&mpcb->mpcb_list_lock);
if (tw->mptcp_tw->in_list) {
list_del_rcu(&tw->mptcp_tw->list);
tw->mptcp_tw->in_list = 0;
}
spin_unlock_bh(&mpcb->tw_lock);
spin_unlock_bh(&mpcb->mpcb_list_lock);

/* Twice, because we increased it above */
mptcp_mpcb_put(mpcb);
Expand Down

0 comments on commit 411ffb5

Please sign in to comment.