Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and Geliang Tang committed Jan 10, 2025
1 parent 727e9db commit 07226f9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 35 deletions.
4 changes: 2 additions & 2 deletions include/net/mptcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ struct mptcp_pm_ops {
struct mptcp_addr_info *skc);
struct mptcp_pm_addr_entry *(*get_addr)(struct mptcp_sock *msk,
u8 id);
int (*dump_addr)(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap);
int (*dump_bitmap)(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap);
int (*set_flags)(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *local,
struct mptcp_addr_info *remote);
Expand Down
6 changes: 3 additions & 3 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ __bpf_mptcp_pm_get_addr(struct mptcp_sock *msk, u8 id)
return NULL;
}

static int __bpf_mptcp_pm_dump_addr(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap)
static int __bpf_mptcp_pm_dump_bitmap(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap)
{
return 0;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ static struct mptcp_pm_ops __bpf_mptcp_pm_ops = {
.get_local_id = __bpf_mptcp_pm_get_local_id,
.get_flags = __bpf_mptcp_pm_get_flags,
.get_addr = __bpf_mptcp_pm_get_addr,
.dump_addr = __bpf_mptcp_pm_dump_addr,
.dump_bitmap = __bpf_mptcp_pm_dump_bitmap,
.set_flags = __bpf_mptcp_pm_set_flags,
.init = __bpf_mptcp_pm_init,
.release = __bpf_mptcp_pm_release,
Expand Down
12 changes: 6 additions & 6 deletions net/mptcp/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,12 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
return ret;
}

static int mptcp_pm_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
static int mptcp_pm_dump_bitmap(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
{
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
return mptcp_userspace_pm_dump_addr(bitmap, info);
return mptcp_pm_nl_dump_addr(bitmap, info);
return mptcp_userspace_pm_dump_bitmap(bitmap, info);
return mptcp_pm_nl_dump_bitmap(bitmap, info);
}

int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
Expand All @@ -519,12 +519,12 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,

bitmap = (struct mptcp_pm_addr_id_bitmap *)cb->ctx;

mptcp_pm_dump_addr(bitmap, info);
mptcp_pm_dump_bitmap(bitmap, info);

for (i = id; i < MPTCP_PM_MAX_ADDR_ID + 1; i++) {
if (test_bit(i, bitmap->map)) {
if (mptcp_pm_get_addr(i, &entry, info))
break;
continue;

if (id && entry.addr.id <= id)
continue;
Expand Down
11 changes: 3 additions & 8 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1780,17 +1780,12 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
return ret;
}

int mptcp_pm_nl_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
int mptcp_pm_nl_dump_bitmap(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
{
struct net *net = genl_info_net(info);
struct pm_nl_pernet *pernet;

pernet = pm_nl_get_pernet(net);
struct pm_nl_pernet *pernet = pm_nl_get_pernet(genl_info_net(info));

rcu_read_lock();
bitmap_copy(bitmap->map, pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
rcu_read_unlock();

return 0;
}
Expand Down
18 changes: 9 additions & 9 deletions net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,14 +688,14 @@ static int mptcp_userspace_pm_reset_bitmap(struct mptcp_sock *msk,
return 0;
}

static int userspace_pm_dump_addr(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap)
static int userspace_pm_dump_bitmap(struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap)
{
return mptcp_userspace_pm_reset_bitmap(msk, bitmap);
}

int mptcp_userspace_pm_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
int mptcp_userspace_pm_dump_bitmap(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info)
{
struct mptcp_sock *msk;
int ret = -EINVAL;
Expand All @@ -709,9 +709,9 @@ int mptcp_userspace_pm_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,

lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
ret = msk->pm.ops->dump_addr ?
msk->pm.ops->dump_addr(msk, bitmap) :
userspace_pm_dump_addr(msk, bitmap);
ret = msk->pm.ops->dump_bitmap ?
msk->pm.ops->dump_bitmap(msk, bitmap) :
userspace_pm_dump_bitmap(msk, bitmap);
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);

Expand Down Expand Up @@ -763,7 +763,7 @@ static struct mptcp_pm_ops mptcp_userspace_pm = {
.get_local_id = userspace_pm_get_local_id,
.get_flags = userspace_pm_get_flags,
.get_addr = userspace_pm_get_addr,
.dump_addr = userspace_pm_dump_addr,
.dump_bitmap = userspace_pm_dump_bitmap,
.set_flags = userspace_pm_set_flags,
.type = MPTCP_PM_TYPE_USERSPACE,
.owner = THIS_MODULE,
Expand All @@ -787,7 +787,7 @@ int mptcp_validate_path_manager(struct mptcp_pm_ops *pm)
if (!pm->address_announce && !pm->address_remove &&
!pm->subflow_create && !pm->subflow_destroy &&
!pm->get_local_id && !pm->get_flags &&
!pm->get_addr && !pm->dump_addr && !pm->set_flags) {
!pm->get_addr && !pm->dump_bitmap && !pm->set_flags) {
pr_err("%u does not implement required ops\n", pm->type);
return -EINVAL;
}
Expand Down
8 changes: 4 additions & 4 deletions net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -1156,10 +1156,10 @@ u8 mptcp_pm_nl_get_flags(struct mptcp_sock *msk,
struct mptcp_addr_info *skc);
u8 mptcp_userspace_pm_get_flags(struct mptcp_sock *msk,
struct mptcp_addr_info *skc);
int mptcp_pm_nl_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info);
int mptcp_userspace_pm_dump_addr(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info);
int mptcp_pm_nl_dump_bitmap(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info);
int mptcp_userspace_pm_dump_bitmap(struct mptcp_pm_addr_id_bitmap *bitmap,
const struct genl_info *info);
int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
const struct genl_info *info);
int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
Expand Down
6 changes: 3 additions & 3 deletions tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ static int mptcp_userspace_pm_reset_bitmap(struct mptcp_sock *msk,
}

SEC("struct_ops")
int BPF_PROG(mptcp_pm_dump_addr, struct mptcp_sock *msk,
int BPF_PROG(mptcp_pm_dump_bitmap, struct mptcp_sock *msk,
struct mptcp_pm_addr_id_bitmap *bitmap)
{
bpf_printk("8 mptcp_pm_dump_addr");
bpf_printk("8 mptcp_pm_dump_bitmap");

return mptcp_userspace_pm_reset_bitmap(msk, bitmap);
}
Expand Down Expand Up @@ -398,7 +398,7 @@ struct mptcp_pm_ops userspace_pm = {
.get_local_id = (void *)mptcp_pm_get_local_id,
.get_flags = (void *)mptcp_pm_get_flags,
.get_addr = (void *)mptcp_pm_get_addr,
.dump_addr = (void *)mptcp_pm_dump_addr,
.dump_bitmap = (void *)mptcp_pm_dump_bitmap,
.set_flags = (void *)mptcp_pm_set_flags,
.init = (void *)mptcp_pm_init,
.release = (void *)mptcp_pm_release,
Expand Down

0 comments on commit 07226f9

Please sign in to comment.