Skip to content

Commit e1aac7e

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: drop free_list for deleting entries
mptcp_pm_remove_addrs() actually only deletes one address, which does not match its name. This patch renames it to mptcp_pm_remove_addr_entry() and changes the parameter "rm_list" to "entry". With the help of mptcp_pm_remove_addr_entry(), it's no longer necessary to move the entry to be deleted to free_list and then traverse the list to delete the entry, which is not allowed in BPF. The entry can be directly deleted through list_del_rcu() and sock_kfree_s() now. Signed-off-by: Geliang Tang <[email protected]>
1 parent 918226a commit e1aac7e

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

net/mptcp/pm_userspace.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,21 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
286286
return err;
287287
}
288288

289-
void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
289+
void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,
290+
struct mptcp_pm_addr_entry *entry)
290291
{
291292
struct mptcp_rm_list alist = { .nr = 0 };
292-
struct mptcp_pm_addr_entry *entry;
293293
int anno_nr = 0;
294294

295-
list_for_each_entry(entry, rm_list, list) {
296-
if (alist.nr >= MPTCP_RM_IDS_MAX)
297-
break;
298-
299-
/* only delete if either announced or matching a subflow */
300-
if (mptcp_remove_anno_list_by_saddr(msk, &entry->addr))
301-
anno_nr++;
302-
else if (!mptcp_lookup_subflow_by_saddr(&msk->conn_list,
303-
&entry->addr))
304-
continue;
295+
/* only delete if either announced or matching a subflow */
296+
if (mptcp_remove_anno_list_by_saddr(msk, &entry->addr))
297+
anno_nr++;
298+
else if (!mptcp_lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
299+
goto out;
305300

306-
alist.ids[alist.nr++] = entry->addr.id;
307-
}
301+
alist.ids[alist.nr++] = entry->addr.id;
308302

303+
out:
309304
if (alist.nr) {
310305
spin_lock_bh(&msk->pm.lock);
311306
msk->pm.add_addr_signaled -= anno_nr;
@@ -318,9 +313,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
318313
{
319314
struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
320315
struct mptcp_pm_addr_entry *match;
321-
struct mptcp_pm_addr_entry *entry;
322316
struct mptcp_sock *msk;
323-
LIST_HEAD(free_list);
324317
int err = -EINVAL;
325318
struct sock *sk;
326319
u8 id_val;
@@ -354,16 +347,14 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
354347
goto out;
355348
}
356349

357-
list_move(&match->list, &free_list);
350+
list_del_rcu(&match->list);
358351
spin_unlock_bh(&msk->pm.lock);
359352

360-
mptcp_pm_remove_addrs(msk, &free_list);
353+
mptcp_pm_remove_addr_entry(msk, match);
361354

362355
release_sock(sk);
363356

364-
list_for_each_entry_safe(match, entry, &free_list, list) {
365-
sock_kfree_s(sk, match, sizeof(*match));
366-
}
357+
sock_kfree_s(sk, match, sizeof(*match));
367358

368359
err = 0;
369360
out:

net/mptcp/protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,8 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,
10421042
const struct mptcp_addr_info *addr,
10431043
bool echo);
10441044
int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list);
1045-
void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list);
1045+
void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,
1046+
struct mptcp_pm_addr_entry *entry);
10461047

10471048
void mptcp_free_local_addr_list(struct mptcp_sock *msk);
10481049

0 commit comments

Comments
 (0)