Skip to contentSkip to conversation

selftests: drv-net: ping: make sure the ping test restores checksum offload

PATCH Applied Jakub Kicinski 3 participants 5 messages May 8, 2025 – May 13, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 selftests: drv-net: ping: make sure the ping test restores checksum offload

The ping test flips checksum offload on and off. Make sure the original value is restored if test fails.

---
CC: [email protected]
CC: [email protected]

---
 tools/testing/selftests/drivers/net/ping.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tools/testing/selftests/drivers/net/ping.py +16 -0
index af8df2313a3b..e0f114612c1a 100755
@@ -50,6 +50,16 @@ no_sleep=False
         cmd(f"echo {test_string} | socat -t 2 -u STDIN TCP:{cfg.remote_baddr}:{port}", shell=True)
     ksft_eq(nc.stdout.strip(), test_string)
 
+def _schedule_checksum_reset(cfg, netnl) -> None:
+    features = ethtool(f"-k {cfg.ifname}", json=True)
+    setting = ""
+    for side in ["tx", "rx"]:
+        f = features[0][side + "-checksumming"]
+        if not f["fixed"]:
+            setting += " " + side
+            setting += " " + ("on" if f["requested"] or f["active"] else "off")
+    defer(ethtool, f" -K {cfg.ifname} " + setting)
+
 def _set_offload_checksum(cfg, netnl, on) -> None:
     try:
         ethtool(f" -K {cfg.ifname} rx {on} tx {on} ")
@@ -139,6 +149,7 @@ no_sleep=False
 def test_default_v4(cfg, netnl) -> None:
     cfg.require_ipver("4")
 
+    _schedule_checksum_reset(cfg, netnl)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v4(cfg)
     _test_tcp(cfg)
@@ -149,6 +160,7 @@ no_sleep=False
 def test_default_v6(cfg, netnl) -> None:
     cfg.require_ipver("6")
 
+    _schedule_checksum_reset(cfg, netnl)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v6(cfg)
     _test_tcp(cfg)
@@ -157,6 +169,7 @@ no_sleep=False
     _test_tcp(cfg)
 
 def test_xdp_generic_sb(cfg, netnl) -> None:
+    _schedule_checksum_reset(cfg, netnl)
     _set_xdp_generic_sb_on(cfg)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v4(cfg)
@@ -168,6 +181,7 @@ no_sleep=False
     _test_tcp(cfg)
 
 def test_xdp_generic_mb(cfg, netnl) -> None:
+    _schedule_checksum_reset(cfg, netnl)
     _set_xdp_generic_mb_on(cfg)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v4(cfg)
@@ -179,6 +193,7 @@ no_sleep=False
     _test_tcp(cfg)
 
 def test_xdp_native_sb(cfg, netnl) -> None:
+    _schedule_checksum_reset(cfg, netnl)
     _set_xdp_native_sb_on(cfg)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v4(cfg)
@@ -190,6 +205,7 @@ no_sleep=False
     _test_tcp(cfg)
 
 def test_xdp_native_mb(cfg, netnl) -> None:
+    _schedule_checksum_reset(cfg, netnl)
     _set_xdp_native_mb_on(cfg)
     _set_offload_checksum(cfg, netnl, "off")
     _test_v4(cfg)
Signature · 1 line
2.49.0
#1 lore raw
Quoted 16 lines · Jakub Kicinski

The ping test flips checksum offload on and off. Make sure the original value is restored if test fails.

---
CC: [email protected]
CC: [email protected]

---
  tools/testing/selftests/drivers/net/ping.py | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
tools/testing/selftests/drivers/net/ping.py +0 -0
index af8df2313a3b..e0f114612c1a 100755

tools/testing/selftests/drivers/net/ping.py no_sleep=False · line 58

Quoted 9 lines
tools/testing/selftests/drivers/net/ping.py +6 -0
@@ -50,6 +50,16 @@ no_sleep=False
          cmd(f"echo {test_string} | socat -t 2 -u STDIN TCP:{cfg.remote_baddr}:{port}", shell=True)
      ksft_eq(nc.stdout.strip(), test_string)
 
+def _schedule_checksum_reset(cfg, netnl) -> None:
+    features = ethtool(f"-k {cfg.ifname}", json=True)
+    setting = ""
+    for side in ["tx", "rx"]:
+        f = features[0][side + "-checksumming"]
+        if not f["fixed"]:

I checked and found that "fixed" is a ternary:

        "rx-checksumming": {
            "active": true,
            "fixed": false,
            "requested": true
        },
        "tx-checksumming": {
            "active": true,
            "fixed": null,
            "requested": null
        },

Python loads this JSON as False and None types respectively, and not f["fixed"] is true for both False and None. Maybe this doesn't matter but flagging it.

tools/testing/selftests/drivers/net/ping.py no_sleep=False · line 61

Quoted 3 lines
tools/testing/selftests/drivers/net/ping.py +3 -0
+            setting += " " + side
+            setting += " " + ("on" if f["requested"] or f["active"] else "off")
+    defer(ethtool, f" -K {cfg.ifname} " + setting)

This does rx/tx-gro too even if not explicitly requested. I assume that is okay?

author maintainer
#2 lore raw
Quoted 20 lines · On Thu, 8 May 2025 14:59:12 -0700 David Wei wrote:

tools/testing/selftests/drivers/net/ping.py no_sleep=False · line 58

Quoted 6 lines
tools/testing/selftests/drivers/net/ping.py +6 -0
+def _schedule_checksum_reset(cfg, netnl) -> None:
+    features = ethtool(f"-k {cfg.ifname}", json=True)
+    setting = ""
+    for side in ["tx", "rx"]:
+        f = features[0][side + "-checksumming"]
+        if not f["fixed"]:  

I checked and found that "fixed" is a ternary:

         "rx-checksumming": {
             "active": true,
             "fixed": false,
             "requested": true
         },
         "tx-checksumming": {
             "active": true,
             "fixed": null,
             "requested": null
         },
Quoted 3 lines

Python loads this JSON as False and None types respectively, and not f["fixed"] is true for both False and None. Maybe this doesn't matter but flagging it.

I think so, yes.

Quoted 6 lines

tools/testing/selftests/drivers/net/ping.py no_sleep=False · line 61

Quoted 3 lines
tools/testing/selftests/drivers/net/ping.py +3 -0
+            setting += " " + side
+            setting += " " + ("on" if f["requested"] or f["active"] else "off")
+    defer(ethtool, f" -K {cfg.ifname} " + setting)  

This does rx/tx-gro too even if not explicitly requested. I assume that is okay?

You mean because those are automatically updated when we change checksumming? If so then yes.

Reviewed-by
#3 lore raw
Quoted 31 lines · Jakub Kicinski
Quoted 20 lines · On Thu, 8 May 2025 14:59:12 -0700 David Wei wrote:

tools/testing/selftests/drivers/net/ping.py no_sleep=False · line 58

Quoted 6 lines
tools/testing/selftests/drivers/net/ping.py +6 -0
+def _schedule_checksum_reset(cfg, netnl) -> None:
+    features = ethtool(f"-k {cfg.ifname}", json=True)
+    setting = ""
+    for side in ["tx", "rx"]:
+        f = features[0][side + "-checksumming"]
+        if not f["fixed"]:

I checked and found that "fixed" is a ternary:

          "rx-checksumming": {
              "active": true,
              "fixed": false,
              "requested": true
          },
          "tx-checksumming": {
              "active": true,
              "fixed": null,
              "requested": null
          },
Quoted 3 lines

Python loads this JSON as False and None types respectively, and not f["fixed"] is true for both False and None. Maybe this doesn't matter but flagging it.

I think so, yes.

Quoted 4 lines
Quoted 3 lines
tools/testing/selftests/drivers/net/ping.py +3 -0
+            setting += " " + side
+            setting += " " + ("on" if f["requested"] or f["active"] else "off")
+    defer(ethtool, f" -K {cfg.ifname} " + setting)
Quoted 5 lines
Quoted 2 lines

This does rx/tx-gro too even if not explicitly requested. I assume that is okay?

You mean because those are automatically updated when we change checksumming? If so then yes.

Thanks for responding.

#4 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 8 May 2025 14:40:05 -0700 you wrote:

The ping test flips checksum offload on and off. Make sure the original value is restored if test fails.

---
CC: [email protected]
CC: [email protected]

[...]

Here is the summary with links:
- [net-next] selftests: drv-net: ping: make sure the ping test restores checksum offload

    https://git.kernel.org/netdev/net-next/c/ef5224ed25e0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html