Skip to content

Commit 3efaed5

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: pm: userspace: drop delete_local_addr helper
Address entries should not be removed from local_addr_list when a subflow is deleted by the userspace PM, should only be removed when sending a REMOVE_ADDR. So mptcp_userspace_pm_delete_local_addr() helper shouldn't be called in mptcp_pm_nl_subflow_create_doit() and mptcp_pm_nl_subflow_destroy_doit(). Since this helper is open-coding in mptcp_pm_nl_remove_doit(), it can be dropped now. Address entries are removed from local_addr_list when sending a REMOVE_ADDR by the userspace PM, the local_addr_used counter of PM should also be decremented accordingly. Closes: multipath-tcp/mptcp_net-next#403 Signed-off-by: Geliang Tang <[email protected]>
1 parent 4974ebb commit 3efaed5

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

net/mptcp/pm_userspace.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
9090
return ret;
9191
}
9292

93-
/* If the subflow is closed from the other peer (not via a
94-
* subflow destroy command then), we want to keep the entry
95-
* not to assign the same ID to another address and to be
96-
* able to send RM_ADDR after the removal of the subflow.
97-
*/
98-
static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
99-
struct mptcp_pm_addr_entry *addr)
100-
{
101-
struct sock *sk = (struct sock *)msk;
102-
struct mptcp_pm_addr_entry *entry;
103-
104-
entry = mptcp_userspace_pm_lookup_addr(msk, &addr->addr);
105-
if (!entry)
106-
return -EINVAL;
107-
108-
/* TODO: a refcount is needed because the entry can
109-
* be used multiple times (e.g. fullmesh mode).
110-
*/
111-
list_del_rcu(&entry->list);
112-
sock_kfree_s(sk, entry, sizeof(*entry));
113-
msk->pm.local_addr_used--;
114-
return 0;
115-
}
116-
11793
static struct mptcp_pm_addr_entry *
11894
mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id)
11995
{
@@ -331,6 +307,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
331307
}
332308

333309
list_del_rcu(&match->list);
310+
msk->pm.local_addr_used--;
334311
spin_unlock_bh(&msk->pm.lock);
335312

336313
mptcp_pm_remove_addr_entry(msk, match);
@@ -412,14 +389,13 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
412389
err = __mptcp_subflow_connect(sk, &local, &addr_r);
413390
release_sock(sk);
414391

415-
if (err)
392+
if (err) {
416393
GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err);
394+
goto create_err;
395+
}
417396

418397
spin_lock_bh(&msk->pm.lock);
419-
if (err)
420-
mptcp_userspace_pm_delete_local_addr(msk, &entry);
421-
else
422-
msk->pm.subflows++;
398+
msk->pm.subflows++;
423399
spin_unlock_bh(&msk->pm.lock);
424400

425401
create_err:
@@ -538,9 +514,6 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
538514
goto release_sock;
539515
}
540516

541-
spin_lock_bh(&msk->pm.lock);
542-
mptcp_userspace_pm_delete_local_addr(msk, &addr_l);
543-
spin_unlock_bh(&msk->pm.lock);
544517
mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN | SEND_SHUTDOWN);
545518
mptcp_close_ssk(sk, ssk, mptcp_subflow_ctx(ssk));
546519
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);

0 commit comments

Comments
 (0)