diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 77cbb9157d11..593c42ac9c29 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1859,7 +1859,10 @@ static int mptcp_pm_nl_dump_addr(struct mptcp_id_bitmap *bitmap, struct pm_nl_pernet *pernet; pernet = pm_nl_get_pernet(net); + + spin_lock_bh(&pernet->lock); bitmap_copy(bitmap->map, pernet->id_bitmap.map, MPTCP_PM_MAX_ADDR_ID + 1); + spin_unlock_bh(&pernet->lock); return 0; } @@ -1877,17 +1880,15 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, { const struct genl_info *info = genl_info_dump(cb); struct mptcp_pm_addr_entry entry; - struct mptcp_id_bitmap *id_bitmap; + struct mptcp_id_bitmap id_bitmap; int id = cb->args[0]; void *hdr; int i; - id_bitmap = (struct mptcp_id_bitmap *)cb->ctx; - if (!id) - mptcp_pm_dump_addr(id_bitmap, info); + mptcp_pm_dump_addr(&id_bitmap, info); for (i = id; i < MPTCP_PM_MAX_ADDR_ID + 1; i++) { - if (test_bit(i, id_bitmap->map)) { + if (test_bit(i, id_bitmap.map)) { if (mptcp_pm_get_addr(i, &entry, info)) break; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index cc708b3ff9ce..1af863e6a25e 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -661,6 +661,8 @@ static int mptcp_userspace_pm_set_bitmap(struct mptcp_sock *msk, { struct mptcp_pm_addr_entry *entry; + bitmap_zero(bitmap->map, MPTCP_PM_MAX_ADDR_ID + 1); + mptcp_for_each_address(msk, entry) { if (test_bit(entry->addr.id, bitmap->map)) continue; diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c index 1e2b0c8260da..934dba9357ea 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c @@ -393,6 +393,8 @@ static int mptcp_userspace_pm_set_bitmap(struct mptcp_sock *msk, { struct mptcp_pm_addr_entry *entry; + bpf_bitmap_zero(bitmap); + mptcp_for_each_address(msk, entry) { entry = bpf_core_cast(entry, struct mptcp_pm_addr_entry);