]> www.infradead.org Git - users/hch/xfs.git/commit
selftests: net: lib: avoid error removing empty netns name
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Wed, 5 Jun 2024 09:21:17 +0000 (11:21 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Jun 2024 15:29:07 +0000 (08:29 -0700)
commit79322174bcc780b99795cb89d237b26006a8b94b
treed2b93cdba177f829f4c90306e8d63ea4235f8170
parent41b02ea4c0adfcc6761fbfed42c3ce6b6412d881
selftests: net: lib: avoid error removing empty netns name

If there is an error to create the first netns with 'setup_ns()',
'cleanup_ns()' will be called with an empty string as first parameter.

The consequences is that 'cleanup_ns()' will try to delete an invalid
netns, and wait 20 seconds if the netns list is empty.

Instead of just checking if the name is not empty, convert the string
separated by spaces to an array. Manipulating the array is cleaner, and
calling 'cleanup_ns()' with an empty array will be a no-op.

Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
Cc: stable@vger.kernel.org
Acked-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20240605-upstream-net-20240605-selftests-net-lib-fixes-v1-2-b3afadd368c9@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/lib.sh