public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Aleksei Oladko <aleksey.oladko@virtuozzo.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Petr Machata <petrm@nvidia.com>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests: net: forwarding: cleanup veth peers created via NUM_NETIFS
Date: Tue, 20 Jan 2026 17:31:27 -0800	[thread overview]
Message-ID: <aXAsb+sCbyeD/xkL@devvm11784.nha0.facebook.com> (raw)
In-Reply-To: <20260120230905.328528-1-aleksey.oladko@virtuozzo.com>

On Tue, Jan 20, 2026 at 11:09:05PM +0000, Aleksei Oladko wrote:
> Some net/forwarding kselftests set NUM_NETIFS, causing lib.sh to create
> the requested number of veth peer interfaces.
> 
> These interfaces are not removed when the tests finish, leaving stale
> veth devices in the system. This can cause subsequent tests to fail,
> for example min_max_mtu.sh.
> 
> Ensure that veth peers created via NUM_NETIFS are properly removed at
> the end of the tests to avoid interference between test runs.
> 
> Signed-off-by: Aleksei Oladko <aleksey.oladko@virtuozzo.com>
> ---
>  tools/testing/selftests/net/forwarding/lib.sh | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index a9034f0bb58b..ae7699c0c7e5 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -597,6 +597,10 @@ vrf_cleanup()
>  	ip -6 rule del pref 32765
>  	ip -4 rule add pref 0 table local
>  	ip -4 rule del pref 32765
> +
> +	for ((i = 1; i <= NUM_NETIFS; i=$i+2)); do

I'd suggest 'i = i + 2' here instead of "i=$i+2", as it seems closer to the rest of lib.sh
style.

> +		ip link delete dev ${NETIFS[p$i]} 2>/dev/null || true
> +	done
>  }
>  
>  adf_vrf_prepare()
> -- 
> 2.43.0
> 

I see that some tests that set NUM_NETIFS do not seem to call
vrf_cleanup() (e.g. bridge_activity_notify.sh), so I think those tests
will still leak?

Maybe lib.sh needs a remove_netif() to go along with create_netif(), and
then tests can call it from their 'cleanup()' EXIT handlers? This avoids
the mismatch between vrf_prepare() not creating devices but
vrf_cleanup() removing them.

Thanks,
Bobby

  reply	other threads:[~2026-01-21  1:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 23:09 [PATCH] selftests: net: forwarding: cleanup veth peers created via NUM_NETIFS Aleksei Oladko
2026-01-21  1:31 ` Bobby Eshleman [this message]
2026-01-21  1:41   ` Bobby Eshleman
2026-01-21 13:39 ` Petr Machata

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXAsb+sCbyeD/xkL@devvm11784.nha0.facebook.com \
    --to=bobbyeshleman@gmail.com \
    --cc=aleksey.oladko@virtuozzo.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox