BPF path manager, part 2
Subsystems (2)
Geliang Tang
reviewerv4 cover BPF path manager, part 2
From: Geliang Tang <[email protected]>
v4:
- move "mptcp: userspace pm set_flags id support" out of this set.
- only add 'local' parameter for set_flags, no 'remote'.
Based-on: <[email protected]>
v3:
- Thanks Matt for the review on dump_addr interfaces. It seems that
it needs more time to be modified. In this version, I removed the patches for dump_addr interfaces from this set and added the patches for set_flags interfaces.
- set_flags interfaces patches address Matt's comments on the set
"mptcp: use GENL_REQ_ATTR_CHECK in userspace pm" v2.
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 (7):
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: drop skb parameter of set_flags
mptcp: change rem type of set_flags
mptcp: add local parameter for set_flags
net/mptcp/pm.c | 86 +++++++++++++++++++++++++++++--- net/mptcp/pm_netlink.c | 104 ++++++++------------------------------- net/mptcp/pm_userspace.c | 81 +++++++----------------------- net/mptcp/protocol.h | 14 +++--- 4 files changed, 124 insertions(+), 161 deletions(-)
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v4 1/7 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
@@ -1827,11 +1827,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) {
@@ -1875,12 +1870,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];
@@ -2056,11 +2045,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
@@ -1028,7 +1028,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,
@@ -1121,12 +1120,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 v4 2/7 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
@@ -1773,7 +1773,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 pm_nl_pernet *pernet =genl_info_pm_nl (info);struct mptcp_pm_addr_entry addr, *entry;
net/mptcp/pm_userspace.c +1 -2
@@ -683,8 +683,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 mptcp_pm_addr_entry addr, *entry;struct mptcp_sock *msk;
net/mptcp/protocol.h +2 -3
@@ -1124,9 +1124,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 v4 3/7 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 | 20 ++++++++++++++++---- net/mptcp/pm_netlink.c | 14 +++----------- net/mptcp/pm_userspace.c | 14 +++----------- net/mptcp/protocol.h | 4 ++-- 4 files changed, 24 insertions(+), 28 deletions(-)
net/mptcp/pm.c +16 -4
@@ -434,16 +434,28 @@ 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 mptcp_pm_addr_entry addr; +struct nlattr *attr; +int ret; + +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); +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 -11
@@ -1773,23 +1773,15 @@ 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 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;struct nlattr *attr;void *reply;int ret; -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); -if (ret <0 ) -return ret; - msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg)return -ENOMEM ;
@@ -1803,7 +1795,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) {NL_SET_ERR_MSG_ATTR (info->extack, attr,"address not found" ); ret = -EINVAL ;
net/mptcp/pm_userspace.c +3 -11
@@ -683,9 +683,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 mptcp_pm_addr_entry addr, *entry; +struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;struct sk_buff *msg;struct nlattr *attr;
@@ -693,20 +693,12 @@ int mptcp_userspace_pm_get_addr(struct genl_info *info)struct sock *sk;void *reply; -if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR )) -return ret; - msk =mptcp_userspace_pm_get_sock (info);if (!msk)return ret; sk = (struct sock *)msk; - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; - 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 ;
@@ -723,7 +715,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) {NL_SET_ERR_MSG_ATTR (info->extack, attr,"address not found" ); ret = -EINVAL ;
net/mptcp/protocol.h +2 -2
@@ -1124,8 +1124,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
Geliang Tang
reviewerPATCH v4 4/7 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 | 40 ++++++-------------------------------- net/mptcp/pm_userspace.c | 42 +++++----------------------------------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 50 insertions(+), 77 deletions(-)
net/mptcp/pm.c +35 -4
@@ -434,17 +434,20 @@ 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 mptcp_pm_addr_entry addr;struct nlattr *attr; +struct sk_buff *msg; +void *reply;int ret;if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR ))
@@ -455,7 +458,35 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)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) { +NL_SET_ERR_MSG_ATTR (info->extack, attr,"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 -34
@@ -1773,49 +1773,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; -struct nlattr *attr; -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) { -NL_SET_ERR_MSG_ATTR (info->extack, attr,"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 -37
66 lines not on this page · raw message
net/mptcp/protocol.h +4 -2
@@ -1124,8 +1124,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 v4 5/7 mptcp: drop skb parameter of set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The first parameter 'skb' in mptcp_pm_nl_set_flags() is only used to obtained the network namespace, which can also be obtained through the second parameters 'info' by using genl_info_net() helper. This patch drops these useless parameters 'skb' in all three set_flags() interfaces.
--- net/mptcp/pm.c | 8 ++++---- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-)
net/mptcp/pm.c +4 -4
@@ -504,16 +504,16 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,return mptcp_pm_dump_addr (msg, cb); } -static int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info) +static int mptcp_pm_set_flags (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); +return mptcp_userspace_pm_set_flags (info); +return mptcp_pm_nl_set_flags (info); }int mptcp_pm_nl_set_flags_doit (struct sk_buff *skb,struct genl_info *info) { -return mptcp_pm_set_flags (skb, info); +return mptcp_pm_set_flags (info); }void mptcp_pm_subflow_chk_stale (const struct mptcp_sock *msk,struct sock *ssk)
net/mptcp/pm_netlink.c +2 -2
@@ -1951,12 +1951,12 @@ static int mptcp_nl_set_flags(struct net *net,return ret; } -int mptcp_pm_nl_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry addr = { .addr = { .family =AF_UNSPEC }, };u8 changed, mask =MPTCP_PM_ADDR_FLAG_BACKUP |MPTCP_PM_ADDR_FLAG_FULLMESH ; -struct net *net =sock_net (skb->sk); +struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet;struct nlattr *attr;
net/mptcp/pm_userspace.c +1 -1
@@ -564,7 +564,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *inforeturn err; } -int mptcp_userspace_pm_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_userspace_pm_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, };struct mptcp_pm_addr_entry rem = { .addr = { .family =AF_UNSPEC }, };
net/mptcp/protocol.h +2 -2
@@ -1028,8 +1028,8 @@ 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_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_nl_set_flags (struct genl_info *info); +int mptcp_userspace_pm_set_flags (struct genl_info *info);int mptcp_pm_announce_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr,bool echo);
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v4 6/7 mptcp: change rem type of set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Generally, in the path manager interfaces, the local address is defined as an mptcp_pm_addr_entry type address, while the remote address is defined as an mptcp_addr_info type one:
(struct mptcp_pm_addr_entry *local, struct mptcp_addr_info *remote)
But the set_flags() interface uses two mptcp_pm_addr_entry type parameters. This patch changes the second one to mptcp_addr_info type and use helper mptcp_pm_parse_addr() to parse it instead of using mptcp_pm_parse_entry().
--- net/mptcp/pm_userspace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/pm_userspace.c +4 -4
@@ -567,7 +567,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *infoint mptcp_userspace_pm_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, }; -struct mptcp_pm_addr_entry rem = { .addr = { .family =AF_UNSPEC }, }; +struct mptcp_addr_info rem = { .family =AF_UNSPEC , };struct mptcp_pm_addr_entry *entry;struct nlattr *attr, *attr_rem;struct mptcp_sock *msk;
@@ -597,11 +597,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) } attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; - ret =mptcp_pm_parse_entry (attr_rem, info, false, &rem); + ret =mptcp_pm_parse_addr (attr_rem, info, &rem);if (ret <0 ) goto set_flags_err; -if (rem.addr.family ==AF_UNSPEC ) { +if (rem.family ==AF_UNSPEC ) {NL_SET_ERR_MSG_ATTR (info->extack, attr_rem,"invalid remote address family" ); ret = -EINVAL ;
@@ -622,7 +622,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info)spin_unlock_bh (&msk->pm.lock);lock_sock (sk); - ret =mptcp_pm_nl_mp_prio_send_ack (msk, &loc.addr, &rem.addr, bkup); + ret =mptcp_pm_nl_mp_prio_send_ack (msk, &loc.addr, &rem, bkup);release_sock (sk);/* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v4 7/7 mptcp: add local parameter for set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch updates the interfaces set_flags to reduce repetitive code, adds a new parameter 'local' for them. The local address is parsed in public helper mptcp_pm_nl_set_flags_doit(), then pass it to mptcp_pm_nl_set_flags() and mptcp_userspace_pm_set_flags().
--- net/mptcp/pm.c | 16 ++++++++++++++-- net/mptcp/pm_netlink.c | 34 ++++++++++++---------------------- net/mptcp/pm_userspace.c | 22 ++++++++-------------- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 38 insertions(+), 40 deletions(-)
net/mptcp/pm.c +14 -2
@@ -506,9 +506,21 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,static int mptcp_pm_set_flags (struct genl_info *info) { +struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, }; +struct nlattr *attr_loc; +int ret = -EINVAL ; + +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR )) +return ret; + + attr_loc = info->attrs[MPTCP_PM_ATTR_ADDR ]; + ret =mptcp_pm_parse_entry (attr_loc, info, false, &loc); +if (ret <0 ) +return ret; +if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_set_flags (info); -return mptcp_pm_nl_set_flags (info); +return mptcp_userspace_pm_set_flags (&loc, info); +return mptcp_pm_nl_set_flags (&loc, info); }int mptcp_pm_nl_set_flags_doit (struct sk_buff *skb,struct genl_info *info)
net/mptcp/pm_netlink.c +12 -22
@@ -1951,61 +1951,51 @@ static int mptcp_nl_set_flags(struct net *net,return ret; } -int mptcp_pm_nl_set_flags (struct genl_info *info) +int mptcp_pm_nl_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info) { -struct mptcp_pm_addr_entry addr = { .addr = { .family =AF_UNSPEC }, };u8 changed, mask =MPTCP_PM_ADDR_FLAG_BACKUP |MPTCP_PM_ADDR_FLAG_FULLMESH ;struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet; -struct nlattr *attr;u8 lookup_by_id =0 ;u8 bkup =0 ; -int ret; - -if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR )) -return -EINVAL ; pernet =pm_nl_get_pernet (net); - attr = info->attrs[MPTCP_PM_ATTR_ADDR ]; - ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) -return ret; - -if (addr.addr.family ==AF_UNSPEC ) { +if (local->addr.family ==AF_UNSPEC ) { lookup_by_id =1 ; -if (!addr.addr.id) { +if (!local->addr.id) {GENL_SET_ERR_MSG (info,"missing address ID" );return -EOPNOTSUPP ; } } -if (addr.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) +if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) bkup =1 ;spin_lock_bh (&pernet->lock); - entry = lookup_by_id ?__lookup_addr_by_id (pernet, addr.addr.id) : -__lookup_addr (pernet, &addr.addr); + entry = lookup_by_id ?__lookup_addr_by_id (pernet, local->addr.id) : +__lookup_addr (pernet, &local->addr);if (!entry) {spin_unlock_bh (&pernet->lock);GENL_SET_ERR_MSG (info,"address not found" );return -EINVAL ; } -if ((addr.flags &MPTCP_PM_ADDR_FLAG_FULLMESH ) && +if ((local->flags &MPTCP_PM_ADDR_FLAG_FULLMESH ) && (entry->flags &MPTCP_PM_ADDR_FLAG_SIGNAL )) {spin_unlock_bh (&pernet->lock);GENL_SET_ERR_MSG (info,"invalid addr flags" );return -EINVAL ; } - changed = (addr.flags ^ entry->flags) & mask; - entry->flags = (entry->flags & ~mask) | (addr.flags & mask); - addr = *entry; + changed = (local->flags ^ entry->flags) & mask; + entry->flags = (entry->flags & ~mask) | (local->flags & mask); + *local = *entry;spin_unlock_bh (&pernet->lock); -mptcp_nl_set_flags (net, &addr.addr, bkup, changed); +mptcp_nl_set_flags (net, &local->addr, bkup, changed);return 0 ; }
net/mptcp/pm_userspace.c +8 -14
@@ -564,19 +564,18 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *inforeturn err; } -int mptcp_userspace_pm_set_flags (struct genl_info *info) +int mptcp_userspace_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info) { -struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, };struct mptcp_addr_info rem = { .family =AF_UNSPEC , };struct mptcp_pm_addr_entry *entry; -struct nlattr *attr, *attr_rem; +struct nlattr *attr_rem;struct mptcp_sock *msk;int ret = -EINVAL ;struct sock *sk;u8 bkup =0 ; -if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR ) || -GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE )) +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE ))return ret; msk =mptcp_userspace_pm_get_sock (info);
@@ -585,12 +584,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) sk = (struct sock *)msk; - attr = info->attrs[MPTCP_PM_ATTR_ADDR ]; - ret =mptcp_pm_parse_entry (attr, info, false, &loc); -if (ret <0 ) - goto set_flags_err; - -if (loc.addr.family ==AF_UNSPEC ) { +if (local->addr.family ==AF_UNSPEC ) {GENL_SET_ERR_MSG (info,"invalid local address family" ); ret = -EINVAL ; goto set_flags_err;
@@ -608,11 +602,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) goto set_flags_err; } -if (loc.flags &MPTCP_PM_ADDR_FLAG_BACKUP ) +if (local->flags &MPTCP_PM_ADDR_FLAG_BACKUP ) bkup =1 ;spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr (msk, &loc.addr); + entry =mptcp_userspace_pm_lookup_addr (msk, &local->addr);if (entry) {if (bkup) entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ;
@@ -622,7 +616,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info)spin_unlock_bh (&msk->pm.lock);lock_sock (sk); - ret =mptcp_pm_nl_mp_prio_send_ack (msk, &loc.addr, &rem, bkup); + ret =mptcp_pm_nl_mp_prio_send_ack (msk, &local->addr, &rem, bkup);release_sock (sk);/* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */
net/mptcp/protocol.h +4 -2
@@ -1028,8 +1028,10 @@ 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_nl_set_flags (struct genl_info *info); -int mptcp_userspace_pm_set_flags (struct genl_info *info); +int mptcp_pm_nl_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info); +int mptcp_userspace_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info);int mptcp_pm_announce_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr,bool echo);
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v4 7/7] mptcp: add local parameter for set_flags
Hi Geliang,
Quoted 6 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch updates the interfaces
set_flagsto reduce repetitive code, adds a new parameter 'local' for them. The local address is parsed in public helpermptcp_pm_nl_set_flags_doit(), then pass it tomptcp_pm_nl_set_flags()andmptcp_userspace_pm_set_flags().
(...)
Quoted 19 lines
net/mptcp/pm_netlink.c +2
-3@@ -1951,61 +1951,51 @@ static int mptcp_nl_set_flags(struct net *net,return ret; } -int mptcp_pm_nl_set_flags (struct genl_info *info) +int mptcp_pm_nl_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info) { -struct mptcp_pm_addr_entry addr = { .addr = { .family =AF_UNSPEC }, };u8 changed, mask =MPTCP_PM_ADDR_FLAG_BACKUP |MPTCP_PM_ADDR_FLAG_FULLMESH ;struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet; -struct nlattr *attr;
net/mptcp/pm_netlink.c static int mptcp_nl_set_flags(struct net *net, · line 1972
Quoted 10 lines
net/mptcp/pm_netlink.c +0
-5u8 lookup_by_id =0 ;u8 bkup =0 ; -int ret; - -if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR )) -return -EINVAL ; pernet =pm_nl_get_pernet (net); - attr = info->attrs[MPTCP_PM_ATTR_ADDR ];
As I mentioned in the "use GENL_REQ_ATTR_CHECK in userspace pm" series, I think this 'attr' can be kept here -- because we still have access to 'info' -- ...
net/mptcp/pm_netlink.c static int mptcp_nl_set_flags(struct net *net, · line 1970
Quoted 10 lines
net/mptcp/pm_netlink.c +2
-6- ret =mptcp_pm_parse_entry (attr, info, false, &addr); -if (ret <0 ) -return ret; - -if (addr.addr.family ==AF_UNSPEC ) { +if (local->addr.family ==AF_UNSPEC ) { lookup_by_id =1 ; -if (!addr.addr.id) { +if (!local->addr.id) {GENL_SET_ERR_MSG (info,"missing address ID" );
... and use NL_SET_ERR_MSG_ATTR() here and below.
That way, the code around the reporting of errors would be uniformed with the rest, and that could still help userspace devs.
I can do the modifications when applying the patches of the other series and this one here.
(...)
Quoted 29 lines
net/mptcp/pm_userspace.c +4
-5@@ -564,19 +564,18 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *inforeturn err; } -int mptcp_userspace_pm_set_flags (struct genl_info *info) +int mptcp_userspace_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct genl_info *info) { -struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, };struct mptcp_addr_info rem = { .family =AF_UNSPEC , };struct mptcp_pm_addr_entry *entry; -struct nlattr *attr, *attr_rem; +struct nlattr *attr_rem;struct mptcp_sock *msk;int ret = -EINVAL ;struct sock *sk;u8 bkup =0 ; -if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR ) || -GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE )) +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE ))return ret; msk =mptcp_userspace_pm_get_sock (info);
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct genl_info *info) · line 588
Quoted 4 lines
net/mptcp/pm_userspace.c +0
-1@@ -585,12 +584,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) sk = (struct sock *)msk; - attr = info->attrs[MPTCP_PM_ATTR_ADDR ];
Same here.
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct genl_info *info) · line 590
Quoted 9 lines
net/mptcp/pm_userspace.c +1
-5- ret =mptcp_pm_parse_entry (attr, info, false, &loc); -if (ret <0 ) - goto set_flags_err; - -if (loc.addr.family ==AF_UNSPEC ) { +if (local->addr.family ==AF_UNSPEC ) {GENL_SET_ERR_MSG (info,"invalid local address family" ); ret = -EINVAL ; goto set_flags_err;
(...)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Critical: Global Timeout ❌
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/12705356024
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/10b9fefc341f
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=924040
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Hi Geliang,
Quoted 5 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v4:
- move "mptcp: userspace pmset_flagsid support" out of this set.
- only add 'local' parameter forset_flags, no 'remote'.
Thank you for the new version! It now looks good to me:
Quoted 1 line
Based-on: <[email protected]>
I have just one question on patch 7/7, linked to the one I had on the "use GENL_REQ_ATTR_CHECK in userspace pm" series. If you are OK with that, I can do the modifications while applying these two series.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerHi Matt,
Thanks for your review.
Quoted 11 lines · Matthieu Baerts
Hi Geliang,
Quoted 5 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v4:
- move "mptcp: userspace pmset_flagsid support" out of this set.
- only add 'local' parameter forset_flags, no 'remote'.Thank you for the new version! It now looks good to me:
Quoted 7 lines
Reviewed-by Matthieu Baerts (NGI0) <[email protected]>Quoted 1 line
Based-on: <[email protected]>
I have just one question on patch 7/7, linked to the one I had on the "use
GENL_REQ_ATTR_CHECKin userspace pm" series. If you are OK with that, I can do the modifications while applying these two series.
Sure. Please update these patches for me when applying them.
Thanks,
-Geliang
Quoted 3 lines
Cheers,
Matt
Matthieu Baerts
maintainerHi Geliang,
Quoted 18 lines · Geliang Tang
Hi Matt,
Thanks for your review.
Quoted 13 lines · Matthieu Baerts
Hi Geliang,
Quoted 5 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v4:
- move "mptcp: userspace pmset_flagsid support" out of this set.
- only add 'local' parameter forset_flags, no 'remote'.Thank you for the new version! It now looks good to me:
Reviewed-by Matthieu Baerts (NGI0) <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Based-on: <[email protected]>
I have just one question on patch 7/7, linked to the one I had on the "use
GENL_REQ_ATTR_CHECKin userspace pm" series. If you are OK with that, I can do the modifications while applying these two series.Sure. Please update these patches for me when applying them.
Done! Now in our tree (feat. for net-next):
New patches for t/upstream:
- d3401e36d040: mptcp: make three pm wrappers static
- ebf01bfde1e1: mptcp: drop skb parameter of get_addr
- 7852370411cf: mptcp: add id parameter for get_addr
- 8f55135854d2: mptcp: reuse sending nlmsg code in get_addr
- 8e9d415a217a: mptcp: drop skb parameter of set_flags
- 6a7efe19ce07: mptcp: change rem type of set_flags
- 7551b7b78dd7: mptcp: add local parameter for set_flags
- Results: 472c88326ee3..99ab203e6854 (export)
Tests are now in progress:
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.