2024-06-07 16:39:16

by Matthieu Baerts (NGI0)

[permalink] [raw]
Subject: [PATCH net-next 0/6] selftests: mptcp: use net/lib.sh to manage netns

The goal of this series is to use helpers from net/lib.sh with MPTCP
selftests.

- Patches 1 to 4 are some clean-ups and preparation in net/lib.sh:

- Patch 1 simplifies the code handling errexit by ignoring possible
errors instead of disabling errexit temporary.

- Patch 2 removes the netns from the list after having cleaned it, not
to try to clean it twice.

- Patch 3 removes the 'readonly' attribute for the netns variable, to
allow using the same name in local variables.

- Patch 4 removes the local 'ns' var, not to conflict with the global
one it needs to setup.

- Patch 5 uses helpers from net/lib.sh to create and delete netns in
MPTCP selftests.

- Patch 6 uses wait_local_port_listen helper from net/net_helper.sh.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
Geliang Tang (3):
selftests: net: lib: remove 'ns' var in setup_ns
selftests: mptcp: lib: use setup/cleanup_ns helpers
selftests: mptcp: lib: use wait_local_port_listen helper

Matthieu Baerts (NGI0) (3):
selftests: net: lib: ignore possible errors
selftests: net: lib: remove ns from list after clean-up
selftests: net: lib: do not set ns var as readonly

tools/testing/selftests/net/lib.sh | 55 +++++++++++++++-----------
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 33 +++++-----------
2 files changed, 42 insertions(+), 46 deletions(-)
---
base-commit: a999973236543f0b8f6daeaa7ecba7488c3a593b
change-id: 20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-365e43e2e1ca

Best regards,
--
Matthieu Baerts (NGI0) <[email protected]>



2024-06-07 16:41:50

by Matthieu Baerts (NGI0)

[permalink] [raw]
Subject: [PATCH net-next 5/6] selftests: mptcp: lib: use setup/cleanup_ns helpers

From: Geliang Tang <[email protected]>

This patch includes lib.sh into mptcp_lib.sh, uses setup_ns helper
defined in lib.sh to set up namespaces in mptcp_lib_ns_init(), and
uses cleanup_ns to delete namespaces in mptcp_lib_ns_exit().

Signed-off-by: Geliang Tang <[email protected]>
Reviewed-by: Matthieu Baerts (NGI0) <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 6ffa9b7a3260..d9e30516dc72 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -1,6 +1,8 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0

+. "$(dirname "${0}")/../lib.sh"
+
readonly KSFT_PASS=0
readonly KSFT_FAIL=1
readonly KSFT_SKIP=4
@@ -438,17 +440,13 @@ mptcp_lib_check_tools() {
}

mptcp_lib_ns_init() {
- local sec rndh
-
- sec=$(date +%s)
- rndh=$(printf %x "${sec}")-$(mktemp -u XXXXXX)
+ if ! setup_ns ${@}; then
+ mptcp_lib_pr_fail "Failed to setup namespace ${@}"
+ exit ${KSFT_FAIL}
+ fi

local netns
for netns in "${@}"; do
- eval "${netns}=${netns}-${rndh}"
-
- ip netns add "${!netns}" || exit ${KSFT_SKIP}
- ip -net "${!netns}" link set lo up
ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=1
ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=0
ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=0
@@ -456,9 +454,10 @@ mptcp_lib_ns_init() {
}

mptcp_lib_ns_exit() {
+ cleanup_ns "${@}"
+
local netns
for netns in "${@}"; do
- ip netns del "${netns}"
rm -f /tmp/"${netns}".{nstat,out}
done
}

--
2.43.0


2024-06-12 03:01:43

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 0/6] selftests: mptcp: use net/lib.sh to manage netns

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Fri, 07 Jun 2024 18:31:01 +0200 you wrote:
> The goal of this series is to use helpers from net/lib.sh with MPTCP
> selftests.
>
> - Patches 1 to 4 are some clean-ups and preparation in net/lib.sh:
>
> - Patch 1 simplifies the code handling errexit by ignoring possible
> errors instead of disabling errexit temporary.
>
> [...]

Here is the summary with links:
- [net-next,1/6] selftests: net: lib: ignore possible errors
https://git.kernel.org/netdev/net-next/c/7e0620bc6a5e
- [net-next,2/6] selftests: net: lib: remove ns from list after clean-up
https://git.kernel.org/netdev/net-next/c/92fe5670271a
- [net-next,3/6] selftests: net: lib: do not set ns var as readonly
https://git.kernel.org/netdev/net-next/c/577db6bd5750
- [net-next,4/6] selftests: net: lib: remove 'ns' var in setup_ns
https://git.kernel.org/netdev/net-next/c/f8a2d2f874b7
- [net-next,5/6] selftests: mptcp: lib: use setup/cleanup_ns helpers
https://git.kernel.org/netdev/net-next/c/f265d3119a29
- [net-next,6/6] selftests: mptcp: lib: use wait_local_port_listen helper
https://git.kernel.org/netdev/net-next/c/1af3bc912eac

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html