BPF path manager, part 3
Subsystems (2)
Geliang Tang
reviewerv5 cover BPF path manager, part 3
From: Geliang Tang <[email protected]>
v5:
- drop "change is_backup interfaces as get_flags"
- move "add struct mptcp_pm_addr_id_bitmap" and "hold msk lock before
removing id 0 address" out of this set.
- a new patch "use ipv6_addr_equal in addresses_equal"
- patch 4, drop inet6_sk() in mptcp_event_add_subflow() and mptcp_event_pm_listener() too.
v4:
- add a new patch, "add a build check for userspace_pm_dump_addr" as Matt suggested.
- patch 4, fix a warning here reported by CI:
WARNING: line length of 84 exceeds 80 columns
#27: FILE: net/mptcp/pm_userspace.c:468:
v3:
- drop "mptcp: update address type of get_local_id".
v2:
- a new patch "hold msk lock before removing id 0 address"
Drop the patch "mptcp: reuse sending nlmsg code in dump_addr", add a new helper mptcp_pm_genl_fill_addr() to save the duplicated code.
Define struct mptcp_pm_addr_id_bitmap in protocol.h, instead of defining mptcp_pm_addr_id_bitmap_t in include/net/mptcp.h, since get_addr() and dump_addr() interfaces of BPF userspace pm is dropped as Matt suggested.
Geliang Tang (5):
mptcp: add a build check for userspace_pm_dump_addr
mptcp: add mptcp_pm_genl_fill_addr helper
mptcp: drop match in userspace_pm_append_new_local_addr
mptcp: drop inet6_sk after inet_sk
mptcp: use ipv6_addr_equal in addresses_equal
net/mptcp/pm.c | 21 +++++++++++++++++++++ net/mptcp/pm_netlink.c | 22 ++++------------------ net/mptcp/pm_userspace.c | 29 +++++++---------------------- net/mptcp/protocol.h | 3 +++ 4 files changed, 35 insertions(+), 40 deletions(-)
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH v5 1/5 mptcp: add a build check for userspace_pm_dump_addr
From: Geliang Tang <[email protected]>
This patch adds a build check for mptcp_userspace_pm_dump_addr() to make sure there is enough space in 'cb->ctx' to store an address id bitmap.
--- net/mptcp/pm_userspace.c | 2 ++ 1 file changed, 2 insertions(+)
net/mptcp/pm_userspace.c +2 -0
@@ -643,6 +643,8 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,struct sock *sk;void *hdr; +BUILD_BUG_ON (sizeof (struct id_bitmap ) >sizeof (cb->ctx)); + bitmap = (struct id_bitmap *)cb->ctx; msk =mptcp_userspace_pm_get_sock (info);
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH v5 2/5 mptcp: add mptcp_pm_genl_fill_addr helper
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
To save some redundant code in dump_addr() interfaces of both the netlink PM and userspace PM, the code that calls netlink message helpers (genlmsg_put/cancel/end) and mptcp_nl_fill_addr() is wrapped into a new helper mptcp_pm_genl_fill_addr().
--- net/mptcp/pm.c | 21 +++++++++++++++++++++ net/mptcp/pm_netlink.c | 12 +----------- net/mptcp/pm_userspace.c | 12 +----------- net/mptcp/protocol.h | 3 +++ 4 files changed, 26 insertions(+), 22 deletions(-)
net/mptcp/pm.c +21 -0
@@ -489,6 +489,27 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret; } +int mptcp_pm_genl_fill_addr (struct sk_buff *msg, +struct netlink_callback *cb, +struct mptcp_pm_addr_entry *entry) +{ +void *hdr; + + 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) +return -EINVAL ; + +if (mptcp_nl_fill_addr (msg, entry) <0 ) { +genlmsg_cancel (msg, hdr); +return -EINVAL ; + } + +genlmsg_end (msg, hdr); +return 0 ; +} +static int mptcp_pm_dump_addr (struct sk_buff *msg,struct netlink_callback *cb) {const struct genl_info *info =genl_info_dump (cb);
net/mptcp/pm_netlink.c +1 -11
@@ -1798,7 +1798,6 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,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);
@@ -1813,19 +1812,10 @@ int mptcp_pm_nl_dump_addr(struct sk_buff *msg,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) +if (mptcp_pm_genl_fill_addr (msg, cb, entry) <0 )break ; -if (mptcp_nl_fill_addr (msg, entry) <0 ) { -genlmsg_cancel (msg, hdr); -break ; - } - id = entry->addr.id; -genlmsg_end (msg, hdr); } }rcu_read_unlock ();
net/mptcp/pm_userspace.c +1 -11
@@ -641,7 +641,6 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,struct mptcp_sock *msk;int ret = -EINVAL ;struct sock *sk; -void *hdr;BUILD_BUG_ON (sizeof (struct id_bitmap ) >sizeof (cb->ctx));
@@ -659,19 +658,10 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,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) +if (mptcp_pm_genl_fill_addr (msg, cb, entry) <0 )break ; -if (mptcp_nl_fill_addr (msg, entry) <0 ) { -genlmsg_cancel (msg, hdr); -break ; - } -__set_bit (entry->addr.id, bitmap->map); -genlmsg_end (msg, hdr); }spin_unlock_bh (&msk->pm.lock);release_sock (sk);
net/mptcp/protocol.h +3 -0
@@ -1061,6 +1061,9 @@ void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subf struct request_sock *req);int mptcp_nl_fill_addr (struct sk_buff *skb,struct mptcp_pm_addr_entry *entry); +int mptcp_pm_genl_fill_addr (struct sk_buff *msg, +struct netlink_callback *cb, +struct mptcp_pm_addr_entry *entry);static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) {
Signature · 1 line
2.43.0
Re: [PATCH mptcp-next v5 2/5] mptcp: add mptcp_pm_genl_fill_addr helper
Hi Geliang,
Quoted 6 lines · Geliang Tang
From: Geliang Tang <[email protected]>
To save some redundant code in
dump_addr()interfaces of both the netlink PM and userspace PM, the code that calls netlink message helpers (genlmsg_put/cancel/end) andmptcp_nl_fill_addr()is wrapped into a new helpermptcp_pm_genl_fill_addr().
Thank you for also having added '< 0' when looking for errors from mptcp_pm_genl_fill_addr().
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v5 3/5 mptcp: drop match in userspace_pm_append_new_local_addr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The variable 'match' in mptcp_userspace_pm_append_new_local_addr() is a redundant one, and this patch drops it.
No need to define 'match' as 'struct mptcp_pm_addr_entry *' type. In this function, it's only used to check whether it's NULL. It can be defined as a Boolean one.
Also other variables 'addr_match' and 'id_match' make 'match' a redundant one, which can be replaced by directly checking 'addr_match && id_match'.
--- net/mptcp/pm_userspace.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
net/mptcp/pm_userspace.c +3 -8
@@ -48,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, 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;struct mptcp_pm_addr_entry *e;bool addr_match = false;
@@ -63,16 +62,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,if (addr_match && entry->addr.id ==0 && needs_id) entry->addr.id = e->addr.id; id_match = (e->addr.id == entry->addr.id); -if (addr_match && id_match) { - match = e; +if (addr_match || id_match)break ; - }else if (addr_match || id_match) { -break ; - }__set_bit (e->addr.id, id_bitmap); } -if (!match && !addr_match && !id_match) { +if (!addr_match && !id_match) {/* Memory for the entry is allocated from the * sock option buffer. */
@@ -90,7 +85,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,list_add_tail_rcu (&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret = e->addr.id; - }else if (match) { + }else if (addr_match && id_match) { ret = entry->addr.id; }
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH v5 4/5 mptcp: drop inet6_sk after inet_sk
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
In mptcp_event_add_subflow(), mptcp_event_pm_listener() and mptcp_nl_find_ssk(), 'issk' has already been got through inet_sk(). No need to use inet6_sk() to get 'ipv6_pinfo' again, just use issk->pinet6 instead. This patch also drops these 'ipv6_pinfo' variables.
---
v2:
- drop inet6_sk() in mptcp_event_add_subflow() and mptcp_event_pm_listener() too.
--- net/mptcp/pm_netlink.c | 8 ++------ net/mptcp/pm_userspace.c | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-)
net/mptcp/pm_netlink.c +2 -6
@@ -2022,9 +2022,7 @@ static int mptcp_event_add_subflow(struct sk_buff *skb, const struct sock *ssk)break ;#if IS_ENABLED (CONFIG_MPTCP_IPV6 )case AF_INET6 : { -const struct ipv6_pinfo *np =inet6_sk (ssk); - -if (nla_put_in6_addr (skb,MPTCP_ATTR_SADDR6 , &np->saddr)) +if (nla_put_in6_addr (skb,MPTCP_ATTR_SADDR6 , &issk->pinet6->saddr))return -EMSGSIZE ;if (nla_put_in6_addr (skb,MPTCP_ATTR_DADDR6 , &ssk->sk_v6_daddr))return -EMSGSIZE ;
@@ -2251,9 +2249,7 @@ void mptcp_event_pm_listener(const struct sock *ssk,break ;#if IS_ENABLED (CONFIG_MPTCP_IPV6 )case AF_INET6 : { -const struct ipv6_pinfo *np =inet6_sk (ssk); - -if (nla_put_in6_addr (skb,MPTCP_ATTR_SADDR6 , &np->saddr)) +if (nla_put_in6_addr (skb,MPTCP_ATTR_SADDR6 , &issk->pinet6->saddr)) goto nla_put_failure;break ; }
net/mptcp/pm_userspace.c +1 -3
@@ -460,9 +460,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,break ;#if IS_ENABLED (CONFIG_MPTCP_IPV6 )case AF_INET6 : { -const struct ipv6_pinfo *pinfo =inet6_sk (ssk); - -if (!ipv6_addr_equal (&local->addr6, &pinfo->saddr) || +if (!ipv6_addr_equal (&local->addr6, &issk->pinet6->saddr) || !ipv6_addr_equal (&remote->addr6, &ssk->sk_v6_daddr))continue ;break ;
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v5 4/5] mptcp: drop inet6_sk after inet_sk
Hi Geliang,
Quoted 8 lines · Geliang Tang
From: Geliang Tang <[email protected]>
In
mptcp_event_add_subflow(),mptcp_event_pm_listener()andmptcp_nl_find_ssk(), 'issk' has already been got throughinet_sk(). No need to useinet6_sk()to get 'ipv6_pinfo' again, just useissk->pinet6instead. This patch also drops these 'ipv6_pinfo' variables.
Quoted 6 lines
Reviewed-by Matthieu Baerts (NGI0) <[email protected]>Signed-off-by Geliang Tang <[email protected]>---
v2:
- dropinet6_sk()inmptcp_event_add_subflow()andmptcp_event_pm_listener()too.
Thank you for this comment, that's helpful!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v5 5/5 mptcp: use ipv6_addr_equal in addresses_equal
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Use ipv6_addr_equal() to check whether two IPv6 addresses are equal in mptcp_addresses_equal() is more appropriate than using ipv6_addr_cmp().
--- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm_netlink.c +1 -1
@@ -64,7 +64,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a, addr_equals = a->addr.s_addr == b->addr.s_addr;#if IS_ENABLED (CONFIG_MPTCP_IPV6 ) else - addr_equals = !ipv6_addr_cmp(&a->addr6, &b->addr6); + addr_equals = ipv6_addr_equal(&a->addr6, &b->addr6); }else if (a->family ==AF_INET ) {if (ipv6_addr_v4mapped (&b->addr6)) addr_equals = a->addr.s_addr == b->addr6.s6_addr32[3 ];
Signature · 1 line
2.43.0
Re: [PATCH mptcp-next v5 5/5] mptcp: use ipv6_addr_equal in addresses_equal
Hi Geliang,
Quoted 15 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Use
ipv6_addr_equal()to check whether two IPv6 addresses are equal inmptcp_addresses_equal()is more appropriate than usingipv6_addr_cmp().Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/mptcp/pm_netlink.c +0
-0
net/mptcp/pm_netlink.c bool mptcp_addresses_equal(const struct mptcp_addr_info *a, · line 67
Quoted 5 lines
net/mptcp/pm_netlink.c +1
-1@@ -64,7 +64,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a, addr_equals = a->addr.s_addr == b->addr.s_addr;#if IS_ENABLED (CONFIG_MPTCP_IPV6 ) else - addr_equals = !ipv6_addr_cmp (&a->addr6, &b->addr6); + addr_equals =ipv6_addr_equal (&a->addr6, &b->addr6);
Good idea, that looks more logical!
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: Success! ✅
- KVM Validation: debug: Critical: Global Timeout ❌
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs-cpuv4_mptcp 🔴
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/12945359042
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/6e73d43e9da0
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=928039
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)
Matthieu Baerts
maintainerHi Geliang,
Quoted 9 lines · Geliang Tang
From: Geliang Tang <[email protected]>
v5:
- drop "changeis_backupinterfaces asget_flags"
- move "add structmptcp_pm_addr_id_bitmap" and "hold msk lock before
removing id 0 address" out of this set.
- a new patch "useipv6_addr_equalinaddresses_equal"
- patch 4, dropinet6_sk()inmptcp_event_add_subflow()andmptcp_event_pm_listener()too.
Thank you for the new version!
Now in our tree (feat. for net-next):
New patches for t/upstream:
- 8b880bfa4362: mptcp: add a build check for userspace_pm_dump_addr
- 5c44b4a4e41f: mptcp: add mptcp_pm_genl_fill_addr helper
- f0d7ae749373: mptcp: drop match in userspace_pm_append_new_local_addr
- be35f8e33917: mptcp: drop inet6_sk after inet_sk
- 6e78ea4d3c94: mptcp: use ipv6_addr_equal in addresses_equal
- Results: e80a31769cf4..ef015705ac0b (export)
Tests are now in progress:
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.