BPF path manager, part 2
Subsystems (2)
Geliang Tang
reviewerv2 cover BPF path manager, part 2
From: Geliang Tang <[email protected]>
v2:
- split patch 7 of v1 into two.
- patches 1-6 have no code changes, only the commit logs have been
updated.
- more commit log to explain why mptcp_pm_addr_id_bitmap_t needs to
be defined.
- use mptcp_pm_addr_id_bitmap_t in userspace_pm_append_new_local_addr
too.
In order to implement BPF userspace path manager, it is necessary to unify the interfaces of the path manager. This set updates get_addr() and dump_addr() interfaces.
Geliang Tang (8):
mptcp: make three pm wrappers static
mptcp: drop skb parameter of get_addr
mptcp: add id parameter for get_addr
mptcp: reuse sending nlmsg code in get_addr
mptcp: change info of get_addr as const
mptcp: add info parameter for dump_addr
mptcp: add mptcp_pm_addr_id_bitmap_t type
mptcp: reuse sending nlmsg code in dump_addr
include/net/mptcp.h | 7 +++ net/mptcp/pm.c | 108 ++++++++++++++++++++++++++++++++++++--- net/mptcp/pm_netlink.c | 105 ++++++------------------------------- net/mptcp/pm_userspace.c | 102 ++++++++++-------------------------- net/mptcp/protocol.h | 21 +++----- 5 files changed, 157 insertions(+), 186 deletions(-)
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v2 1/8 mptcp: make three pm wrappers static
From: Geliang Tang <[email protected]>
Three netlink functions:
mptcp_pm_nl_get_addr_doit() mptcp_pm_nl_get_addr_dumpit() mptcp_pm_nl_set_flags_doit()
are generic, implemented for each PM, in-kernel PM and userspace PM. It's clearer to move them from pm_netlink.c to pm.c.
And the linked three path manager wrappers
mptcp_pm_get_addr() mptcp_pm_dump_addr() mptcp_pm_set_flags()
can be changed as static functions, no need to export them in protocol.h.
--- net/mptcp/pm.c | 23 ++++++++++++++++++++--- net/mptcp/pm_netlink.c | 16 ---------------- net/mptcp/protocol.h | 3 --- 3 files changed, 20 insertions(+), 22 deletions(-)
net/mptcp/pm.c +20 -3
@@ -10,6 +10,7 @@#include "protocol.h" #include "mib.h" +#include "mptcp_pm_gen.h" /* path manager command handlers */
@@ -433,14 +434,19 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_is_backup (msk, &skc_local); } -int mptcp_pm_get_addr (struct sk_buff *skb,struct genl_info *info) +static int mptcp_pm_get_addr (struct sk_buff *skb,struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ])return mptcp_userspace_pm_get_addr (skb, info);return mptcp_pm_nl_get_addr (skb, info); } -int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb) +int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) +{ +return mptcp_pm_get_addr (skb, info); +} + +static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb) {const struct genl_info *info =genl_info_dump (cb);
@@ -449,13 +455,24 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)return mptcp_pm_nl_dump_addr (msg, cb); } -int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_get_addr_dumpit (struct sk_buff *msg, +struct netlink_callback *cb) +{ +return mptcp_pm_dump_addr (msg, cb); +} + +static int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ])return mptcp_userspace_pm_set_flags (skb, info);return mptcp_pm_nl_set_flags (skb, info); } +int mptcp_pm_nl_set_flags_doit (struct sk_buff *skb,struct genl_info *info) +{ +return mptcp_pm_set_flags (skb, info); +} +void mptcp_pm_subflow_chk_stale (const struct mptcp_sock *msk,struct sock *ssk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);
net/mptcp/pm_netlink.c +0 -16
@@ -1812,11 +1812,6 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info)return ret; } -int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) -{ -return mptcp_pm_get_addr (skb, info); -} -int mptcp_pm_nl_dump_addr (struct sk_buff *msg,struct netlink_callback *cb) {
@@ -1860,12 +1855,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,return msg->len; } -int mptcp_pm_nl_get_addr_dumpit (struct sk_buff *msg, -struct netlink_callback *cb) -{ -return mptcp_pm_dump_addr (msg, cb); -} -static int parse_limit (struct genl_info *info,int id,unsigned int *limit) {struct nlattr *attr = info->attrs[id];
@@ -2035,11 +2024,6 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info)return 0 ; } -int mptcp_pm_nl_set_flags_doit (struct sk_buff *skb,struct genl_info *info) -{ -return mptcp_pm_set_flags (skb, info); -} -static void mptcp_nl_mcast_send (struct net *net,struct sk_buff *nlskb,gfp_t gfp) { genlmsg_multicast_netns(&mptcp_genl_family, net,
net/mptcp/protocol.h +0 -3
@@ -1035,7 +1035,6 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr);bool mptcp_remove_anno_list_by_saddr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr); -int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info);int mptcp_pm_nl_set_flags (struct sk_buff *skb,struct genl_info *info);int mptcp_userspace_pm_set_flags (struct sk_buff *skb,struct genl_info *info); int mptcp_pm_announce_addr(struct mptcp_sock *msk,
@@ -1128,12 +1127,10 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inbool mptcp_pm_is_backup (struct mptcp_sock *msk,struct sock_common *skc);bool mptcp_pm_nl_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);bool mptcp_userspace_pm_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc); -int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb);int mptcp_pm_nl_dump_addr (struct sk_buff *msg,struct netlink_callback *cb);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb); -int mptcp_pm_get_addr (struct sk_buff *skb,struct genl_info *info);int mptcp_pm_nl_get_addr (struct sk_buff *skb,struct genl_info *info);int mptcp_userspace_pm_get_addr (struct sk_buff *skb,struct genl_info *info);
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v2 2/8 mptcp: drop skb parameter of get_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The first parameters 'skb' of get_addr() interfaces are now useless since mptcp_userspace_pm_get_sock() helper is used. This patch drops these useless parameters of them.
--- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 2 +- net/mptcp/pm_userspace.c | 3 +-- net/mptcp/protocol.h | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-)
net/mptcp/pm.c +4 -4
@@ -434,16 +434,16 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_is_backup (msk, &skc_local); } -static int mptcp_pm_get_addr (struct sk_buff *skb,struct genl_info *info) +static int mptcp_pm_get_addr (struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_get_addr (skb, info); -return mptcp_pm_nl_get_addr (skb, info); +return mptcp_userspace_pm_get_addr (info); +return mptcp_pm_nl_get_addr (info); }int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) { -return mptcp_pm_get_addr (skb, info); +return mptcp_pm_get_addr (info); }static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb)
net/mptcp/pm_netlink.c +1 -1
@@ -1762,7 +1762,7 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,return -EMSGSIZE ; } -int mptcp_pm_nl_get_addr (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_get_addr (struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info);
net/mptcp/pm_userspace.c +1 -2
@@ -663,8 +663,7 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,return ret; } -int mptcp_userspace_pm_get_addr (struct sk_buff *skb, -struct genl_info *info) +int mptcp_userspace_pm_get_addr (struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct mptcp_pm_addr_entry addr, *entry;
net/mptcp/protocol.h +2 -3
@@ -1131,9 +1131,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb); -int mptcp_pm_nl_get_addr (struct sk_buff *skb,struct genl_info *info); -int mptcp_userspace_pm_get_addr (struct sk_buff *skb, -struct genl_info *info); +int mptcp_pm_nl_get_addr (struct genl_info *info); +int mptcp_userspace_pm_get_addr (struct genl_info *info);static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) {
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v2 3/8 mptcp: add id parameter for get_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The address id is parsed both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. So this patch adds a new parameter 'id' for all get_addr() interfaces. The address id is only parsed in mptcp_pm_nl_get_addr_doit(), then pass it to both mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr().
--- net/mptcp/pm.c | 16 ++++++++++++---- net/mptcp/pm_netlink.c | 11 +++-------- net/mptcp/pm_userspace.c | 11 +++-------- net/mptcp/protocol.h | 4 ++-- 4 files changed, 20 insertions(+), 22 deletions(-)
net/mptcp/pm.c +12 -4
@@ -434,16 +434,24 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_is_backup (msk, &skc_local); } -static int mptcp_pm_get_addr (struct genl_info *info) +static int mptcp_pm_get_addr (u8 id,struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_get_addr (info); -return mptcp_pm_nl_get_addr (info); +return mptcp_userspace_pm_get_addr (id, info); +return mptcp_pm_nl_get_addr (id, info); }int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) { -return mptcp_pm_get_addr (info); +struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; +struct mptcp_pm_addr_entry addr; +int ret; + + ret =mptcp_pm_parse_entry (attr, info, false, &addr); +if (ret <0 ) +return ret; + +return mptcp_pm_get_addr (addr.addr.id, info); }static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb)
net/mptcp/pm_netlink.c +3 -8
@@ -1762,19 +1762,14 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,return -EMSGSIZE ; } -int mptcp_pm_nl_get_addr (struct genl_info *info) +int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info) { -struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info); -struct mptcp_pm_addr_entry addr, *entry; +struct mptcp_pm_addr_entry *entry;struct sk_buff *msg;void *reply;int ret; - ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) -return ret; - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg)return -ENOMEM ;
@@ -1788,7 +1783,7 @@ int mptcp_pm_nl_get_addr(struct genl_info *info) }rcu_read_lock (); - entry =__lookup_addr_by_id (pernet, addr.addr.id); + entry =__lookup_addr_by_id (pernet, id);if (!entry) {GENL_SET_ERR_MSG (info,"address not found" ); ret = -EINVAL ;
net/mptcp/pm_userspace.c +3 -8
@@ -663,10 +663,9 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,return ret; } -int mptcp_userspace_pm_get_addr (struct genl_info *info) +int mptcp_userspace_pm_get_addr (u8 id,struct genl_info *info) { -struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; -struct mptcp_pm_addr_entry addr, *entry; +struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;struct sk_buff *msg;int ret = -EINVAL ;
@@ -679,10 +678,6 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) sk = (struct sock *)msk; - ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) - goto out; - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ;
@@ -699,7 +694,7 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info)lock_sock (sk);spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr_by_id (msk, addr.addr.id); + entry =mptcp_userspace_pm_lookup_addr_by_id (msk, id);if (!entry) {GENL_SET_ERR_MSG (info,"address not found" ); ret = -EINVAL ;
net/mptcp/protocol.h +2 -2
@@ -1131,8 +1131,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb); -int mptcp_pm_nl_get_addr (struct genl_info *info); -int mptcp_userspace_pm_get_addr (struct genl_info *info); +int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info); +int mptcp_userspace_pm_get_addr (u8 id,struct genl_info *info);static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) {
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v2 3/8] mptcp: add id parameter for get_addr
Hi Geliang,
Sorry, I just noticed this will cause conflicts with the series I just sent:
https://lore.kernel.org/all/[email protected]/T/
Quoted 32 lines · Geliang Tang
From: Geliang Tang <[email protected]>
The address id is parsed both in
mptcp_pm_nl_get_addr()andmptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. So this patch adds a new parameter 'id' for allget_addr()interfaces. The address id is only parsed inmptcp_pm_nl_get_addr_doit(), then pass it to bothmptcp_pm_nl_get_addr()andmptcp_userspace_pm_get_addr().Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/pm.c | 16 ++++++++++++---- net/mptcp/pm_netlink.c | 11 +++-------- net/mptcp/pm_userspace.c | 11 +++-------- net/mptcp/protocol.h | 4 ++-- 4 files changed, 20 insertions(+), 22 deletions(-)net/mptcp/pm.c +3
-3@@ -434,16 +434,24 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_is_backup (msk, &skc_local); } -static int mptcp_pm_get_addr (struct genl_info *info) +static int mptcp_pm_get_addr (u8 id,struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_get_addr (info); -return mptcp_pm_nl_get_addr (info); +return mptcp_userspace_pm_get_addr (id, info); +return mptcp_pm_nl_get_addr (id, info);
net/mptcp/pm.c bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) · line 450
Quoted 10 lines
net/mptcp/pm.c +5
-1}int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) { -return mptcp_pm_get_addr (info); +struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; +struct mptcp_pm_addr_entry addr; +int ret; + + ret =mptcp_pm_parse_entry (attr, info, false, &addr);
Could you first check if the attribute is set (to report a more precise error), before parsing it please?
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR))
return -EINVAL;
attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; ret = mptcp_pm_parse_entry(attr, info, false, &addr); (...)
So similar to this:
Quoted 34 lines
net/mptcp/pm.c +4
-0+if (ret <0 ) +return ret; + +return mptcp_pm_get_addr (addr.addr.id, info); }static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb)net/mptcp/pm_netlink.c +2
-7@@ -1762,19 +1762,14 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,return -EMSGSIZE ; } -int mptcp_pm_nl_get_addr (struct genl_info *info) +int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info) { -struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct pm_nl_pernet *pernet =genl_info_pm_nl (info); -struct mptcp_pm_addr_entry addr, *entry; +struct mptcp_pm_addr_entry *entry;struct sk_buff *msg;void *reply;int ret; - ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) -return ret; - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg)return -ENOMEM ;
net/mptcp/pm_netlink.c int mptcp_pm_nl_get_addr(struct genl_info *info) · line 1788
Quoted 7 lines
net/mptcp/pm_netlink.c +1
-1@@ -1788,7 +1783,7 @@ int mptcp_pm_nl_get_addr(struct genl_info *info) }rcu_read_lock (); - entry =__lookup_addr_by_id (pernet, addr.addr.id); + entry =__lookup_addr_by_id (pernet, id);if (!entry) {GENL_SET_ERR_MSG (info,"address not found" );
Mmh, I switched this to NL_SET_ERR_MSG_ATTR() in:
https://patchwork.kernel.org/project/mptcp/patch/[email protected]/
... which requires 'attr'. We could not do the conversion here in the patch I sent. But because you are also moving this part to pm.c in the next patch, I suggest to temporally pass the pointer to 'attr' here in this patch 3, and remove it in patch 4.
WDYT?
Quoted 30 lines
net/mptcp/pm_netlink.c +0
-0ret = -EINVAL ;net/mptcp/pm_userspace.c +2
-7@@ -663,10 +663,9 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,return ret; } -int mptcp_userspace_pm_get_addr (struct genl_info *info) +int mptcp_userspace_pm_get_addr (u8 id,struct genl_info *info) { -struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; -struct mptcp_pm_addr_entry addr, *entry; +struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;struct sk_buff *msg;int ret = -EINVAL ;@@ -679,10 +678,6 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info) sk = (struct sock *)msk; - ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) - goto out; - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg) { ret = -ENOMEM ;
net/mptcp/pm_userspace.c int mptcp_userspace_pm_get_addr(struct genl_info *info) · line 699
Quoted 7 lines
net/mptcp/pm_userspace.c +1
-1@@ -699,7 +694,7 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info)lock_sock (sk);spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr_by_id (msk, addr.addr.id); + entry =mptcp_userspace_pm_lookup_addr_by_id (msk, id);if (!entry) {GENL_SET_ERR_MSG (info,"address not found" );
Same here for GENL_SET_ERR_MSG() vs NL_SET_ERR_MSG_ATTR().
Quoted 6 lines
net/mptcp/pm_userspace.c +0
-0ret = -EINVAL ;net/mptcp/protocol.h +0
-0
net/mptcp/protocol.h int mptcp_pm_nl_dump_addr(struct sk_buff *msg, · line 1138
Quoted 10 lines
net/mptcp/protocol.h +2
-2@@ -1131,8 +1131,8 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb); -int mptcp_pm_nl_get_addr (struct genl_info *info); -int mptcp_userspace_pm_get_addr (struct genl_info *info); +int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info); +int mptcp_userspace_pm_get_addr (u8 id,struct genl_info *info);static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) {
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v2 4/8 mptcp: reuse sending nlmsg code in get_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The netlink messages are sent both in mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. This is because the netlink PM and userspace PM use different locks to protect the address entry that needs to be sent via the netlink message. The former uses rcu read lock, and the latter uses msk->pm.lock.
The current get_addr() flow looks like this:
lock(); entry = get_entry(); send_nlmsg(entry); unlock();
After holding the lock, get the entry from the list, send the entry, and finally release the lock.
This patch changes the process by getting the entry while holding the lock, then making a copy of the entry so that the lock can be released. Finally, the copy of the entry is sent without locking:
lock(); entry = get_entry(); *copy = *entry; unlock(); send_nlmsg(copy);
This way we can reuse the send_nlmsg() code in get_addr() interfaces between the netlink PM and userspace PM. They only need to implement their own get_addr() interfaces to hold the different locks, get the entry from the different lists, then release the locks.
--- net/mptcp/pm.c | 39 ++++++++++++++++++++++++++++++++++---- net/mptcp/pm_netlink.c | 39 ++++++-------------------------------- net/mptcp/pm_userspace.c | 41 +++++----------------------------------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 50 insertions(+), 75 deletions(-)
net/mptcp/pm.c +35 -4
@@ -434,24 +434,55 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_is_backup (msk, &skc_local); } -static int mptcp_pm_get_addr (u8 id,struct genl_info *info) +static int mptcp_pm_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, +struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_get_addr (id, info); -return mptcp_pm_nl_get_addr (id, info); +return mptcp_userspace_pm_get_addr (id, addr, info); +return mptcp_pm_nl_get_addr (id, addr, info); }int mptcp_pm_nl_get_addr_doit (struct sk_buff *skb,struct genl_info *info) {struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct mptcp_pm_addr_entry addr; +struct sk_buff *msg; +void *reply;int ret; ret =mptcp_pm_parse_entry (attr, info, false, &addr);if (ret <0 )return ret; -return mptcp_pm_get_addr (addr.addr.id, info); + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + reply =genlmsg_put_reply (msg, info, &mptcp_genl_family,0 , + info->genlhdr->cmd); +if (!reply) { +GENL_SET_ERR_MSG (info,"not enough space in Netlink message" ); + ret = -EMSGSIZE ; + goto fail; + } + + ret =mptcp_pm_get_addr (addr.addr.id, &addr, info); +if (ret) { +GENL_SET_ERR_MSG (info,"address not found" ); + goto fail; + } + + ret =mptcp_nl_fill_addr (msg, &addr); +if (ret) + goto fail; + +genlmsg_end (msg, reply); + ret =genlmsg_reply (msg, info); +return ret; + +fail: +nlmsg_free (msg); +return ret; }static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb)
net/mptcp/pm_netlink.c +6 -33
@@ -1762,48 +1762,21 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,return -EMSGSIZE ; } -int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info) +int mptcp_pm_nl_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, +struct genl_info *info) {struct pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry *entry; -struct sk_buff *msg; -void *reply; -int ret; - - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); -if (!msg) -return -ENOMEM ; - - reply =genlmsg_put_reply (msg, info, &mptcp_genl_family,0 , - info->genlhdr->cmd); -if (!reply) { -GENL_SET_ERR_MSG (info,"not enough space in Netlink message" ); - ret = -EMSGSIZE ; - goto fail; - } +int ret = -EINVAL ;rcu_read_lock (); entry =__lookup_addr_by_id (pernet, id); -if (!entry) { -GENL_SET_ERR_MSG (info,"address not found" ); - ret = -EINVAL ; - goto unlock_fail; +if (entry) { + *addr = *entry; + ret =0 ; } - - ret =mptcp_nl_fill_addr (msg, entry); -if (ret) - goto unlock_fail; - -genlmsg_end (msg, reply); - ret =genlmsg_reply (msg, info); -rcu_read_unlock (); -return ret; - -unlock_fail:rcu_read_unlock (); -fail: -nlmsg_free (msg);return ret; }
net/mptcp/pm_userspace.c +5 -36
65 lines not on this page · raw message
net/mptcp/protocol.h +4 -2
@@ -1131,8 +1131,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg, struct netlink_callback *cb);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb); -int mptcp_pm_nl_get_addr (u8 id,struct genl_info *info); -int mptcp_userspace_pm_get_addr (u8 id,struct genl_info *info); +int mptcp_pm_nl_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, +struct genl_info *info); +int mptcp_userspace_pm_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, +struct genl_info *info);static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) {
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v2 5/8 mptcp: change info of get_addr as const
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
get_addr() interfaces will be invoked by dump_addr(), which using const parameters 'info', so this patch changes 'info' parameters of get_addr() as const too.
Some adaptations are also needed. No longer use genl_info_pm_nl() because it doesn't accept a 'const' variable, but that's OK to get pernet via genl_info_net().
--- net/mptcp/pm.c | 2 +- net/mptcp/pm_netlink.c | 7 +++++-- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-)
net/mptcp/pm.c +1 -1
@@ -435,7 +435,7 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc) }static int mptcp_pm_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, -struct genl_info *info) +const struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ])return mptcp_userspace_pm_get_addr (id, addr, info);
net/mptcp/pm_netlink.c +5 -2
@@ -1763,12 +1763,15 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, }int mptcp_pm_nl_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, -struct genl_info *info) +const struct genl_info *info) { -struct pm_nl_pernet *pernet =genl_info_pm_nl (info); +struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry; +struct pm_nl_pernet *pernet;int ret = -EINVAL ; + pernet =pm_nl_get_pernet (net); +rcu_read_lock (); entry =__lookup_addr_by_id (pernet, id);if (entry) {
net/mptcp/pm_userspace.c +1 -1
@@ -664,7 +664,7 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, }int mptcp_userspace_pm_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, -struct genl_info *info) +const struct genl_info *info) {struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;
net/mptcp/protocol.h +2 -2
@@ -1132,9 +1132,9 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,int mptcp_userspace_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb);int mptcp_pm_nl_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, -struct genl_info *info); +const struct genl_info *info);int mptcp_userspace_pm_get_addr (u8 id,struct mptcp_pm_addr_entry *addr, -struct genl_info *info); +const struct genl_info *info);static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) {
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v2 5/8] mptcp: change info of get_addr as const
Hi Geliang,
Quoted 9 lines · Geliang Tang
From: Geliang Tang <[email protected]>
get_addr()interfaces will be invoked bydump_addr(), which using const parameters 'info', so this patch changes 'info' parameters ofget_addr()as const too.Some adaptations are also needed. No longer use
genl_info_pm_nl()because it doesn't accept a 'const' variable, but that's OK to get pernet viagenl_info_net().
(...)
Quoted 6 lines
net/mptcp/pm_netlink.c +0
-0@@ -1763,12 +1763,15 @@ int mptcp_nl_fill_addr(struct sk_buff *skb, } int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
net/mptcp/pm_netlink.c int mptcp_nl_fill_addr(struct sk_buff *skb, · line 1773
Quoted 10 lines
net/mptcp/pm_netlink.c +4
-2- struct genl_info *info) + const struct genl_info *info) { -struct pm_nl_pernet *pernet =genl_info_pm_nl (info); +struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry; +struct pm_nl_pernet *pernet;int ret = -EINVAL ; + pernet =pm_nl_get_pernet (net);
A small detail if you have something anything to change: maybe the 'net' variable is not needed, and instead of 3 lines, you can have it in 1:
struct pm_nl_pernet *pernet = pm_nl_get_pernet(genl_info_net(info));
net/mptcp/pm_netlink.c int mptcp_nl_fill_addr(struct sk_buff *skb, · line 1777
Quoted 4 lines
net/mptcp/pm_netlink.c +1
-0+rcu_read_lock (); entry =__lookup_addr_by_id (pernet, id);if (entry) {
(...)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v2 6/8 mptcp: add info parameter for dump_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The genl_info information is useful for dump_addr() interface in both in-kernel PM and userspace PM. The former can use it to get pm_nl_pernet, the latter can use it to get msk through mptcp_userspace_pm_get_sock().
So this patch adds an 'info' parameter to dump_addr interface, so that 'info' can be obtained in mptcp_pm_nl_get_addr_dumpit() and then passed to mptcp_pm_nl_dump_addr() or mptcp_userspace_pm_dump_addr(), without having to get it again in these two functions.
--- net/mptcp/pm.c | 13 +++++++------ net/mptcp/pm_netlink.c | 5 +++-- net/mptcp/pm_userspace.c | 4 ++-- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 16 insertions(+), 12 deletions(-)
net/mptcp/pm.c +7 -6
@@ -485,19 +485,20 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret; } -static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb) +static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb, +const struct genl_info *info) { -const struct genl_info *info =genl_info_dump (cb); -if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_dump_addr (msg, cb); -return mptcp_pm_nl_dump_addr (msg, cb); +return mptcp_userspace_pm_dump_addr (msg, cb, info); +return mptcp_pm_nl_dump_addr (msg, cb, info); }int mptcp_pm_nl_get_addr_dumpit (struct sk_buff *msg,struct netlink_callback *cb) { -return mptcp_pm_dump_addr (msg, cb); +const struct genl_info *info =genl_info_dump (cb); + +return mptcp_pm_dump_addr (msg, cb, info); }static int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info)
net/mptcp/pm_netlink.c +3 -2
@@ -1784,9 +1784,10 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, }int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb) +struct netlink_callback *cb, +const struct genl_info *info) { -struct net *net =sock_net (msg->sk); +struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet;int id = cb->args[0 ];
net/mptcp/pm_userspace.c +2 -2
@@ -615,12 +615,12 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) }int mptcp_userspace_pm_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb) +struct netlink_callback *cb, +const struct genl_info *info) {struct id_bitmap { DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); } *bitmap; -const struct genl_info *info =genl_info_dump (cb);struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;int ret = -EINVAL ;
net/mptcp/protocol.h +4 -2
@@ -1128,9 +1128,11 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);bool mptcp_pm_nl_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);bool mptcp_userspace_pm_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb); +struct netlink_callback *cb, +const struct genl_info *info);int mptcp_userspace_pm_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb); +struct netlink_callback *cb, +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,
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v2 7/8 mptcp: add mptcp_pm_addr_id_bitmap_t type
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
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.
--- include/net/mptcp.h | 7 +++++++ net/mptcp/pm_userspace.c | 14 ++++++-------- net/mptcp/protocol.h | 3 --- 3 files changed, 13 insertions(+), 11 deletions(-)
include/net/mptcp.h +7 -0
@@ -120,6 +120,13 @@ struct mptcp_sched_ops {void (*release)(struct mptcp_sock *msk); }____cacheline_aligned_in_smp ; +/* max value of mptcp_addr_info.id */ +#define MPTCP_PM_MAX_ADDR_ID U8_MAX + +typedef struct { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); +}mptcp_pm_addr_id_bitmap_t ; +#ifdef CONFIG_MPTCP void mptcp_init (void );
net/mptcp/pm_userspace.c +6 -8
@@ -47,15 +47,15 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry, bool needs_id) { - DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);struct mptcp_pm_addr_entry *match =NULL ;struct sock *sk = (struct sock *)msk; +mptcp_pm_addr_id_bitmap_t id_bitmap;struct mptcp_pm_addr_entry *e;bool addr_match = false;bool id_match = false;int ret = -EINVAL ; -bitmap_zero (id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 ); +bitmap_zero (id_bitmap.map,MPTCP_PM_MAX_ADDR_ID +1 );spin_lock_bh (&msk->pm.lock);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, }else if (addr_match || id_match) {break ; } -__set_bit (e->addr.id, id_bitmap); +__set_bit (e->addr.id, id_bitmap.map); }if (!match && !addr_match && !id_match) {
@@ -84,7 +84,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, *e = *entry;if (!e->addr.id && needs_id) - e->addr.id =find_next_zero_bit (id_bitmap, + e->addr.id =find_next_zero_bit (id_bitmap.map,MPTCP_PM_MAX_ADDR_ID +1 ,1 );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,struct netlink_callback *cb, const struct genl_info *info) { - struct id_bitmap { - DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); - } *bitmap; + mptcp_pm_addr_id_bitmap_t *bitmap;struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;int ret = -EINVAL ;struct sock *sk;void *hdr; - bitmap = (struct id_bitmap *)cb->ctx; + bitmap = (mptcp_pm_addr_id_bitmap_t *)cb->ctx; msk =mptcp_userspace_pm_get_sock (info);if (!msk)
net/mptcp/protocol.h +0 -3
@@ -208,9 +208,6 @@ enum mptcp_addr_signal_status { MPTCP_RM_ADDR_SIGNAL, }; -/* max value of mptcp_addr_info.id */ -#define MPTCP_PM_MAX_ADDR_ID U8_MAX -struct mptcp_pm_data {struct mptcp_addr_info local;struct mptcp_addr_info remote;
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v2 7/8] mptcp: add mptcp_pm_addr_id_bitmap_t type
Hi Geliang,
Quoted 30 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Similar to defining types such as
nodemask_t,dma_cap_mask_tandcpumask_tto simplify the use of bitmap, a new type for MPTCP userspace pm id bitmap,mptcp_pm_addr_id_bitmap_tis defined to easily modifydump_addr()interface of the path managers to accept anmptcp_pm_addr_id_bitmap_ttype parameter. It also allows this parameter ofdump_addr()can be modified by BPF program when implementing this interface of a BFP path manager. Because adump_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 useDECLARE_BITMAPmacro in BPF program, and it's not easy to reimplement it in BPF.Signed-off-by Geliang Tang <[email protected]>--- include/net/mptcp.h | 7 +++++++ net/mptcp/pm_userspace.c | 14 ++++++-------- net/mptcp/protocol.h | 3 --- 3 files changed, 13 insertions(+), 11 deletions(-)include/net/mptcp.h +0
-0
include/net/mptcp.h struct mptcp_sched_ops { · line 128
Quoted 9 lines
include/net/mptcp.h +6
-0@@ -120,6 +120,13 @@ struct mptcp_sched_ops {void (*release)(struct mptcp_sock *msk); }____cacheline_aligned_in_smp ; +/* max value of mptcp_addr_info.id */ +#define MPTCP_PM_MAX_ADDR_ID U8_MAX + +typedef struct { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); +}mptcp_pm_addr_id_bitmap_t ;
Why do you need to declare it here and not in protocol.h? Is it for the future BPF PM?
Maybe you don't really need this bitmap if it is only needed for the dump interfaces that are probably not needed with BPF?
Then maybe there is no need to change anything here?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerRe: [PATCH mptcp-next v2 7/8] mptcp: add mptcp_pm_addr_id_bitmap_t type
Hi Matt,
Quoted 39 lines · Matthieu Baerts
Hi Geliang,
Quoted 36 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Similar to defining types such as
nodemask_t,dma_cap_mask_tand
A. > >cpumask_tto simplify the use of bitmap, a new type for
MPTCP
userspace pm id bitmap,mptcp_pm_addr_id_bitmap_tis defined to easily modifydump_addr()interface of the path managers to accept anmptcp_pm_addr_id_bitmap_ttype parameter. It also allows this parameter ofdump_addr()can be modified by BPF program when implementing this interface of a BFP path manager. Because adump_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 useDECLARE_BITMAPmacro in BPF program, and it's not easy to reimplement it in BPF.Signed-off-by Geliang Tang <[email protected]>---
include/net/mptcp.h | 7 +++++++
net/mptcp/pm_userspace.c | 14 ++++++--------
net/mptcp/protocol.h | 3 ---3 files changed, 13 insertions(+), 11 deletions(-)include/net/mptcp.h +0
-0@@ -120,6 +120,13 @@ struct mptcp_sched_ops { void (*release)(struct mptcp_sock *msk); } ____cacheline_aligned_in_smp;include/net/mptcp.h +2
-0+/* max value of mptcp_addr_info.id */ +#define MPTCP_PM_MAX_ADDR_ID U8_MAX
Quoted 8 lines
include/net/mptcp.h struct mptcp_sched_ops { · line 128
Quoted 4 lines
include/net/mptcp.h +4
-0+ +typedef struct { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); +}mptcp_pm_addr_id_bitmap_t ;Why do you need to declare it here and not in
protocol.h? Is it for the
future BPF PM?
Yes, it's for the BPF PM. If we define a struct mptcp_pm_addr_id_bitmap as in the previous version [1], we can indeed put it in protocol.h:
struct mptcp_pm_addr_id_bitmap {DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
};
and just declare it in include/net/mptcp.h:
struct mptcp_pm_addr_id_bitmap;
But as your comments in [1], 'why do you need a
specific structure with only one field?'
This new version uses 'typedef' to define a new type, similar to nodemask_t, dma_cap_mask_t and cpumask_t. I think this is a good way to handle structures with only one field. But on the other hand, we can't declare a 'mptcp_pm_addr_id_bitmap_t' in include/net/mptcp.h, we need to move the entire typedef to include/net/mptcp.h, and the corresponding MPTCP_PM_MAX_ADDR_ID also needs to be moved together.
Which one do you prefer, mptcp_pm_addr_id_bitmap_t or struct mptcp_pm_addr_id_bitmap? I will use it in the next version.
Thanks,
-Geliang
Quoted 8 lines
Maybe you don't really need this bitmap if it is only needed for the dump interfaces that are probably not needed with BPF?
Then maybe there is no need to change anything here?
Cheers,
Matt
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v2 7/8] mptcp: add mptcp_pm_addr_id_bitmap_t type
Hi Geliang,
Quoted 72 lines · Geliang Tang
Hi Matt,
Quoted 39 lines · Matthieu Baerts
Hi Geliang,
Quoted 36 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Similar to defining types such as
nodemask_t,dma_cap_mask_tand
A. > >cpumask_tto simplify the use of bitmap, a new type for
MPTCP
userspace pm id bitmap,mptcp_pm_addr_id_bitmap_tis defined to easily modifydump_addr()interface of the path managers to accept anmptcp_pm_addr_id_bitmap_ttype parameter. It also allows this parameter ofdump_addr()can be modified by BPF program when implementing this interface of a BFP path manager. Because adump_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 useDECLARE_BITMAPmacro in BPF program, and it's not easy to reimplement it in BPF.Signed-off-by Geliang Tang <[email protected]>---
include/net/mptcp.h | 7 +++++++
net/mptcp/pm_userspace.c | 14 ++++++--------
net/mptcp/protocol.h | 3 ---3 files changed, 13 insertions(+), 11 deletions(-)include/net/mptcp.h +0
-0@@ -120,6 +120,13 @@ struct mptcp_sched_ops { void (*release)(struct mptcp_sock *msk); } ____cacheline_aligned_in_smp;include/net/mptcp.h +2
-0+/* max value of mptcp_addr_info.id */ +#define MPTCP_PM_MAX_ADDR_ID U8_MAXQuoted 8 lines
include/net/mptcp.h struct mptcp_sched_ops { · line 128
Quoted 4 lines
include/net/mptcp.h +4
-0+ +typedef struct { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); +}mptcp_pm_addr_id_bitmap_t ;Why do you need to declare it here and not in
protocol.h? Is it for the
future BPF PM?Yes, it's for the BPF PM. If we define a struct
mptcp_pm_addr_id_bitmapas in the previous version [1], we can indeed put it inprotocol.h:struct
mptcp_pm_addr_id_bitmap{DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
};and just declare it in
include/net/mptcp.h:struct
mptcp_pm_addr_id_bitmap;But as your comments in [1], 'why do you need a
specific structure with only one field?'This new version uses 'typedef' to define a new type, similar to
nodemask_t,dma_cap_mask_tandcpumask_t. I think this is a good way to handle structures with only one field. But on the other hand, we can't declare a 'mptcp_pm_addr_id_bitmap_t' ininclude/net/mptcp.h, we need to move the entire typedef toinclude/net/mptcp.h, and the correspondingMPTCP_PM_MAX_ADDR_IDalso needs to be moved together.
Quoted 2 lines
Which one do you prefer,
mptcp_pm_addr_id_bitmap_tor structmptcp_pm_addr_id_bitmap? I will use it in the next version.
My question was more to know why BPF is not happy if the struct or typedef is declared in net/mptcp/protocol.h instead of include/net/mptcp.h.
If really it has to be declared in 'include', then maybe better to add the minimum (struct mptcp_pm_addr_id_bitmap;) and the typedef in protocol.h.
Quoted 4 lines
Quoted 4 lines
Maybe you don't really need this bitmap if it is only needed for the dump interfaces that are probably not needed with BPF?
Then maybe there is no need to change anything here?
Regarding these two questions: why do you need the bitmap? If I'm not mistaken, the BPF PM doesn't need to implement the 'dump' and 'get_addr'
interfaces: no need to expose this to userspace via netlink if the PM is handled in kernelspace with BPF, no?
A BPF PM can expose what it wants via BPF.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v2 8/8 mptcp: reuse sending nlmsg code in dump_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
With the help of get_addr(), we can modify dump_addr() interfaces to reuse send_nlmsg code between the netlink PM and userspace PM.
The current dump_addr() flow looks like this:
lock(); for_each_entry(entry) send_nlmsg(entry); unlock();
After holding the lock, get every entry by walking the address list, send each one looply, and finally release the lock.
This set changes the process by copying the address list to an id bitmap while holding the lock, then release the lock immediately. After that, without locking, walking the copied id bitmap to get every copy of entry by using get_addr(), and send each one looply:
lock();
for_each_entry(entry)
set_bit(bitmap);
unlock();
for_each_bit(bitmap) {
copy = get_addr();
send_nlmsg(copy);
}With this, we can reuse the send_nlmsg() code in dump_addr() interfaces between the netlink PM and userspace PM. They only need to implement their own dump_addr() interfaces to hold the different locks, copy the different address lists to an id bitmap, then release the locks.
--- net/mptcp/pm.c | 43 ++++++++++++++++++++++++++++++++++++---- net/mptcp/pm_netlink.c | 35 +++----------------------------- net/mptcp/pm_userspace.c | 41 ++++++++++++++------------------------ net/mptcp/protocol.h | 6 ++---- 4 files changed, 59 insertions(+), 66 deletions(-)
net/mptcp/pm.c +39 -4
@@ -485,20 +485,55 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret; } -static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb, +static int mptcp_pm_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_dump_addr (msg, cb, info); -return mptcp_pm_nl_dump_addr (msg, cb, info); +return mptcp_userspace_pm_dump_addr (bitmap, info); +return mptcp_pm_nl_dump_addr (bitmap, info); }int mptcp_pm_nl_get_addr_dumpit (struct sk_buff *msg,struct netlink_callback *cb) {const struct genl_info *info =genl_info_dump (cb); +mptcp_pm_addr_id_bitmap_t *bitmap; +struct mptcp_pm_addr_entry entry; +int id = cb->args[0 ]; +void *hdr; +int i; + + bitmap = (mptcp_pm_addr_id_bitmap_t *)cb->ctx; + +mptcp_pm_dump_addr (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 ; + +if (id && entry.addr.id <= id) +continue ; + + hdr =genlmsg_put (msg,NETLINK_CB (cb->skb).portid, + cb->nlh->nlmsg_seq, + &mptcp_genl_family,NLM_F_MULTI , +MPTCP_PM_CMD_GET_ADDR ); +if (!hdr) +break ; + +if (mptcp_nl_fill_addr (msg, &entry) <0 ) { +genlmsg_cancel (msg, hdr); +break ; + } + + id = entry.addr.id; +genlmsg_end (msg, hdr); + } + } -return mptcp_pm_dump_addr (msg, cb, info); + cb->args[0 ] = id; +return msg->len; }static int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info)
net/mptcp/pm_netlink.c +3 -32
@@ -1783,48 +1783,19 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,return ret; } -int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_pm_nl_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info) {struct net *net =genl_info_net (info); -struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet; -int id = cb->args[0 ]; -void *hdr; -int i; pernet =pm_nl_get_pernet (net);rcu_read_lock (); -for (i = id; i <MPTCP_PM_MAX_ADDR_ID +1 ; i++) { -if (test_bit (i, pernet->id_bitmap)) { - entry =__lookup_addr_by_id (pernet, i); -if (!entry) -break ; - -if (entry->addr.id <= id) -continue ; - - hdr =genlmsg_put (msg,NETLINK_CB (cb->skb).portid, - cb->nlh->nlmsg_seq, &mptcp_genl_family, -NLM_F_MULTI ,MPTCP_PM_CMD_GET_ADDR ); -if (!hdr) -break ; - -if (mptcp_nl_fill_addr (msg, entry) <0 ) { -genlmsg_cancel (msg, hdr); -break ; - } - - id = entry->addr.id; -genlmsg_end (msg, hdr); - } - } +bitmap_copy (bitmap->map, pernet->id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 );rcu_read_unlock (); - cb->args[0 ] = id; -return msg->len; +return 0 ; }static int parse_limit (struct genl_info *info,int id,unsigned int *limit)
net/mptcp/pm_userspace.c +15 -26
60 lines not on this page · raw message
net/mptcp/protocol.h +2 -4
@@ -1124,11 +1124,9 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inbool mptcp_pm_is_backup (struct mptcp_sock *msk,struct sock_common *skc);bool mptcp_pm_nl_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);bool mptcp_userspace_pm_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc); -int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_pm_nl_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info); -int mptcp_userspace_pm_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_userspace_pm_dump_addr (mptcp_pm_addr_id_bitmap_t *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);
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v2 8/8] mptcp: reuse sending nlmsg code in dump_addr
Hi Geliang,
It looks like the code below only works if the dump can be done in one call.
I spent quite a bit of time looking at it, and at the end, I would like to say it doesn't look like this modification is worth it: it increases the complexity just to save a bit of duplicated code (which is used differently). WDYT? Or do you really need this for the BPF PM?
Here below, you can find my review, but in short, I don't think we should try to unify the code here. WDYT?
Quoted 20 lines · Geliang Tang
From: Geliang Tang <[email protected]>
With the help of
get_addr(), we can modifydump_addr()interfaces to reusesend_nlmsgcode between the netlink PM and userspace PM.The current
dump_addr()flow looks like this:lock(); for_each_entry(entry) send_nlmsg(entry); unlock();After holding the lock, get every entry by walking the address list, send each one looply, and finally release the lock.
This set changes the process by copying the address list to an id bitmap while holding the lock, then release the lock immediately. After that, without locking, walking the copied id bitmap to get every copy of entry by using
get_addr(), and send each one looply:
Quoted 7 lines
lock();
for_each_entry(entry)
set_bit(bitmap);
unlock();
for_each_bit(bitmap) {
copy = get_addr();What you are hiding here is that there will be a lock again here for each address: so we will lock and unlock once before, and once per address... Maybe we don't care about that here, but is it really worth it?
Quoted 36 lines
send_nlmsg(copy); }With this, we can reuse the
send_nlmsg()code indump_addr()interfaces between the netlink PM and userspace PM. They only need to implement their owndump_addr()interfaces to hold the different locks, copy the different address lists to an id bitmap, then release the locks.Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/pm.c | 43 ++++++++++++++++++++++++++++++++++++---- net/mptcp/pm_netlink.c | 35 +++----------------------------- net/mptcp/pm_userspace.c | 41 ++++++++++++++------------------------ net/mptcp/protocol.h | 6 ++---- 4 files changed, 59 insertions(+), 66 deletions(-)net/mptcp/pm.c +3
-3@@ -485,20 +485,55 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret; } -static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb, +static int mptcp_pm_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_dump_addr (msg, cb, info); -return mptcp_pm_nl_dump_addr (msg, cb, info); +return mptcp_userspace_pm_dump_addr (bitmap, info); +return mptcp_pm_nl_dump_addr (bitmap, info); } int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
net/mptcp/pm.c int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) · line 506
Quoted 10 lines
net/mptcp/pm.c +7
-0struct netlink_callback *cb) {const struct genl_info *info =genl_info_dump (cb); +mptcp_pm_addr_id_bitmap_t *bitmap; +struct mptcp_pm_addr_entry entry; +int id = cb->args[0 ]; +void *hdr; +int i; + + bitmap = (mptcp_pm_addr_id_bitmap_t *)cb->ctx;
Mmh, that feels wrong: you are using cb->ctx and cb->args at the same part, but they are part of an union. This will likely only work the first time, not if dumpit() is called in multiple chunks, no?
For it to work, I guess you should only copy the bitmap the first time (not sure what you can look at, reserve some bits in cb->ctx for that?), then use __test_and_clear_bit() instead of test_bit(). But again, not sure if it is really worth it, that makes things a bit more complex.
BTW, not related to ↑, but it might be safer to add a build check to make sure sizeof(cb->ctx) >= sizeof(mptcp_pm_addr_id_bitmap_t), just in case we change it later.
net/mptcp/pm.c int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) · line 508
Quoted 2 lines
net/mptcp/pm.c +2
-0+ +mptcp_pm_dump_addr (bitmap, info);
Should you not only fill the bitmap the first time? I'm not sure if I fully understand how it is used, but from what I see, the dump can be done in multiple calls, hence the use of cb. Here this fill the bitmap without taking into account what was done before.
net/mptcp/pm.c int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) · line 513
Quoted 5 lines
net/mptcp/pm.c +5
-0+ +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 ;
I don't think you should "break" here, but "continue" instead:
potentially between the two calls, the address at this ID might have been removed.
net/mptcp/pm.c int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) · line 515
Quoted 2 lines
net/mptcp/pm.c +2
-0+ +if (id && entry.addr.id <= id)
Why is the condition different from before in pm_netlink.c? Why do you need to explicitly skip id 0?
If I'm not mistaken, with the in-kernel PM, we cannot have ID 0 here, but we can with the userspace PM, no?
Quoted 64 lines
net/mptcp/pm.c +20
-1+continue ; + + hdr =genlmsg_put (msg,NETLINK_CB (cb->skb).portid, + cb->nlh->nlmsg_seq, + &mptcp_genl_family,NLM_F_MULTI , +MPTCP_PM_CMD_GET_ADDR ); +if (!hdr) +break ; + +if (mptcp_nl_fill_addr (msg, &entry) <0 ) { +genlmsg_cancel (msg, hdr); +break ; + } + + id = entry.addr.id; +genlmsg_end (msg, hdr); + } + } -return mptcp_pm_dump_addr (msg, cb, info); + cb->args[0 ] = id; +return msg->len; }static int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info)net/mptcp/pm_netlink.c +1
-22@@ -1783,48 +1783,19 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,return ret; } -int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_pm_nl_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info) {struct net *net =genl_info_net (info); -struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet; -int id = cb->args[0 ]; -void *hdr; -int i; pernet =pm_nl_get_pernet (net);rcu_read_lock (); -for (i = id; i <MPTCP_PM_MAX_ADDR_ID +1 ; i++) { -if (test_bit (i, pernet->id_bitmap)) { - entry =__lookup_addr_by_id (pernet, i); -if (!entry) -break ; - -if (entry->addr.id <= id) -continue ; - - hdr =genlmsg_put (msg,NETLINK_CB (cb->skb).portid, - cb->nlh->nlmsg_seq, &mptcp_genl_family, -NLM_F_MULTI ,MPTCP_PM_CMD_GET_ADDR ); -if (!hdr) -break ; - -if (mptcp_nl_fill_addr (msg, entry) <0 ) {
net/mptcp/pm_netlink.c int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, · line 1796
Quoted 10 lines
net/mptcp/pm_netlink.c +1
-8-genlmsg_cancel (msg, hdr); -break ; - } - - id = entry->addr.id; -genlmsg_end (msg, hdr); - } - } +bitmap_copy (bitmap->map, pernet->id_bitmap,MPTCP_PM_MAX_ADDR_ID +1 );rcu_read_unlock ();
"pernet->id_bitmap" is not protected by RCU, only the endpoints are (linked to __lookup_addr_by_id()).
In other words, rcu_read_(un)lock() are no longer needed here.
It also means that potentially, we are changing the behaviour of the dump when endpoints are being modified but:
— MPTCP netlink commands are processed one by one, so this should not happen if I'm not mistaken.
— Even if the endpoints were being modified during a dump (maybe it can if the endpoints cannot all fit in the buffer?), that's OK if it reports the previous version of just updated info.
net/mptcp/pm_netlink.c int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr, · line 1799
Quoted 5 lines
net/mptcp/pm_netlink.c +1
-2- cb->args[0 ] = id; -return msg->len; +return 0 ; }
This helper no longer dump addresses any more, it only copies the bitmap. Should it be eventually renamed?
Quoted 51 lines
net/mptcp/pm_netlink.c +0
-0static int parse_limit (struct genl_info *info,int id,unsigned int *limit)net/mptcp/pm_userspace.c +14
-16@@ -614,18 +614,25 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)return ret; } -int mptcp_userspace_pm_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, -const struct genl_info *info) +static int mptcp_userspace_pm_reset_bitmap (struct mptcp_sock *msk, +mptcp_pm_addr_id_bitmap_t *bitmap) { -mptcp_pm_addr_id_bitmap_t *bitmap;struct mptcp_pm_addr_entry *entry; + +bitmap_zero (bitmap->map,MPTCP_PM_MAX_ADDR_ID +1 ); + +mptcp_for_each_userspace_pm_addr (msk, entry) +__set_bit (entry->addr.id, bitmap->map); + +return 0 ; +} + +int mptcp_userspace_pm_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap, +const struct genl_info *info) +{struct mptcp_sock *msk;int ret = -EINVAL ;struct sock *sk; -void *hdr; - - bitmap = (mptcp_pm_addr_id_bitmap_t *)cb->ctx; msk =mptcp_userspace_pm_get_sock (info);if (!msk)@@ -635,27 +642,9 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,lock_sock (sk);spin_lock_bh (&msk->pm.lock); -mptcp_for_each_userspace_pm_addr (msk, entry) { -if (test_bit (entry->addr.id, bitmap->map)) -continue ; - - hdr =genlmsg_put (msg,NETLINK_CB (cb->skb).portid, - cb->nlh->nlmsg_seq, &mptcp_genl_family, -NLM_F_MULTI ,MPTCP_PM_CMD_GET_ADDR ); -if (!hdr) -break ;
net/mptcp/pm_userspace.c int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, · line 645
Quoted 10 lines
net/mptcp/pm_userspace.c +1
-9- -if (mptcp_nl_fill_addr (msg, entry) <0 ) { -genlmsg_cancel (msg, hdr); -break ; - } - -__set_bit (entry->addr.id, bitmap->map); -genlmsg_end (msg, hdr); - } + ret =mptcp_userspace_pm_reset_bitmap (msk, bitmap);
Mmh, I don't understand this. If I'm not mistaken, before, we were using a bitmap because in case the dump had to be done in multiple parts, we required a way to mark which IDs had already been dumped.
But here, with your modification, you fill all the bitmap like we would be able to dump everything in one go: the bitmap is written with all entries, and reset each time we need to "dump the rest". So at the end, we no longer remember what was done in the previous parts, and we would dump the same thing over and over, no?
Quoted 14 lines
net/mptcp/pm_userspace.c +0
-1spin_unlock_bh (&msk->pm.lock);release_sock (sk); - ret = msg->len;sock_put (sk);return ret;net/mptcp/protocol.h +0
-0@@ -1124,11 +1124,9 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_inbool mptcp_pm_is_backup (struct mptcp_sock *msk,struct sock_common *skc);bool mptcp_pm_nl_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);bool mptcp_userspace_pm_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc);
net/mptcp/protocol.h int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_in · line 1132
Quoted 10 lines
net/mptcp/protocol.h +2
-4-int mptcp_pm_nl_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_pm_nl_dump_addr (mptcp_pm_addr_id_bitmap_t *bitmap,const struct genl_info *info); -int mptcp_userspace_pm_dump_addr (struct sk_buff *msg, -struct netlink_callback *cb, +int mptcp_userspace_pm_dump_addr (mptcp_pm_addr_id_bitmap_t *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);
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerHi Geliang,
Quoted 10 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v2:
- split patch 7 of v1 into two.
- patches 1-6 have no code changes, only the commit logs have been
updated.
- more commit log to explain whymptcp_pm_addr_id_bitmap_tneeds to
be defined.
- usemptcp_pm_addr_id_bitmap_tinuserspace_pm_append_new_local_addr
too.
Sorry for the delay: I was waiting for the CI to do the validation, but somehow, it didn't even start. An issue on Patchew side apparently:
https://patchew.org/MPTCP/[email protected]/
The 6 first patches look good to me (just one small thing, and a rebase might be needed).
It is unclear to me if we need the 2 last patches. Maybe patch 7/8 is needed for the BPF path-manager? Not even sure, please see below.
Regarding patch 8/8, it looks like it introduces new issues, and solving them increases the complexity, and I don't think it is worth saving a bit of duplicated code there. WDYT?
Quoted 3 lines
In order to implement BPF userspace path manager, it is necessary to unify the interfaces of the path manager. This set updates
get_addr()anddump_addr()interfaces.
The modifications you are proposing here makes sense. Now, regarding the BPF path-manager, to me, they don't really need to implement get_addr() and dump_addr() because these interfaces are only useful for the userspace:
- with the in-kernel PM, it is useful to list the different endpoints to be able to change the configuration if needed (or to check how endpoints got configured).
- with the userspace one, it can be useful to retrieve addresses when the daemon got restarted, to get info about previously created connections.
- with the BPF PM, I'm not sure if there is really a need to dump addresses to the userspace. Or do you see a case where these interfaces can be useful? I guess BPF PMs will be configured via BPF, and if there is a need, the addresses can also be dumped via BPF, but I don't see the point of exporting them via Netlink.
Maybe there is no need to do much around these interfaces, and the last two patches can be dropped? Or maybe mptcp_pm_addr_id_bitmap_t can be defined in protocol.h instead of in include/net/mptcp.h?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.