From: Rishikesh Jethwani <rjethwani@purestorage.com>
To: netdev@vger.kernel.org
Cc: Rishikesh Jethwani <rjethwani@purestorage.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shuah Khan <shuah@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Sabrina Dubroca <sd@queasysnail.net>,
linux-kselftest@vger.kernel.org
Subject: [PATCH net v3 8/9] selftests: net: test TLS fallback after rerouting to an upper device
Date: Fri, 4 Dec 2026 16:53:55 -0700 [thread overview]
Message-ID: <20261204235642.36653-9-rjethwani@purestorage.com> (raw)
In-Reply-To: <20261204235642.36653-1-rjethwani@purestorage.com>
Move an established offloaded connection to a macvlan on the same
NIC. Unlike a bond bounce, this leaves the NIC up and the socket
offloaded: the NIC must transmit the fallback's ciphertext unchanged.
Check that the resumed echo traverses the macvlan and matches the
original data. Without "tls: device: don't let the NIC encrypt
fallback output again", the echo mismatches.
Signed-off-by: Rishikesh Jethwani <rjethwani@purestorage.com>
---
tools/testing/selftests/drivers/net/hw/config | 1 +
.../drivers/net/hw/tls_hw_offload.py | 84 +++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/config b/tools/testing/selftests/drivers/net/hw/config
index ee658188670a..dab194fb27ee 100644
--- a/tools/testing/selftests/drivers/net/hw/config
+++ b/tools/testing/selftests/drivers/net/hw/config
@@ -14,6 +14,7 @@ CONFIG_IPV6=y
CONFIG_IPV6_GRE=y
CONFIG_IPV6_SIT=y
CONFIG_IPV6_TUNNEL=y
+CONFIG_MACVLAN=m
CONFIG_NET_CLS_ACT=y
CONFIG_NET_CLS_BPF=y
CONFIG_NET_DEVMEM=y
diff --git a/tools/testing/selftests/drivers/net/hw/tls_hw_offload.py b/tools/testing/selftests/drivers/net/hw/tls_hw_offload.py
index 7d90f1c2024a..e1382cee8dd1 100755
--- a/tools/testing/selftests/drivers/net/hw/tls_hw_offload.py
+++ b/tools/testing/selftests/drivers/net/hw/tls_hw_offload.py
@@ -36,6 +36,10 @@ from lib.py import (
)
BOND_IFNAME = "tlsbond0"
+MACVLAN_IFNAME = "tlsmv0"
+
+# Second half of the helper's default echo (-n 100, -b 16384).
+RESUMED_ECHO_BYTES = 50 * 16384
# -T for -P cases, long enough for a bounced NIC to retrain.
PAUSE_IO_TIMEOUT_S = 45
@@ -790,6 +794,85 @@ def test_tls_offload_bond_bounce(cfg, bounce):
run_tls_test(cfg, pause=bounce)
+def read_tx_bytes(ifname):
+ """TX bytes of a local interface."""
+ link = ip(f"-s link show dev {ifname}", json=True)[0]
+ return link["stats64"]["tx"]["bytes"]
+
+
+def sysctl_set(name, value):
+ """Set a sysctl for the rest of the case, restoring it on cleanup."""
+ old = cmd(f"sysctl -n {name}").stdout.strip()
+ cmd(f"sysctl -qw {name}={value}")
+ defer(cmd, f"sysctl -qw {name}={old}")
+
+
+def require_onlink_peer(cfg):
+ """Skip unless reroute_macvlan()'s direct /32 can take over the
+ connection's route without changing its next hop.
+
+ The macvlan is unnumbered and ARPs for the peer itself: a peer behind
+ a gateway would need the gateway, which also could not be made to
+ forget the macvlan's MAC on cleanup. An existing /32 to the peer would
+ clash with the one added, and a route from a table other than main
+ would win over it.
+ """
+ peer, local = cfg.remote_addr_v["4"], cfg.addr_v["4"]
+ route = ip(f"-d route get {peer} from {local}", json=True)[0]
+ if route.get("dev") != cfg.ifname or "gateway" in route:
+ raise KsftSkipEx(f"{peer} is not on-link through {cfg.ifname}")
+ if route.get("table", "main") != "main":
+ raise KsftSkipEx(f"{peer} is routed by table {route['table']}, "
+ f"not main")
+ if ip(f"route show table main exact {peer}/32", json=True):
+ raise KsftSkipEx(f"A host route to {peer} already exists")
+
+
+def setup_macvlan(cfg):
+ """Add a macvlan upper on the DUT NIC for the rest of the case.
+
+ The peer may answer on either MAC, so set loose rp_filter on both.
+ """
+ ip(f"link add {MACVLAN_IFNAME} link {cfg.ifname} type macvlan "
+ "mode bridge")
+ # Runs after the delete: make the peer drop the macvlan's MAC.
+ defer(ip, f"neigh flush to {cfg.addr_v['4']}", host=cfg.remote)
+ defer(ip, f"link del {MACVLAN_IFNAME}")
+ sysctl_set(f"net.ipv4.conf.{cfg.ifname}.rp_filter", 2)
+ sysctl_set(f"net.ipv4.conf.{MACVLAN_IFNAME}.rp_filter", 2)
+ ip(f"link set dev {MACVLAN_IFNAME} up")
+ wait_carrier(MACVLAN_IFNAME)
+
+
+def reroute_macvlan(cfg, _port):
+ """Move the paused connection's route to the macvlan upper."""
+ peer = cfg.remote_addr_v["4"]
+ # The macvlan is unnumbered, so pin the source address.
+ ip(f"route add {peer}/32 dev {MACVLAN_IFNAME} src {cfg.addr_v['4']}")
+ defer(ip, f"route del {peer}/32 dev {MACVLAN_IFNAME}")
+ wait_reachable(MACVLAN_IFNAME, peer)
+
+
+@ksft_disruptive
+def test_tls_offload_upper_reroute(cfg):
+ """Move an offloaded socket's route to an upper device of its NIC.
+
+ The NIC must not encrypt the SW fallback's output again.
+ """
+ require_tls_setup(cfg)
+ if 'Tx' not in cfg.tls_hw_directions:
+ raise KsftSkipEx("Upper device reroute requires DUT TLS TX offload")
+ cfg.require_ipver("4")
+ require_onlink_peer(cfg)
+ setup_macvlan(cfg)
+ before = read_tx_bytes(MACVLAN_IFNAME)
+ run_tls_test(cfg, pause=reroute_macvlan)
+ sent = read_tx_bytes(MACVLAN_IFNAME) - before
+ ksft_ge(sent, RESUMED_ECHO_BYTES,
+ comment=f"resumed echo did not go through {MACVLAN_IFNAME} "
+ f"({sent} bytes)")
+
+
def main() -> None:
"""Set up the DUT/peer environment and run the offload test suites."""
with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
@@ -800,6 +883,7 @@ def main() -> None:
# Flap the NIC last, so a slow retrain cannot fail later cases.
ksft_run([test_tls_offload, test_tls_offload_sizes,
test_tls_offload_record_type, test_tls_offload_bond,
+ test_tls_offload_upper_reroute,
test_tls_offload_bond_bounce], args=(cfg, ))
ksft_exit()
--
2.50.1
next prev parent reply other threads:[~2026-12-04 23:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 23:53 [PATCH net v3 0/9] tls: device: don't put offload plaintext on the wire Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 1/9] net: don't fragment skbs that still need device crypto Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 2/9] tls: device: keep tls_sw_fallback() from encrypting its own output Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 3/9] tls: device: don't let the NIC encrypt fallback output again Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 4/9] tls: device: remove the dead start marker bypass in TX fallback Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 5/9] selftests: net: py: reap commands that fail to report ready Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 6/9] selftests: net: py: add a timeout argument to bkg() Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 7/9] selftests: net: add TLS offload over bond tests Rishikesh Jethwani
2026-12-04 23:53 ` Rishikesh Jethwani [this message]
2026-12-04 23:53 ` [PATCH net v3 9/9] selftests: net: verify that IP refuses to fragment TLS offload data Rishikesh Jethwani
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=20261204235642.36653-9-rjethwani@purestorage.com \
--to=rjethwani@purestorage.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--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