mptcp: fix inconsistent backup usage
Subsystems (6)
Matthieu Baerts (NGI0)
maintainerv3 cover mptcp: fix inconsistent backup usage
In all the backup tests we have, the backup flag is set on one side, and the expected behaviour is to have both sides respecting this decision.
On the scheduler side, only the 'backup' field is checked, which is supposed to be set only if the other peer flagged a subflow as backup. But in various places, this flag is set when the local host flagged the subflow as backup.
One last thing that has been fixed is the backup flag in 'signal'
endpoints: it was working only when setting the backup flag while the connection was already opened. That's what the MPJ selftests were doing to check that the signal endpoint were supporting the backup flag (on purpose I guess, because the support was broken in MP_JOIN...).
The last two patches adapt the BPF selftests to mimic what is now done by the in-kernel packets scheduler.
Note that the Packetdrill tests need to be updated because the behaviour has been changed / fixed:
https://github.com/multipath-tcp/packetdrill/pull/152
---
Changes in v3:
- Small fixes in patch 1 and 5: see the individual ChangeLog
- Use a new dedicated helper in patch 6: see the individual ChangeLog
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- new patches 4 and 5.
- split patch 6 in two (code then tests) to ease the backports.
- patch 6 addresses Mat's comments, and support the ID0 case.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Matthieu Baerts (NGI0) (9):
mptcp: sched: check both directions for backup
mptcp: distinguish rcv vs sent backup flag in requests
mptcp: pm: only set request_bkup flag when sending MP_PRIO
mptcp: mib: count MPJ with backup flag
selftests: mptcp: join: validate backup in MPJ
mptcp: pm: fix backup support in signal endpoints
selftests: mptcp: join: check backup support in signal endp Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Squash to "selftests/bpf: Add bpf_burst scheduler & test"
include/trace/events/mptcp.h | 2 +- net/mptcp/mib.c | 2 + net/mptcp/mib.h | 2 + net/mptcp/options.c | 2 +- net/mptcp/pm.c | 12 ++++ net/mptcp/pm_netlink.c | 19 +++++- net/mptcp/pm_userspace.c | 18 ++++++ net/mptcp/protocol.c | 10 +-- net/mptcp/protocol.h | 4 ++ net/mptcp/subflow.c | 10 +++ tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 3 +- .../testing/selftests/bpf/progs/mptcp_bpf_burst.c | 12 ++-- tools/testing/selftests/net/mptcp/mptcp_join.sh | 72 +++++++++++++++++----- 13 files changed, 142 insertions(+), 26 deletions(-)
---
base-commit: 50d1a79f5003b88b03b37d05189ad02a84d7be49
change-id: 20240711-mptcp-backup-mpj-2f8369fad366
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts (NGI0)
maintainerPATCH v3 1/9 mptcp: sched: check both directions for backup
The 'mptcp_subflow_context' structure has two items related to the backup flags:
- 'backup': the subflow has been marked as backup by the other peer
- 'request_bkup': the backup flag has been set by the host
Before this patch, the scheduler was only looking at the 'backup' flag. That can make sense in some cases, but it looks like that's not what we wanted for the general use, because either the path-manager was setting both of them when sending an MP_PRIO, or the receiver was duplicating the 'backup' flag in the subflow request.
Note that the use of these two flags in the path-manager are going to be fixed in the next commits, but this change here is needed not to modify the behaviour.
---
Notes:
- v3:
- fix indentation of the 2nd bullet point in the commit message (Geliang)
--- include/trace/events/mptcp.h | 2 +- net/mptcp/protocol.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
include/trace/events/mptcp.h +1 -1
@@ -34,7 +34,7 @@ TRACE_EVENT(mptcp_subflow_get_send,struct sock *ssk; __entry->active =mptcp_subflow_active (subflow); - __entry->backup = subflow->backup; + __entry->backup = subflow->backup || subflow->request_bkup;if (subflow->tcp_sock &&sk_fullsock (subflow->tcp_sock)) __entry->free =sk_stream_memory_free (subflow->tcp_sock);
net/mptcp/protocol.c +6 -4
@@ -1422,13 +1422,15 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) }mptcp_for_each_subflow (msk, subflow) { +bool backup = subflow->backup || subflow->request_bkup; +trace_mptcp_subflow_get_send (subflow); ssk =mptcp_subflow_tcp_sock (subflow);if (!mptcp_subflow_active (subflow))continue ; tout =max (tout,mptcp_timeout_from_subflow (subflow)); - nr_active += !subflow->backup; + nr_active += !backup; pace = subflow->avg_pacing_rate;if (unlikely (!pace)) {/* init pacing rate from socket */
@@ -1439,9 +1441,9 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk) } linger_time =div_u64 ((u64 )READ_ONCE (ssk->sk_wmem_queued) <<32 , pace); -if (linger_time < send_info[subflow->backup].linger_time) { - send_info[subflow->backup].ssk = ssk; - send_info[subflow->backup].linger_time = linger_time; +if (linger_time < send_info[backup].linger_time) { + send_info[backup].ssk = ssk; + send_info[backup].linger_time = linger_time; } }__mptcp_set_timeout (sk, tout);
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 2/9 mptcp: distinguish rcv vs sent backup flag in requests
In reply to Matthieu Baerts (NGI0)When sending an MP_JOIN + SYN + ACK, it is possible to mark the subflow as 'backup' by setting the flag with the same name. Before this patch, the backup was set if the other peer set it in its MP_JOIN + SYN request.
It is not correct: the backup flag should be set in the MPJ+SYN+ACK only if the host asks for it, and not mirroring what was done by the other peer. It is then required to have a dedicated bit for each direction, similar to what is done in the subflow context.
--- net/mptcp/options.c | 2 +- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -909,7 +909,7 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,return true; }else if (subflow_req->mp_join) { opts->suboptions =OPTION_MPTCP_MPJ_SYNACK ; - opts->backup = subflow_req->backup; + opts->backup = subflow_req->request_bkup; opts->join_id = subflow_req->local_id; opts->thmac = subflow_req->thmac; opts->nonce = subflow_req->local_nonce;
net/mptcp/protocol.h +1 -0
@@ -448,6 +448,7 @@ struct mptcp_subflow_request_sock { u16 mp_capable : 1, mp_join : 1, backup : 1, + request_bkup : 1, csum_reqd : 1, allow_join_id0 : 1;u8 local_id;
net/mptcp/subflow.c +1 -0
@@ -2005,6 +2005,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->fully_established =1 ; new_ctx->remote_key_valid =1 ; new_ctx->backup = subflow_req->backup; + new_ctx->request_bkup = subflow_req->request_bkup;WRITE_ONCE (new_ctx->remote_id, subflow_req->remote_id); new_ctx->token = subflow_req->token; new_ctx->thmac = subflow_req->thmac;
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 3/9 mptcp: pm: only set request_bkup flag when sending MP_PRIO
In reply to Matthieu Baerts (NGI0)The 'backup' flag from mptcp_subflow_context structure is supposed to be set only when the other peer flagged a subflow as backup, not the opposite.
--- net/mptcp/pm_netlink.c | 1 - 1 file changed, 1 deletion(-)
net/mptcp/pm_netlink.c +0 -1
@@ -471,7 +471,6 @@ static void __mptcp_pm_send_ack(struct mptcp_sock *msk, struct mptcp_subflow_con slow =lock_sock_fast (ssk);if (prio) { subflow->send_mp_prio =1 ; - subflow->backup = backup; subflow->request_bkup = backup; }
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 4/9 mptcp: mib: count MPJ with backup flag
In reply to Matthieu Baerts (NGI0)Without such counters, it is difficult to easily debug issues with MPJ not having the backup flags on production servers.
This is not strictly a fix, but it eases to validate the following patch without requiring to take packet traces, to query ongoing connections with Netlink with admin permissions, or to guess by looking at the behaviour of the scheduler.
--- net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/subflow.c | 6 ++++++ 3 files changed, 10 insertions(+)
net/mptcp/mib.c +2 -0
@@ -19,7 +19,9 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("MPTCPRetrans" ,MPTCP_MIB_RETRANSSEGS ),SNMP_MIB_ITEM ("MPJoinNoTokenFound" ,MPTCP_MIB_JOINNOTOKEN ),SNMP_MIB_ITEM ("MPJoinSynRx" ,MPTCP_MIB_JOINSYNRX ), +SNMP_MIB_ITEM ("MPJoinSynBackupRx" ,MPTCP_MIB_JOINSYNBACKUPRX ),SNMP_MIB_ITEM ("MPJoinSynAckRx" ,MPTCP_MIB_JOINSYNACKRX ), +SNMP_MIB_ITEM ("MPJoinSynAckBackupRx" ,MPTCP_MIB_JOINSYNACKBACKUPRX ),SNMP_MIB_ITEM ("MPJoinSynAckHMacFailure" ,MPTCP_MIB_JOINSYNACKMAC ),SNMP_MIB_ITEM ("MPJoinAckRx" ,MPTCP_MIB_JOINACKRX ), SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC),
net/mptcp/mib.h +2 -0
@@ -14,7 +14,9 @@ enum linux_mptcp_mib_field {MPTCP_MIB_RETRANSSEGS ,/* Segments retransmitted at the MPTCP-level */ MPTCP_MIB_JOINNOTOKEN ,/* Received MP_JOIN but the token was not found */ MPTCP_MIB_JOINSYNRX ,/* Received a SYN + MP_JOIN */ +MPTCP_MIB_JOINSYNBACKUPRX ,/* Received a SYN + MP_JOIN + backup flag */ MPTCP_MIB_JOINSYNACKRX ,/* Received a SYN/ACK + MP_JOIN */ +MPTCP_MIB_JOINSYNACKBACKUPRX ,/* Received a SYN/ACK + MP_JOIN + backup flag */ MPTCP_MIB_JOINSYNACKMAC ,/* HMAC was wrong on SYN/ACK + MP_JOIN */ MPTCP_MIB_JOINACKRX ,/* Received an ACK + MP_JOIN */ MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */
net/mptcp/subflow.c +6 -0
@@ -168,6 +168,9 @@ static int subflow_check_req(struct request_sock *req,return 0 ; }else if (opt_mp_join) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINSYNRX ); + +if (mp_opt.backup) +SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINSYNBACKUPRX ); }if (opt_mp_capable && listener->request_mptcp) {
@@ -577,6 +580,9 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->mp_join =1 ;MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_JOINSYNACKRX ); +if (subflow->backup) +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_JOINSYNACKBACKUPRX ); +if (subflow_use_different_dport (msk, sk)) { pr_debug("synack inet_dport=%d %d", ntohs(inet_sk(sk)->inet_dport),
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 5/9 selftests: mptcp: join: validate backup in MPJ
In reply to Matthieu Baerts (NGI0)A peer can notify the other one that a subflow has to be treated as "backup" by two different ways: either by sending a dedicated MP_PRIO notification, or by setting the backup flag in the MP_JOIN handshake.
The selftests were previously monitoring the former, but not the latter. This is what is now done here by looking at these new MIB counters when validating the 'backup' cases:
MPTcpExtMPJoinSynBackupRx
MPTcpExtMPJoinSynAckBackupRx
The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests, but it will help to validate a new fix for an issue introduced by this commit ID.
---
Notes:
- v3:
- Use error message similar to other JOIN tests (Geliang).
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 42 +++++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +32 -10
@@ -1634,6 +1634,8 @@ chk_prio_nr() { local mp_prio_nr_tx=$1 local mp_prio_nr_rx=$2 + local mpj_syn=$3 + local mpj_syn_ack=$4 local count print_check "ptx"
@@ -1655,6 +1657,26 @@ chk_prio_nr() else print_ok fi + + print_check "syn backup" + count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinSynBackupRx") + if [ -z "$count" ]; then + print_skip + elif [ "$count" != "$mpj_syn" ]; then + fail_test "got $count JOIN[s] syn with Backup expected $mpj_syn" + else + print_ok + fi + + print_check "synack backup" + count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynAckBackupRx") + if [ -z "$count" ]; then + print_skip + elif [ "$count" != "$mpj_syn_ack" ]; then + fail_test "got $count JOIN[s] synack with Backup expected $mpj_syn_ack" + else + print_ok + fi } chk_subflow_nr()
@@ -2612,7 +2634,7 @@ backup_tests() sflags=nobackup speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 1 - chk_prio_nr 0 1 + chk_prio_nr 0 1 1 0 fi # single address, backup
@@ -2625,7 +2647,7 @@ backup_tests() run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 1 chk_add_nr 1 1 - chk_prio_nr 1 1 + chk_prio_nr 1 1 0 0 fi # single address with port, backup
@@ -2638,7 +2660,7 @@ backup_tests() run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 1 chk_add_nr 1 1 - chk_prio_nr 1 1 + chk_prio_nr 1 1 0 0 fi if reset "mpc backup" &&
@@ -2647,7 +2669,7 @@ backup_tests() speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 0 0 0 - chk_prio_nr 0 1 + chk_prio_nr 0 1 0 0 fi if reset "mpc backup both sides" &&
@@ -2657,7 +2679,7 @@ backup_tests() speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 0 0 0 - chk_prio_nr 1 1 + chk_prio_nr 1 1 0 0 fi if reset "mpc switch to backup" &&
@@ -2666,7 +2688,7 @@ backup_tests() sflags=backup speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 0 0 0 - chk_prio_nr 0 1 + chk_prio_nr 0 1 0 0 fi if reset "mpc switch to backup both sides" &&
@@ -2676,7 +2698,7 @@ backup_tests() sflags=backup speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 0 0 0 - chk_prio_nr 1 1 + chk_prio_nr 1 1 0 0 fi }
@@ -3053,7 +3075,7 @@ fullmesh_tests() addr_nr_ns2=1 sflags=backup,fullmesh speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 2 2 2 - chk_prio_nr 0 1 + chk_prio_nr 0 1 1 0 chk_rm_nr 0 1 fi
@@ -3066,7 +3088,7 @@ fullmesh_tests() sflags=nobackup,nofullmesh speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 2 2 2 - chk_prio_nr 0 1 + chk_prio_nr 0 1 1 0 chk_rm_nr 0 1 fi }
@@ -3318,7 +3340,7 @@ userspace_tests() sflags=backup speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 0 - chk_prio_nr 0 0 + chk_prio_nr 0 0 0 0 fi # userspace pm type prevents rm_addr
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 6/9 mptcp: pm: fix backup support in signal endpoints
In reply to Matthieu Baerts (NGI0)There was a support for signal endpoints, but only when the endpoint's flag was changed during a connection. If an endpoint with the signal and backup was already present, the MP_JOIN reply was not containing the backup flag as expected.
That's confusing to have this inconsistent behaviour. On the other hand, the infrastructure to set the backup flag in the SYN + ACK + MP_JOIN was already there, it was just never set before. Now when requesting the local ID from the path-manager, the backup status is also requested.
Note that when the userspace PM is used, the backup flag can be set if the local address was already used before with a backup flag, e.g. if the address was announced with the 'backup' flag, or a subflow was created with the 'backup' flag.
---
Notes:
- v2:
- Only set *backup on success (Mat).
- Support MPJ to/from ID0 with backup.
- Split the tests in a new dedicated commit to ease the backports.
- v3:
- Use a new dedicated helper instead of re-using
mptcp_pm_get_local_id() (Geliang). --- net/mptcp/pm.c | 12 ++++++++++++ net/mptcp/pm_netlink.c | 18 ++++++++++++++++++ net/mptcp/pm_userspace.c | 18 ++++++++++++++++++ net/mptcp/protocol.h | 3 +++ net/mptcp/subflow.c | 3 +++ 5 files changed, 54 insertions(+)
net/mptcp/pm.c +12 -0
@@ -426,6 +426,18 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)return mptcp_pm_nl_get_local_id (msk, &skc_local); } +bool mptcp_pm_is_backup (struct mptcp_sock *msk,struct sock_common *skc) +{ +struct mptcp_addr_info skc_local; + +mptcp_local_address ((struct sock_common *)skc, &skc_local); + +if (mptcp_pm_is_userspace (msk)) +return mptcp_userspace_pm_is_backup (msk, &skc_local); + +return mptcp_pm_nl_is_backup (msk, &skc_local); +} +int mptcp_pm_get_flags_and_ifindex_by_id (struct mptcp_sock *msk,unsigned int id,u8 *flags,int *ifindex) {
net/mptcp/pm_netlink.c +18 -0
@@ -1101,6 +1101,24 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skcreturn ret; } +bool mptcp_pm_nl_is_backup (struct mptcp_sock *msk,struct mptcp_addr_info *skc) +{ +struct pm_nl_pernet *pernet =pm_nl_get_pernet_from_msk (msk); +struct mptcp_pm_addr_entry *entry; +bool backup = false; + +rcu_read_lock (); +list_for_each_entry_rcu (entry, &pernet->local_addr_list, list) { +if (mptcp_addresses_equal (&entry->addr, skc, entry->addr.port)) { + backup = !!(entry->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +break ; + } + } +rcu_read_unlock (); + +return backup; +} +#define MPTCP_PM_CMD_GRP_OFFSET 0#define MPTCP_PM_EV_GRP_OFFSET 1
net/mptcp/pm_userspace.c +18 -0
@@ -165,6 +165,24 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk,return mptcp_userspace_pm_append_new_local_addr (msk, &new_entry, true); } +bool mptcp_userspace_pm_is_backup (struct mptcp_sock *msk, +struct mptcp_addr_info *skc) +{ +struct mptcp_pm_addr_entry *entry; +bool backup = false; + +spin_lock_bh (&msk->pm.lock); +list_for_each_entry (entry, &msk->pm.userspace_pm_local_addr_list, list) { +if (mptcp_addresses_equal (&entry->addr, skc, false)) { + backup = !!(entry->flags &MPTCP_PM_ADDR_FLAG_BACKUP ); +break ; + } + } +spin_unlock_bh (&msk->pm.lock); + +return backup; +} +int mptcp_pm_nl_announce_doit (struct sk_buff *skb,struct genl_info *info) {struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];
net/mptcp/protocol.h +3 -0
@@ -1114,6 +1114,9 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,int mptcp_pm_get_local_id (struct mptcp_sock *msk,struct sock_common *skc);int mptcp_pm_nl_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc);int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc); +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_dump_addr (struct sk_buff *msg,struct netlink_callback *cb);int mptcp_pm_nl_dump_addr (struct sk_buff *msg,struct netlink_callback *cb);
net/mptcp/subflow.c +3 -0
@@ -100,6 +100,7 @@ static struct mptcp_sock *subflow_token_join_request(struct request_sock *req)return NULL ; } subflow_req->local_id = local_id; + subflow_req->request_bkup =mptcp_pm_is_backup (msk, (struct sock_common *)req);return msk; }
@@ -620,6 +621,8 @@ static int subflow_chk_local_id(struct sock *sk)return err;subflow_set_local_id (subflow, err); + subflow->request_bkup =mptcp_pm_is_backup (msk, (struct sock_common *)sk); +return 0 ; }
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 7/9 selftests: mptcp: join: check backup support in signal endp
In reply to Matthieu Baerts (NGI0)Before the previous commit, 'signal' endpoints with the 'backup' flag were ignored when sending the MP_JOIN.
The MPTCP Join selftest has then been modified to validate this case:
the "single address, backup" test, is now validating the MP_JOIN with a backup flag as it is what we expect it to do with such name. The previous version has been kept, but renamed to "single address, switch to backup" to avoid confusions.
The "single address with port, backup" test is also now validating the MPJ with a backup flag, which makes more sense than checking the switch to backup with an MP_PRIO.
The "mpc backup both sides" test is now validating that the backup flag is also set in MP_JOIN from and to the addresses used in the initial subflow, using the special ID 0.
The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID.
---
Notes:
- v2:
- Also validating MPJ to/from ID0 with backup
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 34 ++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +28 -6
@@ -2639,6 +2639,19 @@ backup_tests() # single address, backup if reset "single address, backup" && + continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then + pm_nl_set_limits $ns1 0 1 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup + pm_nl_set_limits $ns2 1 1 + sflags=nobackup speed=slow \ + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + chk_prio_nr 1 0 0 1 + fi + + # single address, switch to backup + if reset "single address, switch to backup" && continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then pm_nl_set_limits $ns1 0 1 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -2654,13 +2667,13 @@ backup_tests() if reset "single address with port, backup" && continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then pm_nl_set_limits $ns1 0 1 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal port 10100 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup port 10100 pm_nl_set_limits $ns2 1 1 - sflags=backup speed=slow \ + sflags=nobackup speed=slow \ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr 1 1 1 chk_add_nr 1 1 - chk_prio_nr 1 1 0 0 + chk_prio_nr 1 0 0 1 fi if reset "mpc backup" &&
@@ -2674,12 +2687,21 @@ backup_tests() if reset "mpc backup both sides" && continue_if mptcp_lib_kallsyms_doesnt_have "T mptcp_subflow_send_ack$"; then - pm_nl_add_endpoint $ns1 10.0.1.1 flags subflow,backup + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 1 2 + pm_nl_add_endpoint $ns1 10.0.1.1 flags signal,backup pm_nl_add_endpoint $ns2 10.0.1.2 flags subflow,backup + + # 10.0.2.2 (non-backup) -> 10.0.1.1 (backup) + pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow + # 10.0.1.2 (backup) -> 10.0.2.1 (non-backup) + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + ip -net "$ns2" route add 10.0.2.1 via 10.0.1.1 dev ns2eth1 # force this path + speed=slow \ run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 - chk_prio_nr 1 1 0 0 + chk_join_nr 2 2 2 + chk_prio_nr 1 1 1 1 fi if reset "mpc switch to backup" &&
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 8/9 Squash to "selftests/bpf: Add bpf_bkup scheduler & test"
In reply to Matthieu Baerts (NGI0)Similar to "mptcp: sched: check both directions for backup": it didn't matter before because the two flags were very likely set by accident. But that's no longer the case now.
--- tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +2 -1
@@ -29,7 +29,8 @@ int BPF_PROG(bpf_bkup_get_subflow, struct mptcp_sock *msk,if (!subflow)break ; -if (!BPF_CORE_READ_BITFIELD_PROBED (subflow, backup)) { +if (!BPF_CORE_READ_BITFIELD_PROBED (subflow, backup) || + !BPF_CORE_READ_BITFIELD_PROBED (subflow, request_bkup)) { nr = i;break ; }
Signature · 1 line
2.45.2
Matthieu Baerts (NGI0)
maintainerPATCH v3 9/9 Squash to "selftests/bpf: Add bpf_burst scheduler & test"
In reply to Matthieu Baerts (NGI0)Similar to "mptcp: sched: check both directions for backup": it didn't matter before because the two flags were very likely set by accident. But that's no longer the case now.
--- tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +8 -4
@@ -85,10 +85,14 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, }for (i =0 ; i < data->subflows && i <MPTCP_SUBFLOWS_MAX ; i++) { +bool backup; + subflow =bpf_mptcp_subflow_ctx_by_pos (data, i);if (!subflow)break ; + backup = subflow->backup || subflow->request_bkup; + ssk =mptcp_subflow_tcp_sock (subflow);if (!mptcp_subflow_active (subflow))continue ;
@@ -103,9 +107,9 @@ static int bpf_burst_get_send(struct mptcp_sock *msk, } linger_time =div_u64 ((__u64 )ssk->sk_wmem_queued <<32 , pace); -if (linger_time < send_info[subflow->backup].linger_time) { - send_info[subflow->backup].subflow_id = i; - send_info[subflow->backup].linger_time = linger_time; +if (linger_time < send_info[backup].linger_time) { + send_info[backup].subflow_id = i; + send_info[backup].linger_time = linger_time; } }mptcp_set_timeout (sk);
@@ -160,7 +164,7 @@ static int bpf_burst_get_retrans(struct mptcp_sock *msk,continue ; } -if (subflow->backup) { +if (subflow->backup || subflow->request_bkup) {if (backup ==MPTCP_SUBFLOWS_MAX ) backup = i;continue ;
Signature · 1 line
2.45.2
Hi Matthieu,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Unstable: 4 failed test(s): packetdrill_mp_join packetdrill_mp_prio packetdrill_regressions packetdrill_syscalls 🔴
- KVM Validation: debug: Unstable: 4 failed test(s): packetdrill_mp_join packetdrill_mp_prio packetdrill_regressions packetdrill_syscalls 🔴
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9994916304
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/962a6c85c567
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=872303
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
maintainerHello,
Quoted 4 lines · MPTCP CI
Our CI did some validations and here is its report:
- KVM Validation: normal: Unstable: 4 failed test(s):
packetdrill_mp_joinpacketdrill_mp_priopacketdrill_regressionspacketdrill_syscalls🔴
- KVM Validation: debug: Unstable: 4 failed test(s):packetdrill_mp_joinpacketdrill_mp_priopacketdrill_regressionspacketdrill_syscalls🔴
Just to avoid some confusions, and as mentioned in my cover-letter, these errors were expected because these tests were looking for the backup flags in the MPJ+SYN+ACK which were not supposed to be there:
https://github.com/multipath-tcp/packetdrill/pull/152
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Quoted 20 lines · On Thu, 18 Jul 2024, Matthieu Baerts (NGI0) wrote:
In all the backup tests we have, the backup flag is set on one side, and the expected behaviour is to have both sides respecting this decision.
On the scheduler side, only the 'backup' field is checked, which is supposed to be set only if the other peer flagged a subflow as backup. But in various places, this flag is set when the local host flagged the subflow as backup.
One last thing that has been fixed is the backup flag in 'signal'
endpoints: it was working only when setting the backup flag while the connection was already opened. That's what the MPJ selftests were doing to check that the signal endpoint were supporting the backup flag (on purpose I guess, because the support was broken inMP_JOIN...).The last two patches adapt the BPF selftests to mimic what is now done by the in-kernel packets scheduler.
Note that the Packetdrill tests need to be updated because the behaviour has been changed / fixed:
Quoted 9 lines
https://github.com/multipath-tcp/packetdrill/pull/152
Signed-off-by Matthieu Baerts (NGI0) <[email protected]>---
Changes in v3:
- Small fixes in patch 1 and 5: see the individual ChangeLog
- Use a new dedicated helper in patch 6: see the individual ChangeLog
- Link to v2: https://lore.kernel.org/r/[email protected]
Hi Matthieu -
v3 LGTM. I'm not sure if the new MIBs are best targeted for net-next, they do help with testing but don't seem critical for -stable.
Quoted 42 lines
Changes in v2:
- new patches 4 and 5.
- split patch 6 in two (code then tests) to ease the backports.
- patch 6 addresses Mat's comments, and support the ID0 case.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Matthieu Baerts (NGI0) (9):
mptcp: sched: check both directions for backup
mptcp: distinguish rcv vs sent backup flag in requests
mptcp: pm: only setrequest_bkupflag when sendingMP_PRIO
mptcp: mib: count MPJ with backup flag
selftests: mptcp: join: validate backup in MPJ
mptcp: pm: fix backup support in signal endpoints
selftests: mptcp: join: check backup support in signal endp Squash to "selftests/bpf: Addbpf_bkupscheduler & test" Squash to "selftests/bpf: Addbpf_burstscheduler & test"include/trace/events/mptcp.h | 2 +- net/mptcp/mib.c | 2 + net/mptcp/mib.h | 2 + net/mptcp/options.c | 2 +- net/mptcp/pm.c | 12 ++++ net/mptcp/pm_netlink.c | 19 +++++- net/mptcp/pm_userspace.c | 18 ++++++ net/mptcp/protocol.c | 10 +-- net/mptcp/protocol.h | 4 ++ net/mptcp/subflow.c | 10 +++ tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c | 3 +- .../testing/selftests/bpf/progs/mptcp_bpf_burst.c | 12 ++-- tools/testing/selftests/net/mptcp/mptcp_join.sh | 72 +++++++++++++++++----- 13 files changed, 142 insertions(+), 26 deletions(-)---
base-commit:50d1a79f5003b88b03b37d05189ad02a84d7be49
change-id: 20240711-mptcp-backup-mpj-2f8369fad366Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
Matthieu Baerts
maintainerHi Mat,
Quoted 33 lines · Mat Martineau
Quoted 22 lines · On Thu, 18 Jul 2024, Matthieu Baerts (NGI0) wrote:
In all the backup tests we have, the backup flag is set on one side, and the expected behaviour is to have both sides respecting this decision.
On the scheduler side, only the 'backup' field is checked, which is supposed to be set only if the other peer flagged a subflow as backup. But in various places, this flag is set when the local host flagged the subflow as backup.
One last thing that has been fixed is the backup flag in 'signal'
endpoints: it was working only when setting the backup flag while the connection was already opened. That's what the MPJ selftests were doing to check that the signal endpoint were supporting the backup flag (on purpose I guess, because the support was broken inMP_JOIN...).The last two patches adapt the BPF selftests to mimic what is now done by the in-kernel packets scheduler.
Note that the Packetdrill tests need to be updated because the behaviour has been changed / fixed:
Quoted 8 lines
Signed-off-by Matthieu Baerts (NGI0) <[email protected]>---
Changes in v3:
- Small fixes in patch 1 and 5: see the individual ChangeLog
- Use a new dedicated helper in patch 6: see the individual ChangeLog
- Link to v2: https://lore.kernel.org/r/20240716-mptcp-backup-mpj-
[email protected]
Quoted 4 lines
Hi Matthieu -
v3 LGTM. I'm not sure if the new MIBs are best targeted for net-next, they do help with testing but don't seem critical for -stable.
Indeed. My reasoning was that the MIB counters were not there, mainly because this behaviour has never been verified. At the end, it is only 10 new but well controlled lines :)
I suggest applying them in our tree, and delay them if they got rejected. At the end, the new MIB counters and the tests are well isolated, and with a note about that.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerHi Mat,
Quoted 33 lines · Mat Martineau
Quoted 22 lines · On Thu, 18 Jul 2024, Matthieu Baerts (NGI0) wrote:
In all the backup tests we have, the backup flag is set on one side, and the expected behaviour is to have both sides respecting this decision.
On the scheduler side, only the 'backup' field is checked, which is supposed to be set only if the other peer flagged a subflow as backup. But in various places, this flag is set when the local host flagged the subflow as backup.
One last thing that has been fixed is the backup flag in 'signal'
endpoints: it was working only when setting the backup flag while the connection was already opened. That's what the MPJ selftests were doing to check that the signal endpoint were supporting the backup flag (on purpose I guess, because the support was broken inMP_JOIN...).The last two patches adapt the BPF selftests to mimic what is now done by the in-kernel packets scheduler.
Note that the Packetdrill tests need to be updated because the behaviour has been changed / fixed:
Quoted 8 lines
Signed-off-by Matthieu Baerts (NGI0) <[email protected]>---
Changes in v3:
- Small fixes in patch 1 and 5: see the individual ChangeLog
- Use a new dedicated helper in patch 6: see the individual ChangeLog
- Link to v2: https://lore.kernel.org/r/20240716-mptcp-backup-mpj-
[email protected]
Quoted 6 lines
Hi Matthieu -
v3 LGTM. I'm not sure if the new MIBs are best targeted for net-next, they do help with testing but don't seem critical for -stable.
Reviewed-by Mat Martineau <[email protected]>
Thank you for the review!
Now in our tree (fixes for -net):
New patches for t/upstream-net and t/upstream:
- 9d426c00aef4: mptcp: sched: check both directions for backup
- cba82af312b3: mptcp: distinguish rcv vs sent backup flag in requests
- 1ed597db4a47: mptcp: pm: only set request_bkup flag when sending MP_PRIO
- 887ecb0faf1d: mptcp: mib: count MPJ with backup flag
- 5e248a08f195: selftests: mptcp: join: validate backup in MPJ
- 237a12154c8f: mptcp: pm: fix backup support in signal endpoints
- 34b6d5cac1f0: selftests: mptcp: join: check backup support in signal endp
- Results: 159097cdb0e8..001fe004e8be (export-net)
- Results: 140ff27ee472..939ca15e71e2 (export)
New patches for t/upstream:
- b4a459e0fd62: "squashed" patch 8/9 in "selftests/bpf: Add bpf_bkup scheduler & test"
- ec4acb003f8a: "squashed" patch 9/9 in "selftests/bpf: Add bpf_burst scheduler & test"
- Results: 939ca15e71e2..f0f02c71ff0d (export)
Tests are now in progress:
- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/293546bf79b70ea127af87026d99cfb91eacb77b/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/b601d6da52375e9a0a078ec38af104b5243c4658/checks
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.