]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: ncdevmem: Properly reset flow steering
authorStanislav Fomichev <sdf@fomichev.me>
Thu, 7 Nov 2024 18:12:06 +0000 (10:12 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Nov 2024 01:01:04 +0000 (17:01 -0800)
ntuple off/on might be not enough to do it on all NICs.
Add a bunch of shell crap to explicitly remove the rules.

Reviewed-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20241107181211.3934153-8-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/ncdevmem.c

index 645ef0bb63ec2fbaa017fd060fb916f18ed30ca0..ad6de8e0e97bcb3dae6b86f0158f0b2ef161d8a1 100644 (file)
@@ -217,13 +217,18 @@ void validate_buffer(void *line, size_t size)
 
 static int reset_flow_steering(void)
 {
-       int ret = 0;
-
-       ret = run_command("sudo ethtool -K %s ntuple off >&2", ifname);
-       if (ret)
-               return ret;
-
-       return run_command("sudo ethtool -K %s ntuple on >&2", ifname);
+       /* Depending on the NIC, toggling ntuple off and on might not
+        * be allowed. Additionally, attempting to delete existing filters
+        * will fail if no filters are present. Therefore, do not enforce
+        * the exit status.
+        */
+
+       run_command("sudo ethtool -K %s ntuple off >&2", ifname);
+       run_command("sudo ethtool -K %s ntuple on >&2", ifname);
+       run_command(
+               "sudo ethtool -n %s | grep 'Filter:' | awk '{print $2}' | xargs -n1 ethtool -N %s delete >&2",
+               ifname, ifname);
+       return 0;
 }
 
 static int configure_headersplit(bool on)