From f0deb892bd08c7a63c3301938ce173721e58c8a8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2024 14:38:26 +0200 Subject: [PATCH] 5.15-stable patches added patches: mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch mptcp-export-local_address.patch mptcp-fix-bad-rcvpruned-mib-accounting.patch mptcp-fix-nl-pm-announced-address-accounting.patch mptcp-mib-count-mpj-with-backup-flag.patch mptcp-pm-fix-backup-support-in-signal-endpoints.patch mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch mptcp-sched-check-both-directions-for-backup.patch selftests-mptcp-join-check-backup-support-in-signal-endp.patch selftests-mptcp-join-validate-backup-in-mpj.patch --- ...-rcv-vs-sent-backup-flag-in-requests.patch | 71 +++++++++ queue-5.15/mptcp-export-local_address.patch | 103 +++++++++++++ ...tcp-fix-bad-rcvpruned-mib-accounting.patch | 60 ++++++++ ...x-nl-pm-announced-address-accounting.patch | 73 +++++++++ ...mptcp-mib-count-mpj-with-backup-flag.patch | 86 +++++++++++ ...x-backup-support-in-signal-endpoints.patch | 142 ++++++++++++++++++ ...quest_bkup-flag-when-sending-mp_prio.patch | 41 +++++ ...hed-check-both-directions-for-backup.patch | 87 +++++++++++ ...-check-backup-support-in-signal-endp.patch | 76 ++++++++++ ...ts-mptcp-join-validate-backup-in-mpj.patch | 106 +++++++++++++ queue-5.15/series | 10 ++ 11 files changed, 855 insertions(+) create mode 100644 queue-5.15/mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch create mode 100644 queue-5.15/mptcp-export-local_address.patch create mode 100644 queue-5.15/mptcp-fix-bad-rcvpruned-mib-accounting.patch create mode 100644 queue-5.15/mptcp-fix-nl-pm-announced-address-accounting.patch create mode 100644 queue-5.15/mptcp-mib-count-mpj-with-backup-flag.patch create mode 100644 queue-5.15/mptcp-pm-fix-backup-support-in-signal-endpoints.patch create mode 100644 queue-5.15/mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch create mode 100644 queue-5.15/mptcp-sched-check-both-directions-for-backup.patch create mode 100644 queue-5.15/selftests-mptcp-join-check-backup-support-in-signal-endp.patch create mode 100644 queue-5.15/selftests-mptcp-join-validate-backup-in-mpj.patch diff --git a/queue-5.15/mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch b/queue-5.15/mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch new file mode 100644 index 00000000000..1fbe2a75bcf --- /dev/null +++ b/queue-5.15/mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch @@ -0,0 +1,71 @@ +From stable+bounces-66128-greg=kroah.com@vger.kernel.org Fri Aug 9 11:06:20 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:06:08 +0200 +Subject: mptcp: distinguish rcv vs sent backup flag in requests +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809090607.2697543-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit efd340bf3d7779a3a8ec954d8ec0fb8a10f24982 upstream. + +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. + +Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in subflow.c, because the context has changed in commit + 4cf86ae84c71 ("mptcp: strict local address ID selection"), and in + commit 967d3c27127e ("mptcp: fix data races on remote_id"), which are + not in this version. These commits are unrelated to this + modification. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/options.c | 2 +- + net/mptcp/protocol.h | 1 + + net/mptcp/subflow.c | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +--- a/net/mptcp/options.c ++++ b/net/mptcp/options.c +@@ -877,7 +877,7 @@ bool mptcp_synack_options(const struct r + 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; +--- a/net/mptcp/protocol.h ++++ b/net/mptcp/protocol.h +@@ -370,6 +370,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; +--- a/net/mptcp/subflow.c ++++ b/net/mptcp/subflow.c +@@ -1766,6 +1766,7 @@ static void subflow_ulp_clone(const stru + new_ctx->mp_join = 1; + new_ctx->fully_established = 1; + new_ctx->backup = subflow_req->backup; ++ new_ctx->request_bkup = subflow_req->request_bkup; + new_ctx->local_id = subflow_req->local_id; + new_ctx->remote_id = subflow_req->remote_id; + new_ctx->token = subflow_req->token; diff --git a/queue-5.15/mptcp-export-local_address.patch b/queue-5.15/mptcp-export-local_address.patch new file mode 100644 index 00000000000..d600d1e6acb --- /dev/null +++ b/queue-5.15/mptcp-export-local_address.patch @@ -0,0 +1,103 @@ +From stable+bounces-66133-greg=kroah.com@vger.kernel.org Fri Aug 9 11:09:34 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:09:13 +0200 +Subject: mptcp: export local_address +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , Geliang Tang , Matthieu Baerts , Larysa Zaremba , Jakub Kicinski , Matthieu Baerts +Message-ID: <20240809090912.2701580-3-matttbe@kernel.org> + +From: Geliang Tang + +commit dc886bce753cc2cf3c88ec5c7a6880a4e17d65ba upstream. + +Rename local_address() with "mptcp_" prefix and export it in protocol.h. + +This function will be re-used in the common PM code (pm.c) in the +following commit. + +Signed-off-by: Geliang Tang +Reviewed-by: Matthieu Baerts +Signed-off-by: Matthieu Baerts +Reviewed-by: Larysa Zaremba +Signed-off-by: Jakub Kicinski +Stable-dep-of: 6834097fc38c ("mptcp: pm: fix backup support in signal endpoints") +[ Conflicts in pm_netlink.c and protocol.h, because the context has + changed in commit 4638de5aefe5 ("mptcp: handle local addrs announced + by userspace PMs") which is not in this version. This commit is + unrelated to this modification. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/pm_netlink.c | 15 +++++++-------- + net/mptcp/protocol.h | 1 + + 2 files changed, 8 insertions(+), 8 deletions(-) + +--- a/net/mptcp/pm_netlink.c ++++ b/net/mptcp/pm_netlink.c +@@ -97,8 +97,7 @@ static bool address_zero(const struct mp + return addresses_equal(addr, &zero, true); + } + +-static void local_address(const struct sock_common *skc, +- struct mptcp_addr_info *addr) ++void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr) + { + addr->family = skc->skc_family; + addr->port = htons(skc->skc_num); +@@ -133,7 +132,7 @@ static bool lookup_subflow_by_saddr(cons + list_for_each_entry(subflow, list, node) { + skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); + +- local_address(skc, &cur); ++ mptcp_local_address(skc, &cur); + if (addresses_equal(&cur, saddr, saddr->port)) + return true; + } +@@ -286,7 +285,7 @@ bool mptcp_pm_sport_in_anno_list(struct + struct mptcp_addr_info saddr; + bool ret = false; + +- local_address((struct sock_common *)sk, &saddr); ++ mptcp_local_address((struct sock_common *)sk, &saddr); + + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(entry, &msk->pm.anno_list, list) { +@@ -693,7 +692,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct + struct sock *sk = (struct sock *)msk; + struct mptcp_addr_info local; + +- local_address((struct sock_common *)ssk, &local); ++ mptcp_local_address((struct sock_common *)ssk, &local); + if (!addresses_equal(&local, addr, addr->port)) + continue; + +@@ -976,8 +975,8 @@ int mptcp_pm_nl_get_local_id(struct mptc + /* The 0 ID mapping is defined by the first subflow, copied into the msk + * addr + */ +- local_address((struct sock_common *)msk, &msk_local); +- local_address((struct sock_common *)skc, &skc_local); ++ mptcp_local_address((struct sock_common *)msk, &msk_local); ++ mptcp_local_address((struct sock_common *)skc, &skc_local); + if (addresses_equal(&msk_local, &skc_local, false)) + return 0; + +@@ -1388,7 +1387,7 @@ static int mptcp_nl_remove_id_zero_addre + if (list_empty(&msk->conn_list)) + goto next; + +- local_address((struct sock_common *)msk, &msk_local); ++ mptcp_local_address((struct sock_common *)msk, &msk_local); + if (!addresses_equal(&msk_local, addr, addr->port)) + goto next; + +--- a/net/mptcp/protocol.h ++++ b/net/mptcp/protocol.h +@@ -583,6 +583,7 @@ void mptcp_subflow_send_ack(struct sock + void mptcp_subflow_reset(struct sock *ssk); + void mptcp_sock_graft(struct sock *sk, struct socket *parent); + struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); ++void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr); + + /* called with sk socket lock held */ + int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, diff --git a/queue-5.15/mptcp-fix-bad-rcvpruned-mib-accounting.patch b/queue-5.15/mptcp-fix-bad-rcvpruned-mib-accounting.patch new file mode 100644 index 00000000000..c5292b25ff3 --- /dev/null +++ b/queue-5.15/mptcp-fix-bad-rcvpruned-mib-accounting.patch @@ -0,0 +1,60 @@ +From stable+bounces-66131-greg=kroah.com@vger.kernel.org Fri Aug 9 11:08:26 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:08:14 +0200 +Subject: mptcp: fix bad RCVPRUNED mib accounting +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , Paolo Abeni , Mat Martineau , Matthieu Baerts +Message-ID: <20240809090813.2700287-2-matttbe@kernel.org> + +From: Paolo Abeni + +commit 0a567c2a10033bf04ed618368d179bce6977984b upstream. + +Since its introduction, the mentioned MIB accounted for the wrong +event: wake-up being skipped as not-needed on some edge condition +instead of incoming skb being dropped after landing in the (subflow) +receive queue. + +Move the increment in the correct location. + +Fixes: ce599c516386 ("mptcp: properly account bulk freed memory") +Cc: stable@vger.kernel.org +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in protocol.c, because the commit 6511882cdd82 ("mptcp: + allocate fwd memory separately on the rx and tx path") is not in this + version. The fix can still be applied before the 'goto drop'. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/protocol.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -288,8 +288,10 @@ static bool __mptcp_move_skb(struct mptc + if (!sk_rmem_schedule(sk, skb, skb->truesize)) { + int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT; + +- if (ssk->sk_forward_alloc < amount) ++ if (ssk->sk_forward_alloc < amount) { ++ MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); + goto drop; ++ } + + ssk->sk_forward_alloc -= amount; + sk->sk_forward_alloc += amount; +@@ -774,10 +776,8 @@ void mptcp_data_ready(struct sock *sk, s + sk_rbuf = ssk_rbuf; + + /* over limit? can't append more skbs to msk, Also, no need to wake-up*/ +- if (__mptcp_rmem(sk) > sk_rbuf) { +- MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); ++ if (__mptcp_rmem(sk) > sk_rbuf) + return; +- } + + /* Wake-up the reader only for in-sequence data */ + mptcp_data_lock(sk); diff --git a/queue-5.15/mptcp-fix-nl-pm-announced-address-accounting.patch b/queue-5.15/mptcp-fix-nl-pm-announced-address-accounting.patch new file mode 100644 index 00000000000..feccc588949 --- /dev/null +++ b/queue-5.15/mptcp-fix-nl-pm-announced-address-accounting.patch @@ -0,0 +1,73 @@ +From stable+bounces-66129-greg=kroah.com@vger.kernel.org Fri Aug 9 11:07:37 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:07:22 +0200 +Subject: mptcp: fix NL PM announced address accounting +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , Paolo Abeni , Matthieu Baerts , "David S . Miller" +Message-ID: <20240809090721.2699120-2-matttbe@kernel.org> + +From: Paolo Abeni + +commit 4b317e0eb287bd30a1b329513531157c25e8b692 upstream. + +Currently the per connection announced address counter is never +decreased. As a consequence, after connection establishment, if +the NL PM deletes an endpoint and adds a new/different one, no +additional subflow is created for the new endpoint even if the +current limits allow that. + +Address the issue properly updating the signaled address counter +every time the NL PM removes such addresses. + +Fixes: 01cacb00b35c ("mptcp: add netlink-based PM") +Cc: stable@vger.kernel.org +Signed-off-by: Paolo Abeni +Reviewed-by: Matthieu Baerts (NGI0) +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: David S. Miller +[ Conflicts in pm_netlink.c, because the commit 6fa0174a7c86 ("mptcp: + more careful RM_ADDR generation") is not in this version. The + conditions are slightly different, but the same fix can be applied: + first checking the IDs, then removing the address. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/pm_netlink.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +--- a/net/mptcp/pm_netlink.c ++++ b/net/mptcp/pm_netlink.c +@@ -1323,6 +1323,7 @@ static bool mptcp_pm_remove_anno_addr(st + ret = remove_anno_list_by_saddr(msk, addr); + if (ret || force) { + spin_lock_bh(&msk->pm.lock); ++ msk->pm.add_addr_signaled -= ret; + mptcp_pm_remove_addr(msk, &list); + spin_unlock_bh(&msk->pm.lock); + } +@@ -1462,19 +1463,20 @@ static void mptcp_pm_remove_addrs_and_su + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, rm_list, list) { +- if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) && +- alist.nr < MPTCP_RM_IDS_MAX && +- slist.nr < MPTCP_RM_IDS_MAX) { ++ if (alist.nr < MPTCP_RM_IDS_MAX && ++ slist.nr < MPTCP_RM_IDS_MAX && ++ lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) { + alist.ids[alist.nr++] = entry->addr.id; + slist.ids[slist.nr++] = entry->addr.id; +- } else if (remove_anno_list_by_saddr(msk, &entry->addr) && +- alist.nr < MPTCP_RM_IDS_MAX) { ++ } else if (alist.nr < MPTCP_RM_IDS_MAX && ++ remove_anno_list_by_saddr(msk, &entry->addr)) { + alist.ids[alist.nr++] = entry->addr.id; + } + } + + if (alist.nr) { + spin_lock_bh(&msk->pm.lock); ++ msk->pm.add_addr_signaled -= alist.nr; + mptcp_pm_remove_addr(msk, &alist); + spin_unlock_bh(&msk->pm.lock); + } diff --git a/queue-5.15/mptcp-mib-count-mpj-with-backup-flag.patch b/queue-5.15/mptcp-mib-count-mpj-with-backup-flag.patch new file mode 100644 index 00000000000..0da67f9f06b --- /dev/null +++ b/queue-5.15/mptcp-mib-count-mpj-with-backup-flag.patch @@ -0,0 +1,86 @@ +From stable+bounces-66130-greg=kroah.com@vger.kernel.org Fri Aug 9 11:08:15 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:07:54 +0200 +Subject: mptcp: mib: count MPJ with backup flag +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809090753.2699805-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit 4dde0d72ccec500c60c798e036b852e013d6e124 upstream. + +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 +patches 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 packet scheduler. Also, the modification is self +contained, isolated, well controlled, and the increments are done just +after others, there from the beginning. It looks then safe, and helpful +to backport this. + +Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in subflow.c because the context has changed in + commit b3ea6b272d79 ("mptcp: consolidate initial ack seq generation") + which is not in this version. This commit is unrelated to this + modification. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/mib.c | 2 ++ + net/mptcp/mib.h | 2 ++ + net/mptcp/subflow.c | 6 ++++++ + 3 files changed, 10 insertions(+) + +--- a/net/mptcp/mib.c ++++ b/net/mptcp/mib.c +@@ -19,7 +19,9 @@ static const struct snmp_mib mptcp_snmp_ + 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), +--- a/net/mptcp/mib.h ++++ b/net/mptcp/mib.h +@@ -12,7 +12,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 */ +--- a/net/mptcp/subflow.c ++++ b/net/mptcp/subflow.c +@@ -163,6 +163,9 @@ static int subflow_check_req(struct requ + 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) { +@@ -462,6 +465,9 @@ static void subflow_finish_connect(struc + 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(mptcp_sk(parent), sk)) { + pr_debug("synack inet_dport=%d %d", + ntohs(inet_sk(sk)->inet_dport), diff --git a/queue-5.15/mptcp-pm-fix-backup-support-in-signal-endpoints.patch b/queue-5.15/mptcp-pm-fix-backup-support-in-signal-endpoints.patch new file mode 100644 index 00000000000..6ea17ff157a --- /dev/null +++ b/queue-5.15/mptcp-pm-fix-backup-support-in-signal-endpoints.patch @@ -0,0 +1,142 @@ +From stable+bounces-66134-greg=kroah.com@vger.kernel.org Fri Aug 9 11:09:35 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:09:14 +0200 +Subject: mptcp: pm: fix backup support in signal endpoints +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809090912.2701580-4-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit 6834097fc38c5416701c793da94558cea49c0a1f upstream. + +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. + +Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows") +Cc: stable@vger.kernel.org +Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/507 +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in pm_userspace.c because the context has changed in commit + 1e07938e29c5 ("net: mptcp: rename netlink handlers to + mptcp_pm_nl__{doit,dumpit}") which is not in this version. This + commit is unrelated to this modification. + Conflicts in protocol.h because the context has changed in commit + 9ae7846c4b6b ("mptcp: dump addrs in userspace pm list") which is not + in this version. This commit is unrelated to this modification. + Conflicts in pm.c because the context has changed in commit + f40be0db0b76 ("mptcp: unify pm get_flags_and_ifindex_by_id") which is + not in this version. This commit is unrelated to this modification. + Conflicts in subflow.c, because the commit 4cf86ae84c71 ("mptcp: + strict local address ID selection") is not in this version. It is then + not needed to modify the subflow_chk_local_id() helper, which is not + in this version. + Also, in this version, there is no pm_userspace.c, because this PM has + been added in v5.19, which also causes conflicts in protocol.h, and + pm_netlink.c. Plus the code in pm.c can be simplified, as there is no + userspace PM. And the code in pm_netlink.c needs to use + addresses_equal() instead of mptcp_addresses_equal(), see commit + 4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs"). + The code in pm_netlink.c also needs to be adapted because the + pm_nl_get_pernet_from_msk() helper is not in this version, introduced + later in commit c682bf536cf4 ("mptcp: add pm_nl_pernet helpers"). ] +Signed-off-by: Matthieu Baerts (NGI0) + +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/pm.c | 9 +++++++++ + net/mptcp/pm_netlink.c | 20 ++++++++++++++++++++ + net/mptcp/protocol.h | 2 ++ + net/mptcp/subflow.c | 1 + + 4 files changed, 32 insertions(+) + +--- a/net/mptcp/pm.c ++++ b/net/mptcp/pm.c +@@ -341,6 +341,15 @@ int mptcp_pm_get_local_id(struct mptcp_s + return mptcp_pm_nl_get_local_id(msk, skc); + } + ++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); ++ ++ return mptcp_pm_nl_is_backup(msk, &skc_local); ++} ++ + void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) + { + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); +--- a/net/mptcp/pm_netlink.c ++++ b/net/mptcp/pm_netlink.c +@@ -1014,6 +1014,26 @@ int mptcp_pm_nl_get_local_id(struct mptc + return ret; + } + ++bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc) ++{ ++ struct mptcp_pm_addr_entry *entry; ++ struct pm_nl_pernet *pernet; ++ bool backup = false; ++ ++ pernet = net_generic(sock_net((struct sock *)msk), pm_nl_pernet_id); ++ ++ rcu_read_lock(); ++ list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { ++ if (addresses_equal(&entry->addr, skc, entry->addr.port)) { ++ backup = !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP); ++ break; ++ } ++ } ++ rcu_read_unlock(); ++ ++ return backup; ++} ++ + void mptcp_pm_nl_data_init(struct mptcp_sock *msk) + { + struct mptcp_pm_data *pm = &msk->pm; +--- a/net/mptcp/protocol.h ++++ b/net/mptcp/protocol.h +@@ -821,6 +821,7 @@ bool mptcp_pm_add_addr_signal(struct mpt + bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, + struct mptcp_rm_list *rm_list); + int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); ++bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc); + + void __init mptcp_pm_nl_init(void); + void mptcp_pm_nl_data_init(struct mptcp_sock *msk); +@@ -828,6 +829,7 @@ void mptcp_pm_nl_work(struct mptcp_sock + void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, + const struct mptcp_rm_list *rm_list); + int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); ++bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc); + unsigned int mptcp_pm_get_add_addr_signal_max(struct mptcp_sock *msk); + unsigned int mptcp_pm_get_add_addr_accept_max(struct mptcp_sock *msk); + unsigned int mptcp_pm_get_subflows_max(struct mptcp_sock *msk); +--- a/net/mptcp/subflow.c ++++ b/net/mptcp/subflow.c +@@ -97,6 +97,7 @@ static struct mptcp_sock *subflow_token_ + return NULL; + } + subflow_req->local_id = local_id; ++ subflow_req->request_bkup = mptcp_pm_is_backup(msk, (struct sock_common *)req); + + return msk; + } diff --git a/queue-5.15/mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch b/queue-5.15/mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch new file mode 100644 index 00000000000..e921c3c3b2c --- /dev/null +++ b/queue-5.15/mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch @@ -0,0 +1,41 @@ +From stable+bounces-66132-greg=kroah.com@vger.kernel.org Fri Aug 9 11:09:00 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:08:46 +0200 +Subject: mptcp: pm: only set request_bkup flag when sending MP_PRIO +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809090845.2700989-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit 4258b94831bb7ff28ab80e3c8d94db37db930728 upstream. + +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. + +Fixes: 067065422fcd ("mptcp: add the outgoing MP_PRIO support") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in pm_netlink.c, because the commit f5360e9b314c ("mptcp: + introduce and use mptcp_pm_send_ack()") is not in this version. This + code is in mptcp_pm_nl_mp_prio_send_ack() instead of in a dedicated + helper. The same modification can be applied there. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/pm_netlink.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/net/mptcp/pm_netlink.c ++++ b/net/mptcp/pm_netlink.c +@@ -699,7 +699,6 @@ int mptcp_pm_nl_mp_prio_send_ack(struct + + if (subflow->backup != bkup) + msk->last_snd = NULL; +- subflow->backup = bkup; + subflow->send_mp_prio = 1; + subflow->request_bkup = bkup; + __MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPPRIOTX); diff --git a/queue-5.15/mptcp-sched-check-both-directions-for-backup.patch b/queue-5.15/mptcp-sched-check-both-directions-for-backup.patch new file mode 100644 index 00000000000..27d42e5405e --- /dev/null +++ b/queue-5.15/mptcp-sched-check-both-directions-for-backup.patch @@ -0,0 +1,87 @@ +From matttbe@kernel.org Fri Aug 9 11:05:44 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:05:31 +0200 +Subject: mptcp: sched: check both directions for backup +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809090530.2696742-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit b6a66e521a2032f7fcba2af5a9bcbaeaa19b7ca3 upstream. + +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. + +Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in protocol.c, because the context has changed in commit + 3ce0852c86b9 ("mptcp: enforce HoL-blocking estimation"), which is not + in this version. This commit is unrelated to this modification. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + include/trace/events/mptcp.h | 2 +- + net/mptcp/protocol.c | 10 ++++++---- + 2 files changed, 7 insertions(+), 5 deletions(-) + +--- a/include/trace/events/mptcp.h ++++ b/include/trace/events/mptcp.h +@@ -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); +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -1514,13 +1514,15 @@ static struct sock *mptcp_subflow_get_se + send_info[i].ratio = -1; + } + 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; + if (!sk_stream_memory_free(subflow->tcp_sock) || !tcp_sk(ssk)->snd_wnd) + continue; + +@@ -1530,9 +1532,9 @@ static struct sock *mptcp_subflow_get_se + + ratio = div_u64((u64)READ_ONCE(ssk->sk_wmem_queued) << 32, + pace); +- if (ratio < send_info[subflow->backup].ratio) { +- send_info[subflow->backup].ssk = ssk; +- send_info[subflow->backup].ratio = ratio; ++ if (ratio < send_info[backup].ratio) { ++ send_info[backup].ssk = ssk; ++ send_info[backup].ratio = ratio; + } + } + __mptcp_set_timeout(sk, tout); diff --git a/queue-5.15/selftests-mptcp-join-check-backup-support-in-signal-endp.patch b/queue-5.15/selftests-mptcp-join-check-backup-support-in-signal-endp.patch new file mode 100644 index 00000000000..bdf82d69758 --- /dev/null +++ b/queue-5.15/selftests-mptcp-join-check-backup-support-in-signal-endp.patch @@ -0,0 +1,76 @@ +From matttbe@kernel.org Fri Aug 9 11:10:41 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:10:32 +0200 +Subject: selftests: mptcp: join: check backup support in signal endp +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809091031.2703339-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit f833470c27832136d4416d8fc55d658082af0989 upstream. + +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. + +Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in mptcp_join.sh because 'run_tests' helper has been + modified in multiple commits that are not in this version, e.g. commit + e571fb09c893 ("selftests: mptcp: add speed env var") and commit + ae7bd9ccecc3 ("selftests: mptcp: join: option to execute specific + tests"). Adaptations have been made to use the old way, similar to + what is done around. + Also in this version, there is no "single address with port, backup" + subtest. Same for "mpc backup both sides". ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -1588,10 +1588,19 @@ backup_tests() + # single address, backup + reset + ip netns exec $ns1 ./pm_nl_ctl limits 0 1 ++ ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal,backup ++ ip netns exec $ns2 ./pm_nl_ctl limits 1 1 ++ run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup ++ chk_join_nr "single address, backup" 1 1 1 ++ chk_add_nr 1 1 ++ chk_prio_nr 1 0 0 1 ++ ++ reset ++ ip netns exec $ns1 ./pm_nl_ctl limits 0 1 + ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal + ip netns exec $ns2 ./pm_nl_ctl limits 1 1 + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup +- chk_join_nr "single address, backup" 1 1 1 ++ chk_join_nr "single address, switch to backup" 1 1 1 + chk_add_nr 1 1 + chk_prio_nr 1 0 0 0 + } diff --git a/queue-5.15/selftests-mptcp-join-validate-backup-in-mpj.patch b/queue-5.15/selftests-mptcp-join-validate-backup-in-mpj.patch new file mode 100644 index 00000000000..53bc10eb82b --- /dev/null +++ b/queue-5.15/selftests-mptcp-join-validate-backup-in-mpj.patch @@ -0,0 +1,106 @@ +From stable+bounces-66135-greg=kroah.com@vger.kernel.org Fri Aug 9 11:10:22 2024 +From: "Matthieu Baerts (NGI0)" +Date: Fri, 9 Aug 2024 11:10:03 +0200 +Subject: selftests: mptcp: join: validate backup in MPJ +To: stable@vger.kernel.org, gregkh@linuxfoundation.org +Cc: MPTCP Upstream , "Matthieu Baerts (NGI0)" , Mat Martineau , Paolo Abeni +Message-ID: <20240809091002.2702612-2-matttbe@kernel.org> + +From: "Matthieu Baerts (NGI0)" + +commit 935ff5bb8a1cfcdf8e60c8f5c794d0bbbc234437 upstream. + +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. + +Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows") +Cc: stable@vger.kernel.org +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Paolo Abeni +[ Conflicts in mptcp_join.sh because the check are done has changed, + e.g. in commit 03668c65d153 ("selftests: mptcp: join: rework detailed + report"), or commit 985de45923e2 ("selftests: mptcp: centralize stats + dumping"), etc. Adaptations have been made to use the old way, similar + to what is done just above. + Also, in this version, some subtests are missing. Only the two using + chk_prio_nr() have been modified. ] +Signed-off-by: Matthieu Baerts (NGI0) +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 ++++++++++++++++++++++-- + 1 file changed, 28 insertions(+), 2 deletions(-) + +--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh +@@ -925,6 +925,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 + local dump_stats + +@@ -952,6 +954,30 @@ chk_prio_nr() + echo "[ ok ]" + fi + ++ printf "%-39s %s" " " "bkp syn" ++ count=$(get_counter ${ns1} "MPTcpExtMPJoinSynBackupRx") ++ if [ -z "$count" ]; then ++ echo -n "[skip]" ++ elif [ "$count" != "$mpj_syn" ]; then ++ echo "[fail] got $count JOIN[s] syn with Backup expected $mpj_syn" ++ ret=1 ++ dump_stats=1 ++ else ++ echo -n "[ ok ]" ++ fi ++ ++ echo -n " - synack " ++ count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckBackupRx") ++ if [ -z "$count" ]; then ++ echo "[skip]" ++ elif [ "$count" != "$mpj_syn_ack" ]; then ++ echo "[fail] got $count JOIN[s] synack with Backup expected $mpj_syn_ack" ++ ret=1 ++ dump_stats=1 ++ else ++ echo "[ ok ]" ++ fi ++ + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp +@@ -1557,7 +1583,7 @@ backup_tests() + ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow,backup + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow nobackup + chk_join_nr "single subflow, backup" 1 1 1 +- chk_prio_nr 0 1 ++ chk_prio_nr 0 1 1 0 + + # single address, backup + reset +@@ -1567,7 +1593,7 @@ backup_tests() + run_tests $ns1 $ns2 10.0.1.1 0 0 0 slow backup + chk_join_nr "single address, backup" 1 1 1 + chk_add_nr 1 1 +- chk_prio_nr 1 0 ++ chk_prio_nr 1 0 0 0 + } + + add_addr_ports_tests() diff --git a/queue-5.15/series b/queue-5.15/series index 53d670998db..444a6de15b4 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -472,3 +472,13 @@ sched-smt-introduce-sched_smt_present_inc-dec-helper.patch sched-smt-fix-unbalance-sched_smt_present-dec-inc.patch drm-bridge-analogix_dp-properly-handle-zero-sized-aux-transactions.patch drm-mgag200-set-ddc-timeout-in-milliseconds.patch +mptcp-sched-check-both-directions-for-backup.patch +mptcp-distinguish-rcv-vs-sent-backup-flag-in-requests.patch +mptcp-fix-nl-pm-announced-address-accounting.patch +mptcp-mib-count-mpj-with-backup-flag.patch +mptcp-fix-bad-rcvpruned-mib-accounting.patch +mptcp-pm-only-set-request_bkup-flag-when-sending-mp_prio.patch +mptcp-export-local_address.patch +mptcp-pm-fix-backup-support-in-signal-endpoints.patch +selftests-mptcp-join-validate-backup-in-mpj.patch +selftests-mptcp-join-check-backup-support-in-signal-endp.patch -- 2.47.3