Skip to content

Commit 4009531

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: add mptcp_pm_addr_id_bitmap_t type
Similar to defining types such as nodemask_t, dma_cap_mask_t and cpumask_t to simplify the use of bitmap, a new type for MPTCP userspace pm id bitmap, mptcp_pm_addr_id_bitmap_t is defined to easily modify dump_addr() interface of the path managers to accept an mptcp_pm_addr_id_bitmap_t type parameter. It also allows this parameter of dump_addr() can be modified by BPF program when implementing this interface of a BFP path manager. Because a dump_addr() interface that accepts an 'unsigned long *bitmap' or 'unsigned long bitmap[]' parameter is difficult to implement in BPF program. In addition, this also makes it easier for us to implement similar logic to mptcp_userspace_pm_append_new_local_addr() in BPF path manager, 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 47d4517 commit 4009531

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

include/net/mptcp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ struct mptcp_sched_ops {
120120
void (*release)(struct mptcp_sock *msk);
121121
} ____cacheline_aligned_in_smp;
122122

123+
/* max value of mptcp_addr_info.id */
124+
#define MPTCP_PM_MAX_ADDR_ID U8_MAX
125+
126+
typedef struct {
127+
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
128+
} mptcp_pm_addr_id_bitmap_t;
129+
123130
#ifdef CONFIG_MPTCP
124131
void mptcp_init(void);
125132

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);
5150
struct mptcp_pm_addr_entry *match = NULL;
5251
struct sock *sk = (struct sock *)msk;
52+
mptcp_pm_addr_id_bitmap_t id_bitmap;
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);
@@ -618,16 +618,14 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
618618
struct netlink_callback *cb,
619619
const struct genl_info *info)
620620
{
621-
struct id_bitmap {
622-
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
623-
} *bitmap;
621+
mptcp_pm_addr_id_bitmap_t *bitmap;
624622
struct mptcp_pm_addr_entry *entry;
625623
struct mptcp_sock *msk;
626624
int ret = -EINVAL;
627625
struct sock *sk;
628626
void *hdr;
629627

630-
bitmap = (struct id_bitmap *)cb->ctx;
628+
bitmap = (mptcp_pm_addr_id_bitmap_t *)cb->ctx;
631629

632630
msk = mptcp_userspace_pm_get_sock(info);
633631
if (!msk)

net/mptcp/protocol.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ enum mptcp_addr_signal_status {
208208
MPTCP_RM_ADDR_SIGNAL,
209209
};
210210

211-
/* max value of mptcp_addr_info.id */
212-
#define MPTCP_PM_MAX_ADDR_ID U8_MAX
213-
214211
struct mptcp_pm_data {
215212
struct mptcp_addr_info local;
216213
struct mptcp_addr_info remote;

0 commit comments

Comments
 (0)