From patchwork Tue Oct 8 09:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13826120 X-Patchwork-Delegate: kuba@kernel.org Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011058.outbound.protection.outlook.com [52.101.65.58]) (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 60ED018C922; Tue, 8 Oct 2024 09:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728380618; cv=fail; b=PGU10AsgvhVoNjyQbLdxZCQxEiNcO7wugazbgikfOXCF8TP/RcZfDzyJsg0JvpNbcV83Av/P+FuDLq1k6b5zARR18dJgSVbNeYNXkmSSerxETZKd1C4kpNg1EsntW331W34EFXI55elcWLVAWtC4R7xAnPIUPsi3exzUZ5kPbJs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728380618; c=relaxed/simple; bh=JfP6S5YHvBOvGhvNVxujDS6KXHgJA5RzUc+BVukmiDY=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=etL6NJ1e3ZRFElGvac472zSYvAGjvhtQUQQaKr8JddHQrTFYgn0kU6As2uzDKw7mvixDBSBzXEaKimLnCdTSc64xeehT70y/okPRcqqQSJ4b8r/ASe2bCQZxEp93c5tSkjXDUpgUrvZ0YH92UYfb0E4on8O7Y0UMR+L462CvZ+g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=WLxs3Zds; arc=fail smtp.client-ip=52.101.65.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="WLxs3Zds" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=y/CRgoXZWfHrMaHdOMELSfKa540khbv7Qv3JtoOFmutQ30aAm++8R45iYemdjJyICIulAFFXcYLHUGQMd9OoWka4sYymBjG6AIj0LZ7qt2KI4v63srrhEn9K5ZSdoiP8evaaHunRJKT11E8zj0GJYIT3MAUU0q8Ofn0/hZywA6Q9TIvMoEhMvZ2epfhdMiiPiSuP72tPXMnp1ODsn0KIxWo/D+3juOrUwGZZ+z9pkA3iGwf1HUKdwAgEevvyShSPElj9Dx3WwXUxNeYg6vfSeREmHYSrMZjPFh5CORU520RhKdWTSEjtnBjyR+kqV9bqEoAybSLP9SbWltYb70zTsA== 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=uCzKNz9YtReFs8wozwS9cdGoK+mDJCXKIcVPLCbQRDs=; b=IUyR7lLTKgFzVwONIW3jdxbELwjXQw4ma6iSVaV080uJ2nedeuMYEMtJhOM4NBP30TU1Y26mAhc1n/Gw6gxjQwxCZOq68EkCQF/n/d6t+mBnN8G9iBl7hpvkn3Y7tG2LDvddY90oZzrmsgDN5rl9alM+Wp6tXSQw4LCqPCclcwBcnukYvjctnVE/rA+pJomVltRJKLjzb43XgXv7yOtqGb3JoWnw9eNZFRxLprxS782D+QqhD0m9w+PMtUqOL9/LOq7ejuMj7QzRNoWKSUbpMgoNpEEoyRPcwyIFri1OmBu62556pj+Cl1+CJ4LvZghRwiqYHSWbpQoQaUh5WZ77XQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uCzKNz9YtReFs8wozwS9cdGoK+mDJCXKIcVPLCbQRDs=; b=WLxs3ZdsTH4riOT9qZSqYmrCvpZ/z1SZMYVVbiU/8pmybsE1LjAlwYjwl5h0BDaZuKnAsfVnSUyZcVZK/BdEYuLdKIMtNC4W80gbXbRs/GJ1fzw4kvZq3tGvNXj1zLOOeCeM7DIrqi3/i+22CS/ALt5xAyrBkNlMAoO8Bu9JWqOtUESFJEn1F1t2Xjl896+h0dg+QG3KXYMoNBRUEdhnJEFLkk3Rrpfil9Aw+mhxMQotMcmZkWk/ZbEYBZBTsDXVOPe1N7mp4TObPYsC5jzo7ZaCITWPuVo955wZIBialCsh4YCWvZhCupRAH7/KbM0FbJxI+T8Q9VtZwgGZeO92eA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) by GV1PR04MB10350.eurprd04.prod.outlook.com (2603:10a6:150:1c7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 09:43:33 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%3]) with mapi id 15.20.8026.019; Tue, 8 Oct 2024 09:43:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Jiri Pirko , Tobias Waldekranz , linux-kernel@vger.kernel.org Subject: [PATCH net] net: dsa: refuse cross-chip mirroring operations Date: Tue, 8 Oct 2024 12:43:20 +0300 Message-ID: <20241008094320.3340980-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: VI1PR0102CA0108.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::49) To AM8PR04MB7779.eurprd04.prod.outlook.com (2603:10a6:20b:24b::14) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8PR04MB7779:EE_|GV1PR04MB10350:EE_ X-MS-Office365-Filtering-Correlation-Id: 55513306-f879-43ca-5f85-08dce77dacaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: sEQW7pIS4swEBzYAps5pybYxdHo4uXDLyu7Wsqe9zpEfrsDtMLfV4SGhq3+QZFxfyHFDYGwp0IPh1IoT16EvaE8U5S7dF2H1Si4gn4hp0cQHkgA8GeCD8owkvoY62vi2aaQoMlnafCZZM+K39XnKqH2IlW/UtjReksNxknwL/hr+3GJtHoZvJr5IMeMQ/UNxlKetOFf4W2dCpoao3F10CdsUOpbG2196+mIPBbLRv7/+MtHVbBFTD95UQ+9rDCHT6edcDVCdMGmP0A60+9GM2BOxELGn17Hq5EE4N7+vEPxmMFtJHBXrPJUnyrJBZ1+mz0mfrvqRK9iA/9X8utVPVzcFSYE/ATE8oR/PU6z8veP2kENfAEy2Sek7UCtPU61KYAa5Z9TZW2rTBwqHJ9qf8iiLdmS2iBQ15CEZu0mi6M+PAu+ha21Nc9Yjcad6R39nxi+qSbN7+uoC/r178U2aBxxTQUm4ein2UVBDeNepW/Zm7pe8qk8Yh/3wmZSy4/2PlAQ3VM8lt4QvFQXy0N7PXF8/ZkvfcvNvoSr5SMk4k92vSSB+6C6wUgm/lhDSV41uBnbo0Fht5wwqaAtcwE8oVpK3Lpp17ZrK/DSfHU8M8b+BxB7uL6XZuoffltvcTmk6vWgK5g0rfSxfMI8UlOoNAe36ySCWcvFGo3MgMu/9iTx6Bs9LoR2WanGxnp/nr7zgrp8U6nFYF8socggkTnG+SuGwzmcVkPAhBT60ANWsemPyros8pCl5I7GZBTSq+BYadBt3N40jUZodmD+vS0phvQGAv0cusGinE29lgQTyUCG8XV36iP7/4altBbAlZhTfw8fyUH6RHuUxMtesgND0fzjKykcJx6EcO7fhcqQsI7oMfcU+9+OrRm/SdTlT/jeG+yWFf83folWI5nH8to09iejpOXz9Ire1DAaEM79jrOObZ3muYlox+1E8y3+j/4tz93xIPR8r63r9DL8vgDu/oL6jgWhIFd7mGZx9qgEj4sC/qpFFN2pUB1Fn8CXl1B0C++k2oyMtmbNY/CrWjjYViML989D+LRFqoghL0Wq8225+sp8vNebL7xHhuxaVnvSlpYhYs0t5olfr+RGpwfEBn8brh19HudU5qW61V5r9cj/3JWZM+VqVdGsfKhzRhxpGEmjy0qcXG3joTeQT392iKQ6EKNCtHsLebHgdNxXSMIiCeSxVMhIPuttl8kRaNzIpPPu1wKfHU6j+6jDMMiWZU1v2htLwBIYGYR2StpngnGr6gUO2GB1KgSZ+R1pX1kIofmfsInYkTfuBdH2eaP/YfpW9D1E7zj0GZr7jbiMJvMJYYtSV+h6Pn0aJFf1yLzV8F+sug7XkAuGZXo2cim7Owg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: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jYGS48RGExIjfKBedOAuXt8f83Opu/PFt5nZXu1SOSPb1fO+auxmYdK3vwIgSCudjTFCt6Wugi1KgqQ6qOu8YqRAk2k3dKe6NzeVDrjGQtUOhGdwr7gLKVDZ/WGv1SgrpiU6M4v63Ga/mQoN4Hhof515szaQoPs4YBulnEyqPe3UuwyHB53FuSxxGlos1R+bi7nHDxP0S4BvS5kSSeWZFwB+SsJ/PvGfltkXkLrO+XUSDMZSHzG83FtzZgDZngcQjuMTbBwh8r9tj3lNWICRzMxxwqs2117rKxzvP4sG3svdmsRLYkIuGCJ0hv0gBbnkPZa/s2UpuqbUD/J94CXBtdEvSmV9xgptXyC/1W3V33yyFBI0Ta0UvQ64x5hD8AK+rsH4WZuda2n9ZTJmMz69xQf642n32tdMgaFDQKOayxvBzQXoA3uQDjEmBZxBlta4Opi2/S1yFwcPkDN12KyIbkifU1zs1Gd64lez6feDhGTUX4PS3dawqNUcx3YsS+DoAaVeyIXQBOKFXcxHl5pmWzN+Fv6IbdzW6Kr7XZ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55513306-f879-43ca-5f85-08dce77dacaa X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 09:43:33.4799 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ks+s6E2HEVme5UYt8bE5iRmeoEEjYeg7M6cUgRsoYeFMPFlBl3G5wW7newwo5ZPNNQcQpTUn3G/DRP2tVEjqBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10350 X-Patchwork-Delegate: kuba@kernel.org In case of a tc mirred action from one switch to another, the behavior is not correct. We simply tell the source switch driver to program a mirroring entry towards mirror->to_local_port = to_dp->index, but it is not even guaranteed that the to_dp belongs to the same switch as dp. For proper cross-chip support, we would need to go through the cross-chip notifier layer in switch.c, program the entry on cascade ports, and introduce new, explicit API for cross-chip mirroring, given that intermediary switches should have introspection into the DSA tags passed through the cascade port (and not just program a port mirror on the entire cascade port). None of that exists today. Reject what is not implemented so that user space is not misled into thinking it works. Fixes: f50f212749e8 ("net: dsa: Add plumbing for port mirroring") Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn --- This is a resubmission of: https://lore.kernel.org/netdev/20240913152915.2981126-5-vladimir.oltean@nxp.com/ with rewritten commit message and targetting the 'net' tree, as preparation for submitting the rest as 'net-next' material. net/dsa/user.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/dsa/user.c b/net/dsa/user.c index 74eda9b30608..64f660d2334b 100644 --- a/net/dsa/user.c +++ b/net/dsa/user.c @@ -1392,6 +1392,14 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, if (!dsa_user_dev_check(act->dev)) return -EOPNOTSUPP; + to_dp = dsa_user_to_port(act->dev); + + if (dp->ds != to_dp->ds) { + NL_SET_ERR_MSG_MOD(extack, + "Cross-chip mirroring not implemented"); + return -EOPNOTSUPP; + } + mall_tc_entry = kzalloc(sizeof(*mall_tc_entry), GFP_KERNEL); if (!mall_tc_entry) return -ENOMEM; @@ -1399,9 +1407,6 @@ dsa_user_add_cls_matchall_mirred(struct net_device *dev, mall_tc_entry->cookie = cls->cookie; mall_tc_entry->type = DSA_PORT_MALL_MIRROR; mirror = &mall_tc_entry->mirror; - - to_dp = dsa_user_to_port(act->dev); - mirror->to_local_port = to_dp->index; mirror->ingress = ingress;