On Fri, 8 Dec 2023, Geliang Tang wrote:
> This patch uses pm_nl_get_pernet_from_msk() to get the pernet id_bitmap
> instead of using a local bitmap when appending a new local address into
> the userspace PM local address list.
>
Please drop this patch.
The pernet bitmap is relevant for the netlink PM, as it shares address IDs
across the namespace. Userspace PMs may have different local address IDs
for each MPTCP connection.
- Mat
> Signed-off-by: Geliang Tang <geliang.tang@linux.dev>
> ---
> net/mptcp/pm_userspace.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
> index efecbe3cf415..b3a606a5e182 100644
> --- a/net/mptcp/pm_userspace.c
> +++ b/net/mptcp/pm_userspace.c
> @@ -28,7 +28,7 @@ void mptcp_free_local_addr_list(struct mptcp_sock *msk)
> static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
> struct mptcp_pm_addr_entry *entry)
> {
> - DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
> + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk);
> struct mptcp_pm_addr_entry *match = NULL;
> struct sock *sk = (struct sock *)msk;
> struct mptcp_pm_addr_entry *e;
> @@ -36,8 +36,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
> bool id_match = false;
> int ret = -EINVAL;
>
> - bitmap_zero(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
> -
> spin_lock_bh(&msk->pm.lock);
> list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) {
> addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true);
> @@ -50,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
> } else if (addr_match || id_match) {
> break;
> }
> - __set_bit(e->addr.id, id_bitmap);
> }
>
> if (!match && !addr_match && !id_match) {
> @@ -65,9 +62,10 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
>
> *e = *entry;
> if (!e->addr.id)
> - e->addr.id = find_next_zero_bit(id_bitmap,
> + e->addr.id = find_next_zero_bit(pernet->id_bitmap,
> MPTCP_PM_MAX_ADDR_ID + 1,
> 1);
> + __set_bit(e->addr.id, pernet->id_bitmap);
> list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list);
> msk->pm.local_addr_used++;
> ret = e->addr.id;
> --
> 2.35.3
>
>
>