From patchwork Fri Oct 25 14:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13850812 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2056.outbound.protection.outlook.com [40.107.237.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FE95206506 for ; Fri, 25 Oct 2024 14:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866439; cv=fail; b=YQlts1t9khg0JowheX/MlGW5C1GjrkIpISUjsqHUqui1GzpzdTABSQWn78I8m1Tjs74E2YTqaMvaix+ZTXaK94VcDPuvS1vKe+pINB47T2KYJUmQJixS37XlPI8t75gt46k0xs6TyCpaCR1uDxnF7wKqJsfawXqSw8odMvWJM7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866439; c=relaxed/simple; bh=c5cPqQNeHDniNtlfYOPGjPsuYBs3ohu7ix1Sqkbwgfg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qSyv2/FW8tUypS7TuRomnxYCglEhYAuywS1pExZT+ACIutu4ASVGm8OK5KNY1+bSHtR/4c0AIswgEmpflkMn7SLzEJHrcM8rT5dgZKSSmhtXHypSJdZgChx1oCCQmJQBoUHudE6ayu65dcTNF8peDwBITlOjLVcxR43Q9rd+8ag= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=MqFMmsOU; arc=fail smtp.client-ip=40.107.237.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="MqFMmsOU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jOP8CymdHKYheINeEu275bSFZCL3BHXMpidXEnAU4Tq5Iz5UaDQKklS8REgEhhvM3IcR+2djRFgYpZnpK7gallnqh3Hh51qAV6q/CTwFGFJD8CoaqR11uerdSUNSWKdXg1yucqKcuVhphkCafDBL0dbOPsH5kfHDcpPTpJJw4S5970iLWrfhxkGHx5Uwk+qfunYO+h3lovdElDVnfCsPqgoVsfv62tzoz923QReA23lS/jI8WbEqpRHvrEJ/C2MXg0laReIFqXMgYHA50fta/usBT9ypZIAvPvzYur+SjWKV9/m2lwHeBbSjibKA1raCVMvi79FVchqZAf85aT1u1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LZybqdDZZdrEvWUZrU0gVe+HH7cHXdwRNNzJsjjlm7c=; b=XBBSAyp6W1Q4aJr6NWOZXdrS1Aw8IV0Pr5FQkF902hcB0B/2s0rBJ5W9ZI1PAWuLgJkLud8Rq4q8hilzYYxOSq/897VRNLrPeRXCPjtKFbUBMd73i23sinXWk7v0UPL7rGYzk1762J2wANHb+XS50UV4UTt3g2lSqrLrvVeHlSKmIS76Hdyt6aiRzCb3i/Hw1pvLwOj9KE7ntUnj4QB5ROyDSnAK9qkAWjNMd+HHYYF+cg7DD9kxOx1/LoHq9PUyDw/TSl3k6dB2D19QLf/0mnics20oIX7RIzKYzrq83MB5bqd6qVt+qowQ4ssAH5fbZpAwmlxfr5D7h9q7iMmdjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LZybqdDZZdrEvWUZrU0gVe+HH7cHXdwRNNzJsjjlm7c=; b=MqFMmsOUhR2SwBfNYKgeJB1FZwd4MYqCjtsgEq0ldcUyqARalDnfVxf2oFANsAy2fhm374qoHX8cQR8Uy90/93TQGcsbmPyBbByoA6Miq9tTZbYGA2rNGZlwzq9rRZntHsZOO2Lz5Eh+czxLWFcfV4ax2/+cpTN5nJSs8JCHU8/9HAuJfxjkM160bXzrRJbXP4HLuYMVKid9POCvAI1xma4UVlUFpp5VV5kqpgo2JbAbJ0N6IfTYluFky66KjfQyBRHetGhmh/azwrrpD3+N4IrrXhriBEX8Ob8ksxEf7jMgykN/qq10O2rCTuP5MA9wA3s8AT0sOlCfaa+PXY4h7Q== Received: from BN8PR03CA0008.namprd03.prod.outlook.com (2603:10b6:408:94::21) by CH3PR12MB8582.namprd12.prod.outlook.com (2603:10b6:610:163::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Fri, 25 Oct 2024 14:27:12 +0000 Received: from BL6PEPF0001AB54.namprd02.prod.outlook.com (2603:10b6:408:94:cafe::81) by BN8PR03CA0008.outlook.office365.com (2603:10b6:408:94::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21 via Frontend Transport; Fri, 25 Oct 2024 14:27:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB54.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 14:27:12 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:26:58 -0700 Received: from fedora.mtl.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:26:52 -0700 From: Petr Machata To: CC: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Danielle Ratson , Petr Machata , Ido Schimmel , Amit Cohen , , Richard Cochran Subject: [PATCH net 1/5] mlxsw: spectrum_ptp: Add missing verification before pushing Tx header Date: Fri, 25 Oct 2024 16:26:25 +0200 Message-ID: <5145780b07ebbb5d3b3570f311254a3a2d554a44.1729866134.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB54:EE_|CH3PR12MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 356115b7-59e3-40f2-1515-08dcf5011de2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: VfrkbCaixnDOdbsGKNcpnBb/EywGqvBmDWK/PYZTtggUUyHZPNUhdMi7IfK1Kle0YFSLLIyLwu74cNCuhvtU5zuUjf+sQrMzxsd0JxNt3o3eyeqXFG8A/HSLabfg1mh7hkc7Q9RMbda2S0HcwVuGlzkXihi9CblbwoLbmeVc3jbb9SMMAq1HGLF5zzZWD1Pxete5nts5gcPr+dx/SMNFb1reuALS04DgcWk9BmUFYJ6gMawnaFYPvSkrflqfErnFu8wcOnLIqhp/85c0w64VKjmCuocZJPJ/y+xQMH2mfK14apuWmd+SBYIbMV2bGx/ktfSY3WIyBxIRzU3J/1Kw2G2N/s195ccHI1bu/hqY3AXs7Q1c+T2iSQnqfkEll5kDB4AX7vPpdkmI1QkCY+GfGmpRvNyC4NQnA2Jda+fNin7rjyJU56P4V1T7X7Wc1FvUtvZg9T0si0iJP0bZfePbz9UgOkHmG63gRgvDKQlp7G6yGjKjwkyV7EfAuZJorfcgnepSe0MLKKHQG5vKgvKLcwFNl4tDjb1o+hP2ITSNT91MPeHjDFH5GE9R+CIseRcxm46zth4pAyYXAxNVSpEM5YZWfcve030nkqjLvOQSQSEdf8v1NZQufHVNt/EGRz24rOaYJIywr2L8wi9DyVAVMW5zk7lGC9Kj+I8U4b+aOidmSFxhWZ7zZbvHifAG+ly5ngAfJmF2KYMA5Px5NuGh2+cLj/sQwfe6FlfcATt2lvscIJZmDuPZ3lwB0nnldt6KV6gnLqouS5azU8urw3l9ubdMEAwj7DC9cm0K+nBw2SjHpSyqw36dwpoXCG3FEfNhYqsrcg54IMSPyqmPDRVIELUP17YCr0deo7xIYMZ492GOkUkUMLpeaS0fZ1ZH6iuQuxlrsbHhMT3qUV8bvyIl3G9hEYTLoqM9KrgyeiFNBgfkW4wlNf0sP0QWB6DRpEdbKjMKLoXcBwjyx5oRPcswes0S6RcyIci+2fBEphc/hB7RlTWnJgQkB/od5tIHs5BnmJbYyvvOEsT+mzQPZ1ZaoJhuanHYRuSX1GTiiTHlNFaX6OpJ8Kk1XxbDrPHcU/IA40UGpxtfXcV2HA5dZ5imV6sMRE9DMxOoB3zkrT8VBjxTlYEbt9/KsUMIgalD9q3t8kqiVfvJ4m9WX+gofF8GyO8bzPpYoFDN8L9t7FQz9tqpn3pfr2ZXjb6JZ9cPLi9xCvbquscVDXxbzIinU+8skFZhzOZiDiKIxMt9weLa2yWjLFkWfG8mzx6d5BlCHP3IAARLCr5UDOImhwprreAjS9CVx8lSHbm+4Ru3NvSWvp6+64oYIjmM5pnhYxz2A2ZHM7om2B80MsEC5RYoS/B4nKPQm7ytRk4ohPpSNtqpgNJgCohIOs2/zHk3gTjUD3b3lGfYv7RTri/YLXeXEx8ykg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 14:27:12.2864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 356115b7-59e3-40f2-1515-08dcf5011de2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB54.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8582 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Tx header should be pushed for each packet which is transmitted via Spectrum ASICs. The cited commit moved the call to skb_cow_head() from mlxsw_sp_port_xmit() to functions which handle Tx header. In case that mlxsw_sp->ptp_ops->txhdr_construct() is used to handle Tx header, and txhdr_construct() is mlxsw_sp_ptp_txhdr_construct(), there is no call for skb_cow_head() before pushing Tx header size to SKB. This flow is relevant for Spectrum-1 and Spectrum-4, for PTP packets. Add the missing call to skb_cow_head() to make sure that there is both enough room to push the Tx header and that the SKB header is not cloned and can be modified. An additional set will be sent to net-next to centralize the handling of the Tx header by pushing it to every packet just before transmission. Cc: Richard Cochran Fixes: 24157bc69f45 ("mlxsw: Send PTP packets as data packets to overcome a limitation") Signed-off-by: Amit Cohen Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c index 5b174cb95eb8..d94081c7658e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c @@ -16,6 +16,7 @@ #include "spectrum.h" #include "spectrum_ptp.h" #include "core.h" +#include "txheader.h" #define MLXSW_SP1_PTP_CLOCK_CYCLES_SHIFT 29 #define MLXSW_SP1_PTP_CLOCK_FREQ_KHZ 156257 /* 6.4nSec */ @@ -1684,6 +1685,12 @@ int mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, const struct mlxsw_tx_info *tx_info) { + if (skb_cow_head(skb, MLXSW_TXHDR_LEN)) { + this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped); + dev_kfree_skb_any(skb); + return -ENOMEM; + } + mlxsw_sp_txhdr_construct(skb, tx_info); return 0; } From patchwork Fri Oct 25 14:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13850813 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB9BB1632C0 for ; Fri, 25 Oct 2024 14:27:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866440; cv=fail; b=fXMTNyfwI4vmS/TUgygv5PNtz5QEJPvJNP1NMf8wZTxrJvZi0uPZECbEUX/q2cTvhJP1XgOLd5P5tS1NlfNDAMuaapHuRtu4H2EBqZRp91FTkaXhydzDtwMYhgsE7XcNNMkB/OcTvb7C7Dh/1JD63CLQodLKe5JvvNecrSnelvk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866440; c=relaxed/simple; bh=6FWInSkyAZM1EaiCbIjK9xCC9i//zsc1EzmPApLjxsk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jLDXfOyLl6xZY/dFRr6ll+c5SVlA62eNmSZR9Uyo8PBMYtZk6mb/JUqjYCWwUJK4SnXeaL0VN5uwxHv/J9HyNEGRKN8Bn1B5zwMFj4H3lnk22VfCgtgw+yOIHD3y8LZjNkby0XGQx5/60aZjd3UdeuwGmEwYiq0sSBHMgl0VPpc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=CWX3h9zi; arc=fail smtp.client-ip=40.107.94.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="CWX3h9zi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NHISJt1Q9e1gA05L4dKnw2smbe6JP/ONQ8tFO/lfHKGLMG8b6xRjXDH3h3UXWjQP2w2Lt530ulyCUDuZVutDcZtwlHQRK+9TforJ8FZWbD2tNiQCT8qlLIOyi5XCsOUO2bEUi6iSjwzCLopUl2RhxmxandKMrXLLsFRs2MxVY5nybt8DTqh61xx8Zt6JN61T35axYJm2e/UviIt6Nc8oILFZapOagZXM+e1CitbeoF50fjntistJsc6IF/hYSGC56ABlVtvKCyYd/z6selKxdFJ3HEC/HdSrEpnmNsip+Wch1eGiwtuYNCDnx3GSHXV+v1GAPDlPcGBtnPOb43qa6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2PAdiw2GZ1bcQCyrPqMubPlWkkty7jB/5Mxdmhh2D64=; b=N6YZ4dix/+Br6ILCKY1xFLGhC8GwaY9j4n9IQpYx7tGMasIoyOWKAkr/YMh1iNOhW6EPARBupodUM2mHHcuh44unWfrcqKhhTdm0Q5pkdqQkf7WLgYALMMso6i5XvinLfHfirNQReUV063ue22jVWPQe36EHQDLvX4dPHPRm52DRx1IdrOAn7TCkrQv0Q05Jml/2NaLKKPC9om0OmNTNQmg5I/lNfSYKu8jR0eGD83IC9t7ehgM6OeMNZ3hf/u91Z8x91YDiIDdh38KPfJdlFuI5R0ikl9DnPRY0PNVDq6Gyq3pRYThRC0omnNX6hreoZyen+/01he8CVRWjF0pzOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2PAdiw2GZ1bcQCyrPqMubPlWkkty7jB/5Mxdmhh2D64=; b=CWX3h9zinYhft6Cd3o7uXE64s0Oz5Oejr30Y0FpfvyG+782UXYDN1/M2r3Atb0EU36RVyYZ2N9HkuHV+BiU+fOZDpISH313g9LGSuhF15WGaaJ+ELF6ovOV97WKwnTc4I/ld4Sf1S2M4cDC1kMFDGSt4sBPD8Ib5KZ3Ho+9GwcjUL+OOaQqDT73rBuBYLsSJkaISsRis8PwRNAZPNYSoHWb5TB5TbEKQ7rA2HqsHW1W4Tk645VgvyMJiwdDQwEaoNbIcwpmONDKLerY5vlt9g+kTB292I1HP3AuYagWVS53od63hV6pwHHkfziMkL/4K3djY1QRqxreKhWaRUkaJEQ== Received: from BL1P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:2c7::7) by DS0PR12MB7899.namprd12.prod.outlook.com (2603:10b6:8:149::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Fri, 25 Oct 2024 14:27:15 +0000 Received: from BL6PEPF0001AB58.namprd02.prod.outlook.com (2603:10b6:208:2c7:cafe::fd) by BL1P222CA0002.outlook.office365.com (2603:10b6:208:2c7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18 via Frontend Transport; Fri, 25 Oct 2024 14:27:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB58.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 14:27:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:03 -0700 Received: from fedora.mtl.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:26:58 -0700 From: Petr Machata To: CC: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Danielle Ratson , Petr Machata , Ido Schimmel , Amit Cohen , , Jiri Pirko Subject: [PATCH net 2/5] mlxsw: pci: Sync Rx buffers for CPU Date: Fri, 25 Oct 2024 16:26:26 +0200 Message-ID: <461486fac91755ca4e04c2068c102250026dcd0b.1729866134.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB58:EE_|DS0PR12MB7899:EE_ X-MS-Office365-Filtering-Correlation-Id: 40a416bf-93fa-42ea-e355-08dcf5011f67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 9EHSnWwe9eGPMpY440CiGPs4dbwrJ0KepQfoX5Yz5M9LVBDS3GpHqtMyyyqwhrBukPit0c6Ze2/HFJBmR0UEVkA2I4swJ5UElQTpbQ6j7eVV4oFn5Y3wqilqJrF9K36skBVXBwP+khTaauTmRVo5eWMART+SF8n58v4M07PKTFkCzU9oXecFcoRT4556rS9y0zU1TjIxxI2rz8PeATbwJRw9JX3z/fxbVUKSrqEPY0PoPN43Fv6GEI662CmansqkGDDdsBDyiTlu5Kgbf8681ThGIj4LKr3td3Vg/YxsLGuFwmPsIQLgHRTEDylHGy4oB9G59sKXOuIemUJiqHbXWRSSnYiiD+CDLER1egIrIR5LmW0SbbRV9NXqCq/GQo6uZrd1yf7adnzJtLTgl2Co3EPmCm7ZWyKXzdPtwFj7eUfVghqk6kKjrWUoVyCM7yvVbXnGsxc3wkHjQNYTvvPdzq19gxcm8GTHjxfTVcBI4ZQSZlKOGy8s0YcAZA1rSkU67fF90oPPSUQln20/dkiPfiBJlsCmBCnlSds58IYPhmHNnXAi25izpSuGGJPHTFzswOPg5s+wYDw0+F3CYgMWDhwGFziWZmNj9w/V7CkWSTzR91eelk72RPN+9ZgxfxTY3HHyxRXR/qjEB8CRtv1zITZKFd0dG6HUz666arGghLmWYLPOmWsh1weESOtb+4nuDTj2v61YzTZ2leEjYXr7Mijz8nzMrqgBAra0SHjNuWACvQu1nW0bCCjWVhxv7640BTg/JDai2UqrDYpfnTyAyXihzYYaQfWI4J8h+NHvX5uQa8x7Pp5UAun3BFJz9WL16B/lb1J6DHZRK3fu5Ot8jJxaJW05c6GFNe54DufBFe4s3xmUlFkREPBySF7QVhIR4b8gVZq3fcEX0/rAhuPjxFxwufSLpD0pfLTllz1CJoF5hhB9DwscAJFYuU46uIQAuTfRv5Y8fV47Hn/clYIPWBh6SuV3Kto46aZa7BjLjKnNvJFkDztU5aX1NZRuFeqKnL4rl+EvZiMO6Y0U4iwGuDu2HeJtWNwg5d0sFD3E0jwomKDWBvrSe1eMDC9I0/5jBBD0fxbJQVvz+Rh75jGABsiptB6zXxDHK5FLksSz1EuUJz+KIRX+AE1OToDjkq9nE7CY1+Z9ByWzcHADV4U6fJUjEUA7tY0RA50c3HntN60JIgck7zjEpnUO2BKiKC45PwhutgzrGcgc8t1MrBt/2uiG9HeI/xb8bYeXfHr15+PBIsrmKfLVK2sXC0O4ZH0837MFoEbVBq9xSoAvtnOHyoqpe8GwfrfScyLJOHfK9tRTQ88sG+P+6084uSlNtE+4puiGQD6LbRyuZ5EggV8DUGUPFB49UbWkR8hCrnGmeH/WAs1iKWJA9TeLAPIaQ1BjptVBUQklQ8OzcbmRCF6cuQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 14:27:14.8567 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40a416bf-93fa-42ea-e355-08dcf5011f67 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB58.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7899 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen When Rx packet is received, drivers should sync the pages for CPU, to ensure the CPU reads the data written by the device and not stale data from its cache. Add the missing sync call in Rx path, sync the actual length of data for each fragment. Cc: Jiri Pirko Fixes: b5b60bb491b2 ("mlxsw: pci: Use page pool for Rx buffers allocation") Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 060e5b939211..2320a5f323b4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -389,15 +389,27 @@ static void mlxsw_pci_wqe_frag_unmap(struct mlxsw_pci *mlxsw_pci, char *wqe, dma_unmap_single(&pdev->dev, mapaddr, frag_len, direction); } -static struct sk_buff *mlxsw_pci_rdq_build_skb(struct page *pages[], +static struct sk_buff *mlxsw_pci_rdq_build_skb(struct mlxsw_pci_queue *q, + struct page *pages[], u16 byte_count) { + struct mlxsw_pci_queue *cq = q->u.rdq.cq; unsigned int linear_data_size; + struct page_pool *page_pool; struct sk_buff *skb; int page_index = 0; bool linear_only; void *data; + linear_only = byte_count + MLXSW_PCI_RX_BUF_SW_OVERHEAD <= PAGE_SIZE; + linear_data_size = linear_only ? byte_count : + PAGE_SIZE - + MLXSW_PCI_RX_BUF_SW_OVERHEAD; + + page_pool = cq->u.cq.page_pool; + page_pool_dma_sync_for_cpu(page_pool, pages[page_index], + MLXSW_PCI_SKB_HEADROOM, linear_data_size); + data = page_address(pages[page_index]); net_prefetch(data); @@ -405,11 +417,6 @@ static struct sk_buff *mlxsw_pci_rdq_build_skb(struct page *pages[], if (unlikely(!skb)) return ERR_PTR(-ENOMEM); - linear_only = byte_count + MLXSW_PCI_RX_BUF_SW_OVERHEAD <= PAGE_SIZE; - linear_data_size = linear_only ? byte_count : - PAGE_SIZE - - MLXSW_PCI_RX_BUF_SW_OVERHEAD; - skb_reserve(skb, MLXSW_PCI_SKB_HEADROOM); skb_put(skb, linear_data_size); @@ -425,6 +432,7 @@ static struct sk_buff *mlxsw_pci_rdq_build_skb(struct page *pages[], page = pages[page_index]; frag_size = min(byte_count, PAGE_SIZE); + page_pool_dma_sync_for_cpu(page_pool, page, 0, frag_size); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 0, frag_size, PAGE_SIZE); byte_count -= frag_size; @@ -760,7 +768,7 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci, if (err) goto out; - skb = mlxsw_pci_rdq_build_skb(pages, byte_count); + skb = mlxsw_pci_rdq_build_skb(q, pages, byte_count); if (IS_ERR(skb)) { dev_err_ratelimited(&pdev->dev, "Failed to build skb for RDQ\n"); mlxsw_pci_rdq_pages_recycle(q, pages, num_sg_entries); From patchwork Fri Oct 25 14:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13850816 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061.outbound.protection.outlook.com [40.107.243.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF31A20BB21 for ; Fri, 25 Oct 2024 14:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866468; cv=fail; b=iYTiKChEMTIncf//tX/QoP4du8wUKIlghWFPLxZZOcN7haJIVaQfudfvkuQ6a5Le+rfmtzU3hdPUBCeIurtznMSTcc4b7/MyzwTegT34PTW/l5wmtj+WyBMgFzdO8qC7Z+16OM7QEjtjTGT3JbUk+6swPmMpwzE3N9nxEWQ/sww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866468; c=relaxed/simple; bh=0xBNyGozvBwky5YWZy6dO6f/jq14uSlpKLdF6yvf+Dk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iUcKJE3rNihpObtu9sWIVi/TtwWQ0DjwtQdvAF5nx3SZKm/EOrUTgaXISu4ho5S8i6QAeYmbGMPXO2qUVOUeefXDTG+1BzddYHYThlxBLLcgGHhysHeOgI0CSg2IfVT6D0UtZvpccTl8UQS2DMgNzOY1iKrJlbIlvWsrHy3OJkU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=VWcOjOfa; arc=fail smtp.client-ip=40.107.243.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="VWcOjOfa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qyWmU5nfQu0N2s4YJWgsSRfRwNse98p0M9ycZ+k06rXLMIXpfJFuFG1JWjm7BRZHRmZVfgj8Kr7XPK39saeHl9TH2F7qf665OBKhqnseu4GoTjyfE93bm2ia8n5gU0G1TrO3iGz1s2ewbIggB7guJQekcT0F/N++up2c5CVrOHrBnICxpa5z1OEPSNacxsWqusYrLoLa0gLYtr31T1N3nHjO6LeEifYBmmQqNGUYT4vyUc3fWq4q+m6AAZgR9P/KlNSFEK4SY9JG9EvoXTfsatq+ZpOxU84YroRy/DkMv8VOX16+dy/spynxDJnKidt708g90qRBZFjwX9fj4H2I3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FTDpnscTtnCmguKoArzxwjo6aQOHkpUOC7+R6iPLjP4=; b=j4OYHpa6OYDKNyaKn3SD1VU5ZXTj5u3GRzl0i1Acq1gKfLD+4wrvAxuh2bPHfwCul7Qn/0GwVbnP8WrTS7AXy9ZCUD0rwSgFbPQi7e8EMCRXlHTvPJun3/wrGqG26hpjD7IZ5CKkINhidFIsY8EpICbyYr6k89PYUp3h4/+oUB+QLo6H5M1px4fCFAnz/VvhOt13caqon5RKUNY6g/Qgi0tpfO18n7xFuS4zRfbsGXX2sGZALt2piSuxIBEINSrT7PZipS9QC5wY+ukwT/PwMbuVptn6NKzm6uhBseRGX3NRZgrQErqyHl8zgEUDPwI9cj8g9n5vUwmTi6I2dND0tw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FTDpnscTtnCmguKoArzxwjo6aQOHkpUOC7+R6iPLjP4=; b=VWcOjOfaIFodBCWwxinMr5gjEXKSlZjQ27L9Ds573i1d6TEjYeG6LrgLNlm/5V6VC4utmGU4Q4nIh83jRZnN0NuLCEKHuRBITXpNDgtbnUA4IS6m8ueIoljZvWCfBsLf1leEitN5j3yX+8JHhey354tCc8V4kWquybY03KNYIWIM8drOhT7Jc6yqQS07DYF73NDOzTo/16Ixl50GEZr+rFyU30VlbfD93cUkMTClGTXRe8/HqruVHs9yCjk5KCeie9mZamCHKncbgKrV/ybPhDoYg6l82rvyccF/KuwvDuffUBfwK/WmBZiEWxqY4+TPc2LpyX3fkZ4OmxBvgOkWlg== Received: from BLAPR03CA0004.namprd03.prod.outlook.com (2603:10b6:208:32b::9) by SJ2PR12MB7992.namprd12.prod.outlook.com (2603:10b6:a03:4c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Fri, 25 Oct 2024 14:27:25 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::2) by BLAPR03CA0004.outlook.office365.com (2603:10b6:208:32b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.19 via Frontend Transport; Fri, 25 Oct 2024 14:27:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 14:27:25 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:09 -0700 Received: from fedora.mtl.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:04 -0700 From: Petr Machata To: CC: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Danielle Ratson , Petr Machata , Ido Schimmel , Amit Cohen , , Jiri Pirko Subject: [PATCH net 3/5] mlxsw: pci: Sync Rx buffers for device Date: Fri, 25 Oct 2024 16:26:27 +0200 Message-ID: <92e01f05c4f506a4f0a9b39c10175dcc01994910.1729866134.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|SJ2PR12MB7992:EE_ X-MS-Office365-Filtering-Correlation-Id: 96cd0c79-9189-4463-f0f5-08dcf50125c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Q2MBzRIYWInXbKcfvcLmFcQC3pP1adkTQ8NNc/kc0IOudHQt9uJu/bZyQSe9OAmnJptfQUVOZaK9pZAlHQ+uk6RfzPWvC68gJtgLKGAZhW4T8h/UUW1Sm8Z/CtQ5penE+WAgwBXRNL3fXwmcNWdmcZNv5NpAeHUIY6hgmJ/YSXXWCYskSV4yaw/dZO954j3dPk9QemUAuvdK7dX1JKSMIP5Vxi8b+8E6W/ahsXuhUDyFFzWZqEhlVpf/8vkzvtfHm2Qcv/IN9WQFfzmXYMO3rRqdbqtSBRlLPbIixnjt/6rMdQnK/LaNZjq5bROuErN+sz3+1lEd+0rbRFkMfRy85Euv5oGMMN/WzazLP+j5gjcRNlcnZiu1j5CctlA89fawlYaJlB8gwIwhaWGO+nT1aeiYQXXr6TyPivE7a3kSQZRwQgXcTnCA74hceNnk5ylfSaZMl9oj7NQPhd24kqknUaoWmeg3wyUKDfvw7f4fPj7hsUTiYEfTBlZ8llyNxhxqMrUlt2IHp9LsNNQraClfrQFoaDp6D68AruqgBal9YO2PdYqNUWFz/rvThaqSvZlo7GtMe8wXAPtmAoQjtAOAvEtjscFcEeX6/zrYtB6e15mRNTlwJYIOIh5YeCB72pIXfEMvqU2DSLvDRZ3v/VoEwK9yCMoTx1VJS6BUonB8rUbaW9pvfgGCIj21dZwRBCp2TuybYIrmBrOZNq1Nj7SzSziSDHToYa10zuj8EvISiuDJrryfAa0NFdzn2Yub1yWIuVi/iBRWBWow1gIHO5W7ixRWsKrO16myWekR1fuhmLTNCpy1gXhRGLD32vO5sMctyXZMsuNPNk7yrVYVihLuMSbg0VVpJhAPz7yyegkgkUYFSdH344RA1lUGI7wwebJ33720GGywtpbLbR9WQDrkT0KwsrEiz8w45PGpr8IuI38c+amuipizSpdxNBvzWpic1Ca/wANv+112f1Vtoj4I8hck7pVpWumnIlu0SLqcLLCk76NxLF0s9XJFHiQA454TUPb5WhhPNFyXADWJXomwCcMbgIQb8pCzVZIoHxZEYyuZPTKn3i63FZdMw10qFR602Rs1WxbRlzqx3Bv/y4ZEVD7+D9pNGRVfOfe9PAVt+cwjuhRhx1wYrg7DW/SfKXSV3RDeNagf8QOaZCdi0hk4w4qP00eTL13HtgcLicfEPkjhAKN3NtUlYKvAVu5RVw4GqvjW3BcRJFIAulboKGaCAE57gm3pcqdc7gmiCw6tEBw3YKaZzfw+ADPsTNlwmXFWqmb2iqy08yro2wa3ieByLJdqR+tnsOfMLyi38K91Y+qJVZnrjuQsJAiZ3SXYSCKj/m7H6W1uHq8D00flzhpIrGZm7CP9ad6UaY7KYQWgo1ZqK9t10SeijjKQWBtpcEPsk89gaJ8iZd227nueCtM1mA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 14:27:25.5303 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96cd0c79-9189-4463-f0f5-08dcf50125c6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7992 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Non-coherent architectures, like ARM, may require invalidating caches before the device can use the DMA mapped memory, which means that before posting pages to device, drivers should sync the memory for device. Sync for device can be configured as page pool responsibility. Set the relevant flag and define max_len for sync. Cc: Jiri Pirko Fixes: b5b60bb491b2 ("mlxsw: pci: Use page pool for Rx buffers allocation") Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c index 2320a5f323b4..d6f37456fb31 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -996,12 +996,13 @@ static int mlxsw_pci_cq_page_pool_init(struct mlxsw_pci_queue *q, if (cq_type != MLXSW_PCI_CQ_RDQ) return 0; - pp_params.flags = PP_FLAG_DMA_MAP; + pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV; pp_params.pool_size = MLXSW_PCI_WQE_COUNT * mlxsw_pci->num_sg_entries; pp_params.nid = dev_to_node(&mlxsw_pci->pdev->dev); pp_params.dev = &mlxsw_pci->pdev->dev; pp_params.napi = &q->u.cq.napi; pp_params.dma_dir = DMA_FROM_DEVICE; + pp_params.max_len = PAGE_SIZE; page_pool = page_pool_create(&pp_params); if (IS_ERR(page_pool)) From patchwork Fri Oct 25 14:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13850814 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2048.outbound.protection.outlook.com [40.107.92.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F2501F754D for ; Fri, 25 Oct 2024 14:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866462; cv=fail; b=OhynVreUnxvWou1DTDqr7gX4uwoq7OTwa1e0d4lxqij1QHaI7xupv1hdL9NdDASY+mWiOS+etBVeBQTs9GSj6/v+fPjXr/Ki8hCsVMTAa53MxL+Un6uiNAz1faolG/wIi9FXWHKO3SB97srnMYqa1ZG2wkCremB9iTQ7Oip/jVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866462; c=relaxed/simple; bh=ujVDe+l8VoGswtd07mC+bTvPvvqe0qStfYnkDUSiDpY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ahpghff8+Qjtynn49ja9K4ww4EgqYmU+XJDjcsAylVkcY/2vabuDObiHsQXJVdoHZWCsvIyggOc3RYVFby+2uDIn82HQGiThRB+naXGC/r3pzAS0iw79DoPp3Im51ySdt4pzFku6V9bqMRfDSQ0NEiD9/Ja/4LInDPQJ+UOeTT8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=GXEDTVIF; arc=fail smtp.client-ip=40.107.92.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="GXEDTVIF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=atBfpYQmWC+yNFkiP2+eapzT25f17hAKVW8F7jpiBehVJdxTLIf3fNClWBojvGvpagHW7ZPC+Ei3wCEgxuLbNYrguOv+Fn3xp6J9ZqSc8Ow6ZqeDGH8qQeHwa8AIXrjqV9ZnMjTuQX3zrmQ38CMz3QuYFNHiZyvMfeh0sCmfxCw8cEB0zJs7Gh1O6dCH3nM4frCLSjt+m8YpLZjWKGKs1nESWZ3mjVP0MxjsA7fxkM6ebQfGT+7teViMsWfTl/CI1T+Zt4Im8kWliY+TfI52SJUEutg2rMh5joF0me8gCo27x3NL7aiX5/PS94SWtiITXAHdkFfC2VvfPKiRs74JFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wm+GMsVl1rVfD7wNT8XZJDSA0DIT+oZ58oiaSsr4nCk=; b=HYUYTeScC2BQsVYoLzBv/elyg9O3Dh0i0xr9oitNuP9tsgZv/syHkVD99ZO0EnsCRQesbbhdkjyPdaplQGN/qgPPgkOVHTvWNCzf3OgtsBiH0AKXFMc8UQ6KrHokg6DhWwBgCzpugPanlQZ48sx0IAIS5l+N0muJLKONmaHdx8kjRhmgQxbyw0+lPGW0dWJu625Y1geEnNeHY/IhB/5aJ+pmAUwQMze8PAfGo4/dDTmUfm1LhWkKcUQfPB8hiEXIDQxdqToHAgcwcJ1P62epBjNq5qQIQM84OevBov59VUT67o8pzzPoU211PCguI1z7ZeLgEiMOHDxksUNQX7iXrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wm+GMsVl1rVfD7wNT8XZJDSA0DIT+oZ58oiaSsr4nCk=; b=GXEDTVIFEPjAdttOzIcVIAvGzoazc1x6ablYco9Pgw8A7iWbakbIB6mSmFGlCgH393l3AvLA+OblAlHbohv5xwOMI5BdcJNcfWEMaCqSfGXFB1RtG1Bc+DKTtfsvYMt8U8LLWf1iFO0LJ9sOB8fS5eUqMvjH7OnFy1uBrz9bWWeUuSxHtGtLr44PiGSByEj5J7G3fNCfQSiNujDQMa1K22pSlks0LZRRWS6dIhAk7+gckrhaeRailA7eZDBP/ZYlyHdsKXs+rChnWWOMGgYzZgYCFDgiILL3/D7FPVmGrGLFfSW11JBYmB9U9z25bn8ZDfuAMOUf53OJPDCYsDHiSA== Received: from BLAPR03CA0022.namprd03.prod.outlook.com (2603:10b6:208:32b::27) by MW4PR12MB7215.namprd12.prod.outlook.com (2603:10b6:303:228::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Fri, 25 Oct 2024 14:27:33 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::6c) by BLAPR03CA0022.outlook.office365.com (2603:10b6:208:32b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21 via Frontend Transport; Fri, 25 Oct 2024 14:27:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 14:27:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:15 -0700 Received: from fedora.mtl.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:10 -0700 From: Petr Machata To: CC: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Danielle Ratson , Petr Machata , Ido Schimmel , Amit Cohen , , Maksym Yaremchuk Subject: [PATCH net 4/5] mlxsw: spectrum_ipip: Fix memory leak when changing remote IPv6 address Date: Fri, 25 Oct 2024 16:26:28 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|MW4PR12MB7215:EE_ X-MS-Office365-Filtering-Correlation-Id: c5266d95-b0e2-490b-9650-08dcf50128b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: NI59LuWt3QMowb6OgoBR3PtPfoCBMURYV9BVYIR0dgphUl5Ot7f0grmoYJByjWsGOkx2Plb5ucvik3OLTzkZ+sfeEXwCRsdieeoXHHeR0FLMiwJBn2pX3SD050RElrejndtw42x8AOp9oImTtmcirGYAblzd4mFJPDkF/1dj/wbCIvgV1ORQZY2yKIgzxuA2ivsyqzGzYdjMB432Sk6rLwJnXFDdNXCab99BEQHT22xch5+2NJcVwvGbLpDkygPcugiZMKCuccNLjCDvNzTbcxgluRyI5cWtZbRhhc3xTgd6F2ZszpB5Mk3VfB4s156C5Z0+KYzUrDTDPSpmDf55PpjaLPcUwnb+Ph2yFPjUiqk6ZimBeZtNxbkrGI12BTeAaLDYaSMEwH+WxZ7Y0ovvpoaEL80ZKjklcZHNU9zX4liztPy3WVSxUfv6g6ZpoMGxKMQk8wQYK9BVl4yhWSNW/AmhOvE0TqJaJfyMa3xriJ+LIILaxGRBuYESURfPUK5yDkwmYFVVStMwSnwowJkN4jOUNszCYauJkzoTEjjDFQUITIY/JK2OlNN6Kz3XDsV55jhPNNEx6KU43sJbGM0aT7jLItujWSQUcpdY9hhCSInRT5ImrGR7IBraUMGl1u/n65O6EFHM0TuYrE+ylC5zaOIA4kXkuGhow5eWGH+3b8TfnXS+hyRGTgvsQEO5YDmQ8kYv7R3UH5/ke2Ms6BI5+AFNavoesUw2D9YYzWWI/fqj9XKt/nnVFdExBJes8s8RQ0ArzW6UvxG0ne6t89kx8bMJKJe2XEjdrkcorjI1L8wX6V8T+aUimZ2vokO+17E4TGe1Z1dP739JK+xmnjpMNhTK00dSddTVXAgc9mQYKVFY476Xk56ze4rJyEntwH7D1hg6AwVfn4+rCvAj95bZe8+5d+ZGwDKXEQ9QgJeldi0ibM5HBvEOtDFuM4FP2xYlnlQaWjCJyUmu5ifw09V4QTOOU/yFmWgsC0MJnpud2bm9ZuAfHmFoNXS9gV2FOT0pwwIN4dxi8kaZbm5N5u3QvX1OLoIxPSz1L96ZA+XGaMve1pajKS2liSeh3s4FvAbgJ02eeN/rlH+TKhRlqkhl32Bdhak5pgBqrI8TwgNW1XX/M30wPqOLEe+nj6hzVrIVuzFgUbaQhT9uovG6hqSZ3iLGxJSmRnk1plMKkIVDQxoU+U0o7//kPb5wd6B7/Elzf/GQlwFqXJHXUaVssXMvsXhVLI6NagfhgezsJSBCK8dZSC2de0nKcK27rNz7yVS8GI9oOryTi0CuNcnU0FrBTCDD7gPRa6O0UeGmaKcMyDZL3Lpp61n9dRb+PuI66g1WrflLS9fzGLiTfIIL3Y7WrehQJ85b8FED1WyGfQZtALoOowmEx6ZNbOrITRkX05CqvvY+ajxIniIP+9qdSCyWAQ== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 14:27:30.4523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5266d95-b0e2-490b-9650-08dcf50128b3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7215 X-Patchwork-Delegate: kuba@kernel.org From: Ido Schimmel The device stores IPv6 addresses that are used for encapsulation in linear memory that is managed by the driver. Changing the remote address of an ip6gre net device never worked properly, but since cited commit the following reproducer [1] would result in a warning [2] and a memory leak [3]. The problem is that the new remote address is never added by the driver to its hash table (and therefore the device) and the old address is never removed from it. Fix by programming the new address when the configuration of the ip6gre net device changes and removing the old one. If the address did not change, then the above would result in increasing the reference count of the address and then decreasing it. [1] # ip link add name bla up type ip6gre local 2001:db8:1::1 remote 2001:db8:2::1 tos inherit ttl inherit # ip link set dev bla type ip6gre remote 2001:db8:3::1 # ip link del dev bla # devlink dev reload pci/0000:01:00.0 [2] WARNING: CPU: 0 PID: 1682 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3002 mlxsw_sp_ipv6_addr_put+0x140/0x1d0 Modules linked in: CPU: 0 UID: 0 PID: 1682 Comm: ip Not tainted 6.12.0-rc3-custom-g86b5b55bc835 #151 Hardware name: Nvidia SN5600/VMOD0013, BIOS 5.13 05/31/2023 RIP: 0010:mlxsw_sp_ipv6_addr_put+0x140/0x1d0 [...] Call Trace: mlxsw_sp_router_netdevice_event+0x55f/0x1240 notifier_call_chain+0x5a/0xd0 call_netdevice_notifiers_info+0x39/0x90 unregister_netdevice_many_notify+0x63e/0x9d0 rtnl_dellink+0x16b/0x3a0 rtnetlink_rcv_msg+0x142/0x3f0 netlink_rcv_skb+0x50/0x100 netlink_unicast+0x242/0x390 netlink_sendmsg+0x1de/0x420 ____sys_sendmsg+0x2bd/0x320 ___sys_sendmsg+0x9a/0xe0 __sys_sendmsg+0x7a/0xd0 do_syscall_64+0x9e/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f [3] unreferenced object 0xffff898081f597a0 (size 32): comm "ip", pid 1626, jiffies 4294719324 hex dump (first 32 bytes): 20 01 0d b8 00 02 00 00 00 00 00 00 00 00 00 01 ............... 21 49 61 83 80 89 ff ff 00 00 00 00 01 00 00 00 !Ia............. backtrace (crc fd9be911): [<00000000df89c55d>] __kmalloc_cache_noprof+0x1da/0x260 [<00000000ff2a1ddb>] mlxsw_sp_ipv6_addr_kvdl_index_get+0x281/0x340 [<000000009ddd445d>] mlxsw_sp_router_netdevice_event+0x47b/0x1240 [<00000000743e7757>] notifier_call_chain+0x5a/0xd0 [<000000007c7b9e13>] call_netdevice_notifiers_info+0x39/0x90 [<000000002509645d>] register_netdevice+0x5f7/0x7a0 [<00000000c2e7d2a9>] ip6gre_newlink_common.isra.0+0x65/0x130 [<0000000087cd6d8d>] ip6gre_newlink+0x72/0x120 [<000000004df7c7cc>] rtnl_newlink+0x471/0xa20 [<0000000057ed632a>] rtnetlink_rcv_msg+0x142/0x3f0 [<0000000032e0d5b5>] netlink_rcv_skb+0x50/0x100 [<00000000908bca63>] netlink_unicast+0x242/0x390 [<00000000cdbe1c87>] netlink_sendmsg+0x1de/0x420 [<0000000011db153e>] ____sys_sendmsg+0x2bd/0x320 [<000000003b6d53eb>] ___sys_sendmsg+0x9a/0xe0 [<00000000cae27c62>] __sys_sendmsg+0x7a/0xd0 Fixes: cf42911523e0 ("mlxsw: spectrum_ipip: Use common hash table for IPv6 address mapping") Reported-by: Maksym Yaremchuk Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Petr Machata --- .../ethernet/mellanox/mlxsw/spectrum_ipip.c | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c index d761a1235994..7ea798a4949e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c @@ -481,11 +481,33 @@ mlxsw_sp_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_ipip_entry *ipip_entry, struct netlink_ext_ack *extack) { + u32 new_kvdl_index, old_kvdl_index = ipip_entry->dip_kvdl_index; + struct in6_addr old_addr6 = ipip_entry->parms.daddr.addr6; struct mlxsw_sp_ipip_parms new_parms; + int err; new_parms = mlxsw_sp_ipip_netdev_parms_init_gre6(ipip_entry->ol_dev); - return mlxsw_sp_ipip_ol_netdev_change_gre(mlxsw_sp, ipip_entry, - &new_parms, extack); + + err = mlxsw_sp_ipv6_addr_kvdl_index_get(mlxsw_sp, + &new_parms.daddr.addr6, + &new_kvdl_index); + if (err) + return err; + ipip_entry->dip_kvdl_index = new_kvdl_index; + + err = mlxsw_sp_ipip_ol_netdev_change_gre(mlxsw_sp, ipip_entry, + &new_parms, extack); + if (err) + goto err_change_gre; + + mlxsw_sp_ipv6_addr_put(mlxsw_sp, &old_addr6); + + return 0; + +err_change_gre: + ipip_entry->dip_kvdl_index = old_kvdl_index; + mlxsw_sp_ipv6_addr_put(mlxsw_sp, &new_parms.daddr.addr6); + return err; } static int From patchwork Fri Oct 25 14:26:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13850815 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58EC01FB8AD for ; Fri, 25 Oct 2024 14:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866463; cv=fail; b=Zo+UZ6r+Zi3bKurfXrJhak7GhpENwS4ScJOr9Ac7nJLDO89wy/9TwkLx7vhSFlfkMYtks/q/xNaJ+otlBles+x8IYOrtU8CwPqOE/uhtEs3XbsHJrtxMVniWgtddb1YnG7Ba3oszw63Sge9m3K/LV8E8JmEw8rSf4UMocSOZutE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729866463; c=relaxed/simple; bh=VZDAVX6h2mzb/hiTeXJhWDumNzggrysGVKzH/miyLiA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z//x6dCNB8JoH0sCW3p5nFs+EnxdwaCxnBBOtJgBEzeIZafpo2BWuR+e5C05NuQ3kro6Ts1JPoST7vX7lErtX2888O9DHlmCWFoOxGF8dADaLk5WOVaCqgDDEEY4s+pRwbV5r39Lh/xCk855lS40F/UHjAxCbJpVE5NjPQ8/j2o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Y+O2/Imk; arc=fail smtp.client-ip=40.107.223.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Y+O2/Imk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bzbTDgqA26rf5i5ho7K5oDnYFEcryA8cCSSFIVkNh/+IFxBcUejuVE98Myzuxdxg/dQJxCLCnLl4e2SDl/QrdPESfgHBmLxq2yHeGP1UxFUSQ+5fL9xoOwdeIX4OujL2DTAbXfSeAa39FYukO4oXT/9AL3jdcroLtQbjsVeX8TtprgUHhorKPAHPoZYKK/q4uktqdcp0DWIcVvnjSiBLlvz3fuNZ8agGhRyihKrpjEWrX6WjsL8XYaenE/6bTWk43BxFz3v5RxbORBMYyNqnHK4ebwlZqviZVV73ORUxt+JeG1HQ4JiTXBaa6B3WhHSDUOpUR1dBCfsjJfw41oArfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+F8KK/ZZnhgRDviFO02ahH5x9I4FlIn+eHXj/TjLeGE=; b=cfYeMFepxKRVyNb0nuqbxklR3oMBxt3PJnAKnOzJkgtz2cyHMW9Ekk8UAMegQHcJNWPWy1prFKOK6FcsyvRPFN2RZshWMPZb1rqVQlwm6HZbyErfZaeo2aJ6V+GL7PW5Ua5r8P0Lx0u/fQbcmvI4lH3/jNnHLQoSPFnGkoD7l2ZKkGMnkyExXryNFBftU81FQCiOtELJYjCr2yPOKiX01lSPS2vk81ZeDCMP0C2Pe1XpcomFfUcFJvrw9jf213NQE1rV399+qS7xa8UeVnyDYxRvfS/v3I+i0G5FP1qZYxJakia0w86zebM2fJ1MV6LXnTRS1Ju8xT/RwqbXOfTjHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+F8KK/ZZnhgRDviFO02ahH5x9I4FlIn+eHXj/TjLeGE=; b=Y+O2/ImkeL2jf+Oh8U48a9w7c3ZNnvCVlMVyj45hu7//2UjqA4ASAHE21DaR5dQU+9iwvLvwukg1eHj0SoSRpUjHR91/Hu3B6vkI4Tvjq+/4ynMI33AZ9TlnjPFTITF+iDUc2jhGvSqugrJlijCjYGn1EV9F59nGwThQEsfo8IEDs/0fgkvbFbGUYpP/6bYCiufsXkfOUyKz5cheQ2cZ+Npq6qHE7gSNz1sD72q52ZGjqi9IK7PhrodKPP5fqwAr5atRtMGvEKRjwBa4Esxm+Lz9Uk9fOXdeOe5cpvMCkHT188CLzUaQRl/0VQHuxjJMISNYn6Npt6G392c9BiXxVg== Received: from MN0PR03CA0007.namprd03.prod.outlook.com (2603:10b6:208:52f::6) by IA1PR12MB9063.namprd12.prod.outlook.com (2603:10b6:208:3a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Fri, 25 Oct 2024 14:27:35 +0000 Received: from BL6PEPF0001AB57.namprd02.prod.outlook.com (2603:10b6:208:52f:cafe::7) by MN0PR03CA0007.outlook.office365.com (2603:10b6:208:52f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21 via Frontend Transport; Fri, 25 Oct 2024 14:27:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB57.mail.protection.outlook.com (10.167.241.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 14:27:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:21 -0700 Received: from fedora.mtl.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 07:27:15 -0700 From: Petr Machata To: CC: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Danielle Ratson , Petr Machata , Ido Schimmel , Amit Cohen , Subject: [PATCH net 5/5] selftests: forwarding: Add IPv6 GRE remote change tests Date: Fri, 25 Oct 2024 16:26:29 +0200 Message-ID: <02b05246d2cdada0cf2fccffc0faa8a424d0f51b.1729866134.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB57:EE_|IA1PR12MB9063:EE_ X-MS-Office365-Filtering-Correlation-Id: 77c596ec-9036-4adb-3b20-08dcf5012bb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: xMV81tiTWYTss9lVxobiEgCGCmqV6XPdw/s2YH2UPPgoxFn8FHrlvQ2LtKztKSyLY6q17UT+Fr49G+sB6XoL1w7x+/79Apbtk5HOwtSRrHj+8hjuvMdTVkbSfeD1SpOaMx4hxdVCcFqmKslD9fjw8Vf2jyimcpq/hHkZvY/lKgKPOoQBjjw2wqk7uFu/fHAJQS/w3PqJ1eTRwndgX/AEIbjQ7pDpFXU3WFl/qcxs665pK00G2ReIsHqZbLUgrAYotH1j5QsvON2X1d3xTFRpB+s2lRqAmYVN4vZAYShwG9Qpd69Oj/psYDERvxq34MndwY0KxZT416CZKlB+Y3zf46nmeQ4rGpb10ml81RiF14uSf2iv1xXnZFj8EQaHKcLVf46aEdgqcGMk/VQImxxd4SRw9PWVwDfELQBwIJcdpOI/9OZf6s/+0Qqj1CqcaRE6W1EWKwhydCnQ+oRiPJSj512cPnejyAuZy1PKVU/P8QrYdxgtzAfZMPasaKeXzTQUsOidNizrdObRiC61cdylqGmmfxeSXjbvsk1UZ4/uc3o+i3KKxgSplzIW8l1/lzJaouawNVK96rZ3uxH17wcg/9Xgzeus5EEU1kymLznZBAdHs9sHMo3KEe6scrTbUhi/opP/DpdKZXFcMGEpfJMPPiLmqvOIR8LlEexCHTt4JUlj0jqu3t9G0PcGmaoJ/2UKD90rl+jJS6QUr2qsnp1xzphO+nsBJBrKNK2/vh84To/DnS+taL/lXvjzVBbgQQCY16wU7Gp8S+JNsewW79TMoXEBZqFxYi/mvhomUqvtowFe1nv4ZELDrolN1D3hAqTurvIBsgCLw6ojinXVesAxiFWwSF+63kImaasmJ7CSG+qQRBPoq+My0U0t7GMkIk0NLswVbPrqZq7G2fsxURDnFV6q8FiRb7Be/ut1LE8TtchdFBvF0hzvTsQj+B7RSGN7LguxRgJC3vV/YmPqgBYAURnSJMNS1XzJBgBZB4FNhVhQp7nYTM333KQSej81e7jXssYvkbOeVLGLOxelHLowPHFtrQe790tUUAQ5nB/qX6d2ZIOzymuO5uFfQRLAN9VsWHa47CN+37XXjBZke8CYqdYqU7j04W+VPdxbMcO2wYnacuu4se6BdJksghO0zS/vbGXwcLB9xbAB9ci1PCOTn6F7z9LVdu0Rt8K1Wz2/9Vt1HXzPwskTbjYdWphYlJ0TTwQY/w6/FmM8qLbdbSFJYI9sI2kQjlcuy/lk1Ud/wAwOInVenj/YKbKqa1wJLFwwkHT2MugdLq0UUBylJuPHeUcGvPhXXAr9U7eKTCA9kVw1LhFjMbliNnIFrTNfFuJV66AElap3cwXbs3euSyhRvCtaB97Bj1ayqLRhePeFNukVSmzfnuQm0X9WobTHTaueP/Q00J+guJLASyXDd7raTg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 14:27:35.5315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77c596ec-9036-4adb-3b20-08dcf5012bb8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB57.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9063 X-Patchwork-Delegate: kuba@kernel.org From: Ido Schimmel Test that after changing the remote address of an ip6gre net device traffic is forwarded as expected. Test with both flat and hierarchical topologies and with and without an input / output keys. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Signed-off-by: Petr Machata --- .../selftests/net/forwarding/ip6gre_flat.sh | 14 ++++ .../net/forwarding/ip6gre_flat_key.sh | 14 ++++ .../net/forwarding/ip6gre_flat_keys.sh | 14 ++++ .../selftests/net/forwarding/ip6gre_hier.sh | 14 ++++ .../net/forwarding/ip6gre_hier_key.sh | 14 ++++ .../net/forwarding/ip6gre_hier_keys.sh | 14 ++++ .../selftests/net/forwarding/ip6gre_lib.sh | 80 +++++++++++++++++++ 7 files changed, 164 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/ip6gre_flat.sh b/tools/testing/selftests/net/forwarding/ip6gre_flat.sh index 96c97064f2d3..becc7c3fc809 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_flat.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_flat.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_flat gre_mtu_change + gre_flat_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change } +gre_flat_remote_change() +{ + flat_remote_change + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 (new remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 (new remote)" + + flat_remote_restore + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 (old remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_flat_key.sh b/tools/testing/selftests/net/forwarding/ip6gre_flat_key.sh index ff9fb0db9bd1..e5335116a2fd 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_flat_key.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_flat_key.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_flat gre_mtu_change + gre_flat_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change } +gre_flat_remote_change() +{ + flat_remote_change + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 with key (new remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 with key (new remote)" + + flat_remote_restore + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 with key (old remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 with key (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_flat_keys.sh b/tools/testing/selftests/net/forwarding/ip6gre_flat_keys.sh index 12c138785242..7e0cbfdefab0 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_flat_keys.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_flat_keys.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_flat gre_mtu_change + gre_flat_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change gre } +gre_flat_remote_change() +{ + flat_remote_change + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 with ikey/okey (new remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 with ikey/okey (new remote)" + + flat_remote_restore + + test_traffic_ip4ip6 "GRE flat IPv4-in-IPv6 with ikey/okey (old remote)" + test_traffic_ip6ip6 "GRE flat IPv6-in-IPv6 with ikey/okey (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_hier.sh b/tools/testing/selftests/net/forwarding/ip6gre_hier.sh index 83b55c30a5c3..e0844495f3d1 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_hier.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_hier.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_hier gre_mtu_change + gre_hier_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change gre } +gre_hier_remote_change() +{ + hier_remote_change + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 (new remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 (new remote)" + + hier_remote_restore + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 (old remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_hier_key.sh b/tools/testing/selftests/net/forwarding/ip6gre_hier_key.sh index 256607916d92..741bc9c928eb 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_hier_key.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_hier_key.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_hier gre_mtu_change + gre_hier_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change gre } +gre_hier_remote_change() +{ + hier_remote_change + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with key (new remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with key (new remote)" + + hier_remote_restore + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with key (old remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with key (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_hier_keys.sh b/tools/testing/selftests/net/forwarding/ip6gre_hier_keys.sh index ad1bcd6334a8..ad9eab4b1367 100755 --- a/tools/testing/selftests/net/forwarding/ip6gre_hier_keys.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_hier_keys.sh @@ -8,6 +8,7 @@ ALL_TESTS=" gre_hier gre_mtu_change + gre_hier_remote_change " NUM_NETIFS=6 @@ -44,6 +45,19 @@ gre_mtu_change() test_mtu_change gre } +gre_hier_remote_change() +{ + hier_remote_change + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with ikey/okey (new remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with ikey/okey (new remote)" + + hier_remote_restore + + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with ikey/okey (old remote)" + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with ikey/okey (old remote)" +} + cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/forwarding/ip6gre_lib.sh b/tools/testing/selftests/net/forwarding/ip6gre_lib.sh index 24f4ab328bd2..2d91281dc5b7 100644 --- a/tools/testing/selftests/net/forwarding/ip6gre_lib.sh +++ b/tools/testing/selftests/net/forwarding/ip6gre_lib.sh @@ -436,3 +436,83 @@ test_mtu_change() check_err $? log_test "ping GRE IPv6, packet size 1800 after MTU change" } + +topo_flat_remote_change() +{ + local old1=$1; shift + local new1=$1; shift + local old2=$1; shift + local new2=$1; shift + + ip link set dev g1a type ip6gre local $new1 remote $new2 + __addr_add_del g1a add "$new1/128" + __addr_add_del g1a del "$old1/128" + ip -6 route add $new2/128 via 2001:db8:10::2 + ip -6 route del $old2/128 + + ip link set dev g2a type ip6gre local $new2 remote $new1 + __addr_add_del g2a add "$new2/128" + __addr_add_del g2a del "$old2/128" + ip -6 route add vrf v$ol2 $new1/128 via 2001:db8:10::1 + ip -6 route del vrf v$ol2 $old1/128 +} + +flat_remote_change() +{ + local old1=2001:db8:3::1 + local new1=2001:db8:3::10 + local old2=2001:db8:3::2 + local new2=2001:db8:3::20 + + topo_flat_remote_change $old1 $new1 $old2 $new2 +} + +flat_remote_restore() +{ + local old1=2001:db8:3::10 + local new1=2001:db8:3::1 + local old2=2001:db8:3::20 + local new2=2001:db8:3::2 + + topo_flat_remote_change $old1 $new1 $old2 $new2 +} + +topo_hier_remote_change() +{ + local old1=$1; shift + local new1=$1; shift + local old2=$1; shift + local new2=$1; shift + + __addr_add_del dummy1 del "$old1/64" + __addr_add_del dummy1 add "$new1/64" + ip link set dev g1a type ip6gre local $new1 remote $new2 + ip -6 route add vrf v$ul1 $new2/128 via 2001:db8:10::2 + ip -6 route del vrf v$ul1 $old2/128 + + __addr_add_del dummy2 del "$old2/64" + __addr_add_del dummy2 add "$new2/64" + ip link set dev g2a type ip6gre local $new2 remote $new1 + ip -6 route add vrf v$ul2 $new1/128 via 2001:db8:10::1 + ip -6 route del vrf v$ul2 $old1/128 +} + +hier_remote_change() +{ + local old1=2001:db8:3::1 + local new1=2001:db8:3::10 + local old2=2001:db8:3::2 + local new2=2001:db8:3::20 + + topo_hier_remote_change $old1 $new1 $old2 $new2 +} + +hier_remote_restore() +{ + local old1=2001:db8:3::10 + local new1=2001:db8:3::1 + local old2=2001:db8:3::20 + local new2=2001:db8:3::2 + + topo_hier_remote_change $old1 $new1 $old2 $new2 +}