Subject: Re: [PATCH net v2 4/4] selftests: drv-net: rss_ctx: test RSS contexts persist after ifdown/up

From: Jakub Kicinski <[email-masked]>
Date: Tue, 10 Feb 2026 20:17:06 -0800

On Wed, 11 Feb 2026 09:28:22 +0530 Pavan Chebbi wrote:
> On Wed, Feb 11, 2026 at 7:16 AM Jakub Kicinski <[email-masked]> wrote:
> > > I checked and tried using the cmd() and it indeed eliminates a lot of
> > > lines here. But the test itself becomes a little unreliable.
> > > I often see TimeoutError: [Errno Wait for file contents failed]
> > > /sys/class/net/ens2f0np0/carrier from the wait_file (Jakub asked me to
> > > use wait_file)  
> >
> > Does the link take more than the default 5 sec to come up?
> > wait_file() has a deadline param that should let us wait longer  
> 
> I did try with increased deadline. But I don't think it's helping.

If you check the carrier manually in a second terminal while it's
running -- do you see it go to 1? The helper keeps the file open
and rewinds to the start, I think that may not work with sysfs :S
Maybe we need:

diff --git a/tools/testing/selftests/net/lib/py/utils.py b/tools/testing/selftests/net/lib/py/utils.py
index 85884f3e827b..24e74475315d 100644
--- a/tools/testing/selftests/net/lib/py/utils.py
+++ b/tools/testing/selftests/net/lib/py/utils.py
@@ -294,11 +294,10 @@ GLOBAL_DEFER_ARMED = False
     """
     end = time.monotonic() + deadline
 
-    with open(fname, "r", encoding=encoding) as fp:
-        while True:
+    while True:
+        with open(fname, "r", encoding=encoding) as fp:
             if test_fn(fp.read()):
                 break
-            fp.seek(0)
             if time.monotonic() > end:
                 raise TimeoutError("Wait for file contents failed", fname)
             time.sleep(sleep)

> > > Also, even when the test succeeds, after the suite exits, I cannot
> > > ping the remote host for a long time. In contrast, my manual loop
> > > worked 100pc of the times I tested.
> > > I am using the command like below:
> > >
> > >    for _ in range(10):
> > >         if cmd(f"ping -c 1 -W 1 {remote_addr}", fail=False, timeout=2).ret == 0:
> > >             break
> > >         time.sleep(1)
> > >     else:
> > >         raise KsftSkipEx("Cannot reach remote host after interface up")
> > >
> > > I am not a py expert so is there something I am missing?  
> >
> > I don't think there's anything Python related here :(  
> 
> What I wanted to check was that if the cmd() invokes some shell and
> has some kind overhead that could affect timing..
> 
> > Is it possible that NIC reports carrier before it can actually send
> > packets? Maybe the wait_file() gives ping has a higher chance of failing
> > with carrier up which makes the neighbor resolution failure more sticky?  
> 
> I am not sure. I am willing to send the manual ping loop version as I
> have high confidence on that.
> If you or Bobby insist I must use cmd() then I can spend more time on that..

cmd() doesn't do any magic, it basically does:

	proc = subprocess.Popen(comm, shell=shell,
				stdout=subprocess.PIPE, stderr=subprocess.PIPE,
				pass_fds=pass_fds, env=env)
	proc.communicate(timeout)

So pretty much the same code as your subprocess.run().

It has support for communicating with extra fds to