From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.227 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796428620; b=oGdc+uO50NfFYEuJgsfce6BlOsY0HSzH+ULacqu+M+XHq+lZXtQ+GXkGompshWk8gtkv qZx133z7EIRDaC109IsH0WT6JMgk6icfqWpeQmA7qqxqPwCMc360at6Ndvt1LJOgdRQpS hQlOTwRVxmRxWSUGDEHIqC+DWdoCMCmVsauj+3zxf2S8A9MVR4wQLQsdNQCjwUBktrp6L UCfksdh6XeSI5CSQoZb5W6bCVleoRtg6PPnL81ZD88E1jpFQ1VgrMSh2RQOI33kdTHard BIw/0u1hPjaiINpZZrjn67uTizmVODsggLjIhfRsZvWmkD4ANwRIWogvep7ieT3qWHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796428620; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:X-Relaying-Domain: Received:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ZhMGoS4SmEazYHtIbbfY+UfgllsZyAiYwoUcaS3NeAo=; b=HJknopesg9C+lrgAsYym8w7eoeaCJUG+QgLoib9jLVti9d4sP0yC3yHmyOkG9AG+NTQD DWAgF7umYtHjy+thcgbi76Dv8aJdMWS0c7RU9JcvTn/Wo+7tTnL6PEFJJBdh0tuNsUQWJ TwAxQK9ZgPyAewVahao8poCqREusfKsTwyjltPGVpnXaloJDhnAeUMSi5CNDRstFIWkPr bNU7nZVVIachuwutNs/PemdvuF6EKLDEVuRVZx5Lf7DXsJ4SKfIgTkyjbJ7uPUCBNafBU AoQxSM8cAX9xvjUXPTT/c/ognoeNKg/Iizc5ujK8Xp9khVDiAPFrH0t526/acgk6a+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=purestorage.com; spf=pass smtp.mailfrom=purestorage.com; dkim=pass header.d=purestorage.com header.i=@purestorage.com header.a=rsa-sha256 header.s=google2022 header.b=DrQ7biGU; arc=none smtp.remote-ip=209.85.222.227 Received: from mail-qk1-f227.google.com (mail-qk1-f227.google.com [209.85.222.227]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC860606A339 for ; Fri, 4 Dec 2026 23:56:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AC860606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.a=rsa-sha256 header.s=google2022 header.b=DrQ7biGU Received: by mail-qk1-f227.google.com with SMTP id af79cd13be357-93f20c3aaa5so121387285a.2 for ; Fri, 04 Dec 2026 15:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1796428616; x=1797033416; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZhMGoS4SmEazYHtIbbfY+UfgllsZyAiYwoUcaS3NeAo=; b=DrQ7biGURi9aoX+mYAhngXmM8vlF471ddml9YA4flX0cq8Ls8hhcLe6lEQWhUEa4FZ YsA7uNRrX2UXqdGokxB9Wr/JxxYhav3785+VCfWGaOWDA+WesWLsdQZwlNaDz+NdBur7 B6y+nZlHVYAgNBmzEUCxI6EQp8104nWKgJuEnXO6zKukBpVZ+s/kLTKI4dfe+Sq2AjIL jMCHPoUQKPcJSjuWYLD+IiZ78K/3kuSOaQPmjZsxkxmXvd8GkjO9NrmWdxZd8qEqp0Lb JieS+oUlHOY/QqQeEsHQ3BRauoUHl7r3Wk1fn5CBWQoa+yc7pXo6Ylu2CQhfBBg+23gA i8iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796428616; x=1797033416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZhMGoS4SmEazYHtIbbfY+UfgllsZyAiYwoUcaS3NeAo=; b=oVecxRYJ402FHVnuC8Qto16OJ73bDE6qBg4WSB0z3T4clsPzwox5diIGzcNsYgTLhP ithIgCrce278i8JR8Fd2dDauAQpvk03vlfDBNjBT47Buznwg8I4qHuCOtqIvQJG8JUJp 7YAB69f/4QrHrDCwzfDd1CCFubmadQbvJetYNAYNdk/m9oFvZOw/C9JS8lO8rJiKPAOa dgoMBtPYzf5KV/8QCmQgCCoYgB547CiLZCmrYVFOlGbWouU5iB9edKShrtXPl8tq4Hv9 tsXJuKQdMuuMJoDrDHp1n7Grt8fALg1QCMX54hBBsErtor20HQcsuKRjRFkTLKRFFxZU zA6w== X-Gm-Message-State: APuU4Z+MYxyQRwBrbxCsEub+KIRmdIjUDAUchUxcYyyRutCkZhJk582O SdSUPyk3yyoIINpC4+bml32Fw9umUBcsE+TuGxs0VLVGyvfdkg/HxyIBpglcUIpszOAsHBotGN4 9G8jveFX7ooxdPUu2XAPho/dd3XTHWU0t3TeC X-Gm-Gg: AZFdTZdNf3kTkPmMFPNytkPnX7h5qZc33rkylsoEgBbzO1nG95g1bGNicNu368kU1lg aXSnVPufRPxDZ5DRf0ZYqoZZeT/GpXcLSRK4ChIsNWKcW+4phpHf69FrMq+la87anV+Fx3h3I7D z8nNlXGuZIcFRe/yaP4nXI4SGpsahz6VzFnkLedXNUjDeYU5Jt/iKlUukXi7YGq5O94ZIVQV50z CEIb7aJ4hqIVPqo0mmwkd3ZYAgHJ6E5UjqLDt8yx7lUiA24QNCuPnTV1dNDTOLgfYBI4K/DNuWD iqOnaychEG1NpXhoz7esZLt7AMlNjKQ+3fJ0o2SU4SesXXKY24HpsOFHqWPS9YelFRruG0AaSJw yAzTouARcsRZ7g2LQQnC9RQIAMSZBMkojcfk= X-Received: by 2002:a05:620a:260d:b0:949:f895:1845 with SMTP id af79cd13be357-94a82e1cc09mr560344385a.74.1796428616476; Fri, 04 Dec 2026 15:56:56 -0800 (PST) Received: from c7-smtp-2026.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id af79cd13be357-94a7e75e00asm32252685a.8.2026.12.04.15.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 15:56:56 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-rjethwani.dev.purestorage.com (dev-rjethwani.dev.purestorage.com [IPv6:2620:125:9025:23::2ea]) by c7-smtp-2026.dev.purestorage.com (Postfix) with ESMTP id A5008400F2; Fri, 4 Dec 2026 16:56:55 -0700 (MST) Received: by dev-rjethwani.dev.purestorage.com (Postfix, from userid 1557719937) id A27F1DCE140; Fri, 4 Dec 2026 16:56:55 -0700 (MST) From: Rishikesh Jethwani To: netdev@vger.kernel.org Cc: Rishikesh Jethwani , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , John Fastabend , Sabrina Dubroca , 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 Message-ID: <20261204235642.36653-9-rjethwani@purestorage.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261204235642.36653-1-rjethwani@purestorage.com> References: <20261204235642.36653-1-rjethwani@purestorage.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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