]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Feb 2024 10:27:47 +0000 (11:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Feb 2024 10:27:47 +0000 (11:27 +0100)
added patches:
mm-zswap-fix-missing-folio-cleanup-in-writeback-race-path.patch
mm-zswap-invalidate-duplicate-entry-when-zswap_enabled.patch
mptcp-add-needs_id-for-netlink-appending-addr.patch
mptcp-userspace-pm-send-rm_addr-for-id-0.patch
selftests-mptcp-add-mptcp_lib_get_counter.patch
selftests-mptcp-join-stop-transfer-when-check-is-done-part-1.patch
selftests-mptcp-join-stop-transfer-when-check-is-done-part-2.patch

queue-6.6/mm-zswap-fix-missing-folio-cleanup-in-writeback-race-path.patch [new file with mode: 0644]
queue-6.6/mm-zswap-invalidate-duplicate-entry-when-zswap_enabled.patch [new file with mode: 0644]
queue-6.6/mptcp-add-needs_id-for-netlink-appending-addr.patch [new file with mode: 0644]
queue-6.6/mptcp-userspace-pm-send-rm_addr-for-id-0.patch [new file with mode: 0644]
queue-6.6/selftests-mptcp-add-mptcp_lib_get_counter.patch [new file with mode: 0644]
queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-1.patch [new file with mode: 0644]
queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-2.patch [new file with mode: 0644]
queue-6.6/series

diff --git a/queue-6.6/mm-zswap-fix-missing-folio-cleanup-in-writeback-race-path.patch b/queue-6.6/mm-zswap-fix-missing-folio-cleanup-in-writeback-race-path.patch
new file mode 100644 (file)
index 0000000..2469343
--- /dev/null
@@ -0,0 +1,48 @@
+From e3b63e966cac0bf78aaa1efede1827a252815a1d Mon Sep 17 00:00:00 2001
+From: Yosry Ahmed <yosryahmed@google.com>
+Date: Thu, 25 Jan 2024 08:51:27 +0000
+Subject: mm: zswap: fix missing folio cleanup in writeback race path
+
+From: Yosry Ahmed <yosryahmed@google.com>
+
+commit e3b63e966cac0bf78aaa1efede1827a252815a1d upstream.
+
+In zswap_writeback_entry(), after we get a folio from
+__read_swap_cache_async(), we grab the tree lock again to check that the
+swap entry was not invalidated and recycled.  If it was, we delete the
+folio we just added to the swap cache and exit.
+
+However, __read_swap_cache_async() returns the folio locked when it is
+newly allocated, which is always true for this path, and the folio is
+ref'd.  Make sure to unlock and put the folio before returning.
+
+This was discovered by code inspection, probably because this path handles
+a race condition that should not happen often, and the bug would not crash
+the system, it will only strand the folio indefinitely.
+
+Link: https://lkml.kernel.org/r/20240125085127.1327013-1-yosryahmed@google.com
+Fixes: 04fc7816089c ("mm: fix zswap writeback race condition")
+Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
+Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
+Acked-by: Johannes Weiner <hannes@cmpxchg.org>
+Reviewed-by: Nhat Pham <nphamcs@gmail.com>
+Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ mm/zswap.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/mm/zswap.c
++++ b/mm/zswap.c
+@@ -1100,6 +1100,8 @@ static int zswap_writeback_entry(struct
+       if (zswap_rb_search(&tree->rbroot, swp_offset(entry->swpentry)) != entry) {
+               spin_unlock(&tree->lock);
+               delete_from_swap_cache(page_folio(page));
++              unlock_page(page);
++              put_page(page);
+               ret = -ENOMEM;
+               goto fail;
+       }
diff --git a/queue-6.6/mm-zswap-invalidate-duplicate-entry-when-zswap_enabled.patch b/queue-6.6/mm-zswap-invalidate-duplicate-entry-when-zswap_enabled.patch
new file mode 100644 (file)
index 0000000..c709ef6
--- /dev/null
@@ -0,0 +1,49 @@
+From 678e54d4bb9a4822f8ae99690ac131c5d490cdb1 Mon Sep 17 00:00:00 2001
+From: Chengming Zhou <zhouchengming@bytedance.com>
+Date: Thu, 8 Feb 2024 02:32:54 +0000
+Subject: mm/zswap: invalidate duplicate entry when !zswap_enabled
+
+From: Chengming Zhou <zhouchengming@bytedance.com>
+
+commit 678e54d4bb9a4822f8ae99690ac131c5d490cdb1 upstream.
+
+We have to invalidate any duplicate entry even when !zswap_enabled since
+zswap can be disabled anytime.  If the folio store success before, then
+got dirtied again but zswap disabled, we won't invalidate the old
+duplicate entry in the zswap_store().  So later lru writeback may
+overwrite the new data in swapfile.
+
+Link: https://lkml.kernel.org/r/20240208023254.3873823-1-chengming.zhou@linux.dev
+Fixes: 42c06a0e8ebe ("mm: kill frontswap")
+Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
+Acked-by: Johannes Weiner <hannes@cmpxchg.org>
+Cc: Nhat Pham <nphamcs@gmail.com>
+Cc: Yosry Ahmed <yosryahmed@google.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ mm/zswap.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/mm/zswap.c
++++ b/mm/zswap.c
+@@ -1215,7 +1215,7 @@ bool zswap_store(struct folio *folio)
+       if (folio_test_large(folio))
+               return false;
+-      if (!zswap_enabled || !tree)
++      if (!tree)
+               return false;
+       /*
+@@ -1231,6 +1231,9 @@ bool zswap_store(struct folio *folio)
+       }
+       spin_unlock(&tree->lock);
++      if (!zswap_enabled)
++              return false;
++
+       /*
+        * XXX: zswap reclaim does not work with cgroups yet. Without a
+        * cgroup-aware entry LRU, we will push out entries system-wide based on
diff --git a/queue-6.6/mptcp-add-needs_id-for-netlink-appending-addr.patch b/queue-6.6/mptcp-add-needs_id-for-netlink-appending-addr.patch
new file mode 100644 (file)
index 0000000..e363f2e
--- /dev/null
@@ -0,0 +1,99 @@
+From 584f3894262634596532cf43a5e782e34a0ce374 Mon Sep 17 00:00:00 2001
+From: Geliang Tang <tanggeliang@kylinos.cn>
+Date: Thu, 15 Feb 2024 19:25:29 +0100
+Subject: mptcp: add needs_id for netlink appending addr
+
+From: Geliang Tang <tanggeliang@kylinos.cn>
+
+commit 584f3894262634596532cf43a5e782e34a0ce374 upstream.
+
+Just the same as userspace PM, a new parameter needs_id is added for
+in-kernel PM mptcp_pm_nl_append_new_local_addr() too.
+
+Add a new helper mptcp_pm_has_addr_attr_id() to check whether an address
+ID is set from PM or not.
+
+In mptcp_pm_nl_get_local_id(), needs_id is always true, but in
+mptcp_pm_nl_add_addr_doit(), pass mptcp_pm_has_addr_attr_id() to
+needs_it.
+
+Fixes: efd5a4c04e18 ("mptcp: add the address ID assignment bitmap")
+Cc: stable@vger.kernel.org
+Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
+Reviewed-by: Mat Martineau <martineau@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/mptcp/pm_netlink.c |   24 +++++++++++++++++++-----
+ 1 file changed, 19 insertions(+), 5 deletions(-)
+
+--- a/net/mptcp/pm_netlink.c
++++ b/net/mptcp/pm_netlink.c
+@@ -904,7 +904,8 @@ static void __mptcp_pm_release_addr_entr
+ }
+ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
+-                                           struct mptcp_pm_addr_entry *entry)
++                                           struct mptcp_pm_addr_entry *entry,
++                                           bool needs_id)
+ {
+       struct mptcp_pm_addr_entry *cur, *del_entry = NULL;
+       unsigned int addr_max;
+@@ -952,7 +953,7 @@ static int mptcp_pm_nl_append_new_local_
+               }
+       }
+-      if (!entry->addr.id) {
++      if (!entry->addr.id && needs_id) {
+ find_next:
+               entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
+                                                   MPTCP_PM_MAX_ADDR_ID + 1,
+@@ -963,7 +964,7 @@ find_next:
+               }
+       }
+-      if (!entry->addr.id)
++      if (!entry->addr.id && needs_id)
+               goto out;
+       __set_bit(entry->addr.id, pernet->id_bitmap);
+@@ -1095,7 +1096,7 @@ int mptcp_pm_nl_get_local_id(struct mptc
+       entry->ifindex = 0;
+       entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
+       entry->lsk = NULL;
+-      ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
++      ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
+       if (ret < 0)
+               kfree(entry);
+@@ -1311,6 +1312,18 @@ next:
+       return 0;
+ }
++static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
++                                    struct genl_info *info)
++{
++      struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
++
++      if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
++                                       mptcp_pm_addr_policy, info->extack) &&
++          tb[MPTCP_PM_ADDR_ATTR_ID])
++              return true;
++      return false;
++}
++
+ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info)
+ {
+       struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
+@@ -1352,7 +1365,8 @@ static int mptcp_nl_cmd_add_addr(struct
+                       goto out_free;
+               }
+       }
+-      ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
++      ret = mptcp_pm_nl_append_new_local_addr(pernet, entry,
++                                              !mptcp_pm_has_addr_attr_id(attr, info));
+       if (ret < 0) {
+               GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", ret);
+               goto out_free;
diff --git a/queue-6.6/mptcp-userspace-pm-send-rm_addr-for-id-0.patch b/queue-6.6/mptcp-userspace-pm-send-rm_addr-for-id-0.patch
new file mode 100644 (file)
index 0000000..405a4de
--- /dev/null
@@ -0,0 +1,85 @@
+From 84c531f54ad9a124a924c9505d74e33d16965146 Mon Sep 17 00:00:00 2001
+From: Geliang Tang <geliang.tang@suse.com>
+Date: Wed, 25 Oct 2023 16:37:04 -0700
+Subject: mptcp: userspace pm send RM_ADDR for ID 0
+
+From: Geliang Tang <geliang.tang@suse.com>
+
+commit 84c531f54ad9a124a924c9505d74e33d16965146 upstream.
+
+This patch adds the ability to send RM_ADDR for local ID 0. Check
+whether id 0 address is removed, if not, put id 0 into a removing
+list, pass it to mptcp_pm_remove_addr() to remove id 0 address.
+
+There is no reason not to allow the userspace to remove the initial
+address (ID 0). This special case was not taken into account not
+letting the userspace to delete all addresses as announced.
+
+Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/379
+Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
+Signed-off-by: Geliang Tang <geliang.tang@suse.com>
+Signed-off-by: Mat Martineau <martineau@kernel.org>
+Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-3-db8f25f798eb@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/mptcp/pm_userspace.c |   39 +++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 39 insertions(+)
+
+--- a/net/mptcp/pm_userspace.c
++++ b/net/mptcp/pm_userspace.c
+@@ -220,6 +220,40 @@ int mptcp_nl_cmd_announce(struct sk_buff
+       return err;
+ }
++static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
++                                                   struct genl_info *info)
++{
++      struct mptcp_rm_list list = { .nr = 0 };
++      struct mptcp_subflow_context *subflow;
++      struct sock *sk = (struct sock *)msk;
++      bool has_id_0 = false;
++      int err = -EINVAL;
++
++      lock_sock(sk);
++      mptcp_for_each_subflow(msk, subflow) {
++              if (subflow->local_id == 0) {
++                      has_id_0 = true;
++                      break;
++              }
++      }
++      if (!has_id_0) {
++              GENL_SET_ERR_MSG(info, "address with id 0 not found");
++              goto remove_err;
++      }
++
++      list.ids[list.nr++] = 0;
++
++      spin_lock_bh(&msk->pm.lock);
++      mptcp_pm_remove_addr(msk, &list);
++      spin_unlock_bh(&msk->pm.lock);
++
++      err = 0;
++
++remove_err:
++      release_sock(sk);
++      return err;
++}
++
+ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
+ {
+       struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
+@@ -251,6 +285,11 @@ int mptcp_nl_cmd_remove(struct sk_buff *
+               goto remove_err;
+       }
++      if (id_val == 0) {
++              err = mptcp_userspace_pm_remove_id_zero_address(msk, info);
++              goto remove_err;
++      }
++
+       lock_sock((struct sock *)msk);
+       list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
diff --git a/queue-6.6/selftests-mptcp-add-mptcp_lib_get_counter.patch b/queue-6.6/selftests-mptcp-add-mptcp_lib_get_counter.patch
new file mode 100644 (file)
index 0000000..e25daf8
--- /dev/null
@@ -0,0 +1,488 @@
+From 61c131f5d4d2b79904af2fdcb2839a9db8e7c55c Mon Sep 17 00:00:00 2001
+From: Geliang Tang <geliang.tang@suse.com>
+Date: Tue, 28 Nov 2023 15:18:55 -0800
+Subject: selftests: mptcp: add mptcp_lib_get_counter
+
+From: Geliang Tang <geliang.tang@suse.com>
+
+commit 61c131f5d4d2b79904af2fdcb2839a9db8e7c55c upstream.
+
+To avoid duplicated code in different MPTCP selftests, we can add
+and use helpers defined in mptcp_lib.sh.
+
+The helper get_counter() in mptcp_join.sh and get_mib_counter() in
+mptcp_connect.sh have the same functionality, export get_counter() into
+mptcp_lib.sh and rename it as mptcp_lib_get_counter(). Use this new
+helper instead of get_counter() and get_mib_counter().
+
+Use this helper in test_prio() in userspace_pm.sh too instead of
+open-coding.
+
+Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
+Signed-off-by: Geliang Tang <geliang.tang@suse.com>
+Signed-off-by: Mat Martineau <martineau@kernel.org>
+Link: https://lore.kernel.org/r/20231128-send-net-next-2023107-v4-11-8d6b94150f6b@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/net/mptcp/mptcp_connect.sh |   41 +++------
+ tools/testing/selftests/net/mptcp/mptcp_join.sh    |   88 ++++++++-------------
+ tools/testing/selftests/net/mptcp/mptcp_lib.sh     |   16 +++
+ tools/testing/selftests/net/mptcp/userspace_pm.sh  |   14 +--
+ 4 files changed, 73 insertions(+), 86 deletions(-)
+
+--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+@@ -341,21 +341,6 @@ do_ping()
+       return 0
+ }
+-# $1: ns, $2: MIB counter
+-get_mib_counter()
+-{
+-      local listener_ns="${1}"
+-      local mib="${2}"
+-
+-      # strip the header
+-      ip netns exec "${listener_ns}" \
+-              nstat -z -a "${mib}" | \
+-                      tail -n+2 | \
+-                      while read a count c rest; do
+-                              echo $count
+-                      done
+-}
+-
+ # $1: ns, $2: port
+ wait_local_port_listen()
+ {
+@@ -441,12 +426,12 @@ do_transfer()
+                       nstat -n
+       fi
+-      local stat_synrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
+-      local stat_ackrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
+-      local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
+-      local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
+-      local stat_csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
+-      local stat_csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
++      local stat_synrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
++      local stat_ackrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
++      local stat_cookietx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent")
++      local stat_cookierx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv")
++      local stat_csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr")
++      local stat_csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr")
+       timeout ${timeout_test} \
+               ip netns exec ${listener_ns} \
+@@ -509,11 +494,11 @@ do_transfer()
+       check_transfer $cin $sout "file received by server"
+       rets=$?
+-      local stat_synrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
+-      local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
+-      local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
+-      local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
+-      local stat_ooo_now=$(get_mib_counter "${listener_ns}" "TcpExtTCPOFOQueue")
++      local stat_synrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
++      local stat_ackrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
++      local stat_cookietx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent")
++      local stat_cookierx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv")
++      local stat_ooo_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtTCPOFOQueue")
+       expect_synrx=$((stat_synrx_last_l))
+       expect_ackrx=$((stat_ackrx_last_l))
+@@ -542,8 +527,8 @@ do_transfer()
+       fi
+       if $checksum; then
+-              local csum_err_s=$(get_mib_counter "${listener_ns}" "MPTcpExtDataCsumErr")
+-              local csum_err_c=$(get_mib_counter "${connector_ns}" "MPTcpExtDataCsumErr")
++              local csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr")
++              local csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr")
+               local csum_err_s_nr=$((csum_err_s - stat_csum_err_s))
+               if [ $csum_err_s_nr -gt 0 ]; then
+--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
+@@ -611,25 +611,9 @@ wait_local_port_listen()
+       done
+ }
+-# $1: ns ; $2: counter
+-get_counter()
+-{
+-      local ns="${1}"
+-      local counter="${2}"
+-      local count
+-
+-      count=$(ip netns exec ${ns} nstat -asz "${counter}" | awk 'NR==1 {next} {print $2}')
+-      if [ -z "${count}" ]; then
+-              mptcp_lib_fail_if_expected_feature "${counter} counter"
+-              return 1
+-      fi
+-
+-      echo "${count}"
+-}
+-
+ rm_addr_count()
+ {
+-      get_counter "${1}" "MPTcpExtRmAddr"
++      mptcp_lib_get_counter "${1}" "MPTcpExtRmAddr"
+ }
+ # $1: ns, $2: old rm_addr counter in $ns
+@@ -649,7 +633,7 @@ wait_rm_addr()
+ rm_sf_count()
+ {
+-      get_counter "${1}" "MPTcpExtRmSubflow"
++      mptcp_lib_get_counter "${1}" "MPTcpExtRmSubflow"
+ }
+ # $1: ns, $2: old rm_sf counter in $ns
+@@ -672,11 +656,11 @@ wait_mpj()
+       local ns="${1}"
+       local cnt old_cnt
+-      old_cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx")
++      old_cnt=$(mptcp_lib_get_counter ${ns} "MPTcpExtMPJoinAckRx")
+       local i
+       for i in $(seq 10); do
+-              cnt=$(get_counter ${ns} "MPTcpExtMPJoinAckRx")
++              cnt=$(mptcp_lib_get_counter ${ns} "MPTcpExtMPJoinAckRx")
+               [ "$cnt" = "${old_cnt}" ] || break
+               sleep 0.1
+       done
+@@ -1271,7 +1255,7 @@ chk_csum_nr()
+       fi
+       print_check "sum"
+-      count=$(get_counter ${ns1} "MPTcpExtDataCsumErr")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr")
+       if [ "$count" != "$csum_ns1" ]; then
+               extra_msg="$extra_msg ns1=$count"
+       fi
+@@ -1284,7 +1268,7 @@ chk_csum_nr()
+               print_ok
+       fi
+       print_check "csum"
+-      count=$(get_counter ${ns2} "MPTcpExtDataCsumErr")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr")
+       if [ "$count" != "$csum_ns2" ]; then
+               extra_msg="$extra_msg ns2=$count"
+       fi
+@@ -1328,7 +1312,7 @@ chk_fail_nr()
+       fi
+       print_check "ftx"
+-      count=$(get_counter ${ns_tx} "MPTcpExtMPFailTx")
++      count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx")
+       if [ "$count" != "$fail_tx" ]; then
+               extra_msg="$extra_msg,tx=$count"
+       fi
+@@ -1342,7 +1326,7 @@ chk_fail_nr()
+       fi
+       print_check "failrx"
+-      count=$(get_counter ${ns_rx} "MPTcpExtMPFailRx")
++      count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx")
+       if [ "$count" != "$fail_rx" ]; then
+               extra_msg="$extra_msg,rx=$count"
+       fi
+@@ -1375,7 +1359,7 @@ chk_fclose_nr()
+       fi
+       print_check "ctx"
+-      count=$(get_counter ${ns_tx} "MPTcpExtMPFastcloseTx")
++      count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFastcloseTx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$fclose_tx" ]; then
+@@ -1386,7 +1370,7 @@ chk_fclose_nr()
+       fi
+       print_check "fclzrx"
+-      count=$(get_counter ${ns_rx} "MPTcpExtMPFastcloseRx")
++      count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFastcloseRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$fclose_rx" ]; then
+@@ -1416,7 +1400,7 @@ chk_rst_nr()
+       fi
+       print_check "rtx"
+-      count=$(get_counter ${ns_tx} "MPTcpExtMPRstTx")
++      count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPRstTx")
+       if [ -z "$count" ]; then
+               print_skip
+       # accept more rst than expected except if we don't expect any
+@@ -1428,7 +1412,7 @@ chk_rst_nr()
+       fi
+       print_check "rstrx"
+-      count=$(get_counter ${ns_rx} "MPTcpExtMPRstRx")
++      count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPRstRx")
+       if [ -z "$count" ]; then
+               print_skip
+       # accept more rst than expected except if we don't expect any
+@@ -1449,7 +1433,7 @@ chk_infi_nr()
+       local count
+       print_check "itx"
+-      count=$(get_counter ${ns2} "MPTcpExtInfiniteMapTx")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtInfiniteMapTx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$infi_tx" ]; then
+@@ -1459,7 +1443,7 @@ chk_infi_nr()
+       fi
+       print_check "infirx"
+-      count=$(get_counter ${ns1} "MPTcpExtInfiniteMapRx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtInfiniteMapRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$infi_rx" ]; then
+@@ -1488,7 +1472,7 @@ chk_join_nr()
+       fi
+       print_check "syn"
+-      count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinSynRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$syn_nr" ]; then
+@@ -1499,7 +1483,7 @@ chk_join_nr()
+       print_check "synack"
+       with_cookie=$(ip netns exec $ns2 sysctl -n net.ipv4.tcp_syncookies)
+-      count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynAckRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$syn_ack_nr" ]; then
+@@ -1516,7 +1500,7 @@ chk_join_nr()
+       fi
+       print_check "ack"
+-      count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinAckRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$ack_nr" ]; then
+@@ -1549,8 +1533,8 @@ chk_stale_nr()
+       print_check "stale"
+-      stale_nr=$(get_counter ${ns} "MPTcpExtSubflowStale")
+-      recover_nr=$(get_counter ${ns} "MPTcpExtSubflowRecover")
++      stale_nr=$(mptcp_lib_get_counter ${ns} "MPTcpExtSubflowStale")
++      recover_nr=$(mptcp_lib_get_counter ${ns} "MPTcpExtSubflowRecover")
+       if [ -z "$stale_nr" ] || [ -z "$recover_nr" ]; then
+               print_skip
+       elif [ $stale_nr -lt $stale_min ] ||
+@@ -1587,7 +1571,7 @@ chk_add_nr()
+       timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
+       print_check "add"
+-      count=$(get_counter ${ns2} "MPTcpExtAddAddr")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtAddAddr")
+       if [ -z "$count" ]; then
+               print_skip
+       # if the test configured a short timeout tolerate greater then expected
+@@ -1599,7 +1583,7 @@ chk_add_nr()
+       fi
+       print_check "echo"
+-      count=$(get_counter ${ns1} "MPTcpExtEchoAdd")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtEchoAdd")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$echo_nr" ]; then
+@@ -1610,7 +1594,7 @@ chk_add_nr()
+       if [ $port_nr -gt 0 ]; then
+               print_check "pt"
+-              count=$(get_counter ${ns2} "MPTcpExtPortAdd")
++              count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtPortAdd")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$port_nr" ]; then
+@@ -1620,7 +1604,7 @@ chk_add_nr()
+               fi
+               print_check "syn"
+-              count=$(get_counter ${ns1} "MPTcpExtMPJoinPortSynRx")
++              count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortSynRx")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$syn_nr" ]; then
+@@ -1631,7 +1615,7 @@ chk_add_nr()
+               fi
+               print_check "synack"
+-              count=$(get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx")
++              count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$syn_ack_nr" ]; then
+@@ -1642,7 +1626,7 @@ chk_add_nr()
+               fi
+               print_check "ack"
+-              count=$(get_counter ${ns1} "MPTcpExtMPJoinPortAckRx")
++              count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortAckRx")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$ack_nr" ]; then
+@@ -1653,7 +1637,7 @@ chk_add_nr()
+               fi
+               print_check "syn"
+-              count=$(get_counter ${ns1} "MPTcpExtMismatchPortSynRx")
++              count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortSynRx")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$mis_syn_nr" ]; then
+@@ -1664,7 +1648,7 @@ chk_add_nr()
+               fi
+               print_check "ack"
+-              count=$(get_counter ${ns1} "MPTcpExtMismatchPortAckRx")
++              count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortAckRx")
+               if [ -z "$count" ]; then
+                       print_skip
+               elif [ "$count" != "$mis_ack_nr" ]; then
+@@ -1686,7 +1670,7 @@ chk_add_tx_nr()
+       timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
+       print_check "add TX"
+-      count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtAddAddrTx")
+       if [ -z "$count" ]; then
+               print_skip
+       # if the test configured a short timeout tolerate greater then expected
+@@ -1698,7 +1682,7 @@ chk_add_tx_nr()
+       fi
+       print_check "echo TX"
+-      count=$(get_counter ${ns2} "MPTcpExtEchoAddTx")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtEchoAddTx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$echo_tx_nr" ]; then
+@@ -1736,7 +1720,7 @@ chk_rm_nr()
+       fi
+       print_check "rm"
+-      count=$(get_counter ${addr_ns} "MPTcpExtRmAddr")
++      count=$(mptcp_lib_get_counter ${addr_ns} "MPTcpExtRmAddr")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$rm_addr_nr" ]; then
+@@ -1746,13 +1730,13 @@ chk_rm_nr()
+       fi
+       print_check "rmsf"
+-      count=$(get_counter ${subflow_ns} "MPTcpExtRmSubflow")
++      count=$(mptcp_lib_get_counter ${subflow_ns} "MPTcpExtRmSubflow")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ -n "$simult" ]; then
+               local cnt suffix
+-              cnt=$(get_counter ${addr_ns} "MPTcpExtRmSubflow")
++              cnt=$(mptcp_lib_get_counter ${addr_ns} "MPTcpExtRmSubflow")
+               # in case of simult flush, the subflow removal count on each side is
+               # unreliable
+@@ -1778,7 +1762,7 @@ chk_rm_tx_nr()
+       local rm_addr_tx_nr=$1
+       print_check "rm TX"
+-      count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
++      count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtRmAddrTx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$rm_addr_tx_nr" ]; then
+@@ -1795,7 +1779,7 @@ chk_prio_nr()
+       local count
+       print_check "ptx"
+-      count=$(get_counter ${ns1} "MPTcpExtMPPrioTx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPPrioTx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$mp_prio_nr_tx" ]; then
+@@ -1805,7 +1789,7 @@ chk_prio_nr()
+       fi
+       print_check "prx"
+-      count=$(get_counter ${ns1} "MPTcpExtMPPrioRx")
++      count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPPrioRx")
+       if [ -z "$count" ]; then
+               print_skip
+       elif [ "$count" != "$mp_prio_nr_rx" ]; then
+@@ -1905,7 +1889,7 @@ wait_attempt_fail()
+       while [ $time -lt $timeout_ms ]; do
+               local cnt
+-              cnt=$(get_counter ${ns} "TcpAttemptFails")
++              cnt=$(mptcp_lib_get_counter ${ns} "TcpAttemptFails")
+               [ "$cnt" = 1 ] && return 1
+               time=$((time + 100))
+--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
++++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+@@ -216,3 +216,19 @@ mptcp_lib_kill_wait() {
+       kill "${1}" > /dev/null 2>&1
+       wait "${1}" 2>/dev/null
+ }
++
++# $1: ns, $2: MIB counter
++mptcp_lib_get_counter() {
++      local ns="${1}"
++      local counter="${2}"
++      local count
++
++      count=$(ip netns exec "${ns}" nstat -asz "${counter}" |
++              awk 'NR==1 {next} {print $2}')
++      if [ -z "${count}" ]; then
++              mptcp_lib_fail_if_expected_feature "${counter} counter"
++              return 1
++      fi
++
++      echo "${count}"
++}
+--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
++++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
+@@ -887,9 +887,10 @@ test_prio()
+       # Check TX
+       print_test "MP_PRIO TX"
+-      count=$(ip netns exec "$ns2" nstat -as | grep MPTcpExtMPPrioTx | awk '{print $2}')
+-      [ -z "$count" ] && count=0
+-      if [ $count != 1 ]; then
++      count=$(mptcp_lib_get_counter "$ns2" "MPTcpExtMPPrioTx")
++      if [ -z "$count" ]; then
++              test_skip
++      elif [ $count != 1 ]; then
+               test_fail "Count != 1: ${count}"
+       else
+               test_pass
+@@ -897,9 +898,10 @@ test_prio()
+       # Check RX
+       print_test "MP_PRIO RX"
+-      count=$(ip netns exec "$ns1" nstat -as | grep MPTcpExtMPPrioRx | awk '{print $2}')
+-      [ -z "$count" ] && count=0
+-      if [ $count != 1 ]; then
++      count=$(mptcp_lib_get_counter "$ns1" "MPTcpExtMPPrioRx")
++      if [ -z "$count" ]; then
++              test_skip
++      elif [ $count != 1 ]; then
+               test_fail "Count != 1: ${count}"
+       else
+               test_pass
diff --git a/queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-1.patch b/queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-1.patch
new file mode 100644 (file)
index 0000000..cc8c8f8
--- /dev/null
@@ -0,0 +1,54 @@
+From 31ee4ad86afd6ed6f4bb1b38c43011216080c42a Mon Sep 17 00:00:00 2001
+From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
+Date: Wed, 31 Jan 2024 22:49:53 +0100
+Subject: selftests: mptcp: join: stop transfer when check is done (part 1)
+
+From: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+
+commit 31ee4ad86afd6ed6f4bb1b38c43011216080c42a upstream.
+
+Since the "Fixes" commit mentioned below, "userspace pm" subtests of
+mptcp_join selftests introduced in v6.5 are launching the whole transfer
+in the background, do the required checks, then wait for the end of
+transfer.
+
+There is no need to wait longer, especially because the checks at the
+end of the transfer are ignored (which is fine). This saves quite a few
+seconds in slow environments.
+
+Note that old versions will need commit bdbef0a6ff10 ("selftests: mptcp:
+add mptcp_lib_kill_wait") as well to get 'mptcp_lib_kill_wait()' helper.
+
+Fixes: 4369c198e599 ("selftests: mptcp: test userspace pm out of transfer")
+Cc: stable@vger.kernel.org # 6.5.x: bdbef0a6ff10: selftests: mptcp: add mptcp_lib_kill_wait
+Cc: stable@vger.kernel.org # 6.5.x
+Reviewed-and-tested-by: Geliang Tang <geliang@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Link: https://lore.kernel.org/r/20240131-upstream-net-20240131-mptcp-ci-issues-v1-8-4c1c11e571ff@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/net/mptcp/mptcp_join.sh |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
+@@ -3430,7 +3430,7 @@ userspace_tests()
+               chk_rm_nr 1 1 invert
+               chk_mptcp_info subflows 0 subflows 0
+               kill_events_pids
+-              wait $tests_pid
++              mptcp_lib_kill_wait $tests_pid
+       fi
+       # userspace pm create destroy subflow
+@@ -3449,7 +3449,7 @@ userspace_tests()
+               chk_rm_nr 1 1
+               chk_mptcp_info subflows 0 subflows 0
+               kill_events_pids
+-              wait $tests_pid
++              mptcp_lib_kill_wait $tests_pid
+       fi
+ }
diff --git a/queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-2.patch b/queue-6.6/selftests-mptcp-join-stop-transfer-when-check-is-done-part-2.patch
new file mode 100644 (file)
index 0000000..0f9c40b
--- /dev/null
@@ -0,0 +1,89 @@
+From 04b57c9e096a9479fe0ad31e3956e336fa589cb2 Mon Sep 17 00:00:00 2001
+From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
+Date: Wed, 31 Jan 2024 22:49:54 +0100
+Subject: selftests: mptcp: join: stop transfer when check is done (part 2)
+
+From: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+
+commit 04b57c9e096a9479fe0ad31e3956e336fa589cb2 upstream.
+
+Since the "Fixes" commits mentioned below, the newly added "userspace
+pm" subtests of mptcp_join selftests are launching the whole transfer in
+the background, do the required checks, then wait for the end of
+transfer.
+
+There is no need to wait longer, especially because the checks at the
+end of the transfer are ignored (which is fine). This saves quite a few
+seconds on slow environments.
+
+While at it, use 'mptcp_lib_kill_wait()' helper everywhere, instead of
+on a specific one with 'kill_tests_wait()'.
+
+Fixes: b2e2248f365a ("selftests: mptcp: userspace pm create id 0 subflow")
+Fixes: e3b47e460b4b ("selftests: mptcp: userspace pm remove initial subflow")
+Fixes: b9fb176081fb ("selftests: mptcp: userspace pm send RM_ADDR for ID 0")
+Cc: stable@vger.kernel.org
+Reviewed-and-tested-by: Geliang Tang <geliang@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Link: https://lore.kernel.org/r/20240131-upstream-net-20240131-mptcp-ci-issues-v1-9-4c1c11e571ff@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/testing/selftests/net/mptcp/mptcp_join.sh |   17 ++++++-----------
+ 1 file changed, 6 insertions(+), 11 deletions(-)
+
+--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
++++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
+@@ -688,13 +688,6 @@ kill_events_pids()
+       mptcp_lib_kill_wait $evts_ns2_pid
+ }
+-kill_tests_wait()
+-{
+-      #shellcheck disable=SC2046
+-      kill -SIGUSR1 $(ip netns pids $ns2) $(ip netns pids $ns1)
+-      wait
+-}
+-
+ pm_nl_set_limits()
+ {
+       local ns=$1
+@@ -3463,7 +3456,8 @@ endpoint_tests()
+               pm_nl_set_limits $ns2 2 2
+               pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
+               speed=slow \
+-                      run_tests $ns1 $ns2 10.0.1.1 2>/dev/null &
++                      run_tests $ns1 $ns2 10.0.1.1 &
++              local tests_pid=$!
+               wait_mpj $ns1
+               pm_nl_check_endpoint "creation" \
+@@ -3478,7 +3472,7 @@ endpoint_tests()
+               pm_nl_add_endpoint $ns2 10.0.2.2 flags signal
+               pm_nl_check_endpoint "modif is allowed" \
+                       $ns2 10.0.2.2 id 1 flags signal
+-              kill_tests_wait
++              mptcp_lib_kill_wait $tests_pid
+       fi
+       if reset "delete and re-add" &&
+@@ -3487,7 +3481,8 @@ endpoint_tests()
+               pm_nl_set_limits $ns2 1 1
+               pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow
+               test_linkfail=4 speed=20 \
+-                      run_tests $ns1 $ns2 10.0.1.1 2>/dev/null &
++                      run_tests $ns1 $ns2 10.0.1.1 &
++              local tests_pid=$!
+               wait_mpj $ns2
+               chk_subflow_nr "before delete" 2
+@@ -3502,7 +3497,7 @@ endpoint_tests()
+               wait_mpj $ns2
+               chk_subflow_nr "after re-add" 2
+               chk_mptcp_info subflows 1 subflows 1
+-              kill_tests_wait
++              mptcp_lib_kill_wait $tests_pid
+       fi
+ }
index 67468632e699ae3b3a20a47aa62494023134e89c..53510b38630034f59c3b640cfdddf6a217110e56 100644 (file)
@@ -288,3 +288,10 @@ drm-syncobj-handle-null-fence-in-syncobj_eventfd_ent.patch
 selftests-iommu-fix-the-config-fragment.patch
 drm-amd-display-fix-memory-leak-in-dm_sw_fini.patch
 i2c-imx-when-being-a-target-mark-the-last-read-as-pr.patch
+selftests-mptcp-join-stop-transfer-when-check-is-done-part-1.patch
+mm-zswap-invalidate-duplicate-entry-when-zswap_enabled.patch
+mm-zswap-fix-missing-folio-cleanup-in-writeback-race-path.patch
+selftests-mptcp-join-stop-transfer-when-check-is-done-part-2.patch
+selftests-mptcp-add-mptcp_lib_get_counter.patch
+mptcp-userspace-pm-send-rm_addr-for-id-0.patch
+mptcp-add-needs_id-for-netlink-appending-addr.patch