Hi Geliang,
On 22/10/2024 11:14, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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.
Maybe clearer to squash this in the previous commit.
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> net/mptcp/pm_userspace.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index 21b2a3b02cfe..e5dfa1a6db31 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -283,9 +283,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
> {
> struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
> struct mptcp_pm_addr_entry *match;
> - struct mptcp_pm_addr_entry *entry;
> struct mptcp_sock *msk;
> - LIST_HEAD(free_list);
> int err = -EINVAL;
> struct sock *sk;
> u8 id_val;
> @@ -312,23 +310,21 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
>
> spin_lock_bh(&msk->pm.lock);
> match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
Can you not remove the entry from the list here (if there is a match?)
> + spin_unlock_bh(&msk->pm.lock);
> if (!match) {
> GENL_SET_ERR_MSG(info, "address with specified id not found");
> - spin_unlock_bh(&msk->pm.lock);
> release_sock(sk);
> goto out;
> }
>
> - list_move(&match->list, &free_list);
(or keep the del here, no?)
> - spin_unlock_bh(&msk->pm.lock);
> -
> mptcp_pm_remove_addr_entry(msk, match);
>
> release_sock(sk);
>
> - list_for_each_entry_safe(match, entry, &free_list, list) {
> - sock_kfree_s(sk, match, sizeof(*match));
> - }
> + spin_lock_bh(&msk->pm.lock);
> + list_del_rcu(&match->list);
> + sock_kfree_s(sk, match, sizeof(*match));
> + spin_unlock_bh(&msk->pm.lock);
>
> err = 0;
> out:
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.