All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] nfsstat02.sh: Properly fix netns enforcement
@ 2026-10-30 11:36 Petr Vorel
  2026-10-30 13:37 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2026-10-30 11:36 UTC (permalink / raw)
  To: ltp; +Cc: Sebastian Chlad

RHOST is not the only variable needed for 2 hosts setup. Add
tst_net_unset_2_hosts_variables() into tst_net.sh which unsets other
NIC related 2 hosts variables and use it in nfsstat02.sh.

Although this is the only test which needs it so far, it's better to
have code in a separate function to avoid the same problem when needed
in other tests in the future.

Fixes: ebd4786fcb ("Add test for per-NS NFS client statistics")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_net.sh                     | 6 ++++++
 testcases/network/nfs/nfsstat01/nfsstat02.sh | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
index 4e7fc26fa0..b0bc82d7e0 100644
--- a/testcases/lib/tst_net.sh
+++ b/testcases/lib/tst_net.sh
@@ -1139,6 +1139,12 @@ else
 	fi
 fi
 
+tst_net_unset_2_hosts_variables()
+{
+	unset IPV4_LHOST IPV4_RHOST IPV6_LHOST IPV6_RHOST LHOST_HWADDRS \
+		LHOST_IFACES RHOST RHOST_HWADDRS RHOST_IFACES
+}
+
 # detect IPv6 support on lhost for tests which don't use test links
 tst_net_detect_ipv6
 
diff --git a/testcases/network/nfs/nfsstat01/nfsstat02.sh b/testcases/network/nfs/nfsstat01/nfsstat02.sh
index 75a1a01b5b..193a52b593 100755
--- a/testcases/network/nfs/nfsstat01/nfsstat02.sh
+++ b/testcases/network/nfs/nfsstat01/nfsstat02.sh
@@ -20,7 +20,7 @@ do_test()
 }
 
 # Force use of nested net namespace
-unset RHOST
+tst_net_use_netns || tst_net_unset_2_hosts_variables
 
 . nfs_lib.sh
 tst_run
-- 
2.56.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] nfsstat02.sh: Properly fix netns enforcement
  2026-10-30 11:36 [LTP] [PATCH 1/1] nfsstat02.sh: Properly fix netns enforcement Petr Vorel
@ 2026-10-30 13:37 ` linuxtestproject.agent
  2026-10-30 15:20   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: linuxtestproject.agent @ 2026-10-30 13:37 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr,

On Fri Oct 30 12:36:37 2026 +0100, Petr Vorel <pvorel@suse.cz> wrote:
> nfsstat02.sh: Properly fix netns enforcement

> diff --git a/testcases/network/nfs/nfsstat01/nfsstat02.sh b/testcases/network/nfs/nfsstat01/nfsstat02.sh
> index 75a1a01b5..193a52b59 100755
> --- a/testcases/network/nfs/nfsstat01/nfsstat02.sh
> +++ b/testcases/network/nfs/nfsstat01/nfsstat02.sh
> @@ -20,7 +20,7 @@ do_test()
>  }
>  
>  # Force use of nested net namespace
> -unset RHOST
> +tst_net_use_netns || tst_net_unset_2_hosts_variables
>  
>  . nfs_lib.sh
>  tst_run

tst_net_use_netns and tst_net_unset_2_hosts_variables are called before
nfs_lib.sh (which sources tst_net.sh) is sourced, so both functions are
undefined at this point and fail with "not found". Calling them after
sourcing nfs_lib.sh is also too late because tst_net.sh already evaluates
RHOST and runs tst_net_setup_network at top level while being sourced. Set a
variable such as TST_NET_FORCE_NETNS=1 before sourcing nfs_lib.sh and handle
unsetting the 2-host variables inside tst_net.sh before the RHOST check.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] nfsstat02.sh: Properly fix netns enforcement
  2026-10-30 13:37 ` [LTP] " linuxtestproject.agent
@ 2026-10-30 15:20   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2026-10-30 15:20 UTC (permalink / raw)
  To: linuxtestproject.agent; +Cc: ltp

> Hi Petr,

> On Fri Oct 30 12:36:37 2026 +0100, Petr Vorel <pvorel@suse.cz> wrote:
> > nfsstat02.sh: Properly fix netns enforcement

> > diff --git a/testcases/network/nfs/nfsstat01/nfsstat02.sh b/testcases/network/nfs/nfsstat01/nfsstat02.sh
> > index 75a1a01b5..193a52b59 100755
> > --- a/testcases/network/nfs/nfsstat01/nfsstat02.sh
> > +++ b/testcases/network/nfs/nfsstat01/nfsstat02.sh
> > @@ -20,7 +20,7 @@ do_test()
> >  }

> >  # Force use of nested net namespace
> > -unset RHOST
> > +tst_net_use_netns || tst_net_unset_2_hosts_variables

> >  . nfs_lib.sh
> >  tst_run

> tst_net_use_netns and tst_net_unset_2_hosts_variables are called before
> nfs_lib.sh (which sources tst_net.sh) is sourced, so both functions are
> undefined at this point and fail with "not found". Calling them after
> sourcing nfs_lib.sh is also too late because tst_net.sh already evaluates
> RHOST and runs tst_net_setup_network at top level while being sourced. Set a
> variable such as TST_NET_FORCE_NETNS=1 before sourcing nfs_lib.sh and handle
> unsetting the 2-host variables inside tst_net.sh before the RHOST check.

I must have been really tired to overlook so obvious error.
TST_NET_FORCE_NETNS might be overkill, but I really prefer have that code in the
library than broken test due forget to set some variable.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-30 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 11:36 [LTP] [PATCH 1/1] nfsstat02.sh: Properly fix netns enforcement Petr Vorel
2026-10-30 13:37 ` [LTP] " linuxtestproject.agent
2026-10-30 15:20   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.