Skip to content

Commit 371a578

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: add struct mptcp_pm_addr_id_bitmap
To simplify the use of bitmap in BPF, a new type for MPTCP userspace pm id bitmap, struct mptcp_pm_addr_id_bitmap is defined. Because there's no way to use DECLARE_BITMAP macro in BPF program, and it's not easy to reimplement it in BPF. Signed-off-by: Geliang Tang <[email protected]>
1 parent af51a65 commit 371a578

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

net/mptcp/pm_userspace.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
4747
struct mptcp_pm_addr_entry *entry,
4848
bool needs_id)
4949
{
50-
DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
50+
struct mptcp_pm_addr_id_bitmap id_bitmap;
5151
struct mptcp_pm_addr_entry *match = NULL;
5252
struct sock *sk = (struct sock *)msk;
5353
struct mptcp_pm_addr_entry *e;
5454
bool addr_match = false;
5555
bool id_match = false;
5656
int ret = -EINVAL;
5757

58-
bitmap_zero(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
58+
bitmap_zero(id_bitmap.map, MPTCP_PM_MAX_ADDR_ID + 1);
5959

6060
spin_lock_bh(&msk->pm.lock);
6161
mptcp_for_each_userspace_pm_addr(msk, e) {
@@ -69,7 +69,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
6969
} else if (addr_match || id_match) {
7070
break;
7171
}
72-
__set_bit(e->addr.id, id_bitmap);
72+
__set_bit(e->addr.id, id_bitmap.map);
7373
}
7474

7575
if (!match && !addr_match && !id_match) {
@@ -84,7 +84,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
8484

8585
*e = *entry;
8686
if (!e->addr.id && needs_id)
87-
e->addr.id = find_next_zero_bit(id_bitmap,
87+
e->addr.id = find_next_zero_bit(id_bitmap.map,
8888
MPTCP_PM_MAX_ADDR_ID + 1,
8989
1);
9090
list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list);
@@ -633,16 +633,14 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
633633
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
634634
struct netlink_callback *cb)
635635
{
636-
struct id_bitmap {
637-
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
638-
} *bitmap;
639636
const struct genl_info *info = genl_info_dump(cb);
637+
struct mptcp_pm_addr_id_bitmap *bitmap;
640638
struct mptcp_pm_addr_entry *entry;
641639
struct mptcp_sock *msk;
642640
int ret = -EINVAL;
643641
struct sock *sk;
644642

645-
bitmap = (struct id_bitmap *)cb->ctx;
643+
bitmap = (struct mptcp_pm_addr_id_bitmap *)cb->ctx;
646644

647645
msk = mptcp_userspace_pm_get_sock(info);
648646
if (!msk)

net/mptcp/protocol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ enum mptcp_addr_signal_status {
212212
/* max value of mptcp_addr_info.id */
213213
#define MPTCP_PM_MAX_ADDR_ID U8_MAX
214214

215+
struct mptcp_pm_addr_id_bitmap {
216+
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
217+
};
218+
215219
struct mptcp_pm_data {
216220
struct mptcp_addr_info local;
217221
struct mptcp_addr_info remote;

0 commit comments

Comments
 (0)