Skip to content

Commit ad14d47

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 5426f98 commit ad14d47

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);
@@ -408,14 +385,13 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
408385
err = __mptcp_subflow_connect(sk, &local, &addr_r);
409386
release_sock(sk);
410387

411-
if (err)
388+
if (err) {
412389
GENL_SET_ERR_MSG_FMT(info, "connect error: %d", err);
390+
goto create_err;
391+
}
413392

414393
spin_lock_bh(&msk->pm.lock);
415-
if (err)
416-
mptcp_userspace_pm_delete_local_addr(msk, &entry);
417-
else
418-
msk->pm.subflows++;
394+
msk->pm.subflows++;
419395
spin_unlock_bh(&msk->pm.lock);
420396

421397
create_err:
@@ -534,9 +510,6 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
534510
goto release_sock;
535511
}
536512

537-
spin_lock_bh(&msk->pm.lock);
538-
mptcp_userspace_pm_delete_local_addr(msk, &addr_l);
539-
spin_unlock_bh(&msk->pm.lock);
540513
mptcp_subflow_shutdown(sk, ssk, RCV_SHUTDOWN | SEND_SHUTDOWN);
541514
mptcp_close_ssk(sk, ssk, mptcp_subflow_ctx(ssk));
542515
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);

0 commit comments

Comments
 (0)