mptcp: pm: increase limits, and related fixes and cleanup
Subsystems (3)
Matthieu Baerts (NGI0)
maintainercover mptcp: pm: increase limits, and related fixes and cleanup
The initial intension was to increase the limits, but some fixes were needed, then when looking at the code around, other fixes had to be added too. So now I ended up with 8 fixes (including one early exit while at it), followed by 3 patches increasing limits, 3 to validate the modifications, one small improvement in the selftests, and some renaming.
The patches with a Fixes tag are for -net, the rest for net-next.
The last patch contains multiple renaming: please tell me what you think before I start splitting in smaller commits.
---
Matthieu Baerts (NGI0) (16):
mptcp: pm: resched blocked ADD_ADDR quicker
mptcp: pm: allow retransmitting ADD_ADDR with ID 0
mptcp: pm: retrans ADD_ADDR: free sk if last
mptcp: pm: retrans ADD_ADDR: always decrease sk refcount
mptcp: pm: retrans ADD_ADDR: skip inactive subflows
mptcp: pm: retrans ADD_ADDR: return early if no retrans
mptcp: pm: prio: skip closed subflows
selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl
mptcp: pm: in-kernel: explicitly limit batches to array size
mptcp: pm: in-kernel: increase all limits to 64
mptcp: pm: in-kernel: increase endpoints limit
selftests: mptcp: join: allow changing ifaces nr per test
selftests: mptcp: join: validate 8x8 subflows
selftests: mptcp: pm: validate new limits
selftests: mptcp: pm: use simpler send/recv forms
mptcp: pm: clearer ADD_ADDR related helpers names
net/mptcp/options.c | 2 +- net/mptcp/pm.c | 165 +++++++++++++----------- net/mptcp/pm_kernel.c | 55 ++++---- net/mptcp/pm_userspace.c | 4 +- net/mptcp/protocol.h | 17 +-- net/mptcp/subflow.c | 4 +- tools/testing/selftests/net/mptcp/mptcp_join.sh | 33 ++++- tools/testing/selftests/net/mptcp/pm_netlink.sh | 62 +++++---- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 7 +- 9 files changed, 205 insertions(+), 144 deletions(-)
---
base-commit: 7fe1c6148c0a11ed9a1fcfaf70cf380cf890c1bf
change-id: 20260403-mptcp-inc-limits-ce9811024066
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH 1/16 mptcp: pm: resched blocked ADD_ADDR quicker
When an ADD_ADDR needs to be retransmitted and another one has already been prepared -- e.g. multiple ADD_ADDRs have been sent in a row and need to be retransmitted later -- this additional retransmission will need to wait.
In this case, the timer was reset to TCP_RTO_MAX / 8, which is ~15 seconds. This delay is unnecessary long: it should just be rescheduled at the next opportunity, e.g. after the retransmission timeout.
Without this modification, some issues can be seen from time to time in the selftests when multiple ADD_ADDRs are sent, and the host takes time to process them, e.g. the "signal addresses, ADD_ADDR timeout" MPTCP Join selftest, especially with a debug kernel config.
Note that on older kernels, 'timeout' is not available. It should be enough to replace it by one second (HZ).
--- net/mptcp/pm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/mptcp/pm.c +5 -5
@@ -340,15 +340,15 @@ static void mptcp_pm_add_timer(struct timer_list *timer)if (!entry->addr.id)return ; -if (mptcp_pm_should_add_signal_addr (msk)) { -sk_reset_timer (sk, timer, jiffies +TCP_RTO_MAX /8 ); - goto out; - } - timeout =mptcp_adjust_add_addr_timeout (msk);if (!timeout) goto out; +if (mptcp_pm_should_add_signal_addr (msk)) { +sk_reset_timer (sk, timer, jiffies + timeout); + goto out; + } +spin_lock_bh (&msk->pm.lock);if (!mptcp_pm_should_add_signal_addr (msk)) {
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 2/16 mptcp: pm: allow retransmitting ADD_ADDR with ID 0
In reply to Matthieu Baerts (NGI0)ADD_ADDR can be sent for the ID 0, which corresponds to the local address and port linked to the initial subflow.
Indeed, this address could be removed, and re-added later on, e.g. what is done in the "delete re-add signal" MPTCP Join selftests. So no reason to ignore it.
--- net/mptcp/pm.c | 3 --- 1 file changed, 3 deletions(-)
net/mptcp/pm.c +0 -3
@@ -337,9 +337,6 @@ static void mptcp_pm_add_timer(struct timer_list *timer)if (inet_sk_state_load (sk) ==TCP_CLOSE )return ; -if (!entry->addr.id) -return ; - timeout =mptcp_adjust_add_addr_timeout (msk);if (!timeout) goto out;
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 3/16 mptcp: pm: retrans ADD_ADDR: free sk if last
In reply to Matthieu Baerts (NGI0)When an ADD_ADDR is retransmitted, the sk is held in sk_reset_timer(), and released at the end.
If at that moment, it was the last reference being held, the sk would not be freed. sock_put() should then be called instead of __sock_put().
--- net/mptcp/pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm.c +1 -1
@@ -365,7 +365,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)mptcp_pm_subflow_established (msk); out: -__sock_put (sk); +sock_put (sk); } struct mptcp_pm_add_entry *
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 4/16 mptcp: pm: retrans ADD_ADDR: always decrease sk refcount
In reply to Matthieu Baerts (NGI0)When an ADD_ADDR is retransmitted, the sk is held in sk_reset_timer(). It should then be released in all cases at the end.
Some (unlikely) checks were returning directly instead of calling sock_put() to decrease the refcount. Jump to the 'out' label to fix this potential leak.
While at it, regroup the conditions, and explicitly mark them as "unlikely".
--- net/mptcp/pm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/mptcp/pm.c +2 -5
@@ -331,11 +331,8 @@ static void mptcp_pm_add_timer(struct timer_list *timer)pr_debug ("msk=%p\n" , msk); -if (!msk) -return ; - -if (inet_sk_state_load (sk) ==TCP_CLOSE ) -return ; +if (unlikely (!msk ||inet_sk_state_load (sk) ==TCP_CLOSE )) + goto out; timeout =mptcp_adjust_add_addr_timeout (msk);if (!timeout)
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 5/16 mptcp: pm: retrans ADD_ADDR: skip inactive subflows
In reply to Matthieu Baerts (NGI0)When looking at the maximum RTO amongst the subflows, inactive subflows were taken into account: that includes stale ones, and the initial one if it has been already been closed.
Unusable subflows are now simply skipped. Stale ones are used as an
alternative: if there are only stale ones, to take their maximum RTO and avoid to eventually fallback to net.mptcp.add_addr_timeout, which is set to 2 minutes by default.
--- net/mptcp/pm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
net/mptcp/pm.c +12 -5
@@ -305,20 +305,27 @@ static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk)const struct net *net =sock_net ((struct sock *)msk);unsigned int rto =mptcp_get_add_addr_timeout (net);struct mptcp_subflow_context *subflow; -unsigned int max =0 ; +unsigned int max =0 , max_stale =0 ;mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);struct inet_connection_sock *icsk =inet_csk (ssk); -if (icsk->icsk_rto > max) +if (!__mptcp_subflow_active (subflow)) +continue ; + +if (unlikely (subflow->stale)) { +if (icsk->icsk_rto > max_stale) + max_stale = icsk->icsk_rto; + }else { max = icsk->icsk_rto; + } } -if (max && max < rto) - rto = max; +if (max) +return max < rto ? max : rto; -return rto; +return max_stale && max_stale < rto ? max_stale : rto; }static void mptcp_pm_add_timer (struct timer_list *timer)
Signature · 1 line
2.53.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 05/16] mptcp: pm: retrans ADD_ADDR: skip inactive subflows
Hello
Quoted 28 lines · On 09/04/2026 22:51, Matthieu Baerts (NGI0) wrote:
When looking at the maximum RTO amongst the subflows, inactive subflows were taken into account: that includes stale ones, and the initial one if it has been already been closed.
Unusable subflows are now simply skipped. Stale ones are used as an
alternative: if there are only stale ones, to take their maximum RTO and avoid to eventually fallback to net.mptcp.add_addr_timeout, which is set to 2 minutes by default.Fixes 30549eebc4d8 ("mptcp: make ADD_ADDR retransmission timeout adaptive")Signed-off-by Matthieu Baerts (NGI0) <[email protected]>--- net/mptcp/pm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)net/mptcp/pm.c +1
-1@@ -305,20 +305,27 @@ static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk)const struct net *net =sock_net ((struct sock *)msk);unsigned int rto =mptcp_get_add_addr_timeout (net);struct mptcp_subflow_context *subflow; -unsigned int max =0 ; +unsigned int max =0 , max_stale =0 ;mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);
net/mptcp/pm.c static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk) · line 320
Quoted 10 lines
net/mptcp/pm.c +7
-1struct inet_connection_sock *icsk =inet_csk (ssk); -if (icsk->icsk_rto > max) +if (!__mptcp_subflow_active (subflow)) +continue ; + +if (unlikely (subflow->stale)) { +if (icsk->icsk_rto > max_stale) + max_stale = icsk->icsk_rto; + }else {
I accidentally removed the condition here, it should be:
} else if (icsk->icsk_rto > max) {Quoted 5 lines
net/mptcp/pm.c +1
-0max = icsk->icsk_rto; + } }
net/mptcp/pm.c static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk) · line 331
Quoted 10 lines
net/mptcp/pm.c +3
-3-if (max && max < rto) - rto = max; +if (max) +return max < rto ? max : rto; -return rto; +return max_stale && max_stale < rto ? max_stale : rto; }static void mptcp_pm_add_timer (struct timer_list *timer)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts (NGI0)
maintainerPATCH 6/16 mptcp: pm: retrans ADD_ADDR: return early if no retrans
In reply to Matthieu Baerts (NGI0)No need to iterate over all subflows if there is no retransmission needed.
Exit early in this case then.
--- net/mptcp/pm.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/pm.c +3 -0
@@ -307,6 +307,9 @@ static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk)struct mptcp_subflow_context *subflow;unsigned int max =0 , max_stale =0 ; +if (!rto) +return 0 ; +mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);struct inet_connection_sock *icsk =inet_csk (ssk);
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 7/16 mptcp: pm: prio: skip closed subflows
In reply to Matthieu Baerts (NGI0)When sending an MP_PRIO, closed subflows needs to be skipped.
This fixes the case where the initial subflow got closed, re-opened later, then an MP_PRIO is needed for the same local address.
--- net/mptcp/pm.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/pm.c +3 -0
@@ -283,6 +283,9 @@ int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,struct sock *ssk =mptcp_subflow_tcp_sock (subflow);struct mptcp_addr_info local, remote; +if (!__mptcp_subflow_active (subflow)) +continue ; +mptcp_local_address ((struct sock_common *)ssk, &local);if (!mptcp_addresses_equal (&local, addr, addr->port))continue ;
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 8/16 selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl
In reply to Matthieu Baerts (NGI0)When pm_netlink.sh is executed with '-i', 'ip mptcp' is used instead of 'pm_nl_ctl'. IPRoute2 doesn't support the 'unknown' flag, which has only been added to 'pm_nl_ctl' for this specific check: to ensure that the kernel ignores such unsupported flag.
No reason to add this flag to 'ip mptcp'. Then, this check should be skipped when 'ip mptcp' is used.
--- tools/testing/selftests/net/mptcp/pm_netlink.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +7 -3
@@ -192,9 +192,13 @@ check "show_endpoints" \ flush_endpoint check "show_endpoints" "" "flush addrs" -add_endpoint 10.0.1.1 flags unknown -check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" "ignore unknown flags" -flush_endpoint +# "unknown" flag is only supported by pm_nl_ctl +if ! mptcp_lib_is_ip_mptcp; then + add_endpoint 10.0.1.1 flags unknown + check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" \ + "ignore unknown flags" + flush_endpoint +fi set_limits 9 1 2>/dev/null check "get_limits" "${default_limits}" "rcv addrs above hard limit"
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 9/16 mptcp: pm: in-kernel: explicitly limit batches to array size
In reply to Matthieu Baerts (NGI0)The in-kernel PM can create subflows in reply to ADD_ADDR by batch of maximum 8 subflows for the moment. Same when adding new "subflow" endpoints with the fullmesh flag. This limit is linked to the arrays used during these steps.
There was no explicit limit to the arrays size (8), because the limit of extra subflows is the same (8). It seems safer to use an explicit limit, but also these two sizes are going to be different in the next commit.
--- net/mptcp/pm_kernel.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
net/mptcp/pm_kernel.c +21 -11
@@ -201,7 +201,8 @@ fill_remote_addr(struct mptcp_sock *msk, struct mptcp_addr_info *local,static unsigned int fill_remote_addresses_fullmesh (struct mptcp_sock *msk,struct mptcp_addr_info *local, -struct mptcp_addr_info *addrs) +struct mptcp_addr_info *addrs, +int addrs_size) {u8 limit_extra_subflows =mptcp_pm_get_limit_extra_subflows (msk);bool deny_id0 =READ_ONCE (msk->pm.remote_deny_join_id0);
@@ -236,7 +237,8 @@ fill_remote_addresses_fullmesh(struct mptcp_sock *msk, msk->pm.extra_subflows++; i++; -if (msk->pm.extra_subflows >= limit_extra_subflows) +if (msk->pm.extra_subflows >= limit_extra_subflows || + i == addrs_size)break ; }
@@ -248,7 +250,8 @@ fill_remote_addresses_fullmesh(struct mptcp_sock *msk,*/ static unsigned int fill_remote_addresses_vec (struct mptcp_sock *msk,struct mptcp_addr_info *local, -bool fullmesh,struct mptcp_addr_info *addrs) +bool fullmesh,struct mptcp_addr_info *addrs, +int addrs_size) {/* Non-fullmesh: fill in the single entry corresponding to the primary * MPC subflow remote address, and return 1, corresponding to 1 entry.
@@ -257,7 +260,7 @@ fill_remote_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *local,return fill_remote_addr (msk, local, addrs);/* Fullmesh endpoint: fill all possible remote addresses */ -return fill_remote_addresses_fullmesh (msk, local, addrs); +return fill_remote_addresses_fullmesh (msk, local, addrs, addrs_size); } static struct mptcp_pm_addr_entry *
@@ -407,7 +410,8 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)else /* local_addr_used is not decr for ID 0 */ msk->pm.local_addr_used++; - nr =fill_remote_addresses_vec (msk, &local.addr, fullmesh, addrs); + nr =fill_remote_addresses_vec (msk, &local.addr, fullmesh, + addrs,ARRAY_SIZE (addrs));if (nr ==0 )continue ;
@@ -444,6 +448,7 @@ static unsigned int fill_local_addresses_vec_fullmesh(struct mptcp_sock *msk, struct mptcp_addr_info *remote, struct mptcp_pm_local *locals, + int locals_size, bool c_flag_case) { u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk);
@@ -485,7 +490,8 @@ fill_local_addresses_vec_fullmesh(struct mptcp_sock *msk, msk->pm.extra_subflows++; i++; -if (msk->pm.extra_subflows >= limit_extra_subflows) +if (msk->pm.extra_subflows >= limit_extra_subflows || + i == locals_size)break ; }rcu_read_unlock ();
@@ -556,7 +562,8 @@ fill_local_laminar_endp(struct mptcp_sock *msk, struct mptcp_addr_info *remote,static unsigned int fill_local_addresses_vec_c_flag (struct mptcp_sock *msk,struct mptcp_addr_info *remote, -struct mptcp_pm_local *locals) +struct mptcp_pm_local *locals, +int locals_size) {u8 limit_extra_subflows =mptcp_pm_get_limit_extra_subflows (msk);struct pm_nl_pernet *pernet =pm_nl_get_pernet_from_msk (msk);
@@ -583,7 +590,8 @@ fill_local_addresses_vec_c_flag(struct mptcp_sock *msk, msk->pm.extra_subflows++; i++; -if (msk->pm.extra_subflows >= limit_extra_subflows) +if (msk->pm.extra_subflows >= limit_extra_subflows || + i == locals_size)break ; }
@@ -617,13 +625,14 @@ fill_local_address_any(struct mptcp_sock *msk, struct mptcp_addr_info *remote,*/ static unsigned int fill_local_addresses_vec (struct mptcp_sock *msk,struct mptcp_addr_info *remote, -struct mptcp_pm_local *locals) +struct mptcp_pm_local *locals,int locals_size) {bool c_flag_case = remote->id &&mptcp_pm_add_addr_c_flag_case (msk);/* If there is at least one MPTCP endpoint with a fullmesh flag */ if (mptcp_pm_get_endp_fullmesh_max (msk))return fill_local_addresses_vec_fullmesh (msk, remote, locals, + locals_size, c_flag_case);/* If there is at least one MPTCP endpoint with a laminar flag */
@@ -634,7 +643,8 @@ fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote,* limits are used -- accepting no ADD_ADDR -- and use subflow endpoints */ if (c_flag_case) -return fill_local_addresses_vec_c_flag (msk, remote, locals); +return fill_local_addresses_vec_c_flag (msk, remote, locals, + locals_size);/* No special case: fill in the single 'IPADDRANY' local address */ return fill_local_address_any (msk, remote, &locals[0 ]);
@@ -669,7 +679,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)/* connect to the specified remote address, using whatever * local address the routing configuration will pick. */ - nr =fill_local_addresses_vec (msk, &remote, locals); + nr =fill_local_addresses_vec (msk, &remote, locals,ARRAY_SIZE (locals));if (nr ==0 )return ;
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 10/16 mptcp: pm: in-kernel: increase all limits to 64
In reply to Matthieu Baerts (NGI0)This means switching the maximum from 8 to 64 for the number of subflows and accepted ADD_ADDR.
The previous limit of 8 subflows makes sense in most cases. Using more subflows will very likely *not* improve the situation, and could even decrease the performances. But there are no technical limitations nor performance impact to raise this limit, so let's do it: this will allow people with very specific use-cases, and researchers to easily create more subflows, and measure the performance impact by themselves.
The theoretical limit is 255 -- the ID is written in a u8 on the wire -- but 64 is more than enough. With so many subflows, it will be costly to iterate over all of them when operations are done in bottom half.
Note that the in-kernel PM will continue to create subflows in reply to ADD_ADDR by batch of maximum 8 subflows. Same when adding new "subflow" endpoints with the fullmesh flag. Increasing those batch limits would have a memory impact.
--- net/mptcp/pm_kernel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/mptcp/pm_kernel.c +3 -2
@@ -30,6 +30,7 @@ struct pm_nl_pernet { };#define MPTCP_PM_ADDR_MAX 8 +#define MPTCP_PM_SUBFLOWS_MAX 64static struct pm_nl_pernet *pm_nl_get_pernet (const struct net *net) {
@@ -1378,10 +1379,10 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit)return 0 ; *limit =nla_get_u32 (attr); -if (*limit >MPTCP_PM_ADDR_MAX ) { +if (*limit >MPTCP_PM_SUBFLOWS_MAX ) {NL_SET_ERR_MSG_ATTR_FMT (info->extack, attr,"limit greater than maximum (%u)" , -MPTCP_PM_ADDR_MAX ); +MPTCP_PM_SUBFLOWS_MAX );return -EINVAL ; }return 0 ;
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 11/16 mptcp: pm: in-kernel: increase endpoints limit
In reply to Matthieu Baerts (NGI0)The endpoints are managed in a list which was limited to 8 entries.
This limit can be too small in some cases: by having the same limit as the number of subflows, it might not allow creating all expected subflows when having a mix of v4 and v6 addresses that can all use MPTCP on v4/v6 only networks.
While increasing the limit above the new subflows one, why not using the technical limit: 254. Indeed, the endpoint will each have an ID that will be used on the wire, limited to u8, and the ID 0 is reserved to the initial subflow.
--- net/mptcp/pm_kernel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm_kernel.c +1 -1
@@ -743,7 +743,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,*/ if (pernet->next_id ==MPTCP_PM_MAX_ADDR_ID ) pernet->next_id =1 ; -if (pernet->endpoints >=MPTCP_PM_ADDR_MAX ) { +if (pernet->endpoints ==MPTCP_PM_MAX_ADDR_ID ) { ret = -ERANGE ; goto out; }
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 12/16 selftests: mptcp: join: allow changing ifaces nr per test
In reply to Matthieu Baerts (NGI0)By default, 4 network interfaces are created per subtest in a dedicated net namespace. Each netns has a dedicated pair of v4 and v6 addresses. Future tests will need more.
Simply always creating more network interfaces per test will increase the execution time for all other tests, for no other benefits. So now it is possible to change this number only when needed, by setting ifaces_nr when calling 'reset', e.g.
ifaces_nr=8 reset "Subtest title"
Note that it might also be interesting to decrease the default value to 2 to reduce the setup time, especially when a debug kernel config is being used.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +3 -2
@@ -63,6 +63,7 @@ unset fastclose unset fullmesh unset speed unset bind_addr +unset ifaces_nr unset join_syn_rej unset join_csum_ns1 unset join_csum_ns2
@@ -146,7 +147,7 @@ init_partial() # ns1eth4 ns2eth4 local i - for i in $(seq 1 4); do + for i in $(seq 1 "${ifaces_nr:-4}"); do ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2" ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
@@ -165,7 +166,7 @@ init_partial() init_shapers() { local i - for i in $(seq 1 4); do + for i in $(seq 1 "${ifaces_nr:-4}"); do tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1ms tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1ms done
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 13/16 selftests: mptcp: join: validate 8x8 subflows
In reply to Matthieu Baerts (NGI0)The limits have been recently increased, it is required to validate that having 64 subflows is allowed.
Here, both the client and the server have 8 network interfaces. The server has 8 endpoints marked as 'signal' to announce all its v4 addresses. The client also has 8 endpoints, but marked as 'subflow' and 'fullmesh' in order to create 8 subflows to each address announced by the server. This means 63 additional subflows will be created after the initial one.
If it is not possible to increase the limits to 64, it means an older kernel version is being used, and the test is skipped.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +28 -0
@@ -513,6 +513,19 @@ reset_with_tcp_filter() fi } +# For kernel supporting limits above 8 +# $1: title ; $2,4: addrs limit ns1,2 ; $3,5: subflows limit ns1,2 +reset_with_high_limits() +{ + reset "${1}" || return 1 + + if ! pm_nl_set_limits "${ns1}" "${2}" "${3}" 2>/dev/null || + ! pm_nl_set_limits "${ns2}" "${4}" "${5}" 2>/dev/null; then + mark_as_skipped "unable to set the limits to ${*:2}" + return 1 + fi +} + # $1: err msg fail_test() {
@@ -3670,6 +3683,21 @@ fullmesh_tests() chk_prio_nr 0 1 1 0 chk_rm_nr 0 1 fi + + # fullmesh in 8x8 to create 63 additional subflows + if ifaces_nr=8 reset_with_high_limits "fullmesh 8x8" 64 64 64 64; then + # higher chance to loose ADD_ADDR: allow retransmissions + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 + local i + for i in $(seq 1 8); do + pm_nl_add_endpoint $ns2 10.0.$i.2 flags subflow,fullmesh + pm_nl_add_endpoint $ns1 10.0.$i.1 flags signal + done + speed=slow \ + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr 63 63 63 + fi + } fastclose_tests()
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 14/16 selftests: mptcp: pm: validate new limits
In reply to Matthieu Baerts (NGI0)These limits have been recently updated, from 8 to:
- 64 for the subflows and accepted add_addr
- 255 for the MPTCP endpoints
These modifications validate the new limits, but are also compatible with the previous ones, to be able to continue to validate stable kernel using the last version of the selftests. That's why new variables are now used instead of hard-coded values.
--- tools/testing/selftests/net/mptcp/pm_netlink.sh | 52 +++++++++++++++---------- 1 file changed, 31 insertions(+), 21 deletions(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +31 -21
@@ -66,6 +66,15 @@ get_limits() { fi } +get_limits_nb() { + if mptcp_lib_is_ip_mptcp; then + ip -n "${ns1}" mptcp limits | awk '{ print $2" "$4 }' + else + ip netns exec "${ns1}" ./pm_nl_ctl limits | \ + awk '{ printf "%s ", $2 }' + fi +} + format_endpoints() { mptcp_lib_pm_nl_format_endpoints "${@}" }
@@ -162,6 +171,7 @@ check "get_endpoint 2" "" "simple del addr" check "show_endpoints" \ "$(format_endpoints "1,10.0.1.1" \ "3,10.0.1.3,signal backup")" "dump addrs after del" +add_endpoint 10.0.1.2 id 2 add_endpoint 10.0.1.3 2>/dev/null check "get_endpoint 4" "" "duplicate addr"
@@ -169,25 +179,25 @@ check "get_endpoint 4" "" "duplicate addr" add_endpoint 10.0.1.4 flags signal check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment" -for i in $(seq 5 9); do - add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1 -done -check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit" -check "get_endpoint 10" "" "above hard addr limit" +read -r -a default_limits_nb <<< "$(get_limits_nb)" +# limits have been increased: from 8 to 64 for subflows/add_addr & 255 for endp +if mptcp_lib_expect_all_features || set_limits 9 9 2>/dev/null; then + max_endp=255 + max_limits=64 +else + max_endp=8 + max_limits=8 +fi +set_limits "${default_limits_nb[@]}" -del_endpoint 9 -for i in $(seq 10 255); do - add_endpoint 10.0.0.9 id "${i}" - del_endpoint "${i}" +for i in $(seq 5 ${max_endp}); do + add_endpoint "10.0.0.${i}" id "${i}" done -check "show_endpoints" \ - "$(format_endpoints "1,10.0.1.1" \ - "3,10.0.1.3,signal backup" \ - "4,10.0.1.4,signal" \ - "5,10.0.1.5,signal" \ - "6,10.0.1.6,signal" \ - "7,10.0.1.7,signal" \ - "8,10.0.1.8,signal")" "id limit" +check "get_endpoint ${max_endp}" \ + "$(format_endpoints "${max_endp},10.0.0.${max_endp}")" "id limit" + +check "add_endpoint '10.0.1.1' &>/dev/null && echo 'no error'" "" \ + "above hard addr limit" flush_endpoint check "show_endpoints" "" "flush addrs"
@@ -200,15 +210,15 @@ if ! mptcp_lib_is_ip_mptcp; then flush_endpoint fi -set_limits 9 1 2>/dev/null +set_limits $((max_limits + 1)) 1 2>/dev/null check "get_limits" "${default_limits}" "rcv addrs above hard limit" -set_limits 1 9 2>/dev/null +set_limits 1 $((max_limits + 1)) 2>/dev/null check "get_limits" "${default_limits}" "subflows above hard limit" -set_limits 8 8 +set_limits ${max_limits} ${max_limits} flush_endpoint ## to make sure it doesn't affect the limits -check "get_limits" "$(format_limits 8 8)" "set limits" +check "get_limits" "$(format_limits ${max_limits} ${max_limits})" "set limits" flush_endpoint add_endpoint 10.0.1.1
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 15/16 selftests: mptcp: pm: use simpler send/recv forms
In reply to Matthieu Baerts (NGI0)Instead of sendto() and recvfrom() which the NL address that was already provided before.
Just simpler and easier to read.
--- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/pm_nl_ctl.c +2 -5
@@ -217,8 +217,6 @@ static int capture_events(int fd, int event_group)/* do a netlink command and, if max > 0, fetch the reply ; nh's size >1024B */ static int do_nl_req (int fd,struct nlmsghdr *nh,int len,int max) { -struct sockaddr_nl nladdr = { .nl_family =AF_NETLINK }; -socklen_t addr_len;void *data = nh;int rem, ret;int err =0 ;
@@ -230,12 +228,11 @@ static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max) } nh->nlmsg_len = len; - ret =sendto (fd, data, len,0 , (void *)&nladdr,sizeof (nladdr)); + ret =send (fd, data, len,0 );if (ret != len)error (1 , errno,"send netlink: %uB != %uB\n" , ret, len); - addr_len =sizeof (nladdr); - rem = ret =recvfrom (fd, data, max,0 , (void *)&nladdr, &addr_len); + rem = ret =recv (fd, data, max,0 );if (ret <0 )error (1 , errno,"recv netlink: %uB\n" , ret);
Signature · 1 line
2.53.0
Matthieu Baerts (NGI0)
maintainerPATCH 16/16 mptcp: pm: clearer ADD_ADDR related helpers names
In reply to Matthieu Baerts (NGI0)Here is a suggestion, and if it is OK, I will split this in multiple
commits: it is not the first time the 'add' and 'anno' names to describe ADD_ADDR related functions are confusing. Eric already pointed that in [1].
I started by renaming only the internal helper names, then while at it, I tried to uniform that.
WDYT?
--- net/mptcp/options.c | 2 +- net/mptcp/pm.c | 122 ++++++++++++++++++++++++----------------------- net/mptcp/pm_kernel.c | 16 +++---- net/mptcp/pm_userspace.c | 4 +- net/mptcp/protocol.h | 17 +++---- net/mptcp/subflow.c | 4 +- 6 files changed, 84 insertions(+), 81 deletions(-)
net/mptcp/options.c +1 -1
@@ -1211,7 +1211,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_ADDADDR ); }else {mptcp_pm_add_addr_echoed (msk, &mp_opt.addr); -mptcp_pm_del_add_timer (msk, &mp_opt.addr, true); +mptcp_pm_del_add_addr_timer (msk, &mp_opt.addr, true);MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_ECHOADD ); }
net/mptcp/pm.c +62 -60
248 lines not on this page · raw message
net/mptcp/pm_kernel.c +8 -8
@@ -367,7 +367,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)/* If the alloc fails, we are on memory pressure, not worth * continuing, and trying to create subflows. */ -if (!mptcp_pm_alloc_anno_list (msk, &local.addr)) +if (!mptcp_pm_alloc_add_addr_list (msk, &local.addr))return ;__clear_bit (local.addr.id, msk->pm.id_avail_bitmap);
@@ -1051,16 +1051,16 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret; } -static void mptcp_pm_remove_anno_addr (struct mptcp_sock *msk, -const struct mptcp_addr_info *addr, -bool force) +static void mptcp_pm_remove_add_addr (struct mptcp_sock *msk, +const struct mptcp_addr_info *addr, +bool force) {struct mptcp_rm_list list = { .nr =0 };bool announced; list.ids[list.nr++] =mptcp_endp_get_local_id (msk, addr); - announced =mptcp_remove_anno_list_by_saddr (msk, addr); + announced =mptcp_remove_add_addr_by_saddr (msk, addr);if (announced || force) {spin_lock_bh (&msk->pm.lock);if (announced)
@@ -1097,8 +1097,8 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net,lock_sock (sk); remove_subflow =mptcp_lookup_subflow_by_saddr (&msk->conn_list, addr); -mptcp_pm_remove_anno_addr (msk, addr, remove_subflow && - !(entry->flags &MPTCP_PM_ADDR_FLAG_IMPLICIT )); +mptcp_pm_remove_add_addr (msk, addr, remove_subflow && + !(entry->flags &MPTCP_PM_ADDR_FLAG_IMPLICIT )); list.ids[0 ] =mptcp_endp_get_local_id (msk, addr);
@@ -1232,7 +1232,7 @@ static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk, slist.ids[slist.nr++] =mptcp_endp_get_local_id (msk, &entry->addr);if (alist.nr <MPTCP_RM_IDS_MAX && -mptcp_remove_anno_list_by_saddr (msk, &entry->addr)) +mptcp_remove_add_addr_by_saddr (msk, &entry->addr)) alist.ids[alist.nr++] =mptcp_endp_get_local_id (msk, &entry->addr); }
net/mptcp/pm_userspace.c +2 -2
@@ -228,7 +228,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)lock_sock (sk);spin_lock_bh (&msk->pm.lock); -if (mptcp_pm_alloc_anno_list (msk, &addr_val.addr)) { +if (mptcp_pm_alloc_add_addr_list (msk, &addr_val.addr)) { msk->pm.add_addr_signaled++;mptcp_pm_announce_addr (msk, &addr_val.addr, false);mptcp_pm_addr_send_ack (msk);
@@ -281,7 +281,7 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,int anno_nr =0 ;/* only delete if either announced or matching a subflow */ -if (mptcp_remove_anno_list_by_saddr (msk, &entry->addr)) +if (mptcp_remove_add_addr_by_saddr (msk, &entry->addr)) anno_nr++;else if (!mptcp_lookup_subflow_by_saddr (&msk->conn_list, &entry->addr))return ;
net/mptcp/protocol.h +9 -8
@@ -1132,16 +1132,17 @@ int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,struct mptcp_addr_info *addr, struct mptcp_addr_info *rem, u8 bkup); -bool mptcp_pm_alloc_anno_list (struct mptcp_sock *msk, -const struct mptcp_addr_info *addr); -bool mptcp_pm_sport_in_anno_list (struct mptcp_sock *msk,const struct sock *sk); -struct mptcp_pm_add_entry * -mptcp_pm_del_add_timer (struct mptcp_sock *msk, -const struct mptcp_addr_info *addr,bool check_id); +bool mptcp_pm_alloc_add_addr_list (struct mptcp_sock *msk, +const struct mptcp_addr_info *addr); +bool mptcp_pm_sport_in_add_addr_list (struct mptcp_sock *msk, +const struct sock *sk); +struct mptcp_pm_add_addr * +mptcp_pm_del_add_addr_timer (struct mptcp_sock *msk, +const struct mptcp_addr_info *addr,bool check_id);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); +bool mptcp_remove_add_addr_by_saddr (struct mptcp_sock *msk, +const struct mptcp_addr_info *addr);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,
net/mptcp/subflow.c +2 -2
@@ -235,7 +235,7 @@ static int subflow_check_req(struct request_sock *req,pr_debug ("syn inet_sport=%d %d\n" ,ntohs (inet_sk (sk_listener)->inet_sport),ntohs (inet_sk ((struct sock *)subflow_req->msk)->inet_sport)); -if (!mptcp_pm_sport_in_anno_list (subflow_req->msk, sk_listener)) { +if (!mptcp_pm_sport_in_add_addr_list (subflow_req->msk, sk_listener)) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_MISMATCHPORTSYNRX );subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT );return -EPERM ;
@@ -926,7 +926,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,pr_debug ("ack inet_sport=%d %d\n" ,ntohs (inet_sk (sk)->inet_sport),ntohs (inet_sk ((struct sock *)owner)->inet_sport)); -if (!mptcp_pm_sport_in_anno_list (owner, sk)) { +if (!mptcp_pm_sport_in_add_addr_list (owner, sk)) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_MISMATCHPORTACKRX );subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); goto dispose_child;
Signature · 1 line
2.53.0
Hi Matthieu,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_mp_capable ⚠️
- KVM Validation: debug (only selftest_mptcp_join): 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/24213856022
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/66c601bbbc1a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1079423
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)