diff mbox series

[net-next,v3,4/8] selftests/net: Open /proc/thread-self in open_netns()

Message ID 20240815-tcp-ao-selftests-upd-6-12-v3-4-7bd2e22bb81c@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net/selftests: TCP-AO selftests updates | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-16--21-00 (tests: 710)

Commit Message

Dmitry Safonov via B4 Relay Aug. 15, 2024, 9:32 p.m. UTC
From: Dmitry Safonov <0x7f454c46@gmail.com>

It turns to be that open_netns() is called rarely from the child-thread
and more often from parent-thread. Yet, on initialization of kconfig
checks, either of threads may reach kconfig_lock mutex first.
VRF-related checks do create a temprary ksft-check VRF in
an unshare()'d namespace and than setns() back to the original.
As original was opened from "/proc/self/ns/net", it's valid for
thread-leader (parent), but it's invalid for the child, resulting
in the following failure on tests that check has_vrfs() support:
> # ok 54 TCP-AO required on socket + TCP-MD5 key: prefailed as expected: Key was rejected by service
> # not ok 55 # error 381[unsigned-md5.c:24] Failed to add a VRF: -17
> # not ok 56 # error 383[unsigned-md5.c:33] Failed to add a route to VRF: -22: Key was rejected by service
> not ok 1 selftests: net/tcp_ao: unsigned-md5_ipv6 # exit=1

Use "/proc/thread-self/ns/net" which is valid for any thread.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
---
 tools/testing/selftests/net/tcp_ao/lib/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Aug. 21, 2024, 7:11 p.m. UTC | #1
On Thu, Aug 15, 2024 at 10:32:29PM +0100, Dmitry Safonov via B4 Relay wrote:
> From: Dmitry Safonov <0x7f454c46@gmail.com>
> 
> It turns to be that open_netns() is called rarely from the child-thread
> and more often from parent-thread. Yet, on initialization of kconfig
> checks, either of threads may reach kconfig_lock mutex first.
> VRF-related checks do create a temprary ksft-check VRF in

nit: temporary

     Flagged by checkpatch.pl --codespell

> an unshare()'d namespace and than setns() back to the original.
> As original was opened from "/proc/self/ns/net", it's valid for
> thread-leader (parent), but it's invalid for the child, resulting
> in the following failure on tests that check has_vrfs() support:
> > # ok 54 TCP-AO required on socket + TCP-MD5 key: prefailed as expected: Key was rejected by service
> > # not ok 55 # error 381[unsigned-md5.c:24] Failed to add a VRF: -17
> > # not ok 56 # error 383[unsigned-md5.c:33] Failed to add a route to VRF: -22: Key was rejected by service
> > not ok 1 selftests: net/tcp_ao: unsigned-md5_ipv6 # exit=1
> 
> Use "/proc/thread-self/ns/net" which is valid for any thread.
> 
> Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>

...
Dmitry Safonov Aug. 21, 2024, 9:44 p.m. UTC | #2
On Wed, 21 Aug 2024 at 20:11, Simon Horman <horms@kernel.org> wrote:
>
> On Thu, Aug 15, 2024 at 10:32:29PM +0100, Dmitry Safonov via B4 Relay wrote:
> > From: Dmitry Safonov <0x7f454c46@gmail.com>
> >
> > It turns to be that open_netns() is called rarely from the child-thread
> > and more often from parent-thread. Yet, on initialization of kconfig
> > checks, either of threads may reach kconfig_lock mutex first.
> > VRF-related checks do create a temprary ksft-check VRF in
>
> nit: temporary
>
>      Flagged by checkpatch.pl --codespell

A-ha, b4 has this b4.prep-perpatch-check-cmd git setting:
https://github.com/mricon/b4/blob/37811c93f50e70f325e45107a9a20ffc69f2f6dc/src/b4/ez.py#L1667C20-L1667C43

Going to set it and hopefully, it will help avoid spellings/typos in
future, thanks!
Simon Horman Aug. 22, 2024, 10:14 a.m. UTC | #3
On Wed, Aug 21, 2024 at 10:44:30PM +0100, Dmitry Safonov wrote:
> On Wed, 21 Aug 2024 at 20:11, Simon Horman <horms@kernel.org> wrote:
> >
> > On Thu, Aug 15, 2024 at 10:32:29PM +0100, Dmitry Safonov via B4 Relay wrote:
> > > From: Dmitry Safonov <0x7f454c46@gmail.com>
> > >
> > > It turns to be that open_netns() is called rarely from the child-thread
> > > and more often from parent-thread. Yet, on initialization of kconfig
> > > checks, either of threads may reach kconfig_lock mutex first.
> > > VRF-related checks do create a temprary ksft-check VRF in
> >
> > nit: temporary
> >
> >      Flagged by checkpatch.pl --codespell
> 
> A-ha, b4 has this b4.prep-perpatch-check-cmd git setting:
> https://github.com/mricon/b4/blob/37811c93f50e70f325e45107a9a20ffc69f2f6dc/src/b4/ez.py#L1667C20-L1667C43
> 
> Going to set it and hopefully, it will help avoid spellings/typos in
> future, thanks!

--codespell is very handy for that :)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/tcp_ao/lib/setup.c b/tools/testing/selftests/net/tcp_ao/lib/setup.c
index e408b9243b2c..d5212ffe9489 100644
--- a/tools/testing/selftests/net/tcp_ao/lib/setup.c
+++ b/tools/testing/selftests/net/tcp_ao/lib/setup.c
@@ -111,7 +111,7 @@  static void sig_int(int signo)
 
 int open_netns(void)
 {
-	const char *netns_path = "/proc/self/ns/net";
+	const char *netns_path = "/proc/thread-self/ns/net";
 	int fd;
 
 	fd = open(netns_path, O_RDONLY);