From 07226f9116b9eba5d890fe71727604ba01f6e442 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Thu, 9 Jan 2025 15:56:22 +0800 Subject: [PATCH] fix Signed-off-by: Geliang Tang --- include/net/mptcp.h | 4 ++-- net/mptcp/bpf.c | 6 +++--- net/mptcp/pm.c | 12 ++++++------ net/mptcp/pm_netlink.c | 11 +++-------- net/mptcp/pm_userspace.c | 18 +++++++++--------- net/mptcp/protocol.h | 8 ++++---- .../bpf/progs/mptcp_bpf_userspace_pm.c | 6 +++--- 7 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 1c14aa1b55c1..3af97daec59a 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -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); diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index 17d5bf621d0c..3448502e9f98 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -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; } @@ -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, diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 36bec7b12b28..2a200d6cc631 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -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, @@ -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; diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c023ab77ab78..74e20a3658fa 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -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; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index c15f449fb7cd..b1227b704cd2 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -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; @@ -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); @@ -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, @@ -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; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 5211ea4d4270..9a7bfc3a98df 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -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, 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 5bdb94c2a853..0a3d4c2e3a62 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_userspace_pm.c @@ -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); } @@ -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,