From patchwork Thu Aug 15 00:06:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764276 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 80FF4A5F; Thu, 15 Aug 2024 00:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680571; cv=fail; b=D48WzjKBiJf3FqVg+98hc0CdP2mTj54gFR6ekMX4Ula1G+oTnMSBeiBYB649C8yeDt3u6YPCrTKApnyNkUO2mQG5B7ERUicPGSgEd833WPc5AUt5vDDkq29IJd7spCBKBlBvWq+68JGR7DL+vW9aBj5eYSqjCQneQEwj1B87YUw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680571; c=relaxed/simple; bh=XLQqw9qGpbaI+f1SJO9XgCFqe1LzNvVZapeMXJOG6ho=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=vGVogxpOAhbhejVqBEP8D0UFMdOilyPDFo143sXZT5E9hdgakNPUeX9VlgIWiT+4RXJf7llZxm9nwxTLkqQO9VkxY+vHgRFJEc690oz+220Peuk9JjC5AjKJGatMzdmWWv/z5Y1M1qJEpJpWbh61eqjJx8dDS0jk4Kru0SZTaxU= 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=Qxlfva7B; arc=fail smtp.client-ip=52.101.70.30 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="Qxlfva7B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IJXhpoe66zeL5v7G+8dgP65gmttTUtMO0ez5XsJCehFZfoSasGOvLQSArqLlUkAVKKROFguYyteJ+Mw4Unt5svZeABxR7OdZmF/qLTAMUx/opoQshAmlZlLtuW4RWV4oO1qUfXD0uhMuQO6sYsPmRGg1f2uWDVUY7HSGbz2W/eRYvn2HT5zsThjtqkjMeSkSq4IZg8xTr4Gx44m72TD7GUelvnm14IopefA4qOLv8q525WPUUdVvuoA6LtXbofP4P/ExKqq7fiDLmV9igvLIaBQzXH5zd+nKjo11FmhUehFU5GJBKCEV5Q8DokhQX+BAqAL4DCymcVVRwVrKnrIBCg== 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=lpQPqjpxvg5cga134G8GkigAdde7bePZD1zsjo13MEE=; b=LV3MNWg1tyGM3F/A8ysTMElyvFdPFHOchbQtjpH3Jltvh6FpVly03IJEslhJ+MboAiqUAH7q3R7Z5O+gq3tnpI1nlwYO3RT8ohU8IrppZOzv0nw3J9bWLVMSQnNYD5JrwpkmSSkG2GujtFcGCX/bglGcy5dRnbS95TNGtPeVlE9vdGrgiO28ChBPjy7/Ub5EwX8C58TxfzKuYcEW/9njQOvOdmeAmE27XlgOBbuHsquvpzXshMfGh6blOoBOP4h8Y2Cey00ojdHJVvOnm/iS+jLUGH4SyfezS5K03aPYRBxqeolzLlmVtoQb0wAA8DpkNPWkGfOi1oj1EXiMhK6HGg== 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=lpQPqjpxvg5cga134G8GkigAdde7bePZD1zsjo13MEE=; b=Qxlfva7BJB7vpMOlAgl/7FNjJK7Z3c5UjGRGpHxt4NujDU20v0/TlPEwU5w351GezmkAuUd7NuMZ3iTGUC9BfhegYazlE2oe4zh7BAGV6k9+exKTKuC5S27ajPO3TajobN5Gp+oOBOJbzPxVcRwKDQNeG337QKiHsX/eqIoxI783PZ2eDcXcVE2ybhhzHFgJLkDPaNWb5V3dhXYpsA3zwYwrMCw/16P79+eAtYTZKt+//Y7wDs4KxDEkmdy22d+qCzqbsmps5fyV+Tz6tVBQLTNYtKyv2ae+QH336mKxuaOm/C0sGxxt/k0X/hG0H0GNDgjiwK2HiIF1ng8kHcAyEA== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:25 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:25 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 01/14] selftests: net: local_termination: refactor macvlan creation/deletion Date: Thu, 15 Aug 2024 03:06:54 +0300 Message-Id: <20240815000707.2006121-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: f147f40c-f3f7-40b3-e823-08dcbcbe85c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: ynCeM1L5cNpAEazSX0hOQRiIlbXnPoHoxS88Iq4g5d+9NWR5QIeW/9wr8+4nqzMI5SnasnzpgND5YfheyONtw5xl7nwptUuQthU/zkU8gipOC09AlzsPMbwi7PWuXYFnFZoDgRjxWl9kupjghFsj2N1zWN/s626EIBVXmpTKZcjdjeL1bH/AoWw7Ijs9uCP7NHlEjl1c4mbFlWQp5Ve0v6WSow5Ta0WFsPAD+zQ3v/k+pBQDLa3RDZUylRtf5dhNNpPPVnPnXFGf0s64C5koY7zdgLfRgSJ9v1bxMcRAMKJv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gcUQGW+AbstUfveyW07BYIS8BpN+M0uT4UsIubJOk6EXGBWl0eAA== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2NO42McsfASzR8qDifiNA7QUxw7EmTz7xA85OpEcjLAVWUvCtKatPyw9LfUrXfyjz5A428GT0/x8f+PPpA6nxolGEyM3NoiI9wGLevFelWobxpDRRUgiQk5KcSapBVhMO58MiDIRFPXPEbsW0OEOM3SqPTm4yvPMz5uGvfzwZ5Zc65vDpBLGkTz8cQKK9qAsNols8RkpZeqU1P0KWP/GjJMtnjh+/bTxtzkWyiUJmtqOt7WrOPGFlqBAv11dxpxDulpQZdt2FiL1yoPQUEiX6zRlJpf60xuFhsq/4xRp4payVgFHmhS5iLDaNmIR+zXHfNsA6km2Zu6aAMhCeIzKaA0/1ZeLyyWxtgiJcbaD0Ftrl/f9r0yHNGM33E3YyOmUGLWLLl3l7iHST0xiHaK8Rf6djVRhzY6je08/y75HwYdc9VsyjILmn1f/J3w3W88SjeUYscIBB9eL6XSkxzwx2dB5eLlb2uoAqnYheNHS0W4wGJFaYvksrcrkukd1dA4DZEu0ITf0LB908dLC8gzLkeoTEkHoKPGTJ4V/uOm2RIrywhbKG7TtBo9Me/zSyIL5kOXdBzSWGTasSDMOaWiovC0US4A8lbNd8nZNF+9NbkaK8WP84Uy0oM9ricR30EQubZNAw9W55Nsx1dtyluXP1GEGuS6C7a5RnXzAoZg1ePfeiVVoYAk2pfFsT9Zg5+IKK56mSSHhb8QXogioWa3YM66DPUBU0nbI53aqsLLEzSz85GUD3tOQ4eOnC02ANbM8QM6bgpMZtB/Vi/LBEkllG6Jr60H+zT/6tLDB+/F/qQMDc1TCJsMQ3tA/lu1Ki0rlH3odJsez9rrioY1k5yP1QTjuKR+rjX1FT7p3O8OwHeaxHOQ1RlIDygL4nTKXoV9ToR3AcKpn7hBpCxD/vh/+0ueA9VD96pA8nOa10RiB0nBRUCJHPmAGAYKOTceEu1ISIxNx7wFk6agUCdGqrwjA/GzUWmLpAKeQ9ijZVs9cG6iM0vZ17KVHEokTvxukZhoe02TJirnaslxdNXt3kxBQe4pLTuaS04Tvzv5n2FnvbKgF6J8VNLsWPEI9va5Szmg+yr0Jo16Hq1lraIv6gsKaqGgnsXsi5l8ytO9kCt6DbS+9qHMwt+gRoX1sMrYsAbds9dh2KYstEYeYFmUAAD91NVGB50qxfonZmR97wKPZz4cLW0yitXh6TPMpEb2J5DyvdsHrTxNFprQqkzxBs2bhEYiv192XHqvitrT+hMOGAjdMwHKYrVdR9S0TwJARbCcZHXyDpZcMA0IXc82dPcyhPXMpIE/XoVlTVBSqWV24JET4lsPUmmyFP/9AJubFkDHv86TMphGbuoiyLp2z942xPDs2ilQ92oflm03BAtm4mD3FFupNMB6Xbs/BjvpIEGxYVk9IbPGWmNOPcpdUTmo9+dOcvN24Q0eFevV0x+xnemD/uDh5BCty5nPTWYFS7foSkXovAkdqmK8Pj8nJoKQxl+RguNHpX7Bu3pdrl+nkSqg4nso62/wAwhuu1rvtJj6TuwECrrGFq2WwpBlH+YfQM8fF7j+W1c7qkCs52xlOJisJFpU8xj+KLA+tQ7tjkNtQAxABLbffyLJfYdah4JwH1g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f147f40c-f3f7-40b3-e823-08dcbcbe85c4 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:25.6236 (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: 8e+rVuCfj9w1DAJcSez3oWBgTmcpMkDCJxSufDE5UPqhoVvGU/2V2BtiVpWi3Wrv2GLyXZncdfJFDf8ICpDU4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org This will be used in other subtests as well; make new macvlan_create() and macvlan_destroy() functions. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index 4b364cdf3ef0..36f3d577d0be 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -247,19 +247,29 @@ bridge_destroy() ip link del br0 } -standalone() +macvlan_create() { - h1_create - h2_create + local lower=$1 - ip link add link $h2 name macvlan0 type macvlan mode private + ip link add link $lower name macvlan0 type macvlan mode private ip link set macvlan0 address $MACVLAN_ADDR ip link set macvlan0 up +} - run_test $h2 - +macvlan_destroy() +{ ip link del macvlan0 +} + +standalone() +{ + h1_create + h2_create + macvlan_create $h2 + + run_test $h2 + macvlan_destroy h2_destroy h1_destroy } @@ -268,15 +278,11 @@ bridge() { h1_create bridge_create - - ip link add link br0 name macvlan0 type macvlan mode private - ip link set macvlan0 address $MACVLAN_ADDR - ip link set macvlan0 up + macvlan_create br0 run_test br0 - ip link del macvlan0 - + macvlan_destroy bridge_destroy h1_destroy } From patchwork Thu Aug 15 00:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764277 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 B502B2F36; Thu, 15 Aug 2024 00:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680573; cv=fail; b=bjG53WzkUMOQYr4JuZKbe97N/XzVHG/Ruur1TW2OxglhUjsyxAYNx0GeV7o3vp694yP6ySA/34jFh00b+EwSmtpctAunKdd9HfGobbtILh/DCvylOVYUJnEhT8TeMiHXUchyU0tv2KkHWCaN4XJ3aSWeAk4xdY4CNqmHLsw13K0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680573; c=relaxed/simple; bh=G4pwKGe+WsX1UC+GBdHvGckleB48mtCEHy0usf9zCKs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h9deLhcFckPfuoyHLfe14ecP31Ju3Wgefm2A/BT40985Dbzh4wbpr41jf5dBmRqOHnw8LS73Ns5jYHocho7FOJ+txmkF+DXR/HD4LqXR8ggHoriEHp+sQkOcQJXhrmx0w/q3Y84X4UvY88SDaWWig33Jym7IdlSqak2TsPSo8wM= 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=L3qsk6yr; arc=fail smtp.client-ip=52.101.70.30 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="L3qsk6yr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HvGY3wRr+EKKj/sR9WQOExrn2ufDLOKwgMShvtBnm+Wao78sGB2KSc7lDbTTgPCJ748qKNfgPFx0kjWgXz+44SkYdJsx6utEBggSRQ/+0NkOh4vArMDLEmZDfiGnTtibStXNYu1yxw8Q6a4kvs9la5ZaphNme4HOPCzFGP1V/QOtjLkTCmXWmo1XRkuixs4qWVAqXvF6c2NFS8x/m/fQoRRb9H6mUKKxb05fgf78Jvz/PjRMhWHzcc+j8ePKM3amgkF+YlG2ZzJ5MgUpNOmISpRwtplO1oim+XiRsX8zymKHetlSOhzwl9kgbVgqa8I8VpHuVT231vOW3/i4OFJhmg== 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=zEvSFc1lQI1uob82+ImRUmyxFZAv+rGlxzitzLcdjQQ=; b=R2cvMwQJl+giNImdf4kJcEkkH9kylMZxTqqW6rB2DX7fB4N7d/wTVS2R6askiCv+BwkxLJ5z0Tu0N2YjhOQ6EPXIAEeZlJ2prWkwwnZ33M/9wcj1qxqMhlgUYtsP3EcFREnuy1YzIZRxFAKlzqkZQiShzoFg9V5aD4ufu1fOE5YDGstmb8MEaWLesFApWLlVIKYD9MEshIrqznIGRXW+GWxUQWYH9DVosV6j9azLTHoAVCvsHLOEbt+Ll7w9a0fwLJJLuzOobS24DebMeBQ+LSuRrqW6bI+VR6u0GW1oB5TIkZpSo91pEIo8NPSLWADNYQ1CZJwkTRqF2h9t2m2lmQ== 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=zEvSFc1lQI1uob82+ImRUmyxFZAv+rGlxzitzLcdjQQ=; b=L3qsk6yrEjDC981uzjA9E7hknTRR+nZNd9zMWJbWbyrnKGOyKJgiPFdNgzHftJxWORS5u5x/ochIf/NsvNrm42M4KVIO6GuWZS21B4xEwfR1o23r//Ozi3eesaZb0+rLDmYtI82JoZqY/HXMBU37JaRlKbDdjQgLOt9j3LmyZS1DzVm3TQWWdXFCkgZIltVpRe19Xl2x4U9m5UDTK5JLLWClB1NJ3jGkM3cfAt+4E83IwYXeOT99UXkh9I3iMKmknRMqVFpDmnIHc6O5ySIVSx+Fm7HZFcNG0N9UQuPbbqpgitR5bV72V7EQomQJyy0wa456b9d4stDfSlwBsLgbfQ== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:27 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:27 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 02/14] selftests: net: local_termination: parameterize sending interface Date: Thu, 15 Aug 2024 03:06:55 +0300 Message-Id: <20240815000707.2006121-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 891f7bef-c27d-4ef4-0c94-08dcbcbe8718 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: zfOLVUqTX/zjI7+RprvSa5q+TWYyE0K+e7lTBQWHSkea9ZjbjaMC+82Xwa9ahXp2GcZYB9Vyw6Tvt8LQjTK/twponGOH4RvLL+0tIOMdVbvZVd9ieFonpltZcWNcTs6F4vUqUVxfuETAk1uDWWFY1A5EFguaDYi6IEL2W38Cl0Enn075BBYQj6HD/cIH+s3cBDpyAsv3eAEoznjHpVBzWp5+SFqoZMJKfJhtpCw+wdEyH4WMdvdqeUJYd+ketRMLwR5TMNgRRQtn5R9deoNg8ymgA4AbZqhxxTEltLuYubiMpM9I+EqSHXh+9aFRN0dGvRmy6Xft/AdgpwntnmbH0OwCfTBhJttbM8HWeQ88rdaE/lEAVQ63giy9at3T9v6fhcmWO2dfAHYkSa5P/jCRK89V9KILHn+suXKJA+deZIFOgYiZpwG8tt/PpowfZO/1WkMww3NUc6mY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CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rhxpkHHXc2rTthXltA5+Bqqm4XLV5F1bY6KYe6AXYGL2WU2EdFFNmnJ2mFowkjKkzehlcOJMIoDupJoHKE3TVxw7qErRhC8ohAoGTQFznZnd3Vrhp28YRZjba73G85fcqlfxNcQHLk8jY5TjOuYx2TsNoz8ZoJ2q6oVf2tnV68yhSkFYXC5UGWq9pcxoYq68N31PIzQOPLzFUeqfZCnjF2SCfnCvRKehf98n7FbbrWHBurGPGmSgdCLMgobVVkpPpxnvbbaKagZ869Iw2lWXPrdP5Hakhc1JZzA0JkqePs5mTpTRyjB3/mmWGdkcTae0w//Der51xbo6gaZzeGYt/aMWRmVOSVvLsJMKasTXFwWqBH+4CSGAGJu2AiMAiRHbJvbjWo7m1vch7uTSUO5iIKWm3kZyZCfXgdzkg4VyRKBXgPctNg5jqIuNgomBfDv6W9Mja7I7PRGK4uuwt3WLA6CZsPLAgUs7FS/kImHNnDeCR9GP4zg5jwaxzOlQyLku1rJDmGtORW49Kg1wV4CEqOWEdQLa9tpwK8bAosgesiJy+7UW8fT1DGWK6MytLGxXKLK2azoQpPvA3f7nk1/P4rjTD3G8wns1EnbY2qNgN1oNdNTbjVMBVenq1Jm2QLOhMK8a0phVwl5z/8J9rHVnYxTgmx+Cn5WXzuTAoW4gmoM+shVoGNTLhRu8+52KSCQtD/KnguX+cJY8QYIHsurf32XcBGyCZCPoUsAVpnwbHdgyXor3BQoF2jPiMFekprOE4+qS7gyCta7ze1E4U+c06EXrBLYGK36rSusIwjdPrISd7U2kXD+l/wrK9QOeEbCwdlJS5VAhpvg3oa+MvoNC5H0aoyzAxcCgkvCKwxZje8eDhYHCfYQKX66MPfcwS7ZkTw0T+YRUv1KoKK+9xOUASZ/gyqZZPiK2UoHM7tthvqbVfeZqoZ6SIUt3iJEAkwIICMjhD9/K6v7R7fWYw60RfjbYNLntrwvpxvKmCkP0IOmHSGfhBW0/OS/9ANT31cI/KWWYkjBsMskLtAQOauJN3nd8bzJms7detRe4c8KrZriHLCtoDUOAje/C5SG1GXhz/qNqF7cPpPsnprKo7bUjxTm59wQURq9F5yD8K/13KKsZ/xMDwLyHk5G9+gaLDKH3xmA7EiPYPd+ciXBbO0CNchFAmfk7AACXNGvkfHNTB+7ncstGUWqS23UdPgDImBF/fL7Jej4rza1oBQu3y2gfcaXO/X4gsiiS+88u+DpMj+q840ApR5Y0FbSmQ2+tHH/OSF9+NFEPKLSabhSekJgxpE2ChalODLO0eDpfGHj3nJBKirPXzfL+16ZOw+0U7XitpYkB86gVbVPpawWe9Z5tBt7+X6xWiZDqpsJmFmAQPWZwLqziwM9Ww2Ls1ZE0uJ+sweBCLw0rG9cBcKrlMgOdUfC5Vn0I7Og+/Er5h3DjIXlkK3By5o3EMZSdTkhDW5INbe9tUXe/aTasuC40RmCoBL1XJ/TpdrVyeR7Ky3QCKL5fO90EVTCY0keUQtQyqM9TvdRf+Gw/Kn51S7DBnnHL0OpBaWdV3JYJyVwYTxsRo4YhHSbRiTqrhVNASLIpmWt9sj5jR4C0sbwTfmhOS+4jrA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 891f7bef-c27d-4ef4-0c94-08dcbcbe8718 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:27.7953 (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: WBDC5fseWmVhI9Am4FFV5dOr7RA2K+gCWqD+Dn9xNddOZXipK1C1h55PqE8CfzTJ/Sid5itVQ87fbgMywo6JyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org In future changes we will want to subject the DUT, $h2, to additional VLAN-tagged traffic. For that, we need to run the tests using $h1.100 as a sending interface, rather than the currently hardcoded $h1. Add a parameter to run_test() and modify its 2 callers to explicitly pass $h1, as was implicit before. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index 36f3d577d0be..92f0e242d119 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -104,44 +104,45 @@ mc_route_destroy() run_test() { - local rcv_if_name=$1 - local smac=$(mac_get $h1) + local send_if_name=$1; shift + local rcv_if_name=$1; shift + local smac=$(mac_get $send_if_name) local rcv_dmac=$(mac_get $rcv_if_name) tcpdump_start $rcv_if_name - mc_route_prepare $h1 + mc_route_prepare $send_if_name mc_route_prepare $rcv_if_name - send_uc_ipv4 $h1 $rcv_dmac - send_uc_ipv4 $h1 $MACVLAN_ADDR - send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR1 + send_uc_ipv4 $send_if_name $rcv_dmac + send_uc_ipv4 $send_if_name $MACVLAN_ADDR + send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR1 ip link set dev $rcv_if_name promisc on - send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR2 - mc_send $h1 $UNKNOWN_IPV4_MC_ADDR2 - mc_send $h1 $UNKNOWN_IPV6_MC_ADDR2 + send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR2 + mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR2 + mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR2 ip link set dev $rcv_if_name promisc off mc_join $rcv_if_name $JOINED_IPV4_MC_ADDR - mc_send $h1 $JOINED_IPV4_MC_ADDR + mc_send $send_if_name $JOINED_IPV4_MC_ADDR mc_leave mc_join $rcv_if_name $JOINED_IPV6_MC_ADDR - mc_send $h1 $JOINED_IPV6_MC_ADDR + mc_send $send_if_name $JOINED_IPV6_MC_ADDR mc_leave - mc_send $h1 $UNKNOWN_IPV4_MC_ADDR1 - mc_send $h1 $UNKNOWN_IPV6_MC_ADDR1 + mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR1 + mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR1 ip link set dev $rcv_if_name allmulticast on - send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR3 - mc_send $h1 $UNKNOWN_IPV4_MC_ADDR3 - mc_send $h1 $UNKNOWN_IPV6_MC_ADDR3 + send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR3 + mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR3 + mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR3 ip link set dev $rcv_if_name allmulticast off mc_route_destroy $rcv_if_name - mc_route_destroy $h1 + mc_route_destroy $send_if_name sleep 1 @@ -267,7 +268,7 @@ standalone() h2_create macvlan_create $h2 - run_test $h2 + run_test $h1 $h2 macvlan_destroy h2_destroy @@ -280,7 +281,7 @@ bridge() bridge_create macvlan_create br0 - run_test br0 + run_test $h1 br0 macvlan_destroy bridge_destroy From patchwork Thu Aug 15 00:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764278 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 1B2708BEE; Thu, 15 Aug 2024 00:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680576; cv=fail; b=mLNnPsMFxTi/O2J6sF+AK1ISX+uu14fRKcAOjLSJ7AXyU+aKJ4RHfKuO+mdxJxX0OaWoP11USICFptFwq/188H60GyQ18ZQf7aZqewadmx8tArr7wwR4lfDzfYClDI4msqEJ86mmf9qAoGC1PmYy7DrHcZ/NF3oTOwdejv8pJEo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680576; c=relaxed/simple; bh=7Zsh2xze+PBiVnfngp6e2xCuNcT+TlnxJ7uJHX3tI0k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rq4qVIsIzV7/Cc7qfZd1LAu9K6CYal/77Ti/gYG/l2/8IomKFehQG/BGFnV6MK6HvaZ/ZA6jsdn3AMNZowHXBXFeWGh7+X5WFb6OMI7inRQpx/pAYu/e+lm2IUVpk9JgfVf31A3NrGlvAbW64OjuJz/hge1GD2VGL+HOy32tMA8= 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=NjoGRNqx; arc=fail smtp.client-ip=52.101.70.30 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="NjoGRNqx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BHh67d2HQ3qHaAC3zfgLkj0Xjp/IHP96Dhv1p3XTbm+ePt2uC7VWAfWqUWerDuXfzTNCXk3/VxX3GVZ8uIliIelaLllNfP5F1WmvpJQAcYqKGS6eIuMrmAxSJnbSEE60PR8KLgrJdKMymVckJKdXI44dkQE5h14s3U8Vk+Zldu/GcMSmobEtVCpgXTpmUaQgcAML9gIVr6YuXCfKVH0PoxCb2kN6JISJ7s22Bib+Dnf2nY1l+m5IaKMcgBbkC2dQzgMpFArHbfLLN1iZVevvkDsDK+OJbo72TPnyAGFQp5qdCODWHHjyjjUyQ3H6EOFmviMbWY0zTMEWc2LuPYfu1Q== 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=/T9HoCwDQUtLtIclI7JKLweByU386jJHwAnfPaEDP1I=; b=X6qxX1rwT4fzHSjK3/Zmcyxy8TtluhpLWytBdDXxtFYomE5xGJNVWGlU1dPD6ElVkqg+dcuBsWKFhV65d6sFWv4MRJDaReIqgF1siNNUrf5cI8I0YhPf5Y9LwbUKs95p1/oK3dzqql3OshEFcTQ/rEzAhmhu7wh/E+YsFS30ymkvAO3KGtk86sJG4zSGolfOuxYia6ECBYzx5DvA+SAeqAagHvbQK0253FxV6kUCgBd0JzC62UKEbSHMqi0Eyy6vh0jHT8AR45sklTVzrtskbde5AHuJdu/f7Gdiu4qRolKfpK9FosD92uBGTHrU6wzOCr7klp9oGOjDBm/UlLlS2w== 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=/T9HoCwDQUtLtIclI7JKLweByU386jJHwAnfPaEDP1I=; b=NjoGRNqxyUxjg1wOzkIl1/YLKhaD+BI15k2WHP4JQ5lwYgA7R5ZOy4nlSOTNPsMXOtJtyV3lbQ65NUYydDhx3yTgOJo249Nj6oZeopz3qwzqJy/hlM1qr/mv01OmqioKjt1ZeCQqDlSibYiVWp2jaAEgu0cVs7/Wf7B6CeldNvH1h6NSBWMUOtnU323OeHdpWqecZ29gtVMGjEKdr0Bfl0lK5bymiOzB+Y+Rnkcm3cpDZR8YYZvwdfWbjcM8L1WMQtGX8dVWKQ0R86irgMmT7dUXVvzPPz1T/U8jwbviqUdINydFfrGuItrUvg41xg+1rkbB5AcmznaE/RW/dGYFDQ== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:30 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:29 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 03/14] selftests: net: local_termination: parameterize test name Date: Thu, 15 Aug 2024 03:06:56 +0300 Message-Id: <20240815000707.2006121-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 98e37a3d-8cc4-48d6-7f4f-08dcbcbe885e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 1qFdxZzwS6/Y+r68ybq0GG3Vu9uv3R6/8voZhqVvujVINeuxOuyPxzndmeeQQRpwR3icpi+CYx5xZrw0BWhXcHW5YmxTVgwFnmERhxud0+HpV5HQmZQ8iKNRE7K7blvm+mHvU+PwmDcZ7ScxuOroxtM4wDtwPGmHtrB+OzvSoO/pYjbnxvpMwCGwpQUBYqJedX+3aa/64zF+NVgnFzIVXMVHpML1XE4XmeOFXqowz1klwbx0fO9vY5PR+RyiUOKfw2JHwn5D4Q83VN04Lp+RpgZ4LmSHtX0A+x2je/UJFNcpt34YAY/xZNxT/0gHAYVT+S208W36r33N1HwXxXFIpSxjlt6MTScqxD/8FGLZrVfjT42cuvHFaIIKLfpotb8BGDA6Rpw2Cj8VKs/tM2GKcwO/cJ+PONLk4YR4ew4db5tlcKVN10ifbU//sUP+FYRwG4N99aatWIp6Up0wcl1KMPriIGudX3VPBfN1aHIPB+/pO0gghNz8qyGSmqkExcMvsjGp1Jh3WIOj6r7SRchDd/wGu0JBrb+JbiDuNJe+HPIJI7yEb2CZpfG5PEZdKZG2sd7JJ4B63fIQZR5PlHpPb3Q/+g3l+qowxdX7vmG8L83DBQlOpJK1rFwGfUxJ+jt7mlhvfVIN5BtY5ZYpEVmW0I5ATFedBMRqpICDHh3PcZi9e7J/MtVl+qrR9VxeqOgA6juvS+OT4G7NsdCtBwPHp0IRFRiO1EWHtBR1fYCm1ZrR86w+aMP43nQa2nqVTHZCvaH+Uonecxb2GyYo/432saP+ab2IiKyG0H2w347TU3HKt9Q1DBNJgrAjP4ssEaEBEu5z8nJTYR97P3hbRhDbMuMFOTmMOd9K3BXJ5uGuS0VhAO2Zz8r/GnclfXPLXiAfTmaBwrccp2a1oM6vhCmHSXtYFIv+nl1eM7CO2Mlt5N+TJSYc21jLn4rUCb90h7riV1oVj+bBtdcUvajX8fYFc9sJ7VlZjgMAE5gIdhreDd3kw379k/n9ksrDB0MMSPlE6FnCoz83nKCMAdNn7CuP3S8q5311e4bHrU3zGFrjGj5WUK0unkiQRETZkJjWyEFJ5Je31lF75M4OxTBP+mel6wPr3W83tWQBmRe8UGJ2At2lV29IwsW6D1RIZ7GEtsGG5owjyO2E3TlF4Hlvw8HNNIueR7sUGSXwjLrSvXWoc56SzVAmbExheLfsiaDUPw+ZU3fY01bgabaX8Y/grMCGPIgJHRGTlLaCXcA6HGgAjvmQRzCQynJsO0BMpb+D74vTeV79zR+h6JOlxDhloJXXAxPXOq2LhiQsGDdfrlcNoqJC3nIRrkWLOK+l6GlGwlf/2ii4va9UkbKv5UGXNAiwGa/NMuyKpjk28kn2Y285WtiA7PIZgQQlBXvYpRwFvBsWVBaIMjmHu2TWZAHjahHKAA== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-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NGqsiMNq0t6EovRw4HmrwBgcxj8i2RI7LBcqAykZ4kB41EUT7PX60GhQIqRxBKEaGG2Gic8912LcMiL2BWBpZcEIAbRVoGHlnpEsFsEu8EzeXdEOOh/AToCHg9QKmO0Tj1W0L6CuN5JYzzsbCPBQzQxjsnt+LSqErHl2xkZRuY2zLBnGMuGJM97yOrJlAe+YBFggKzy05jy+ZHc2oDhziooJpRUEvkz1G7Qg7VtfR+iITEK3X5AnDoY/Mesq9EBgqEoRmcjGR7gyvFQOc29MusqnDarzXPHgUZIJvSAgvMflwgCaDs4U4vCP/20Tx7x5rq5ARXDTBtax6k7hzw9KBezo0EF+Ehqz+G3sV6swJuggPEriDviewrflSpChDeZ1PrArT4f4asgE0oYiWJVjubaftQtPPtNKNvIMuEoJpsBo2yySS1RfWMZS0u3GMS3JjIg7GhG2lvaYUFtNmDBUFugb4wQ7ilrB3F4PD4JHIRp1z/yHRnkQT7ENNRaab2etcLNhBi/xw0M4zFNOB/iU5EZ2PVHp+YnJcrpWxpk7ixYX1PNRhg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98e37a3d-8cc4-48d6-7f4f-08dcbcbe885e X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:29.9052 (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: SU7nn/w2BVYxrCtGYz48QFcTESlfRZJAqvld90szbuDwIQTBCADQhVxQr4yEusKkntYunnUCPfHZ/QbGg92Ggw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org There are upcoming tests which verify the RX filtering of a bridge (or bridge port), but under differing vlan_filtering conditions. Since we currently print $h2 (the DUT) in the log_test() output, it becomes necessary to make a further distinction between tests, to not give the user the impression that the exact same thing is run twice. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index 92f0e242d119..af284edaf401 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -68,10 +68,11 @@ send_uc_ipv4() check_rcv() { - local if_name=$1 - local type=$2 - local pattern=$3 - local should_receive=$4 + local if_name=$1; shift + local type=$1; shift + local pattern=$1; shift + local should_receive=$1; shift + local test_name="$1"; shift local should_fail= [ $should_receive = true ] && should_fail=0 || should_fail=1 @@ -81,7 +82,7 @@ check_rcv() check_err_fail "$should_fail" "$?" "reception" - log_test "$if_name: $type" + log_test "$test_name: $type" } mc_route_prepare() @@ -106,6 +107,7 @@ run_test() { local send_if_name=$1; shift local rcv_if_name=$1; shift + local test_name="$1"; shift local smac=$(mac_get $send_if_name) local rcv_dmac=$(mac_get $rcv_if_name) @@ -150,61 +152,61 @@ run_test() check_rcv $rcv_if_name "Unicast IPv4 to primary MAC address" \ "$smac > $rcv_dmac, ethertype IPv4 (0x0800)" \ - true + true "$test_name" check_rcv $rcv_if_name "Unicast IPv4 to macvlan MAC address" \ "$smac > $MACVLAN_ADDR, ethertype IPv4 (0x0800)" \ - true + true "$test_name" xfail_on_veth $h1 \ check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \ "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \ - false + false "$test_name" check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \ "$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \ - true + true "$test_name" xfail_on_veth $h1 \ check_rcv $rcv_if_name \ "Unicast IPv4 to unknown MAC address, allmulti" \ "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \ - false + false "$test_name" check_rcv $rcv_if_name "Multicast IPv4 to joined group" \ "$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \ - true + true "$test_name" xfail_on_veth $h1 \ check_rcv $rcv_if_name \ "Multicast IPv4 to unknown group" \ "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \ - false + false "$test_name" check_rcv $rcv_if_name "Multicast IPv4 to unknown group, promisc" \ "$smac > $UNKNOWN_MACV4_MC_ADDR2, ethertype IPv4 (0x0800)" \ - true + true "$test_name" check_rcv $rcv_if_name "Multicast IPv4 to unknown group, allmulti" \ "$smac > $UNKNOWN_MACV4_MC_ADDR3, ethertype IPv4 (0x0800)" \ - true + true "$test_name" check_rcv $rcv_if_name "Multicast IPv6 to joined group" \ "$smac > $JOINED_MACV6_MC_ADDR, ethertype IPv6 (0x86dd)" \ - true + true "$test_name" xfail_on_veth $h1 \ check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \ "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \ - false + false "$test_name" check_rcv $rcv_if_name "Multicast IPv6 to unknown group, promisc" \ "$smac > $UNKNOWN_MACV6_MC_ADDR2, ethertype IPv6 (0x86dd)" \ - true + true "$test_name" check_rcv $rcv_if_name "Multicast IPv6 to unknown group, allmulti" \ "$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \ - true + true "$test_name" tcpdump_cleanup $rcv_if_name } From patchwork Thu Aug 15 00:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764279 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 85CF718D634; Thu, 15 Aug 2024 00:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680578; cv=fail; b=YwB12634SRW0JhntFAzpeYZ/Ak0nxj1sjKiuMt+Txjej2ffbrqpCIq3oPnE/v2oljQiskDvC9VU6ojOjf6DbvOMnmxy4t9eOQ2uZ5F3Asvdct0pA60TYHaREypViAFD1COGMh/fdX4+X/Al2wXCc4MHx47dvNl0UgtqwwUo0f7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680578; c=relaxed/simple; bh=J9E10ilEkc0v5nU9Vx3EbuA5JtLa182zUx1cYU5XrKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jvyZ0+HZxnB4K/NZOWI4oZmh9twHAytajMQ8jeEDPbj3EpnKmfYSj4imyWs0U0M29T7FGerzdgPHJlPGm2dYF9ys5uF8MHk4lkQh/3XC/VjG9c3LYTBB9fCFf7yLVaxC6TDCxfNdbIjmkqgt1AZOU/55BL4UhKFMbcMllNy5S6w= 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=Z0CIwSDL; arc=fail smtp.client-ip=52.101.70.30 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="Z0CIwSDL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ydl09aAFThEYeR6+yRKQNvgJzuHfo3b5IhJmEud10sbsIAql+qkqVNewOdHd2iiPFfi9rZJ4M6LWXr3+xrpx+oU+9Fznr1d81TaA6f5mZ0Siq3yZ3wFAyZIwT/uhZtkpp4XFJLB5HwXdn3kWpE6OBlBlo/5Qug0AfROLj/DuFjIo/EjwR1EC+zlwUfgguECK6L2oOuLITlDH5amg/4waLiPJLPhqniEGlVWTTHbI8laNKBBE3877JlZWWPFK93WVKXSXo+WvyrETN2fkQb4d9ewh5pQiPt1yw9hCjb/oV9S0IThauS9utnCQVK19uBKSe+/tGNjFAPSXakGWnXwKgw== 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=kqTB6hAXz3HNHSntiZ19+++LKg6qLNq0aRsiMC5+8Es=; b=cPZ6SjbaBdS2s4pG8SnTxAS24wvGSutfjoLcexPeyJYm0HasDRAxbuEEnKP9Rtc1pAtntf6mcR84emc6JBxw0dCiFRtDmaviEbD4Fya61YS/rq73spTFvAalUdsV5fc+Eba/zF9HROK3ZMbzFTczLKrDmotWeVHu6gM6IavjyiYBmUeT9HetiMcqz6wPuqLpMKvRP1BIjieQp1EfCkiZD7pa//A2MjKzoGS9tc+Va5RRVgtzQMWoyedtMpYK/yU2xszQZi4lC9Yp35fgm5WN+zoyGKbk5vQqRcVjtYhbQTSCLYRxlb0NW5Aws2Q4XXQWJUWsnZni3a0/RIZjRmU3rA== 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=kqTB6hAXz3HNHSntiZ19+++LKg6qLNq0aRsiMC5+8Es=; b=Z0CIwSDLuR5N7/TXR5c5r4IjqFJvtQmdUR6cahA4Rj0ZBs8rxNdG+4QqzwDgzA5JMZLk7VrZNMSlJQBCQmW/l/5gozcoSPbg19ABBwwC4CvU8lAc28nmxB7TtQ96VqZj2gklyANZrYJoQ949f0rdFgcTLtvz5LF1Quxo9wkvGxModbbFJRbUBELtIduPB9jP8D5xW0cpO0b+U87Hr03JdFnpA49UChWRJGa4oWsHKKqH5rHFOX0OR8VLALzadyWrDimQ3Xcm/YbGS0fzOiozSfseMSvgmQjlUHTkgLBf/H1DxWFVugsgm/UQrlfh8cy33K9m5iaV0Bki4zmb3i7hpA== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:32 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 04/14] selftests: net: local_termination: add one more test for VLAN-aware bridges Date: Thu, 15 Aug 2024 03:06:57 +0300 Message-Id: <20240815000707.2006121-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: d95289f7-e3cc-4d2b-5c3d-08dcbcbe89a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: u4U/W5UeYjE0loewEdqTqbvA+ZRG1/N7yAGb8qRHwKK4i+KKskUK9CAu6rcL/dr+BdpYD0gOcHwuTF7mgh3SBH2BtjqjpbScH6Um/82z6tvu+GQxm1R37roq3D1DbNXfmpsE7r/TE3EXf/LLNcdee/pkvbuMvfQaEHIs26ajRVihejQZPuyt1sC82HiOHpx/OZfhnFQdt4oDElsvgG1en45dTMXlIN7VAO9/1TWedAWvj/GB9v2kg+mC06XJqfwC40L3iYdVu4B5msXRjbRFRTBKNgwODuKVdIo1DiThykbfy6BRSGdlHNeyEih76yLFQVy3E0e1+XhiSywlMU+9VkWOUiPQzFCoMI/kii/USH9Qzf9/ItR4Re6sJinhH+ulXYKSIiwfXZ3rOuoW5GCHwX9Fjm3C9IaIZFd9O/YcdD0DzB8qviGOUGSzV9CoAAAnfPG/z46SkWa7bM+9BzSTk1QG46tN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NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KSVgqf1hr010rQiM+xptU0XuGJcHMmrKRAqS+MLLHpGkGf/62CCzy1ulQ2N2hk9JLUM6avk1og+HlmgPHmO6D9Q+W+AqnOXo2DAovUGShkn+aFUP+NZ0oLnaqTHczRfLT3DIG9aX4hlsNDLlL34oxDVP6xrwBok/xEYAyrYoKoO6JhL49KXQQodOoVVLhoQQRZoOXQuaWElf8zJT2RcE4cWKM8iGGytfdZXDPkEGvSotUidxVSNxETQwRGVJlVm03880OOaAZX9c3KkT0tkP+rPlep05q0FWLYnbMgxTg/o6oDUux7oZBicw3AKYnumzQWpJCjF3NXlDgQ7xUI+n0Tnr2XRiwkeqS7n85WZVL4gYEivDGSHRAvRM55Ofrs7/rhcp5hEofEyAXJz7dASHddXgEwFR1I6cQtCqYjzyg3uTbSXTCn2ZsUCmPtTtVC0z/xefXilAE/rFp7sVO4rQDOO7aKBDAhN8DRNHy7Lf3bFUpl/5G2d4isfSbZVOMoc4HmDwztm3g+cb4AYV+dSX0B1mLy+ykv0CxrJpkzXsicNoipg/vb19IMTp8ibD/KZFVvX7SjjSeSyB02XcIYrmBil9ZSfLoQr6PRgPaSQEUBL38bJpS+KbrcPrZoDCD3EWk5Fz3MbnpUln01ObeOeL5NGs/dYSw0cLBkxCoOqbOzsScSYwU6LNlgQIzYWbDdce+6idpl59s8gvSbKvEXelKmjll34pdqej6R4FWjXbz35UrUVtOnQATzkWD9bixokTVRbQxkNU5ugnLnSP4NFh8gVSv1Hed92/3uBL8kNAy4Xmzg31Nj3uTjo+iIrs8tNbFbAY1fWzxBt1utQOa7K3Bb+mWZzQZGvpAY6uxVk84LMvBYedFoENnDwC1bJ19UuDRUMmRLct5lniFq9EEnJ3/8Pn7BT1qE4p1hdv7C5nMZVkMQVpuFhCvn78/XodxE0AJ2YFvTn0XjHZsz0Too/ZJN6R+lbCcDTiVrpfBSEUz6sCSop873XKJRHZv1M/fUe1h8J/sn5eze8e3I8lNya+ziUFSGlnCuwnYWAYikFjS5Ru3mMD/VaW4rpwA1QRsn86/h+nUJ7y4IMnHBHEShFy9yyS3Sii/rbXLhPezxmTsZdBkxBIM9xKtJIivSE1I1cgezmAXUppBXvkUpcHnZWXQWRqryXItQoZzMH5kj865p3s0cij64BKcu6qYPaKUZNzHNRlfEiRLzqYcxkJEl+RkfaQelsn3rJlbO1ip525CGqrc7GcURcd5sL3HXXMOrbA3cQBAh7AIl5ooulICY902GbzWaNznUVqeiYl2TfmufZ3CuVStoeoiU5x0wg/wm0zNB3eKMsH0BNQDUDlQvIRQwxBwNjx5m7Vhf3yEqB1hp1sc4XVoHQDzZT7xKiAomTJhZ7ow8oTERZCazf3K1r8EpTa4a5zi93picErULnh2XzgLjkpCdMvb/5KbidDSEISIMRK/BdcJzF8xAYoptjWIVKb2bbdWPGY5S4qvNlsVfe6o375NIdkI4M2/Y0ArFMji5isqVbMRX95F+eJOptxBqF8t9/WYWISfOThB222/6CR9pa7Z2bGx1q6xwJ4IfIEQdhgVNyl+6Pc9HK6x4u7Bg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d95289f7-e3cc-4d2b-5c3d-08dcbcbe89a0 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:32.0074 (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: XbXOWdTGVWETKNSRWOvvnxAA48pxL6lkni5sr+mYcuQopksGn3W9eyI4wrIgG2MSKVAqKO4sHidrRiW3MVV/8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org The current bridge() test is for packet reception on a VLAN-unaware bridge. Some things are different enough with VLAN-aware bridges that it's worth renaming this test into vlan_unaware_bridge(), and add a new vlan_aware_bridge() test. The two will share the same implementation: bridge() becomes a common function, which receives $vlan_filtering as an argument. Rename it to test_bridge() at the same time, because just bridge() pollutes the global namespace and we cannot invoke the binary with the same name from the iproute2 package currently. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index af284edaf401..5aa364b40e33 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -ALL_TESTS="standalone bridge" +ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge" NUM_NETIFS=2 PING_COUNT=1 REQUIRE_MTOOLS=yes @@ -233,7 +233,9 @@ h2_destroy() bridge_create() { - ip link add br0 type bridge + local vlan_filtering=$1 + + ip link add br0 type bridge vlan_filtering $vlan_filtering ip link set br0 address $BRIDGE_ADDR ip link set br0 up @@ -277,10 +279,12 @@ standalone() h1_destroy } -bridge() +test_bridge() { + local vlan_filtering=$1 + h1_create - bridge_create + bridge_create $vlan_filtering macvlan_create br0 run_test $h1 br0 @@ -290,6 +294,16 @@ bridge() h1_destroy } +vlan_unaware_bridge() +{ + test_bridge 0 +} + +vlan_aware_bridge() +{ + test_bridge 1 +} + cleanup() { pre_cleanup From patchwork Thu Aug 15 00:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764280 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 AB6FA18D63F; Thu, 15 Aug 2024 00:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680580; cv=fail; b=p4HDmxRvqg4xRh3WMCUYE2Nu2rPU4OxkL3z6/EN8g+OhZPI7zvIeFJAI0yJMoOH7luCZN13K3Eqn8JBVCbl0wxm7+ee8GZvrq01QXNDDfFASnfpqSbN617HXuz8+P4y3RAEO72P8a1wmZrDEqakxSsaVGwvmKmUVORcb21HdVNs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680580; c=relaxed/simple; bh=pcjavQkcbyW+3dxD/qTZhKFDigvWBQqvfT2DOgOJwDQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=V5XRGNGHb5QdYYzS5se/Ifoqssn7AG/U7zhm+vdYgGR2HUVP89JmZDJbNrS6xlZzaUmCjYV+X3xTgHguMx4zsQt6RBMIbBfNqQhFRXbc1F9R/AfdVdVF0vmWs8IUqvTkn+0qYwYRvDpvevyz6Q1o5kO9TtZDm3KWAwjVKNP2wT8= 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=I2XQBgwr; arc=fail smtp.client-ip=52.101.70.30 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="I2XQBgwr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UQ4Fug7Z5sqLI4DiHrIK74acalNhuYe7uaz88hHrVJpwTUw4UtWosJpOCPe1RRExvw77eW3WVFz4EQxNas/p9AoZ1PlpsnjHYS9nxOLdKLcxaP0GYSJ64VoGsxLySJO+s544hqT0DwAuwV+QJk+gRFXkCz+2ZW1V876cZo/5xqjycA4mZ7jG7WpbIrxFcIDZ2VS7StZ486OO5mtO4Gb+1DjL+xgxQwD1XlDZIGaTUqicvLBdauBsIWcBVXTwEVwMCMoVYg0wcG3FC7tiUKb6TPgyTsOUGC9ATl21hawVhwgBfQGM339z78J4JwFNexBw6VE+hRB69XEtuNPZsdX5Hw== 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=7Q1iWuTX03yxGDOOqYhE9jWi8hCJOF4tyGzrZjEodVw=; b=oAcibrCX6FZzrS3Z5PxTOEiPGiL4ncInEVH1QFrzJFYFzix7knQmeWf/rR2tIPlLmjiOMyJIkFXlriX7ClSzUrVrpTBN1nTPkPME4nV88cssZeU5vn1n+PDPDmtL9KfGK8xjdKCmsqF+0otaY+RrmfAGF1y+Y6utDBYWIroygavkF99JtZuosi4DsALnqPeOe+Jr2XAIW2zN+FnVxphccwnsX64T7ioWLejqnDMVZPbJArOxLVopI4T7YjZzWYubq5tc2eLZeT3Vi16utO99O0fW1QaPLvR3nNZGfqbm0+cM9FxYflz172GvureuEAgc5ZUiIaEX2MNKzShIgi/bWg== 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=7Q1iWuTX03yxGDOOqYhE9jWi8hCJOF4tyGzrZjEodVw=; b=I2XQBgwr7Akncbh7AIoWe1Utbv/SeuB/GLw0QMfj3eel4nNqlZzMg2GauL4n0iQqBDoxG7cxu1Q+pGhUany85iNiRLA7UI3HBZakF4PewnumVvqD4fADEfba8Os4QsbSOSGdqlafPIXtNTo0/rkdPE388U+aoay6c8sd9sq3kVY6n1WquFf2sh+mALLmppDtteeeRc8UWK7Gb4x51B8geEmyWCh9HJNcOBRm1644Df86JlWcR0mPompIAnlgy8L7ut35STIPKgzHP30btoth/Q9Teb9K1ERsLzBz3V9gJ9IhejVW1XDv2yEdS+klIFMPBKC5OQXTesCmAUjx8eyXDA== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:34 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 05/14] selftests: net: local_termination: introduce new tests which capture VLAN behavior Date: Thu, 15 Aug 2024 03:06:58 +0300 Message-Id: <20240815000707.2006121-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f08b2a2-3cdd-4c57-77e7-08dcbcbe8ae7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: CvZd0epN/HU0u+UItTjo/fkmXVf+vXUzTtHJPrAZgsGnUewbj7PR6uQ0BZMBJf07aA+xHZCScYOE0GCNdfzjxMhjcnwCP5ht7gIjCkKIt+GaXaUg/waTuV2L0SNhF2pMXudsJTSWrsPsJ9bj3u2Q6FdrZrT4aw4lVfyw7ShSxFvMaCq6rQZ1jhXk2DBsMvpDuBp9RTJ35X/Om8DNLdc8wQIbFmxpsDzlL6i21WD4mOgsowExjjhhEMrhBXNBegNYR4wayvGeTM6BxZDBxBqZiA/A/gK6TvY6l61ACAgbcRC6Gove2ArHAYkn4bBlcisjuAPsKR2MbU6Sf38jc5qHgF4VGqqG97G6GM51Gbt95dzN/kRkxeBQr00L+CsBjLx/GsrH+mO4+nZMBk48n/yihFvwE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V:NLI;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: obwbBYgxYvEuvSl0q4U1IJBEPot6VgJeXO8tvpaf3yopsdQnwa+tFmhabK4PtH5tbhVTTR55kJER9wF5LIwS7AHYES2l9uINkOsaTlL6729n7AHFGL8ckqmvGnQoqlnyzk+MLC1AZVRripisxRA6h9nC/ZjPo5Qr2m8XOU1txfHmEJ3/K8uOSdW/qRhosAO3tROacQNvqNwmSpXG744dXPuYGbMyDlD1+D1h7AKo7Q/EVZs7JrF3/MQprIQuHyviiL+qk+heGkrUOfIOsTcarRKKQBahLmoDCAlpdUvVjtllVIKu1VTxbK4UoBungMa3TUZKfNLPuSGm5YFmTr6gK3iG8h6j//uXxNqReyNs2LP7X0JGsPHKfJejNeTpAA7XkUwuaKq0xeSnNyattRHsis/r0UiEiVQDO4Ewt0F6QAMRbryrAujN6kB8shL0FAzpUFd+Rri892ysmGoPCAmt94kyP/wZGn19uoOOQVo17qsxiGmzGfu+UPiGKHlbQwf6turj7roLt4ZRGtpsYDPjUzAOp0K6vcKiW16QXfOmlcsOK7t7ReymWQOJCoWOLXMedKlkCtni3OUpw3/cO/kHWlMu6uQXN6dhQ+FcNb9WDetj9gJ2pDN9VU4q4+APJYRSD40n9bHbqRtdUs8LgMYlIepukRq/AR2VQT+5q2kezhh7IPJlVIfv9xYTBTKLcVJ0Dg7iIX3iR9BKHznG3wLIRnXH4EqR9wosdRZZ5reI0Ayutx7ibkQ2c9wJQxLse6+bPBd1wuSi+9Fip5LTugFytRqG3DDBWeuuhYt+G2IQOsUTQmYR3JzMhoBn5hg13WbPUcVhId/Up+PYtzbFy/ksxS8oY72o79/C6bTVyI4o4FN3UbLCBwp0078mgrgKUDyX/ULesKg/9dyw6gThk2D9wjU/0FhMp+r4lu71JYSVKG0J0UYVB/DXYVOWgfi30sJ18or+5rRXLBGEyYdyAa/VDf8T6+e7X7Eqz18OiqtOdwy+O7E3CFpBsOmuG17QKPf3PlkznsgGdQ7H2zlUWLBdMngUw3aA35ivQdNyQ9sJHBBMcg2uoAX/ik/1HpweT+QQAFosYOZQA2Rq9gN1k/sf00t08feUFzZrzUafjgKsj9vMZgqPXznXvA4IWXMLfnV8f5i4HC/Q6zWLTTUx8cUKPyUJy61kYnUSa9fxFJYj6ot7ebuyBk9knzkuW7bt/vdlZDOlZ+2xr1dXNssgNKag/G97OK3ww05ebjOTQCPXKS/my08mlNZzSjodHR8c6cA1J8HTqPlpAKBcNQQK1MghdXkfbgD1XbgkPScpbRl9gN3xGS4eE6BPsxrNz66ZPFfJwjsO/osx6vUuDMKEENbNsONs/WA/ktm+dTO3DVZUdlGRGVrFOujOAkAsbDja1Z4yEOsi2eGPrdaD+5KJjlI6X9C/3betkjGudcxSB2dpIR9lx+sn+DDdPZjif/+4KkCvMv5t+aXmU19Dy59+d9WPBPdFtRlU4PWOy29cjmAlCWFxnCoBFqIQ+5XRLeYw17R6x23ISAmgZC5CDIgiYZZAqZpmUGYN9nc6jO3UUkyI328gC1qERq5prRYWUSnuut9GnbXloOhSPnQqgHZkJavarQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f08b2a2-3cdd-4c57-77e7-08dcbcbe8ae7 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:34.1567 (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: YekTvIkP355e9UQ5kvHs2jWg8VC2kNqHheDjiGsKT6sCIg6QoBHu7FAl4VwS6DNHPG/xdox3XBDHoHnRh8ik0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org Add more coverage to the local termination selftest as follows: - 8021q upper of $h2 - 8021q upper of $h2, where $h2 is a port of a VLAN-unaware bridge - 8021q upper of $h2, where $h2 is a port of a VLAN-aware bridge - 8021q upper of VLAN-unaware br0, which is the upper of $h2 - 8021q upper of VLAN-aware br0, which is the upper of $h2 Especially the cases with traffic sent through the VLAN upper of a VLAN-aware bridge port will be immediately relevant when we will start transmitting PTP packets as an additional kind of traffic. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 117 ++++++++++++++++-- 1 file changed, 110 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index 5aa364b40e33..e22c6a693bef 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -1,7 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge" +ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge test_vlan \ + vlan_over_vlan_unaware_bridged_port vlan_over_vlan_aware_bridged_port \ + vlan_over_vlan_unaware_bridge vlan_over_vlan_aware_bridge" NUM_NETIFS=2 PING_COUNT=1 REQUIRE_MTOOLS=yes @@ -231,6 +233,30 @@ h2_destroy() simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64 } +h1_vlan_create() +{ + simple_if_init $h1 + vlan_create $h1 100 v$h1 $H1_IPV4/24 $H1_IPV6/64 +} + +h1_vlan_destroy() +{ + vlan_destroy $h1 100 + simple_if_fini $h1 +} + +h2_vlan_create() +{ + simple_if_init $h2 + vlan_create $h2 100 v$h2 $H2_IPV4/24 $H2_IPV6/64 +} + +h2_vlan_destroy() +{ + vlan_destroy $h2 100 + simple_if_fini $h2 +} + bridge_create() { local vlan_filtering=$1 @@ -241,14 +267,10 @@ bridge_create() ip link set $h2 master br0 ip link set $h2 up - - simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64 } bridge_destroy() { - simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64 - ip link del br0 } @@ -272,7 +294,7 @@ standalone() h2_create macvlan_create $h2 - run_test $h1 $h2 + run_test $h1 $h2 "$h2" macvlan_destroy h2_destroy @@ -285,11 +307,13 @@ test_bridge() h1_create bridge_create $vlan_filtering + simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64 macvlan_create br0 - run_test $h1 br0 + run_test $h1 br0 "vlan_filtering=$vlan_filtering bridge" macvlan_destroy + simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64 bridge_destroy h1_destroy } @@ -304,6 +328,85 @@ vlan_aware_bridge() test_bridge 1 } +test_vlan() +{ + h1_vlan_create + h2_vlan_create + macvlan_create $h2.100 + + run_test $h1.100 $h2.100 "VLAN upper" + + macvlan_destroy + h2_vlan_destroy + h1_vlan_destroy +} + +vlan_over_bridged_port() +{ + local vlan_filtering=$1 + + h1_vlan_create + h2_vlan_create + bridge_create $vlan_filtering + macvlan_create $h2.100 + + run_test $h1.100 $h2.100 "VLAN over vlan_filtering=$vlan_filtering bridged port" + + macvlan_destroy + bridge_destroy + h2_vlan_destroy + h1_vlan_destroy +} + +vlan_over_vlan_unaware_bridged_port() +{ + vlan_over_bridged_port 0 +} + +vlan_over_vlan_aware_bridged_port() +{ + vlan_over_bridged_port 1 +} + +vlan_over_bridge() +{ + local vlan_filtering=$1 + + h1_vlan_create + bridge_create $vlan_filtering + simple_if_init br0 + vlan_create br0 100 vbr0 $H2_IPV4/24 $H2_IPV6/64 + macvlan_create br0.100 + + if [ $vlan_filtering = 1 ]; then + bridge vlan add dev $h2 vid 100 master + bridge vlan add dev br0 vid 100 self + fi + + run_test $h1.100 br0.100 "VLAN over vlan_filtering=$vlan_filtering bridge" + + if [ $vlan_filtering = 1 ]; then + bridge vlan del dev br0 vid 100 self + bridge vlan del dev $h2 vid 100 master + fi + + macvlan_destroy + vlan_destroy br0 100 + simple_if_fini br0 + bridge_destroy + h1_vlan_destroy +} + +vlan_over_vlan_unaware_bridge() +{ + vlan_over_bridge 0 +} + +vlan_over_vlan_aware_bridge() +{ + vlan_over_bridge 1 +} + cleanup() { pre_cleanup From patchwork Thu Aug 15 00:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764281 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 1C03018D64E; Thu, 15 Aug 2024 00:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680583; cv=fail; b=ra4htoVcpaQllfipwxsToW7sNpa5qTZBULsyqo2iObo08Ji3w3VGiJnjKMhiiGTaFlKm1mbUkOMSsHs5rq4+afClRCS5bwfxWYb1xnBLTYbO1B38RRQBQu2DE6sta836GxBIDWCekHpx2Juom0a1LoECiFsGsPyBgC9Dv5Oyh3U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680583; c=relaxed/simple; bh=kiC1aBzZik3frYM2xJDS3xMO/dXeowPEMXdkjfsF0JA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JD4aVpjnSFKLFram+Ij3G62uA1wtK2eulvGAvEaNRoJi2FpwihNzBLM10XmtS9CYT/ib4nPKJ1i1jfp5E8ms7vFdjCL9ZWYydm3kEAmHDPHMF7xk/q5vYeiUG7Ic+G/6K4MHwD+tv66CDCTCqUeFHorzBe/0oscbWi33ItLuH7E= 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=Mu0hB3py; arc=fail smtp.client-ip=52.101.70.30 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="Mu0hB3py" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oh6hdxLmaS2VDhOS65qAFoUXmWjqPQUj561Qa8M/E/mDvc0AanSZ4/DzyqMiL4gjEkx/pZLkZDHr8bbjB4idZPmky+DoyRxa9pKyuAcEx1fASvlBggaMEayy/e92KQCZnblqFiKqapV9kQc4DLoCdW0hpWrHd+ETQ8p8UAAzc2hpZUHbU4lAqWGGbB+tbou6FcLSvVk6eYcKYDvVDdBSgWRDK6j1wX2WaxH0RYsylMeSN8uopHO5lKLy1n78zgfeK4kDeEvNBAWeUeErHgh4vn5ULwpKN3469WisDCUlL5qI1AF/tiY0E0XrU8STBJYH14UIryF6swhAOrtaeXhqNQ== 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=iapdVsPVDwJAQMwEyKbqzgUxfq7FOyMpaekU4nSYng8=; b=Los09c4CIey5nX1cRMBXpn3l2FabY+bQxLIfb04NSEqTwxpBUMcA2Jx2VNOpAewG5LG/56IVGvrg7pi1RVWoeTAS5VaDMKx6OFouzePOmA0On4x6B4yuZa1CYFJlqBdOcuSWeA/LaRcors7zI54sg40y1TrsefoMp5MaTPorV2xMj3XaI3OPkSxraEl+8fzEKuloPX8f9kTZHM1XShUHWGz0HvFppmTh83d3riPkQEqLBllpWf4j6X7pIasdWxWk4O5bbKpkl5T0mKJMKnYHh+nz6M+sTGKfKGcWRTtvUvUmD1b7wXoJh/fmsf57K7xG3Hf1Swm3NIb1XIQ+CexsvQ== 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=iapdVsPVDwJAQMwEyKbqzgUxfq7FOyMpaekU4nSYng8=; b=Mu0hB3pyGq/k3gSTX6v6PKEcwARtGpvMwQzD6OUu+4dRq3kJolW7275J9OoasF4F7llUi7w0YPEhwPpAop+F5YX2W5Oya7X3rZC8Zf5oZlVWZLAbMAyEYy04jbH/Kig23LZ2a//SPM05kM9QlosBjGZILuMrI3KCj0sZrZ+a3ITdyCUN84aD0zJhbw2pgxhYgCGdmCTDaCS1D/5rUJ1eHfsnIiq8aAwmbH1dWpSqSXKN6xdsiB1pgkGlr5Pr32oHJ1Kh5GP9A48F7VROwrn+fMkV4a0VhCu28wpnbUe+GYHtfJg828iv7AuaP4bZ5QSOq+OzS3E0DK7lwq0RBbq10Q== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:36 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:36 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 06/14] selftests: net: local_termination: don't use xfail_on_veth() Date: Thu, 15 Aug 2024 03:06:59 +0300 Message-Id: <20240815000707.2006121-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ad49aa6-3ae4-4104-03cd-08dcbcbe8c2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: rnqH48gpW1o/v61hGWMfZzuFFmkvxcPp+BzI9114+UWFr3Xkb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+QVgMWN3HAlg9YcSsbP+/Og//qGCCbSrPsaYKHrnHlW0HCsOMQ4LSfjQFtf5SMfrZPX/pjW2LW9Q1TQWWVJ35R5nn7+1NBjpeQAkDXCNTiDuJ5Lth5sPaKTcTd64dv2kX2hsKR1EI5Bfr5iMAcf4RZ3SeuU7ckY4NS+7VCksaa1C+vu9nG277XMOsrfU1dxQPxRC/GkEr6YP0FFHVPF6yLnvNdI4D8bCYyDixX6RUDCRXMuZq2dT1T4FlOSKzohJFTXYOgfVBMR60S9W4qBlOTsiiVsqtXKPpLNkKm5k3oOSf2fuZg== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2k2BtNEvTc1UZY8UjVczZVL5G3PBsQqXszmOtRkGMRiLJY3ybtSreOEiHxl81nQqXOsenfAYfq+2trisOA/a0MAuL2YO+qcPBvK6e2fXO+3kd3voIPRjGRsJbLr5km4W0Ziz6PqFq87H1KfibHzVQwDHCWOrtlQ6vpe2ArBivr0TWN0uKQllSN9SMB/KLniw+zt5gO523eEZOcp0kCb1pr/zgLUpP0O+BVFJHmCAVLBk/XUDtDPqIKVvurQNu7Y9/8B4UsEnApMTrU6Rj9Pb4QT+83ErUaeVhKCpyYIkp0C+IsvEB7kPE1bywhah50tkeZ0NN6fUhKqGnOBS7KRvlU8CsKAHmhQ7PbPBkgwilheG8pbor2+wCLFYbbAyZSk//kXZlUziw1TcPL97q/t6GPlmFtytcshhxe2s4t0jBNa1o+y6pfdpZxdZZ3Pt+ss5d5gDdmk1ToLz4WWRuBG14l1/PSGR18kfW4pyxkHeTehc3HaOofnkPu179rIaBvyJzIlRtIW7YhWKhiTg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BGGPLm3TYMg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ad49aa6-3ae4-4104-03cd-08dcbcbe8c2a X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:36.2656 (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: ihMfl9S8FGUZiXbYpumguI6vqzH4jU/cCUz03noKoVkBoDoEQ4NZueCndjp0PoM7idEhfDEdvwIh5GvXJBCqyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org xfail_on_veth() for this test is an incorrect approximation which gives false positives and false negatives. When local_termination fails with "reception succeeded, but should have failed", it is because the DUT ($h2) accepts packets even when not configured as promiscuous. This is not something specific to veth; even the bridge behaves that way, but this is not captured by the xfail_on_veth test. The IFF_UNICAST_FLT flag is not explicitly exported to user space, but it can somewhat be determined from the interface's behavior. We have to create a macvlan upper with a different MAC address. This forces a dev_uc_add() call in the kernel. When the unicast filtering list is not empty, but the device doesn't support IFF_UNICAST_FLT, __dev_set_rx_mode() force-enables promiscuity on the interface, to ensure correct behavior (that the requested address is received). We can monitor the change in the promiscuity flag and infer from it whether the device supports unicast filtering. There is no equivalent thing for allmulti, unfortunately. We never know what's hiding behind a device which has allmulti=off. Whether it will actually perform RX multicast filtering of unknown traffic is a strong "maybe". The bridge driver, for example, completely ignores the flag. We'll have to keep the xfail behavior, but instead of XFAIL on just veth, always XFAIL. Signed-off-by: Vladimir Oltean --- tools/testing/selftests/net/forwarding/lib.sh | 57 ++++++++++++++++++ .../net/forwarding/local_termination.sh | 58 ++++++++++++++----- 2 files changed, 99 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index cb0fcd6f0293..c992e385159c 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -500,6 +500,11 @@ check_err_fail() fi } +xfail() +{ + FAIL_TO_XFAIL=yes "$@" +} + xfail_on_slow() { if [[ $KSFT_MACHINE_SLOW = yes ]]; then @@ -1120,6 +1125,39 @@ mac_get() ip -j link show dev $if_name | jq -r '.[]["address"]' } +ether_addr_to_u64() +{ + local addr="$1" + local order="$((1 << 40))" + local val=0 + local byte + + addr="${addr//:/ }" + + for byte in $addr; do + byte="0x$byte" + val=$((val + order * byte)) + order=$((order >> 8)) + done + + printf "0x%x" $val +} + +u64_to_ether_addr() +{ + local val=$1 + local byte + local i + + for ((i = 40; i >= 0; i -= 8)); do + byte=$(((val & (0xff << i)) >> i)) + printf "%02x" $byte + if [ $i -ne 0 ]; then + printf ":" + fi + done +} + ipv6_lladdr_get() { local if_name=$1 @@ -2236,3 +2274,22 @@ absval() echo $((v > 0 ? v : -v)) } + +has_unicast_flt() +{ + local dev=$1; shift + local mac_addr=$(mac_get $dev) + local tmp=$(ether_addr_to_u64 $mac_addr) + local promisc + + ip link set $dev up + ip link add link $dev name macvlan-tmp type macvlan mode private + ip link set macvlan-tmp address $(u64_to_ether_addr $((tmp + 1))) + ip link set macvlan-tmp up + + promisc=$(ip -j -d link show dev $dev | jq -r '.[].promiscuity') + + ip link del macvlan-tmp + + [[ $promisc == 1 ]] && echo "no" || echo "yes" +} diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index e22c6a693bef..80ea4c10d764 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -109,9 +109,11 @@ run_test() { local send_if_name=$1; shift local rcv_if_name=$1; shift + local no_unicast_flt=$1; shift local test_name="$1"; shift local smac=$(mac_get $send_if_name) local rcv_dmac=$(mac_get $rcv_if_name) + local should_receive tcpdump_start $rcv_if_name @@ -160,26 +162,26 @@ run_test() "$smac > $MACVLAN_ADDR, ethertype IPv4 (0x0800)" \ true "$test_name" - xfail_on_veth $h1 \ - check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \ - "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \ - false "$test_name" + [ $no_unicast_flt = true ] && should_receive=true || should_receive=false + check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \ + "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \ + $should_receive "$test_name" check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \ "$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \ true "$test_name" - xfail_on_veth $h1 \ - check_rcv $rcv_if_name \ - "Unicast IPv4 to unknown MAC address, allmulti" \ - "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \ - false "$test_name" + [ $no_unicast_flt = true ] && should_receive=true || should_receive=false + check_rcv $rcv_if_name \ + "Unicast IPv4 to unknown MAC address, allmulti" \ + "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \ + $should_receive "$test_name" check_rcv $rcv_if_name "Multicast IPv4 to joined group" \ "$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \ true "$test_name" - xfail_on_veth $h1 \ + xfail \ check_rcv $rcv_if_name \ "Multicast IPv4 to unknown group" \ "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \ @@ -197,7 +199,7 @@ run_test() "$smac > $JOINED_MACV6_MC_ADDR, ethertype IPv6 (0x86dd)" \ true "$test_name" - xfail_on_veth $h1 \ + xfail \ check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \ "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \ false "$test_name" @@ -290,11 +292,17 @@ macvlan_destroy() standalone() { + local no_unicast_flt=true + + if [ $(has_unicast_flt $h2) = yes ]; then + no_unicast_flt=false + fi + h1_create h2_create macvlan_create $h2 - run_test $h1 $h2 "$h2" + run_test $h1 $h2 $no_unicast_flt "$h2" macvlan_destroy h2_destroy @@ -303,6 +311,7 @@ standalone() test_bridge() { + local no_unicast_flt=true local vlan_filtering=$1 h1_create @@ -310,7 +319,7 @@ test_bridge() simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64 macvlan_create br0 - run_test $h1 br0 "vlan_filtering=$vlan_filtering bridge" + run_test $h1 br0 $no_unicast_flt "vlan_filtering=$vlan_filtering bridge" macvlan_destroy simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64 @@ -330,11 +339,17 @@ vlan_aware_bridge() test_vlan() { + local no_unicast_flt=true + + if [ $(has_unicast_flt $h2) = yes ]; then + no_unicast_flt=false + fi + h1_vlan_create h2_vlan_create macvlan_create $h2.100 - run_test $h1.100 $h2.100 "VLAN upper" + run_test $h1.100 $h2.100 $no_unicast_flt "VLAN upper" macvlan_destroy h2_vlan_destroy @@ -343,14 +358,23 @@ test_vlan() vlan_over_bridged_port() { + local no_unicast_flt=true local vlan_filtering=$1 + # br_manage_promisc() will not force a single vlan_filtering port to + # promiscuous mode, so we should still expect unicast filtering to take + # place if the device can do it. + if [ $(has_unicast_flt $h2) = yes ] && [ $vlan_filtering = 1 ]; then + no_unicast_flt=false + fi + h1_vlan_create h2_vlan_create bridge_create $vlan_filtering macvlan_create $h2.100 - run_test $h1.100 $h2.100 "VLAN over vlan_filtering=$vlan_filtering bridged port" + run_test $h1.100 $h2.100 $no_unicast_flt \ + "VLAN over vlan_filtering=$vlan_filtering bridged port" macvlan_destroy bridge_destroy @@ -370,6 +394,7 @@ vlan_over_vlan_aware_bridged_port() vlan_over_bridge() { + local no_unicast_flt=true local vlan_filtering=$1 h1_vlan_create @@ -383,7 +408,8 @@ vlan_over_bridge() bridge vlan add dev br0 vid 100 self fi - run_test $h1.100 br0.100 "VLAN over vlan_filtering=$vlan_filtering bridge" + run_test $h1.100 br0.100 $no_unicast_flt \ + "VLAN over vlan_filtering=$vlan_filtering bridge" if [ $vlan_filtering = 1 ]; then bridge vlan del dev br0 vid 100 self From patchwork Thu Aug 15 00:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764282 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 721CC1EB46; Thu, 15 Aug 2024 00:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680585; cv=fail; b=innWgJockgb584h8XGWCjTGqs3qzD1kc6TO5cYLQBjMaRUua+As7FBbz+C6sSYUL4ncBixT8j3iHUBjm1qqfuKFbj4RpcZseHl3GiZHIkfFWeVReUWedwSeYm3omlLGgiwP+DY9uQE7k3RpHZD+250HiR2jPvYnRVnYlqk47OAo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680585; c=relaxed/simple; bh=qehDAs1pa8Q1SKGJqJDjCj4NerbOL3efC3syimLs3Cc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OM9BFQvMU9OZmrHKyBEWwrQp8MIL5K97zH4EPxdYV8JX1ulSHqDKFZRaBnvVtoCgCempvlCgOx8vp6GCW8SjgaGMGaLgXcSdd+ylHD+fJG/pw6SQ2SAQxsgPs8vYPOO2kQTdtxZF9D7F9RN/VbHVghikOcBlH4rT4Q/TTIJXpiA= 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=jI/0FkL0; arc=fail smtp.client-ip=52.101.70.30 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="jI/0FkL0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hegwgz6DbIFZ7KO4vvgmDftN5upw8q5CgS6iQoQohCpyeRGLF2a8OTpZcIUU5AA9obw5meSk8cYe4tfw5F+z05cx2kFfjdETIh9yx3Hf96rNqAXH9NuZNIdESFpNmaUpH8ebCVn8WanpS3OAAJItqKBvdX8UG0d8pCVC8oLWCbgHfAuPFCGdCEAiGoo3rWTMHEzhhnogGUQInr82Wi1q5TqrnZ5c/9n6C8uYEdERymrz3OxsD941rR7VmDSv2Y5Fu4cIszdJ6vtFIGtqSTH2jI0HJQkej4VDwF4S1Y6bg12Kq9GwHmeGTEIM20ol1G4UYnlXNq/LoI6qdvC2gjX1LA== 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=NKTuxN3Nem7Ye7Mz87vdjHN6iUukj/i+kZNh0Ot9Vp0=; b=NrWDxuev1zBQP2x/Dv8E0yIxpNlvF6TXdLoX8uE8jtaTYudG1EnizfZEy0Eb44FmKsvqLVCqHNaKQhzwVdCQH4+DUlSFrrfIoBb9UPrldqJz4q0dVM0lD0oe/btTmeKR+GtxO5EfgW3EROCJhlztsHs79gM0XoykImsbcAvNXgPH1XsJvvCYHhOPG8w2IJcUR8ghIn27tOkpmVq7BZTY13uaz4IQ2uYJJIyaKFmNv6b0k8nbvkCmxMMighW0K/Ns8uj3lVVl4HYlLa939lDKQhtGyTFd0coDLfUtpVc0CpNjTFI5H1Ela3bpWQpE/E3vx6auN2UbfPbmyjPx2Rt0WA== 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=NKTuxN3Nem7Ye7Mz87vdjHN6iUukj/i+kZNh0Ot9Vp0=; b=jI/0FkL00uF3pXIBsRlryq8jwygdh5GPgqirJBYbBUoQpq8FM6C1nMdOIpZ/yL0aFGRYV31/SM2yVVCzDRn8VnmRhMYkCs1TGr31DjGOw0B6szL5KcayeodPykWD/NWYSm7zeyE7g4BWfHu7jJZKTdzM7T1S+5kPIm3OwSxsFD66JdnxDUFScKrB3INwrilNgBEuPL4r9cAw5frAUXwrAanCBt/Eqf3bdI6q8+E3HHcK54kiEVxSlQTNQtBiI0Y4dgVyESqAuNcoFG+baoix7D3f1cwKS/h4WoM1bKfLjGFkWq4pftbejKXoZqQ2mznR5/AO1yQsyFXn4wS5RGLLKA== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:38 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:38 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 07/14] selftests: net: local_termination: add PTP frames to the mix Date: Thu, 15 Aug 2024 03:07:00 +0300 Message-Id: <20240815000707.2006121-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: a1c38934-b1e1-4fe4-cfbe-08dcbcbe8d6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: v9qIFWOPuGETpKa4UAAVISsdG5d/cKOEBH0UmsBw5k/qo32k8sDhSIHOHg+Hhz1TtRjp9xcUDl0x88MKIwFQ+AmfihokF9uwGei6h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K1gthO/hRT2qTaI+F0jU4h24Ix2Rz9nBbhFOyKAtCGDjbUwVARFVMDkhsF5+LrNw621EAG+XlT++LkUdmXRSiCMF73P0oF7nCsj0xt1A980e97pJuoGORaQjkA2Fy8i5k6VQGiJ8qU323xh2DSTdeNy97Ah8c8dOdpqF75lPrPG1VocmrCotuuANSatBuZuBogy4jWcU8FXsN0s1mHvLSBWJ9+TBpljpzF8JXm3A5VVNhMOHcpkjOg== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 27uTxV3KT1x9FFLY+e/Qkey6TaYacF0pOsdwOjPG+Ne/pt012qzu4ddsD86vEqa0/Q00AOQLkyO07HTeNDbCu/qk1EGoTGsU5zNcvcwcJg3D3OgTPtqvgfjp4wf9XLEqI8wuhS3pPuEToZZKJCqOgnYwcpqreGx9qy6sfKnknVi6xjF0ziU6ScQBWjxjy87OYIiHTsgPJT5dHVYpulbkteYeGE7boA5BYmxQPQKHI8RlHm4cWdKw7GfGlGKPfv/vYw7qH89TqvtqM613Z8pBajpFhP6kN2n1oq0K9oWnyT0wHf59aBfolZlMDssPSXGf43MCw+HOxNCjQjm9bzk+SARo/cOWeJQXEHLwx84GyprIi0Ck/3oliL1MJVOllQX59Mwa4NdSGyTn+KVpxoy01zIML/1KLND46is7yrJAPo+3At9B9G596n/RuMg8Bk2gZJZNRC/hOX260vo4j52hLEQkuljA54kVHQS9H35bBkyzXaXeY0QfZB896dOXjhbb330iBD1n+C55vjStMihvjkQiQJnF6iPb7va3PqIqnKs0uFWbr+lVsjYOx4pyt3yuG9FfBJ2JwMSN8ZGEcAOb+maVCOtaHEJPZ6JiZlX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e-08dcbcbe8d6c X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:38.3598 (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: gks7L81D+Cr26x6nGXdssw3iM0tTOZD7Erj2uMBFAw0DgOhTBKatIZhvmHLfz82/LeTX5myfQ2eIwh1QbO0eAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org A breakage in the felix DSA driver shows we do not have enough test coverage. More generally, it is sufficiently special that it is likely drivers will treat it differently. This is not meant to be a full PTP test, it just makes sure that PTP packets sent to the different addresses corresponding to their profiles are received correctly. The local_termination selftest seemed like the most appropriate place for this addition. PTP RX/TX in some cases makes no sense (over a bridge) and this is why $skip_ptp exists. And in others - PTP over a bridge port - the IP stack needs convincing through the available bridge netfilter hooks to leave the PTP packets alone and not stolen by the bridge rx_handler. It is safe to assume that users have that figured out already. This is a driver level test, and by using tcpdump, all that extra setup is out of scope here. send_non_ip() was an unfinished idea; written but never used. Replace it with a more generic send_raw(), and send 3 PTP packet types times 3 transports. Signed-off-by: Vladimir Oltean --- .../net/forwarding/local_termination.sh | 161 ++++++++++++++++-- 1 file changed, 148 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh index 80ea4c10d764..648868f74604 100755 --- a/tools/testing/selftests/net/forwarding/local_termination.sh +++ b/tools/testing/selftests/net/forwarding/local_termination.sh @@ -39,9 +39,68 @@ UNKNOWN_MACV6_MC_ADDR1="33:33:01:02:03:05" UNKNOWN_MACV6_MC_ADDR2="33:33:01:02:03:06" UNKNOWN_MACV6_MC_ADDR3="33:33:01:02:03:07" -NON_IP_MC="01:02:03:04:05:06" -NON_IP_PKT="00:04 48:45:4c:4f" -BC="ff:ff:ff:ff:ff:ff" +PTP_1588_L2_SYNC=" \ +01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 00 02 \ +00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00" +PTP_1588_L2_FOLLOW_UP=" \ +01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 08 02 \ +00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \ +00 00 66 83 c5 f1 17 97 ed f0" +PTP_1588_L2_PDELAY_REQ=" \ +01:80:c2:00:00:0e 00:00:de:ad:be:ef 88:f7 02 02 \ +00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 06 05 7f \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00" +PTP_1588_IPV4_SYNC=" \ +01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \ +00 48 0a 9a 40 00 01 11 cb 88 c0 00 02 01 e0 00 \ +01 81 01 3f 01 3f 00 34 a3 c8 00 02 00 2c 00 00 \ +02 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \ +63 ff fe cf 17 0e 00 01 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00" +PTP_1588_IPV4_FOLLOW_UP=" +01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \ +00 48 0a 9b 40 00 01 11 cb 87 c0 00 02 01 e0 00 \ +01 81 01 40 01 40 00 34 a3 c8 08 02 00 2c 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \ +63 ff fe cf 17 0e 00 01 00 00 02 00 00 00 66 83 \ +c6 0f 1d 9a 61 87" +PTP_1588_IPV4_PDELAY_REQ=" \ +01:00:5e:00:00:6b 00:00:de:ad:be:ef 08:00 45 00 \ +00 52 35 a9 40 00 01 11 a1 85 c0 00 02 01 e0 00 \ +00 6b 01 3f 01 3f 00 3e a2 bc 02 02 00 36 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \ +63 ff fe cf 17 0e 00 01 00 01 05 7f 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" +PTP_1588_IPV6_SYNC=" \ +33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 06 \ +7c 2f 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \ +00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \ +00 00 00 00 01 81 01 3f 01 3f 00 36 2e 92 00 02 \ +00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00" +PTP_1588_IPV6_FOLLOW_UP=" \ +33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 0a \ +00 bc 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \ +00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \ +00 00 00 00 01 81 01 40 01 40 00 36 2e 92 08 02 \ +00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \ +00 00 66 83 c6 2a 32 09 bd 74 00 00" +PTP_1588_IPV6_PDELAY_REQ=" \ +33:33:00:00:00:6b 00:00:de:ad:be:ef 86:dd 60 0c \ +5c fd 00 40 11 01 fe 80 00 00 00 00 00 00 3c 37 \ +63 ff fe cf 17 0e ff 02 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 6b 01 3f 01 3f 00 40 b4 54 02 02 \ +00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 3e 37 63 ff fe cf 17 0e 00 01 00 01 05 7f \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00" # Disable promisc to ensure we don't receive unknown MAC DA packets export TCPDUMP_EXTRA_FLAGS="-pl" @@ -49,13 +108,15 @@ export TCPDUMP_EXTRA_FLAGS="-pl" h1=${NETIFS[p1]} h2=${NETIFS[p2]} -send_non_ip() +send_raw() { - local if_name=$1 - local smac=$2 - local dmac=$3 + local if_name=$1; shift + local pkt="$1"; shift + local smac=$(mac_get $if_name) - $MZ -q $if_name "$dmac $smac $NON_IP_PKT" + pkt="${pkt/00:00:de:ad:be:ef/$smac}" + + $MZ -q $if_name "$pkt" } send_uc_ipv4() @@ -109,6 +170,7 @@ run_test() { local send_if_name=$1; shift local rcv_if_name=$1; shift + local skip_ptp=$1; shift local no_unicast_flt=$1; shift local test_name="$1"; shift local smac=$(mac_get $send_if_name) @@ -150,6 +212,35 @@ run_test() mc_route_destroy $rcv_if_name mc_route_destroy $send_if_name + if [ $skip_ptp = false ]; then + ip maddress add 01:1b:19:00:00:00 dev $rcv_if_name + send_raw $send_if_name "$PTP_1588_L2_SYNC" + send_raw $send_if_name "$PTP_1588_L2_FOLLOW_UP" + ip maddress del 01:1b:19:00:00:00 dev $rcv_if_name + + ip maddress add 01:80:c2:00:00:0e dev $rcv_if_name + send_raw $send_if_name "$PTP_1588_L2_PDELAY_REQ" + ip maddress del 01:80:c2:00:00:0e dev $rcv_if_name + + mc_join $rcv_if_name 224.0.1.129 + send_raw $send_if_name "$PTP_1588_IPV4_SYNC" + send_raw $send_if_name "$PTP_1588_IPV4_FOLLOW_UP" + mc_leave + + mc_join $rcv_if_name 224.0.0.107 + send_raw $send_if_name "$PTP_1588_IPV4_PDELAY_REQ" + mc_leave + + mc_join $rcv_if_name ff0e::181 + send_raw $send_if_name "$PTP_1588_IPV6_SYNC" + send_raw $send_if_name "$PTP_1588_IPV6_FOLLOW_UP" + mc_leave + + mc_join $rcv_if_name ff02::6b + send_raw $send_if_name "$PTP_1588_IPV6_PDELAY_REQ" + mc_leave + fi + sleep 1 tcpdump_stop $rcv_if_name @@ -212,6 +303,44 @@ run_test() "$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \ true "$test_name" + if [ $skip_ptp = false ]; then + check_rcv $rcv_if_name "1588v2 over L2 transport, Sync" \ + "ethertype PTP (0x88f7).* PTPv2.* msg type : sync msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over L2 transport, Follow-Up" \ + "ethertype PTP (0x88f7).* PTPv2.* msg type : follow up msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over L2 transport, Peer Delay Request" \ + "ethertype PTP (0x88f7).* PTPv2.* msg type : peer delay req msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv4, Sync" \ + "ethertype IPv4 (0x0800).* PTPv2.* msg type : sync msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv4, Follow-Up" \ + "ethertype IPv4 (0x0800).* PTPv2.* msg type : follow up msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv4, Peer Delay Request" \ + "ethertype IPv4 (0x0800).* PTPv2.* msg type : peer delay req msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv6, Sync" \ + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : sync msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv6, Follow-Up" \ + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : follow up msg" \ + true "$test_name" + + check_rcv $rcv_if_name "1588v2 over IPv6, Peer Delay Request" \ + "ethertype IPv6 (0x86dd).* PTPv2.* msg type : peer delay req msg" \ + true "$test_name" + fi + tcpdump_cleanup $rcv_if_name } @@ -293,6 +422,7 @@ macvlan_destroy() standalone() { local no_unicast_flt=true + local skip_ptp=false if [ $(has_unicast_flt $h2) = yes ]; then no_unicast_flt=false @@ -302,7 +432,7 @@ standalone() h2_create macvlan_create $h2 - run_test $h1 $h2 $no_unicast_flt "$h2" + run_test $h1 $h2 $skip_ptp $no_unicast_flt "$h2" macvlan_destroy h2_destroy @@ -313,13 +443,15 @@ test_bridge() { local no_unicast_flt=true local vlan_filtering=$1 + local skip_ptp=true h1_create bridge_create $vlan_filtering simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64 macvlan_create br0 - run_test $h1 br0 $no_unicast_flt "vlan_filtering=$vlan_filtering bridge" + run_test $h1 br0 $skip_ptp $no_unicast_flt \ + "vlan_filtering=$vlan_filtering bridge" macvlan_destroy simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64 @@ -340,6 +472,7 @@ vlan_aware_bridge() test_vlan() { local no_unicast_flt=true + local skip_ptp=false if [ $(has_unicast_flt $h2) = yes ]; then no_unicast_flt=false @@ -349,7 +482,7 @@ test_vlan() h2_vlan_create macvlan_create $h2.100 - run_test $h1.100 $h2.100 $no_unicast_flt "VLAN upper" + run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt "VLAN upper" macvlan_destroy h2_vlan_destroy @@ -360,6 +493,7 @@ vlan_over_bridged_port() { local no_unicast_flt=true local vlan_filtering=$1 + local skip_ptp=false # br_manage_promisc() will not force a single vlan_filtering port to # promiscuous mode, so we should still expect unicast filtering to take @@ -373,7 +507,7 @@ vlan_over_bridged_port() bridge_create $vlan_filtering macvlan_create $h2.100 - run_test $h1.100 $h2.100 $no_unicast_flt \ + run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt \ "VLAN over vlan_filtering=$vlan_filtering bridged port" macvlan_destroy @@ -396,6 +530,7 @@ vlan_over_bridge() { local no_unicast_flt=true local vlan_filtering=$1 + local skip_ptp=true h1_vlan_create bridge_create $vlan_filtering @@ -408,7 +543,7 @@ vlan_over_bridge() bridge vlan add dev br0 vid 100 self fi - run_test $h1.100 br0.100 $no_unicast_flt \ + run_test $h1.100 br0.100 $skip_ptp $no_unicast_flt \ "VLAN over vlan_filtering=$vlan_filtering bridge" if [ $vlan_filtering = 1 ]; then From patchwork Thu Aug 15 00:07:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764283 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 D21082A8D0; Thu, 15 Aug 2024 00:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680587; cv=fail; b=I5j4llP5PS9dfWjJopxO+y1D1Oty9FYpNb/8zmthENtt7j8WZ0ALoqxKkea0ektyGY1ePXFyUYJlA77o1Brk+ikb4XjuWzJD8Gp759vWixfWjYwSnfUi/Z3kCkvfBax++uVilfRBO70A+ZdvZKGEbM/XJCJlZk6d1V3TC7E+xfY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680587; c=relaxed/simple; bh=JIR1sy0F9vmqeNRwxSxMS4lJhnehJ7t+hZFm/3Tv3pE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jIL4YMOnuX1qOE68MSx+GYeRWyAXb8Ew1ioFHS04SS+Dkjyn/zWC+W12F5XZ0qDdUQZWf5FPw1dzQpBWSbctB6Ft9HCYVQhJX/+oMsFA+5IgBeCrX0yfiQmxwgxQyx9w9mugxIsWFETIYxwsuxpoPtwT8rdr/NtG+sRJf17VLBQ= 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=fi9a2ONr; arc=fail smtp.client-ip=52.101.70.30 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="fi9a2ONr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YSlOFE7MvigPVHq8QDkc5Xerk7CDtZALoP7pV9dVHa3jEb1wSSmqlON+R7B5pBCWi/8HkhZVu70gOh86fj9vSpGDEh5yhpK72/YNlTDd+mt8LTZ/nu/7+orvvkgCBDMpuaDvXCjBrPScah71fp30oTqwXqx53wxZV7OtuYqXH5/wYvd0jpm6U6vOSfVCwFpEjLYU029nT2X9LcBhE2hxfZoEE7SJzJfqJj4DsJpon22ZVMOcU6twfSH7qFj8avU9QAaFrmDKXou/KsfPJATx162Bfv8BFfDETKcWnb0MhlAaHNK38cv7JS4+oChkIcmKR74KcBH9bV1t79O0g753nQ== 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=0s1MqFRA2krXeubenVd6D9DjZBf1ABW8Qi6HceVxlU0=; b=dIeXKweSSw8E8b6ykV/cbzZ5FarC+5UCy08ZJo9tbyMwKl52Ph5DSu9PHsumYZ17ZvW9/TBJmsbn47oK8UXQHZfdQ7eAEQhNVcvF2j7otxU55TPNiJa6EmLwrZwdZwXSl3nhC7PbK/TH0bxxm1brHNlv5dtawa76KHwo/1ivUzjl8XdoXbJp4BWwoC6CcyNq0EnBqodbFfPckUDZRSvXQU71CVpzLNcbuvP6xmAgizgAKc/pGZhTb7LlehKo3ZGerhLIRWtiZVjFvP+tZHIk5JEuroY2UL1qji3EJ7arUEJ/q29Hv/o7Z/GdCVimhnbmIQxT0V/EXfFiySUM8OEsOw== 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=0s1MqFRA2krXeubenVd6D9DjZBf1ABW8Qi6HceVxlU0=; b=fi9a2ONrTSzFGztqx/MmDuk09ziThg7XOQGbhYsy5NbkC5sD4t4VsD+2yT9FDu+qRmZXV12twWd0JsYkJv/HE8mZNGV6Hu+dUe4q2BDR+Q2+XcUuNjhR2xKZHiQzytH7BroaeEIduHXqQdNnXvhGpGMZ+bKdMuYnVu0xYdgxprhhWMZVNp3mJDSiwGgL7E6ClaCERYr2I4gNd/on1wfwNsWjFIax05EVS1vN036G4LCwArCDKUhBz/888Ac5vf/2eNiXmg44wzDTCdoaE6JmsCjJeDxW1qbKUUdW+5ohJVLrm8yE01TMFA2fDT6CFtBXdL2NUsC5B6eReg3jPZLgsw== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:40 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:40 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 08/14] selftests: net: bridge_vlan_aware: test that other TPIDs are seen as untagged Date: Thu, 15 Aug 2024 03:07:01 +0300 Message-Id: <20240815000707.2006121-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 99452f56-0b8c-421b-31e1-08dcbcbe8eac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: dZH8SX+C3GJ0oaQvuIE4dqBVunzayEW8Rem6RI8wKddoqpfIjWIaHt2FuXEsgk8GU1vn40Qy9LsJtoSWIEiKylhknI+YvBWC2tDHRjL4vwm7OT86ZwyAylflDk0rqimIWjWtAVcoUOT0QHDvHfp0hh84LpiyK14qU7/QT11o/kvckJ+8nZXKpIADkruXfrccjQa/E0qFS+C5kDgLKmuwWlZHqU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TOPu4jgbuIXa6sPXcZjF16lpH9nWNGj7EZMMFGNdztY7Uw1h5fGFv1Erxv2W18rYrXtJNbZZ015Pf7SFKoijT2pektm9EtGi4atc0aPfJER7pTzFNOJ8c1PAm4WW5+0Tk/4LCeyw== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: br84RqIQE1xXahFsAxjDJ8b8XwDbouyXeNqFzScgLpSteRpZrlzX4aG2lbv1LMTif1v1M3LSSsUqebJ6KKxE4Nx3hzgeAIFnnh/S6O/Xv9JzZHEIahqpBqPg6hoUKsB3jXeaJ6PwsHg7E9XRg8Rh2Dd4ySOlpDSXnZ4a+9UAuQJRuAdbhBW67YHQ7W+9S2vQE2AFLDTOazJArx8bxBnYXOgmQ9zwc6XvfIaO96DaGy1wCbnV8iK3ot12afOptbvSgDlOdLyZPauNdQaerSjEsAOA/ac3tMfLHD0z5izxYUffDGolDGSCkT920hXGxl9mWW8FMuHcMigluJafZNPyNAFbLcIyDC8FfDfMLMcqcCiklavnN6m6RKGsFlxBzmOe7+JI9k6LoseIslGaiXfYEndhdN+6JYx5muyh7xxX/nCVCi1t7WWCTJv2RPi1mPBYu/74KPxPlxPzLEvLm5MAgAG2gBIBuqRTcJ38Qtzqq4uOGFTWoX22N5ilHnWwaTuMu6I77yxGlfaFYiMhhm6n2Bx4+PGH9izFMqhN70NZMJtAOp23gT5evh65W8KFsmPkOTYMPylcaUXdCQL57ZLIQ9lt6ETzHBgUwmqWJ6tfpSQ2G0vq8DMbfop/jkLdvtuUyerZUpZDky2U87Gy3+PYbm5Y/14sw2Pwv9Qw6pfZt2Z38oomcHSKFvqu7YKVCfFObhJGvVfeT/RaTSirI9S6dYQmORlzZuk9++pwVNdtqM0U9pojM1LM+uXeAGt43CbqHcWU+cncuBULvl3YGfdkigQzlBN/r/eTgYsUH0f7ygs/ZlHnEJvkPBZ9gLll2ahrINuDcN1iaNF8hjWTxzsdz3fZOnUs0JJGR6Ra9tzYcv4MDmQmsvJ+FG2yIjuF8U+O1IvY4+70ikGg9RPQStPDYEbM5DAsa9gwEorVUaHfV/oEogxJ7hxdP/Fe/70H7Q74Ni2BFJV2nvvTrppoaYXsWIw6IlXbx0K0WlceH1cFxX+H4JRWBCMxrVSq106emyAZvm1CVxd7YOgKhL1yvas03hlZVMr9w+YWlnjy+oBNwzQYsnUudjv5gM9vd2h5Yi7WMMC1mjvMlrRmr5YUbVkASItyiFbu92AoW4ku6coQ7+Kj8TTyCDBIGQE7zg7B7v0bq1QRFyVpp4YKBuhSFk68uG1k7xrrtGSr3tEvU8ag9ph5b0+6cZ1WvYUpVn3MxyqO+42eaKQgf87F1R7iwEBTt8PLK+ibru+uBojR/GmS+DwYQ59ALFo4/w0yPzmjwQF0DmkMm2hsqeCLhBe2nDzqz7xe9YanXIQcLW4lvJ661V91QG6F0qpeR7iNlgrvS4APUTI4KPCBbasTuO6aX9nNal5XhmdIR6NDGoPXDFx/XNWnQ9sLXPjJKnlWDYQ4Ukiyy981Ld8PupCQ8NcRVl1YhLWCQ7bnATGj88HEdRqJBWw7PN4NNzAYpzObDRrPm75cYEHt+X1a48di5MHmywHl5TqfJpgBbfbjid7/h4CzdXfR3yMPL1HrT1nxYDxV9aekrDqsuAa2nWDr3MYDN50a1wsfiO4ppQBf0asmpZq82HtX/NdnR8xx5Bz4YecHWxJtYbTTfFoU0tN4lPl7x28R1g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99452f56-0b8c-421b-31e1-08dcbcbe8eac X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:40.4616 (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: 1iwRuSABkLKaDL7UG5KlR4mUJhggQszBG4GbRit59EWtNG7KBHlstQJ5D5YlCLW9Cgx9biUitDSQt/no1RD6sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org The bridge VLAN implementation w.r.t. VLAN protocol is described in merge commit 1a0b20b25732 ("Merge branch 'bridge-next'"). We are only sensitive to those VLAN tags whose TPID is equal to the bridge's vlan_protocol. Thus, an 802.1ad VLAN should be treated as 802.1Q-untagged. Add 3 tests which validate that: - 802.1ad-tagged traffic is learned into the PVID of an 802.1Q-aware bridge - Double-tagged traffic is forwarded when just the PVID of the port is present in the VLAN group of the ports - Double-tagged traffic is not forwarded when the PVID of the port is absent from the VLAN group of the ports The test passes with both veth and ocelot. Signed-off-by: Vladimir Oltean Reviewed-by: Ido Schimmel Tested-by: Ido Schimmel --- .../net/forwarding/bridge_vlan_aware.sh | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh index 64bd00fe9a4f..90f8a244ea90 100755 --- a/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh +++ b/tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn" +ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn other_tpid" NUM_NETIFS=4 CHECK_TC="yes" source lib.sh @@ -142,6 +142,58 @@ extern_learn() bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null } +other_tpid() +{ + local mac=de:ad:be:ef:13:37 + + # Test that packets with TPID 802.1ad VID 3 + TPID 802.1Q VID 5 are + # classified as untagged by a bridge with vlan_protocol 802.1Q, and + # are processed in the PVID of the ingress port (here 1). Not VID 3, + # and not VID 5. + RET=0 + + tc qdisc add dev $h2 clsact + tc filter add dev $h2 ingress protocol all pref 1 handle 101 \ + flower dst_mac $mac action drop + ip link set $h2 promisc on + ethtool -K $h2 rx-vlan-filter off rx-vlan-stag-filter off + + $MZ -q $h1 -c 1 -b $mac -a own "88:a8 00:03 81:00 00:05 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa" + sleep 1 + + # Match on 'self' addresses as well, for those drivers which + # do not push their learned addresses to the bridge software + # database + bridge -j fdb show $swp1 | \ + jq -e ".[] | select(.mac == \"$(mac_get $h1)\") | select(.vlan == 1)" &> /dev/null + check_err $? "FDB entry was not learned when it should" + + log_test "FDB entry in PVID for VLAN-tagged with other TPID" + + RET=0 + tc -j -s filter show dev $h2 ingress \ + | jq -e ".[] | select(.options.handle == 101) \ + | select(.options.actions[0].stats.packets == 1)" &> /dev/null + check_err $? "Packet was not forwarded when it should" + log_test "Reception of VLAN with other TPID as untagged" + + bridge vlan del dev $swp1 vid 1 + + $MZ -q $h1 -c 1 -b $mac -a own "88:a8 00:03 81:00 00:05 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa" + sleep 1 + + RET=0 + tc -j -s filter show dev $h2 ingress \ + | jq -e ".[] | select(.options.handle == 101) \ + | select(.options.actions[0].stats.packets == 1)" &> /dev/null + check_err $? "Packet was forwarded when should not" + log_test "Reception of VLAN with other TPID as untagged (no PVID)" + + bridge vlan add dev $swp1 vid 1 pvid untagged + ip link set $h2 promisc off + tc qdisc del dev $h2 clsact +} + trap cleanup EXIT setup_prepare From patchwork Thu Aug 15 00:07:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764284 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 3F89534545; Thu, 15 Aug 2024 00:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680590; cv=fail; b=Vq65RexCBalzVOkfHjMmU2vLyO6IxxSKTFvK9rcDCxM4MmL8FdIXg8yhq37INGBA5hsyzjSwYgQ5EA64FEHcb3/qWL4layCdg65TbRQQ4ENPfeHTOVQEejLm2sRh/J6fguzS9TEeFWBRL3lW6XUrr0h0Qf1sCqATcmJhvrr/+oo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680590; c=relaxed/simple; bh=sJCKlESlpTWPfCFz3pE7CHgkCPkPcLdrbRFLpI5fl+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YGcs003mv7KPR2JwFrgIlwoY4Rp1dcSvzqMZmE3WN6xUAcFoE48CLLX7PtJn3/UaITt2Etwc8VGipu26RFO6Yc8esvUGgvMDSnuKBwm6Wth4AkYVcJzmKeSvUKcYYfyQ3NxzQ157Hq8WSilj9uz85/WvW693m7HFG2sAB31e6Ec= 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=CLYd0Co0; arc=fail smtp.client-ip=52.101.70.30 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="CLYd0Co0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Oi0k2e1NUdv1Cqg5ztJsypNeSUb91UFPqJr7+tXZ+SD8sCBQYW4KAW6NI6QKfgXyfUCykKERjKavx4YQg6Pv9zVaDyAfMXYXte0Pp5UBUkD9VyWaDdM7un5o4pjce0koQLEdhhidW/Pf9kg+K58aAqUwkAV4/i11Jpv5vWGTklq00NI35DmH85aJ4V0qGkSUo9mZhJ9zXElVqWcVGUQQz1abcF4ZPVVvdto49inPpRUQoBvblZvxWS/bHmRkbf0cSu6LhsAnoKnxWQJfIB9+HJ79HXtyQQWEVrQGg1nT6zoWOgo42iTBHO1UwN8uiSgHaXJQpTBQJ+CS/M34x6ey2w== 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=Zi13mTGYFPkuHRsE67SiIHqIHDStOx4pUBPgtgrBaMY=; b=yB+GlT5+ZzXYkwI3ND505XdfXDtLwl3T+W9QsAXbDiOuAut4naQ5C6IzjY4KC4NGsJwK/q4D9tz9jPfvzzlkGdIl+nX6NEPJIf/PulwxoBN+S/QvtsMo4viJrScQuZKCf6szC1LzQo79XhWMsqmB2DIDR0hHn2q395BNAP9ojMxzPxjB9BFENBQMZ4Of0blLo5FQHW7p9W9e4K5AVQ8FCnXWN5Bo/2csHMg2BBu/ica9J75UUio9OCLYeAzMRuE7Ftjdq9+vXr8yMUFj6JNsU1GTjku6xI4fO9ZiRwR1C27ZTBWV9sM6DGOQbW7QJQwNuLOZkcd79zvUFGiGTAuCZw== 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=Zi13mTGYFPkuHRsE67SiIHqIHDStOx4pUBPgtgrBaMY=; b=CLYd0Co06TnEYnlZ+8mxHWzexDdPgzM0wFQnStcMZ6CAXOZKsRjrVYVenBg484doIN0qp3DZvaaZmEfgiK6u9SXk6PrJ+ikq3J3sHVMrT8e34GHQEzJTuYXrQYfhGw+ruSSlUhOegrjlSYKnUJrTYaaGT3U0PY3MgbjKGS5sbeu3yMEEfjfg3ZXnG9qX4+qT55klzVJKpOtghD7ZqE7s4Pp8ow9CfuDBJQ00e0r3rctxCpC4M8AdQn1xydFjNglccnYG7An+OLaiZk3lPECvc/DPcFuWAkPSs5IjU2oT6RKaToX1s2hMz/VQSpwM6atTd+x0EMKprd1FTP1WXu/QvQ== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:42 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 09/14] net: mscc: ocelot: use ocelot_xmit_get_vlan_info() also for FDMA and register injection Date: Thu, 15 Aug 2024 03:07:02 +0300 Message-Id: <20240815000707.2006121-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 05850c8f-f806-4513-76ea-08dcbcbe8fed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: VKMw36enhFJm3dYSNIyrLC4pGZTt+UVCHqxlPAF+sbiqJ9+3Yth2wdTdgbnuL3edOJAW/BF+QUOcOxgiIY1KeFW2X1RAhizLef4gAVOwCOkgFgsyInYP3Kwx0wAsFd2PFV+UYQBAmp7KyYXq/8TBkfRmYo4rP8Q74K1/n0fMUqkLGcYXi7n2TGtiIzWvImFuXkhj94gKuJY9dPBaJ8Qz6c7uy/8bJ22TBQbHWR1bh2M6LhdtMxnMTwM0LbdA/W0lQv+d+tttwQ4+vl7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45ACbUbxTMEfeGtdPUSkNijn3mSxDjrvwVZBtyq/IFBwiQ6yAlQt4Lk8ojVnOLJ27dcA== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BhIGTJvM2iO2xb0GT5ISw+FPTXcG67RFTAofwtPSK2a4GHtWEPkHchD1eYtFZxCs9tCrmldLk+iXL8PRBFqZLqeRkUkZfH4/FvAsBVEIbYukAIzEdPzOhvOVON4DXcY7yaC4bHaS/ZyBI/qjgI8W/+U0LBjCUVu9YjQlK4zu7foRZ1st3O6QB0SYG9bhaE4z4/5iJwU+SuXo9cCNb07GuaYQ9pQ5kB+ZXWoxTPcaLwWkNLOcGiEceT96khBG72qU9iMZ1zhLHqVL6n0JXZTlzWEBZwrCk3ZfwAt/CGlc57eqk2mvpxkQBXvnw+Yo2H43CqdOzQPTZrhunGK4T6ZM6KxQaZgIT7v5mFWMB7R82f06e2kWgLIrkXIy6TymritoeemHg5zCGi2BvN64UZQU9tQeyAjyUHx6J2+OgExCoUXwdpZqBkJ2oTMo6vaM61yAa7Gf3yO3d2Nr+rfr85Q2AUo8gokttG5Cldo8//G8HysMBc4FOzWigE9wrFq3YjOFDYQAMpkgCMHnYaMxaGCbaly9oOWYX7z9ziG30Xfli5Ye2mHFxK90SDtPMmabWPA7WVFbSstJ1mV/dcgJOUE7kEHqnMM9VKpG1Dip5SQdtXMzaqSv0Lr6S5raw3o1/5E6ExF1zHpKugN1QWE4D5gWQ/pZJ7qGRXxQ/vKWmTrfqNbpJ1ExU11X8ZxG3oulu0k+6Bwa07a+fWyRA6H0Tn2mjESqaOdn4vKwPAjN0K5a4eeslVp6dwWQoM/Usxicf9TR5VD07pklSBb6S9IlveI5DVp7jqHayTuIQb7H0T4xjK+wJQw5+LT7I+MU+W8BCVM9qW9262LloxMteLledv7fSVvC9Hj1m21PFRZhGUrnoI1taMCjCVMlEcI7mZGM/wVYVwDKv3kS/wrtG7F+6tGdTQYRwRupte6+LjxOatkyKt1QrlMMq6z5WpJZj733MEnJ9DB3JWZPhWIANcrxSF1zOC6qKbWFOzrYKkKN2Zh74iH3lhpi3HLfBI+TfaPd93ci3bHwETYvS4ZUniwnYIpkgDNV93p9V8SS/cqcjXgP7FYhcT8c0+fre0wk7rDrI0sLJu04Qq5y3JIx/XHszUVpGhv85h/KzrSnpu86w06ymVSOSn0jF0ZsmUrviJnlfDoYse2Dn7dU9MK/KR7pjB5twEnBVHcfAO/ZAlxQlNMM2v3OSIuPMWqciHuUwQTkIjYMiALoVoUUtPSi5ikmxlfzmEHj1VheBDgX60BvZk7k4uwMIAmO6Loro+hRUeeRdD3iJnObsDGttwRR1pcGu9nvlsofnHSbBFBu0gQdaC52CDBWZFMyd/vp2a9Q62Q60cisgSB5QwhFdT8bPsY1qmXoeDUvoyvdkc/zkDv/7ODa6gnzticOYpZsBRSV7Uf9+9O++N8YlVegLR9Jo3ZNyBo+gn7m1LulIg852BGdktILjrh+0EMEj6lgrANZn1eoCaqhfzmQF6RgafzzcZJca5425EL/jw+AXScRMaX0aPkG+v7L6bJn5XDMz4PT+WLmUHZXpYHIjD/ZO1JCDFbMjBBfg4x0l2SgUZFb755jXpa6pwiZUgl1LvP7zNY/hfFjAMtQECaHh49FxOkMY7ROe0sOLA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05850c8f-f806-4513-76ea-08dcbcbe8fed X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:42.5590 (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: jdcgLLX4hx6D6TkAc8Sgw/kZl57x4neRqW6r+6EYmhlRIrHFihaAJQS8mY78dBZw83DJ9Fo9EbZBQSkomSoJww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org Problem description ------------------- On an NXP LS1028A (felix DSA driver) with the following configuration: - ocelot-8021q tagging protocol - VLAN-aware bridge (with STP) spanning at least swp0 and swp1 - 8021q VLAN upper interfaces on swp0 and swp1: swp0.700, swp1.700 - ptp4l on swp0.700 and swp1.700 we see that the ptp4l instances do not see each other's traffic, and they all go to the grand master state due to the ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES condition. Jumping to the conclusion for the impatient ------------------------------------------- There is a zero-day bug in the ocelot switchdev driver in the way it handles VLAN-tagged packet injection. The correct logic already exists in the source code, in function ocelot_xmit_get_vlan_info() added by commit 5ca721c54d86 ("net: dsa: tag_ocelot: set the classified VLAN during xmit"). But it is used only for normal NPI-based injection with the DSA "ocelot" tagging protocol. The other injection code paths (register-based and FDMA-based) roll their own wrong logic. This affects and was noticed on the DSA "ocelot-8021q" protocol because it uses register-based injection. By moving ocelot_xmit_get_vlan_info() to a place that's common for both the DSA tagger and the ocelot switch library, it can also be called from ocelot_port_inject_frame() in ocelot.c. We need to touch the lines with ocelot_ifh_port_set()'s prototype anyway, so let's rename it to something clearer regarding what it does, and add a kernel-doc. ocelot_ifh_set_basic() should do. Investigation notes ------------------- Debugging reveals that PTP event (aka those carrying timestamps, like Sync) frames injected into swp0.700 (but also swp1.700) hit the wire with two VLAN tags: 00000000: 01 1b 19 00 00 00 00 01 02 03 04 05 81 00 02 bc ~~~~~~~~~~~ 00000010: 81 00 02 bc 88 f7 00 12 00 2c 00 00 02 00 00 00 ~~~~~~~~~~~ 00000020: 00 00 00 00 00 00 00 00 00 00 00 01 02 ff fe 03 00000030: 04 05 00 01 00 04 00 00 00 00 00 00 00 00 00 00 00000040: 00 00 The second (unexpected) VLAN tag makes felix_check_xtr_pkt() -> ptp_classify_raw() fail to see these as PTP packets at the link partner's receiving end, and return PTP_CLASS_NONE (because the BPF classifier is not written to expect 2 VLAN tags). The reason why packets have 2 VLAN tags is because the transmission code treats VLAN incorrectly. Neither ocelot switchdev, nor felix DSA, declare the NETIF_F_HW_VLAN_CTAG_TX feature. Therefore, at xmit time, all VLANs should be in the skb head, and none should be in the hwaccel area. This is done by: static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb, netdev_features_t features) { if (skb_vlan_tag_present(skb) && !vlan_hw_offload_capable(features, skb->vlan_proto)) skb = __vlan_hwaccel_push_inside(skb); return skb; } But ocelot_port_inject_frame() handles things incorrectly: ocelot_ifh_port_set(ifh, port, rew_op, skb_vlan_tag_get(skb)); void ocelot_ifh_port_set(struct sk_buff *skb, void *ifh, int port, u32 rew_op) { (...) if (vlan_tag) ocelot_ifh_set_vlan_tci(ifh, vlan_tag); (...) } The way __vlan_hwaccel_push_inside() pushes the tag inside the skb head is by calling: static inline void __vlan_hwaccel_clear_tag(struct sk_buff *skb) { skb->vlan_present = 0; } which does _not_ zero out skb->vlan_tci as seen by skb_vlan_tag_get(). This means that ocelot, when it calls skb_vlan_tag_get(), sees (and uses) a residual skb->vlan_tci, while the same VLAN tag is _already_ in the skb head. The trivial fix for double VLAN headers is to replace the content of ocelot_ifh_port_set() with: if (skb_vlan_tag_present(skb)) ocelot_ifh_set_vlan_tci(ifh, skb_vlan_tag_get(skb)); but this would not be correct either, because, as mentioned, vlan_hw_offload_capable() is false for us, so we'd be inserting dead code and we'd always transmit packets with VID=0 in the injection frame header. I can't actually test the ocelot switchdev driver and rely exclusively on code inspection, but I don't think traffic from 8021q uppers has ever been injected properly, and not double-tagged. Thus I'm blaming the introduction of VLAN fields in the injection header - early driver code. As hinted at in the early conclusion, what we _want_ to happen for VLAN transmission was already described once in commit 5ca721c54d86 ("net: dsa: tag_ocelot: set the classified VLAN during xmit"). ocelot_xmit_get_vlan_info() intends to ensure that if the port through which we're transmitting is under a VLAN-aware bridge, the outer VLAN tag from the skb head is stripped from there and inserted into the injection frame header (so that the packet is processed in hardware through that actual VLAN). And in all other cases, the packet is sent with VID=0 in the injection frame header, since the port is VLAN-unaware and has logic to strip this VID on egress (making it invisible to the wire). Fixes: 08d02364b12f ("net: mscc: fix the injection header") Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 29 +++++++++++---- drivers/net/ethernet/mscc/ocelot_fdma.c | 2 +- include/linux/dsa/ocelot.h | 47 +++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 3 +- net/dsa/tag_ocelot.c | 37 ++----------------- 5 files changed, 75 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ed2fb44500b0..69a4e5a90475 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1193,17 +1193,34 @@ bool ocelot_can_inject(struct ocelot *ocelot, int grp) } EXPORT_SYMBOL(ocelot_can_inject); -void ocelot_ifh_port_set(void *ifh, int port, u32 rew_op, u32 vlan_tag) +/** + * ocelot_ifh_set_basic - Set basic information in Injection Frame Header + * @ifh: Pointer to Injection Frame Header memory + * @ocelot: Switch private data structure + * @port: Egress port number + * @rew_op: Egress rewriter operation for PTP + * @skb: Pointer to socket buffer (packet) + * + * Populate the Injection Frame Header with basic information for this skb: the + * analyzer bypass bit, destination port, VLAN info, egress rewriter info. + */ +void ocelot_ifh_set_basic(void *ifh, struct ocelot *ocelot, int port, + u32 rew_op, struct sk_buff *skb) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + u64 vlan_tci, tag_type; + + ocelot_xmit_get_vlan_info(skb, ocelot_port->bridge, &vlan_tci, + &tag_type); + ocelot_ifh_set_bypass(ifh, 1); ocelot_ifh_set_dest(ifh, BIT_ULL(port)); - ocelot_ifh_set_tag_type(ifh, IFH_TAG_TYPE_C); - if (vlan_tag) - ocelot_ifh_set_vlan_tci(ifh, vlan_tag); + ocelot_ifh_set_tag_type(ifh, tag_type); + ocelot_ifh_set_vlan_tci(ifh, vlan_tci); if (rew_op) ocelot_ifh_set_rew_op(ifh, rew_op); } -EXPORT_SYMBOL(ocelot_ifh_port_set); +EXPORT_SYMBOL(ocelot_ifh_set_basic); void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, u32 rew_op, struct sk_buff *skb) @@ -1214,7 +1231,7 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) | QS_INJ_CTRL_SOF, QS_INJ_CTRL, grp); - ocelot_ifh_port_set(ifh, port, rew_op, skb_vlan_tag_get(skb)); + ocelot_ifh_set_basic(ifh, ocelot, port, rew_op, skb); for (i = 0; i < OCELOT_TAG_LEN / 4; i++) ocelot_write_rix(ocelot, ifh[i], QS_INJ_WR, grp); diff --git a/drivers/net/ethernet/mscc/ocelot_fdma.c b/drivers/net/ethernet/mscc/ocelot_fdma.c index 312a46832154..87b59cc5e441 100644 --- a/drivers/net/ethernet/mscc/ocelot_fdma.c +++ b/drivers/net/ethernet/mscc/ocelot_fdma.c @@ -666,7 +666,7 @@ static int ocelot_fdma_prepare_skb(struct ocelot *ocelot, int port, u32 rew_op, ifh = skb_push(skb, OCELOT_TAG_LEN); skb_put(skb, ETH_FCS_LEN); memset(ifh, 0, OCELOT_TAG_LEN); - ocelot_ifh_port_set(ifh, port, rew_op, skb_vlan_tag_get(skb)); + ocelot_ifh_set_basic(ifh, ocelot, port, rew_op, skb); return 0; } diff --git a/include/linux/dsa/ocelot.h b/include/linux/dsa/ocelot.h index dca2969015d8..6fbfbde68a37 100644 --- a/include/linux/dsa/ocelot.h +++ b/include/linux/dsa/ocelot.h @@ -5,6 +5,8 @@ #ifndef _NET_DSA_TAG_OCELOT_H #define _NET_DSA_TAG_OCELOT_H +#include +#include #include #include #include @@ -273,4 +275,49 @@ static inline u32 ocelot_ptp_rew_op(struct sk_buff *skb) return rew_op; } +/** + * ocelot_xmit_get_vlan_info: Determine VLAN_TCI and TAG_TYPE for injected frame + * @skb: Pointer to socket buffer + * @br: Pointer to bridge device that the port is under, if any + * @vlan_tci: + * @tag_type: + * + * If the port is under a VLAN-aware bridge, remove the VLAN header from the + * payload and move it into the DSA tag, which will make the switch classify + * the packet to the bridge VLAN. Otherwise, leave the classified VLAN at zero, + * which is the pvid of standalone ports (OCELOT_STANDALONE_PVID), although not + * of VLAN-unaware bridge ports (that would be ocelot_vlan_unaware_pvid()). + * Anyway, VID 0 is fine because it is stripped on egress for these port modes, + * and source address learning is not performed for packets injected from the + * CPU anyway, so it doesn't matter that the VID is "wrong". + */ +static inline void ocelot_xmit_get_vlan_info(struct sk_buff *skb, + struct net_device *br, + u64 *vlan_tci, u64 *tag_type) +{ + struct vlan_ethhdr *hdr; + u16 proto, tci; + + if (!br || !br_vlan_enabled(br)) { + *vlan_tci = 0; + *tag_type = IFH_TAG_TYPE_C; + return; + } + + hdr = (struct vlan_ethhdr *)skb_mac_header(skb); + br_vlan_get_proto(br, &proto); + + if (ntohs(hdr->h_vlan_proto) == proto) { + vlan_remove_tag(skb, &tci); + *vlan_tci = tci; + } else { + rcu_read_lock(); + br_vlan_get_pvid_rcu(br, &tci); + rcu_read_unlock(); + *vlan_tci = tci; + } + + *tag_type = (proto != ETH_P_8021Q) ? IFH_TAG_TYPE_S : IFH_TAG_TYPE_C; +} + #endif diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 6a37b29f4b4c..ed18e6bafc8d 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -969,7 +969,8 @@ void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target, bool ocelot_can_inject(struct ocelot *ocelot, int grp); void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, u32 rew_op, struct sk_buff *skb); -void ocelot_ifh_port_set(void *ifh, int port, u32 rew_op, u32 vlan_tag); +void ocelot_ifh_set_basic(void *ifh, struct ocelot *ocelot, int port, + u32 rew_op, struct sk_buff *skb); int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb); void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp); void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb, diff --git a/net/dsa/tag_ocelot.c b/net/dsa/tag_ocelot.c index e0e4300bfbd3..bf6608fc6be7 100644 --- a/net/dsa/tag_ocelot.c +++ b/net/dsa/tag_ocelot.c @@ -8,40 +8,6 @@ #define OCELOT_NAME "ocelot" #define SEVILLE_NAME "seville" -/* If the port is under a VLAN-aware bridge, remove the VLAN header from the - * payload and move it into the DSA tag, which will make the switch classify - * the packet to the bridge VLAN. Otherwise, leave the classified VLAN at zero, - * which is the pvid of standalone and VLAN-unaware bridge ports. - */ -static void ocelot_xmit_get_vlan_info(struct sk_buff *skb, struct dsa_port *dp, - u64 *vlan_tci, u64 *tag_type) -{ - struct net_device *br = dsa_port_bridge_dev_get(dp); - struct vlan_ethhdr *hdr; - u16 proto, tci; - - if (!br || !br_vlan_enabled(br)) { - *vlan_tci = 0; - *tag_type = IFH_TAG_TYPE_C; - return; - } - - hdr = skb_vlan_eth_hdr(skb); - br_vlan_get_proto(br, &proto); - - if (ntohs(hdr->h_vlan_proto) == proto) { - vlan_remove_tag(skb, &tci); - *vlan_tci = tci; - } else { - rcu_read_lock(); - br_vlan_get_pvid_rcu(br, &tci); - rcu_read_unlock(); - *vlan_tci = tci; - } - - *tag_type = (proto != ETH_P_8021Q) ? IFH_TAG_TYPE_S : IFH_TAG_TYPE_C; -} - static void ocelot_xmit_common(struct sk_buff *skb, struct net_device *netdev, __be32 ifh_prefix, void **ifh) { @@ -53,7 +19,8 @@ static void ocelot_xmit_common(struct sk_buff *skb, struct net_device *netdev, u32 rew_op = 0; u64 qos_class; - ocelot_xmit_get_vlan_info(skb, dp, &vlan_tci, &tag_type); + ocelot_xmit_get_vlan_info(skb, dsa_port_bridge_dev_get(dp), &vlan_tci, + &tag_type); qos_class = netdev_get_num_tc(netdev) ? netdev_get_prio_tc_map(netdev, skb->priority) : skb->priority; From patchwork Thu Aug 15 00:07:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764285 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 C11B739FF3; Thu, 15 Aug 2024 00:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680592; cv=fail; b=eTk4dQzVERctKZLCENhDAcpYyflDnxfB7X+eKfBImbtqr+nZ54gI2f4MQlM4KZEkw3HRyQ2uVYaxUDSgyzke5P6BEhhe7GpROWUrdRS+klV5xTZgKrdyUBxYWmr6M2W3EQlFuhpjw4vC28dB1vSZW/m9RKw3o1f6QBVD9d3hD8U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680592; c=relaxed/simple; bh=YuJ7NQyQWm76vxmErrRlK7JMZexUZ7hjgATCEw9l11M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P95nqEuFC3RE4BXlajWhlspdcTidLxL9aK6+oUXgxGpGRT79+EcllRVHtb2bNQ1TBpca3DRwEmfuxPIKbfmxgfQPphT07DC4QFL1KcGKXrLpJiPvzaDa/HFqqFn/CBAWzrLIM9yx1qbvMA8Kz11XwdYESHK4Yv51R8iiFsoQ3QA= 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=SWeZ0t6o; arc=fail smtp.client-ip=52.101.70.30 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="SWeZ0t6o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CqkmD7nzl+2ADeDxpUNioV618bVxtrDRxQTuFrnt9B48yViUT2eUwZqwRl7e0rsPM4R0cNHRAuCLuF5v6YDenUDmRZJYFl4IW323L9I3zhaDfF6zCuE0QcUQXqbjRVRxs2uxZN9Kq42M3nhvovo6RQJvuwxlUDQigJU1SNmtiIQW96Vui8tZhZenbyhGixRP/gOsqqfz8YS7q4WTbCmKGWA1xT/ji/umjKf0slHD6kK4JfMgj7QIBhJfxXwzXgFeaXXsu/Z+wuQt0RmFDPKNUivL3wfrp1wqKBbuWFesoRlOpY/9fdqKDJxM3hueeLLgUNdh4VN70OLYP5yD3LBYlw== 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=uRvdSMSbREMt7oTN8amvkVPhsMYDAV6b4DEsItJsj/8=; b=Dtcapo/RnK4xqYIVp0SZBdGRqAYbwrmHsNGq9JiArBxNRrH/fUouAjvk7o5JrDFn/J5SqOVsMLlwZwYcuPlmKzIZENFAFE4tdZ7cvZQePR2YxAFGE8Y+/L9a82RPMl8Ozms1k4r7ocBlRH7AVJQAvNp72Bt+UGXwiO2GGvDXxpXzZdgorhV8fmpwH3IXChz0G14fzabP+06DsN6vG3bCfU5ovSeEIfpRbq+p7AFTlHYqK6yVviGi/Nc+dmbYqLjgT6hzDFRWPB2CUmXjKcOWgAqYSxLBEACnBor/9jLYh3qvZ/aEC00Dn3ifsIZ8mu8hP7YsadQ98GE+P1KUOCWWIA== 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=uRvdSMSbREMt7oTN8amvkVPhsMYDAV6b4DEsItJsj/8=; b=SWeZ0t6ow6ssUy19wYW4EaSJnFxRcjJrvLZ2IyZeKFW0K9wrbAS4rdoNm8v2mEKQlyfL3tcikflyoGuB/qPWbq6pn+Vs3i+I9Yjhc+8+YYat1hzJlSv2IH/nGUme69LveS+airNm96mmvP46XtUhHEC152wIgnSjuLQZdf0oppZQImc4pcvo28x+GIAKnUyHbC45TE8Itp7RgAbF9ZU7eA4YH/1BaIZwSQOPFIosUkDWTNUH4TR+1S1bL9CwH8dG/5dLAJkSqh5Ob6YeZhzIziorxefVXXpd5+nrMdonclFaJ4TL2ZgBMzeYcJ3D94nDF/TH3vtrsrvz3HPsNSJBkw== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:46 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:46 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 10/14] net: mscc: ocelot: fix QoS class for injected packets with "ocelot-8021q" Date: Thu, 15 Aug 2024 03:07:03 +0300 Message-Id: <20240815000707.2006121-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: f4de2165-b29b-441f-4ca6-08dcbcbe912c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: uQ3jjszLf9ybbnt4rCmf6qt1+D/LLTZugr2H3wi2tQOa/1Jt6e/v91kyi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LK1ferkeb2h1myYxwToHJRX9dr5WwBNrJxbLzklLTjRT6P1EcRLHEE5O7rU9F6TAnYnnsyQK0PbEZO9iUY7uCqjike3B1fpPCw0Jf8laLV3vwy9lDt0LvqQW/a9RdZEj8x6qQD4DabcUn/9fmH9dvlEyvC5BazrI20v+IMYBUW15uc8/+iLngL0jEAuFb/wgDBze+MdwRiY1QCHQe/WgcaAo2yZxhbi/MrumX8fofWC4jjoBiXO1W8If4QHI0Ix1fQE08L1YLlrD3n8bq/TcaWDremLeqRK7f1aEsR0wYReKwVGg== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yeYTKkoUA5vIWAm2ki/S/A40lsrE+hQtRBFg5xTeT5B8FTfUxQlEybsINUjDPEqiy8OQgDg7KRqJ+aH4FY+8HiiqYGrCxnRZ/hsekqNL0RnE/Via0l+WYjYGtvGAUlsoOKkHiifTEBt6/Z7tjepYKHuUgwduiCoI4dDKPEQTOFxNKNgeB7D+Z8dgNPd9/ddq3UAifIjYFTJJDfnIuzubJIkDZMLTubCCWY8dtGUtdVw8My9ikDULUy2cg/RuMtVXIC7Wc+oglK4g+x89jKX+F3ZM19Vmg3qZJAP2lPFOKkMAuq8A2UoYd2DiFktns10AUqtSW41n8ShBRt0M6nQZetDeHnNC49alhK0gU/rubs6uBVRmarr1vzFmlIQJoUhNPfCFrxn8RfGkJWcAtSnFk88J8REDHdZbMtDAh3lwxAWhqhTojSq6vo2Sb/jUjNkbIWz1ik5FxgvRV5kimekvSVAsiNxZhRkL5YUZMxRk4Z2Krh3U/kVr5CLMBoxeWHVuRsoCgaQ8dgOSERIgTOztFNfmSe1WJ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riginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4de2165-b29b-441f-4ca6-08dcbcbe912c X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:46.2033 (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: 9/Uo8s9H08tY4IlcHpsgbq93RmLPIoQxgTiGPV6MBqtsgdzUjTME9djeTKCQYWdI565JNmdSeXfXqbB71Rgi/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org There are 2 distinct code paths (listed below) in the source code which set up an injection header for Ocelot(-like) switches. Code path (2) lacks the QoS class and source port being set correctly. Especially the improper QoS classification is a problem for the "ocelot-8021q" alternative DSA tagging protocol, because we support tc-taprio and each packet needs to be scheduled precisely through its time slot. This includes PTP, which is normally assigned to a traffic class other than 0, but would be sent through TC 0 nonetheless. The code paths are: (1) ocelot_xmit_common() from net/dsa/tag_ocelot.c - called only by the standard "ocelot" DSA tagging protocol which uses NPI-based injection - sets up bit fields in the tag manually to account for a small difference (destination port offset) between Ocelot and Seville. Namely, ocelot_ifh_set_dest() is omitted out of ocelot_xmit_common(), because there's also seville_ifh_set_dest(). (2) ocelot_ifh_set_basic(), called by: - ocelot_fdma_prepare_skb() for FDMA transmission of the ocelot switchdev driver - ocelot_port_xmit() -> ocelot_port_inject_frame() for register-based transmission of the ocelot switchdev driver - felix_port_deferred_xmit() -> ocelot_port_inject_frame() for the DSA tagger ocelot-8021q when it must transmit PTP frames (also through register-based injection). sets the bit fields according to its own logic. The problem is that (2) doesn't call ocelot_ifh_set_qos_class(). Copying that logic from ocelot_xmit_common() fixes that. Unfortunately, although desirable, it is not easily possible to de-duplicate code paths (1) and (2), and make net/dsa/tag_ocelot.c directly call ocelot_ifh_set_basic()), because of the ocelot/seville difference. This is the "minimal" fix with some logic duplicated (but at least more consolidated). Fixes: 0a6f17c6ae21 ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping") Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 10 +++++++++- drivers/net/ethernet/mscc/ocelot_fdma.c | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 69a4e5a90475..9301716e21d5 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1208,13 +1208,21 @@ void ocelot_ifh_set_basic(void *ifh, struct ocelot *ocelot, int port, u32 rew_op, struct sk_buff *skb) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct net_device *dev = skb->dev; u64 vlan_tci, tag_type; + int qos_class; ocelot_xmit_get_vlan_info(skb, ocelot_port->bridge, &vlan_tci, &tag_type); + qos_class = netdev_get_num_tc(dev) ? + netdev_get_prio_tc_map(dev, skb->priority) : skb->priority; + + memset(ifh, 0, OCELOT_TAG_LEN); ocelot_ifh_set_bypass(ifh, 1); + ocelot_ifh_set_src(ifh, BIT_ULL(ocelot->num_phys_ports)); ocelot_ifh_set_dest(ifh, BIT_ULL(port)); + ocelot_ifh_set_qos_class(ifh, qos_class); ocelot_ifh_set_tag_type(ifh, tag_type); ocelot_ifh_set_vlan_tci(ifh, vlan_tci); if (rew_op) @@ -1225,7 +1233,7 @@ EXPORT_SYMBOL(ocelot_ifh_set_basic); void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, u32 rew_op, struct sk_buff *skb) { - u32 ifh[OCELOT_TAG_LEN / 4] = {0}; + u32 ifh[OCELOT_TAG_LEN / 4]; unsigned int i, count, last; ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) | diff --git a/drivers/net/ethernet/mscc/ocelot_fdma.c b/drivers/net/ethernet/mscc/ocelot_fdma.c index 87b59cc5e441..00326ae8c708 100644 --- a/drivers/net/ethernet/mscc/ocelot_fdma.c +++ b/drivers/net/ethernet/mscc/ocelot_fdma.c @@ -665,7 +665,6 @@ static int ocelot_fdma_prepare_skb(struct ocelot *ocelot, int port, u32 rew_op, ifh = skb_push(skb, OCELOT_TAG_LEN); skb_put(skb, ETH_FCS_LEN); - memset(ifh, 0, OCELOT_TAG_LEN); ocelot_ifh_set_basic(ifh, ocelot, port, rew_op, skb); return 0; From patchwork Thu Aug 15 00:07:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764286 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 1E64C320E; Thu, 15 Aug 2024 00:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680595; cv=fail; b=i+BtOtV3WQGwHExqOP0NJQg7AifKVhR+/ijaFvIGj70J+IvQXddGNQBsYY5JsL/abbL7TvPRG6TNekZliV4xUNtQubYYNV6vRRK7kU2paNSk6u7Cz8i5UV7DRDXOQMtC9O3B9VuckZIH2FZqK4898GupVx+3GxPjcuI/lR/dVnM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680595; c=relaxed/simple; bh=ewTTNPXhP4CLWiFHYHaRPM30X/YLC16EVHzDGVYAAsI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=e3xc49qzlZvRUKYgEwKgwvIjuAEOtqBWpJakBy/+HU7B2KlWFQGdXyp03CnfOqNByPqbh2UyWfolHKleViQb0WIpTvP3NArK8WRKoqMaPi90CVJX8lEsgOu0+K16GxDOgOoSTaG85R4ATyh+M60rRZtpayi7JNHvjOnrR888IcI= 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=cQOTC5CC; arc=fail smtp.client-ip=52.101.70.30 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="cQOTC5CC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JWUv8sumFq8ykULEHHos75QLOYGFJ0Di0YXyLSxcBNngjXsYZje8qi8Ie6utXQfS6S50IgZgzGnhAmlgDqXB5Pbut3AVCMrKMAzWLx80qPS6YlR6BU7KfnL3h1G3uaF308itvz7NZORmqJw8wHGajMHzhL/U7Uv2Vmw2aMHTfVf0FUGyOFTPh3xYmntBNWfvlVyUB37RgW5fux1I/ZA0XutI83OofeAbvBuE84pfUq2/S5MfIrAPgvTg+SBWPS1aXasjy66vp16XsebyTWYmZhTg1wHaejmDygpvvJCEd3m1xIwB43VncR3/MOT/adDI8qLcDt2mIdqY5farIZIPRA== 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=IK93u+FqJVMNrJ0tPhYKi5rVGTAXodfmHm59ntPUjhk=; b=ZkljvCTjn/Sk1w6LrQpWwaDuI+FMOPpaplZKVjm2132fFsuG9OHuW6UTJ/GRMSbBUOf5jY5IoVdBeftjL1+hDl+fJeeDslFvDTVsmnjz0WLUofQ0DNDSq9Pmb+cJ6zcrg7YML4qfCk9/QguPOnptWB1p2h0KoRsH5RFhLJ+uuuijK6PBbmJkSgRwS1Ip00NEHjm7D7cqmnRBPLcHvj8fEW7hUaKcGy40eJwGt/jhclHbhJFj2N4fOlh1zOSvse4rifJLWJMgTrSKlCsDk40myJk37b6jtn2cga+iCFAmsmnRv2BE2tSWwNAZSFFdkr9St60a+q2SXIvlcw+o3BSfkQ== 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=IK93u+FqJVMNrJ0tPhYKi5rVGTAXodfmHm59ntPUjhk=; b=cQOTC5CC5pQ13FZBGwiXfLcuGFMzp0B/+/fyaPkQ3XBn+ryaLad0liywYBHHBtzhe4L+vlB2pBamixfvw8+IB4yLxjhDWK2lwNM96jZRtlZGDyP3XavyN2DzLgyERx7+9fPsJJc0Jk3rhEV7pDVZGL4DZH93chPhH5+2ew5bGTnxtOdo7VrsEU+LcGjACOIZlI70g5AG9XN3Uat6LjHKxS6CMApcARQRGaodTH5Fb6KstPT58iEtS/bNmunib715c3t6O+NPgK+suTVWvJ+LIu4Aq8AkynEZR0k+aMWTe4oUht37JLwwIR04Czhi3C3q4E15b28rtD2gwZ8MtyADSQ== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:48 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:48 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 11/14] net: mscc: ocelot: serialize access to the injection/extraction groups Date: Thu, 15 Aug 2024 03:07:04 +0300 Message-Id: <20240815000707.2006121-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bf4ae45-641e-43c8-a811-08dcbcbe935b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230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5arRJS5MN1/lYrf5izLCpYhLyAA06/xDS9h7H673gHTrEGQqj16Qw700towqSoWtx053NRf0w3XPCBUN+RrTeRDYNJws0dDRjEGZ/tkbP5YwQeGjEEaoaAlpxDsHJ8Z7WgaKwFEyKC0Yzat/cL59TC3Zn4+wdOFkyJmuUX1daYdAEAiceb5Yk3ErgDmAzoB65YRPIUSPjRuFyFCITUFnjVHhgFxZe2D3Q3UnbcLCeNlTe5OjrAGqnAKmwTFa7w9wMPzXzPQ3eGIScCiyIW4xmBBSd66VsVTOCYrvh8clpP5GZHAlzP5oy3B1RhiGo51KsXbm/YPSWu7q1DpAhWoMCVv8KVHfD/ABxKaGepCi3B2RQNnfWWGaQxTsUm59B+eK5Jf7wNU/BrQT/ZYNBOlCa/710EpTg== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wHeIikE2DR/aBCyo5SOwIF8AgUIWw6VqNqmkV+bGUXNE/p5MaqdjpBnuM4K5hfryNM0pnaDGKazzSuIGsHSXPvcspnDBTDSDlVeiY+jQrwvMEXgGwuHP7tLrYrmpAC356PQRMU4rKsxkzdHQDw9zilgX8fD4kPNrVoJ6Erv9k45eU1xel5LHVs+P9FzX5dMPNrNFA6fdNJlHPxPKdMt4boYKkWzuRyA8Y6WCoSrG5HZBF+5yKhsWeqZWOIdh0eAyriyfOrizFa/agw3ddC6oHo9TWPsMevrCYkrVwA5zqqX4cOB61eTOpLKlq/GN73cjvugZodsSzi5FLEICsZRVI+UMqe8RCFDy2o84oKLiH5lOj+3fWPFnHwsgiukfj+hsEqq/LlT1WzJGEZEtDWfEMo8j2tCKCeo0QWvyG+73xBV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A7mXe1Yq/Ks2w6QXv8OMGhTd4ZL2lM+eNqGvaVR447Sfm58aIJzJ5uIHZHShty0zQdYbDSq8g32CXbRutRsFELntQqYFBFBb7reklEEBa6O+nC5TmOFow== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf4ae45-641e-43c8-a811-08dcbcbe935b X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:48.3432 (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: Hyz377l1QhJwG/DImikFEugFugPZMPCnQ5s4bo17hErAmlEfhnhvGMgknfj9IYI3mCNicArX3seoVesBUkQHyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org As explained by Horatiu Vultur in commit 603ead96582d ("net: sparx5: Add spinlock for frame transmission from CPU") which is for a similar hardware design, multiple CPUs can simultaneously perform injection or extraction. There are only 2 register groups for injection and 2 for extraction, and the driver only uses one of each. So we'd better serialize access using spin locks, otherwise frame corruption is possible. Note that unlike in sparx5, FDMA in ocelot does not have this issue because struct ocelot_fdma_tx_ring already contains an xmit_lock. I guess this is mostly a problem for NXP LS1028A, as that is dual core. I don't think VSC7514 is. So I'm blaming the commit where LS1028A (aka the felix DSA driver) started using register-based packet injection and extraction. Fixes: 0a6f17c6ae21 ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 11 +++++ drivers/net/ethernet/mscc/ocelot.c | 52 ++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 4 ++ include/soc/mscc/ocelot.h | 9 ++++ 4 files changed, 76 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index e554699f06d4..8d31ff18c5c7 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -528,7 +528,9 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) * so we need to be careful that there are no extra frames to be * dequeued over MMIO, since we would never know to discard them. */ + ocelot_lock_xtr_grp_bh(ocelot, 0); ocelot_drain_cpu_queue(ocelot, 0); + ocelot_unlock_xtr_grp_bh(ocelot, 0); return 0; } @@ -1518,6 +1520,8 @@ static void felix_port_deferred_xmit(struct kthread_work *work) int port = xmit_work->dp->index; int retries = 10; + ocelot_lock_inj_grp(ocelot, 0); + do { if (ocelot_can_inject(ocelot, 0)) break; @@ -1526,6 +1530,7 @@ static void felix_port_deferred_xmit(struct kthread_work *work) } while (--retries); if (!retries) { + ocelot_unlock_inj_grp(ocelot, 0); dev_err(ocelot->dev, "port %d failed to inject skb\n", port); ocelot_port_purge_txtstamp_skb(ocelot, port, skb); @@ -1535,6 +1540,8 @@ static void felix_port_deferred_xmit(struct kthread_work *work) ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb); + ocelot_unlock_inj_grp(ocelot, 0); + consume_skb(skb); kfree(xmit_work); } @@ -1694,6 +1701,8 @@ static bool felix_check_xtr_pkt(struct ocelot *ocelot) if (!felix->info->quirk_no_xtr_irq) return false; + ocelot_lock_xtr_grp(ocelot, grp); + while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) { struct sk_buff *skb; unsigned int type; @@ -1730,6 +1739,8 @@ static bool felix_check_xtr_pkt(struct ocelot *ocelot) ocelot_drain_cpu_queue(ocelot, 0); } + ocelot_unlock_xtr_grp(ocelot, grp); + return true; } diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 9301716e21d5..f4e027a6fe95 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1099,6 +1099,48 @@ void ocelot_ptp_rx_timestamp(struct ocelot *ocelot, struct sk_buff *skb, } EXPORT_SYMBOL(ocelot_ptp_rx_timestamp); +void ocelot_lock_inj_grp(struct ocelot *ocelot, int grp) + __acquires(&ocelot->inj_lock) +{ + spin_lock(&ocelot->inj_lock); +} +EXPORT_SYMBOL_GPL(ocelot_lock_inj_grp); + +void ocelot_unlock_inj_grp(struct ocelot *ocelot, int grp) + __releases(&ocelot->inj_lock) +{ + spin_unlock(&ocelot->inj_lock); +} +EXPORT_SYMBOL_GPL(ocelot_unlock_inj_grp); + +void ocelot_lock_xtr_grp(struct ocelot *ocelot, int grp) + __acquires(&ocelot->inj_lock) +{ + spin_lock(&ocelot->inj_lock); +} +EXPORT_SYMBOL_GPL(ocelot_lock_xtr_grp); + +void ocelot_unlock_xtr_grp(struct ocelot *ocelot, int grp) + __releases(&ocelot->inj_lock) +{ + spin_unlock(&ocelot->inj_lock); +} +EXPORT_SYMBOL_GPL(ocelot_unlock_xtr_grp); + +void ocelot_lock_xtr_grp_bh(struct ocelot *ocelot, int grp) + __acquires(&ocelot->xtr_lock) +{ + spin_lock_bh(&ocelot->xtr_lock); +} +EXPORT_SYMBOL_GPL(ocelot_lock_xtr_grp_bh); + +void ocelot_unlock_xtr_grp_bh(struct ocelot *ocelot, int grp) + __releases(&ocelot->xtr_lock) +{ + spin_unlock_bh(&ocelot->xtr_lock); +} +EXPORT_SYMBOL_GPL(ocelot_unlock_xtr_grp_bh); + int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb) { u64 timestamp, src_port, len; @@ -1109,6 +1151,8 @@ int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb) u32 val, *buf; int err; + lockdep_assert_held(&ocelot->xtr_lock); + err = ocelot_xtr_poll_xfh(ocelot, grp, xfh); if (err) return err; @@ -1184,6 +1228,8 @@ bool ocelot_can_inject(struct ocelot *ocelot, int grp) { u32 val = ocelot_read(ocelot, QS_INJ_STATUS); + lockdep_assert_held(&ocelot->inj_lock); + if (!(val & QS_INJ_STATUS_FIFO_RDY(BIT(grp)))) return false; if (val & QS_INJ_STATUS_WMARK_REACHED(BIT(grp))) @@ -1236,6 +1282,8 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, u32 ifh[OCELOT_TAG_LEN / 4]; unsigned int i, count, last; + lockdep_assert_held(&ocelot->inj_lock); + ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) | QS_INJ_CTRL_SOF, QS_INJ_CTRL, grp); @@ -1272,6 +1320,8 @@ EXPORT_SYMBOL(ocelot_port_inject_frame); void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp) { + lockdep_assert_held(&ocelot->xtr_lock); + while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) ocelot_read_rix(ocelot, QS_XTR_RD, grp); } @@ -2954,6 +3004,8 @@ int ocelot_init(struct ocelot *ocelot) mutex_init(&ocelot->fwd_domain_lock); spin_lock_init(&ocelot->ptp_clock_lock); spin_lock_init(&ocelot->ts_id_lock); + spin_lock_init(&ocelot->inj_lock); + spin_lock_init(&ocelot->xtr_lock); ocelot->owq = alloc_ordered_workqueue("ocelot-owq", 0); if (!ocelot->owq) diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index 993212c3a7da..c09dd2e3343c 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -51,6 +51,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) struct ocelot *ocelot = arg; int grp = 0, err; + ocelot_lock_xtr_grp(ocelot, grp); + while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) { struct sk_buff *skb; @@ -69,6 +71,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) if (err < 0) ocelot_drain_cpu_queue(ocelot, 0); + ocelot_unlock_xtr_grp(ocelot, grp); + return IRQ_HANDLED; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index ed18e6bafc8d..462c653e1017 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -813,6 +813,9 @@ struct ocelot { const u32 *const *map; struct list_head stats_regions; + spinlock_t inj_lock; + spinlock_t xtr_lock; + u32 pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM]; int packet_buffer_size; int num_frame_refs; @@ -966,6 +969,12 @@ void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target, u32 val, u32 reg, u32 offset); /* Packet I/O */ +void ocelot_lock_inj_grp(struct ocelot *ocelot, int grp); +void ocelot_unlock_inj_grp(struct ocelot *ocelot, int grp); +void ocelot_lock_xtr_grp(struct ocelot *ocelot, int grp); +void ocelot_unlock_xtr_grp(struct ocelot *ocelot, int grp); +void ocelot_lock_xtr_grp_bh(struct ocelot *ocelot, int grp); +void ocelot_unlock_xtr_grp_bh(struct ocelot *ocelot, int grp); bool ocelot_can_inject(struct ocelot *ocelot, int grp); void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, u32 rew_op, struct sk_buff *skb); From patchwork Thu Aug 15 00:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764287 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 7620C3FB1B; Thu, 15 Aug 2024 00:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680597; cv=fail; b=KV11+0O/RN8Ubg0XFijq8IVdlreleMRLnzzJUrQIK9XfkDCBYTuMQxqDRQyWdgTsQyCGkr9kQ9Ah/aPFsHQjGyHyIalJtI7nMUQKuGEmGm47Ol56/NDVT2pq2XTrzQOgGLkTBabh+QTGHZZr0isRrPYWD1rGYHfYOZVOCk1nGFc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680597; c=relaxed/simple; bh=4iDMZpNjH9wd+SJ08fKUkSY9a7FVu8ZyWrWdaAT4xgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DUOTTgBidhw30cu19oUIQcc0M2CIxbIBTR0rNjouZ/DZZrLQ6H0P2PwzhHcDnqlBTonR1qlsG/YWMOkwbMM+Xxd7JImb6KbzXsMeeFc0dpUibXqE5LE4TTaNk0SRX+gsJGzkEbEc2YInNVnohBHMfP/P8oiX0v6OQBYJpaAQ820= 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=Rt8yhkpq; arc=fail smtp.client-ip=52.101.70.30 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="Rt8yhkpq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fccRzltrrhqsIR7m/I+wWMv0wNZUHoSuFHV5pyiz/athnJu4RTzebU+G0rF1ps+mQGrlgl4HrE4p8gQoLAc8hTs/q0xf9Te+VUiU7D92Ra9hJ5vsOEatlRGvHK/Vgnz0xZqCiHtzZKuOsYfZKxvf5kdu54vc5NCCMOoECtzoESpIWtAgq58+5gNjnW+MYtCFABs6teSFdq8VxKOxljajgwwdkaEkETggDDgbfrUujbY/bnGbcURAHrxfqhl61BUFTFll3P5D0aqwAEbUe32Y79ZaatG/gh/3BE5KN/7lIQtsle8I7yabLOWUrPmoAt9YdgM19UlJ9AqeTtC5deeAxQ== 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=EgsffPOM8rXOTns59/RY1lYK6l81MKC6Z8yN/i/CIhs=; b=Kk2y9pcz89y6g4DAJrbV+9xoV11Fx8FNE6imRt+vj3Z6nMBKcvTsSe9DhR6QfRoytekBttR/UObtf4FrVU5/3GbCc/xWix5iYCIG21qewvx8ZaXlqYmOveh0cHWWTEZ8TNgnZe+iZzSkArX39rLMCqYDzBpGNf/TT93XN7oDzGC9wNeQNFekkPwukaI3lK8cvDDI3X7/lZTXh+mrkQ/B03reKfwgyJsvAHzA0+M5uCVH4uN3WL26d3vHWB6gKHWGWMNSpinMkcJTtAUTuHxzB5L5cxsO3dg+3j96JI06pI5yrI5TyTMQGDa+NUCze3EReh9QRLrHUUPBJG8zVUibFg== 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=EgsffPOM8rXOTns59/RY1lYK6l81MKC6Z8yN/i/CIhs=; b=Rt8yhkpqXHVjBIdTPxZILxcmoU+sLK79u393WDg7PLA+T9gWKqy+6ugN1e1me4u7w6VxQGJXqrTeDpOZ+jTGWoT6vuub5TWuK51qLn3Klk69CL+foZzg/8gRP3MiNVRfAlXTPRkfup4HCG0iZNHsPYysY/wyLTPglRRO2U6rvSioDkOJJM9iYWUIVHlUb7vnKrjd28h0aLCJhyn5xeogxR8z09yclfN/fVURcP7uL1ZPbz712AHgti8Z/OOYbm/f9CZS6mlnhLWJkdLlT1+ERxB0p6C6zgPA6WKvSSq/yMvh+FC6Fw2Q70045fcZSY2fb/4NSzCS9Hmz90dH5uDucg== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:50 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 12/14] net: dsa: provide a software untagging function on RX for VLAN-aware bridges Date: Thu, 15 Aug 2024 03:07:05 +0300 Message-Id: <20240815000707.2006121-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 305d7dff-3276-4137-97ca-08dcbcbe949f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: sF4Entb4T4NOTw3yLvkRlYIvxWtxc2demQ7bFqMtmpHot85WpB0KhwQRVMIaG/9rnclsFQHR69A3SCCrTOEPbIcmv+SP05Hoc8n5MrW5OrXcM7tA/TlezJppU6teoX+yqig0ML3VW0zAuEe8CCEkiFHj5nYnIr7NpPjxe5g/3yx/Zt18+/l+/RtQQi5gbmpE5Q4uYYSsnWUidI9rxdgeab54amj55Lbsh+s2Zs8T22mcfXPhs2YsUNnPc4E/VJ1H2KelnNk1rSyA2g1UEFqiCiBaKb3ENNKzHVM29oYeu+v7Sj6+pPIhFxd8cH6yLp6wdlvvZaxzuxSsFbtRQg56AmsZ1pxcSM1WoKAgKmBeRwC8WmFdMvX7LgUoI7gMVy1cw7LwElTH20fBLBjbmJijzprZlHJLpNfi5UiCKNNjNcqzeTyxTZpKheznuj5tGIrD4K6PIuv5iRhUiS/ufGpPPbSRH0tfCqUUWkLKsw3KbHrgIFalZgL8BdrI03nBXvNO9GSJEw/Me8yzPTYuDBT+Dd+oIlaoGdtr5shqfl4CWH0XSaeBLo3A6ER9hZTtiHEzNDavlPaJdKxprKRMecGj9qmpsLpeD6k/6sO2L7LGzVXmigjeG0Nnot0rK+o8qLhQxwd2ltSIe/XC7qk1h2gpvtYzQ3adHtsfFFhX52LYYy4QLdqLgRqJ9uf0JBXri5x/hbfxFos/nwaCFjmDSSMOORqvWxrW8LmGutvCFItOwZoAn+mj2qyiZ5MKqa+bzQOxnJWnXTQ3vALcCWQ3KL68Fs4wUzH7rcbxxE7IwR+jIFJZADZAvd2jPBpsJlZdRaYX5qJGmVTrZf3aNuJox3SGYIy9Rqfml6HOOoladO2KNAb5nZFPuPk7rHayzpGQo/Gg1iEenKg22a1R/hn3wTgpUphOwT1DZwIt5hE9jiJF0xpHkPY3ESaz8S5F/eNW8PM8GLWSdaWVJZB80tvVVXVjiJFu+hVz1N1sdjJcnJ3yG92L/DZpFD5qz/TcJc0UXa/zs8QBvR3/ZSFWZ5xXedGgu+H6ik7rrqDbZ6nw41Q1tfLJP4m7DWroRtHRZsaJL+jqB4eusuEsq4kypGtc2d32MeHjjHZa8Wp4nuECSjBvgoybYHcCnNMDSBAhxGWalGFKUvTN23WjhbpbvbYsEsVRGFwAgkjTwLztfvTLdRT+Oq07FlFEd6f4tVx+aOJOLjmU2QLie0Wig4tvyVM4RrWhLYkE619XExH51Y7zNe5l5IckhYg/Z20h1EbkAzQ1Fj0KdLXx68CWchHlbdR7K38T6Y5iF1G7VC6yCauovrRkwfKW48WLuriq4uXmHRLh1AHnqO+YEnTqMZ2fsvDgD4GEE/iUDA1ZaciXzKil86ATuI3BXgABIGJFBD0crVFuKXunYRGWcS9Xhy/r6DUAw8g50Q== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1dy3zrDBLQATXZYiR+xoaVp3/dfXi/M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Guca037BpeKnZTfv2ryvIzumbm07o6iBjLUjn9664MfnXnATBQ2EuGMUDRcPLgd8vEOQzYLNkFGqQx89Q0LtFeGjszsa9+dneCXOE+1jMwdcDcBtoiwFwIHEz+frAdSbg6Nc96nSfrOFQYLs32TvjuJ0vXJg4QitWTFfR1+2tZ5QHJ6ZvOfpn4Db/ic6B1HE5o3f3Cx17/yqa4RXDp5zUisYlJhV5AsMXXXf3lel9srpguYB3gX91gObJ2JjJRX8I2lMX3cB7wB+MypsVs7qq2D/KVaUEt8mDH1dNTVfR8sKqGjjMikJBh3h/01VwKOMxX5FSmeJrLsJxdLmdQrO5lfIxJ6AgZnWHhEXctDnMerx3evXtg9Tw4oiu7bLsSuaSp2mIzcSlCQPa9FtSHUsW3Z3WvPexlq2U5Bp24eWP5blcc1cgOeaiktIA53E24PDqYR5o9+UjntxIQoiMZcOcyud7zVMhgvBq1K7GW5Qh04N12GLPYArqsN4m9sRYBBcz3hQA08g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 305d7dff-3276-4137-97ca-08dcbcbe949f X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:50.4591 (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: qU7q2IRN0av3scSwUL4XZn4L0QxrF+yNSBAMxj/StJU7fOT4ctnk5lsFi9lQYTpX6WE/uoRfJ6Bdl3+B0oioAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org Through code analysis, I realized that the ds->untag_bridge_pvid logic is contradictory - see the newly added FIXME above the kernel-doc for dsa_software_untag_vlan_unaware_bridge(). Moreover, for the Felix driver, I need something very similar, but which is actually _not_ contradictory: untag the bridge PVID on RX, but for VLAN-aware bridges. The existing logic does it for VLAN-unaware bridges. Since I don't want to change the functionality of drivers which were supposedly properly tested with the ds->untag_bridge_pvid flag, I have introduced a new one: ds->untag_vlan_aware_bridge_pvid, and I have refactored the DSA reception code into a common path for both flags. TODO: both flags should be unified under a single ds->software_vlan_untag, which users of both current flags should set. This is not something that can be carried out right away. It needs very careful examination of all drivers which make use of this functionality, since some of them actually get this wrong in the first place. For example, commit 9130c2d30c17 ("net: dsa: microchip: ksz8795: Use software untagging on CPU port") uses this in a driver which has ds->configure_vlan_while_not_filtering = true. The latter mechanism has been known for many years to be broken by design: https://lore.kernel.org/netdev/CABumfLzJmXDN_W-8Z=p9KyKUVi_HhS7o_poBkeKHS2BkAiyYpw@mail.gmail.com/ and we have the situation of 2 bugs canceling each other. There is no private VLAN, and the port follows the PVID of the VLAN-unaware bridge. So, it's kinda ok for that driver to use the ds->untag_bridge_pvid mechanism, in a broken way. Signed-off-by: Vladimir Oltean --- include/net/dsa.h | 16 +++--- net/dsa/tag.c | 5 +- net/dsa/tag.h | 135 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 118 insertions(+), 38 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index b06f97ae3da1..d7a6c2930277 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -403,14 +403,18 @@ struct dsa_switch { */ u32 configure_vlan_while_not_filtering:1; - /* If the switch driver always programs the CPU port as egress tagged - * despite the VLAN configuration indicating otherwise, then setting - * @untag_bridge_pvid will force the DSA receive path to pop the - * bridge's default_pvid VLAN tagged frames to offer a consistent - * behavior between a vlan_filtering=0 and vlan_filtering=1 bridge - * device. + /* Pop the default_pvid of VLAN-unaware bridge ports from tagged frames. + * DEPRECATED: Do NOT set this field in new drivers. Instead look at + * the dsa_software_vlan_untag() comments. */ u32 untag_bridge_pvid:1; + /* Pop the default_pvid of VLAN-aware bridge ports from tagged frames. + * Useful if the switch cannot preserve the VLAN tag as seen on the + * wire for user port ingress, and chooses to send all frames as + * VLAN-tagged to the CPU, including those which were originally + * untagged. + */ + u32 untag_vlan_aware_bridge_pvid:1; /* Let DSA manage the FDB entries towards the * CPU, based on the software bridge database. diff --git a/net/dsa/tag.c b/net/dsa/tag.c index 6e402d49afd3..79ad105902d9 100644 --- a/net/dsa/tag.c +++ b/net/dsa/tag.c @@ -105,8 +105,9 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, p = netdev_priv(skb->dev); - if (unlikely(cpu_dp->ds->untag_bridge_pvid)) { - nskb = dsa_untag_bridge_pvid(skb); + if (unlikely(cpu_dp->ds->untag_bridge_pvid || + cpu_dp->ds->untag_vlan_aware_bridge_pvid)) { + nskb = dsa_software_vlan_untag(skb); if (!nskb) { kfree_skb(skb); return 0; diff --git a/net/dsa/tag.h b/net/dsa/tag.h index f6b9c73718df..d5707870906b 100644 --- a/net/dsa/tag.h +++ b/net/dsa/tag.h @@ -44,46 +44,81 @@ static inline struct net_device *dsa_conduit_find_user(struct net_device *dev, return NULL; } -/* If under a bridge with vlan_filtering=0, make sure to send pvid-tagged - * frames as untagged, since the bridge will not untag them. +/** + * dsa_software_untag_vlan_aware_bridge: Software untagging for VLAN-aware bridge + * @skb: Pointer to received socket buffer (packet) + * @br: Pointer to bridge upper interface of ingress port + * @vid: Parsed VID from packet + * + * The bridge can process tagged packets. Software like STP/PTP may not. The + * bridge can also process untagged packets, to the same effect as if they were + * tagged with the PVID of the ingress port. So packets tagged with the PVID of + * the bridge port must be software-untagged, to support both use cases. */ -static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) +static inline void dsa_software_untag_vlan_aware_bridge(struct sk_buff *skb, + struct net_device *br, + u16 vid) { - struct dsa_port *dp = dsa_user_to_port(skb->dev); - struct net_device *br = dsa_port_bridge_dev_get(dp); - struct net_device *dev = skb->dev; - struct net_device *upper_dev; - u16 vid, pvid, proto; + u16 pvid, proto; int err; - if (!br || br_vlan_enabled(br)) - return skb; - err = br_vlan_get_proto(br, &proto); if (err) - return skb; + return; - /* Move VLAN tag from data to hwaccel */ - if (!skb_vlan_tag_present(skb) && skb->protocol == htons(proto)) { - skb = skb_vlan_untag(skb); - if (!skb) - return NULL; - } + err = br_vlan_get_pvid_rcu(skb->dev, &pvid); + if (err) + return; - if (!skb_vlan_tag_present(skb)) - return skb; + if (vid == pvid && skb->vlan_proto == htons(proto)) + __vlan_hwaccel_clear_tag(skb); +} - vid = skb_vlan_tag_get_id(skb); +/** + * dsa_software_untag_vlan_unaware_bridge: Software untagging for VLAN-unaware bridge + * @skb: Pointer to received socket buffer (packet) + * @br: Pointer to bridge upper interface of ingress port + * @vid: Parsed VID from packet + * + * The bridge ignores all VLAN tags. Software like STP/PTP may not (it may run + * on the plain port, or on a VLAN upper interface). Maybe packets are coming + * to software as tagged with a driver-defined VID which is NOT equal to the + * PVID of the bridge port (since the bridge is VLAN-unaware, its configuration + * should NOT be committed to hardware). DSA needs a method for this private + * VID to be communicated by software to it, and if packets are tagged with it, + * software-untag them. Note: the private VID may be different per bridge, to + * support the FDB isolation use case. + * + * FIXME: this is currently implemented based on the broken assumption that + * the "private VID" used by the driver in VLAN-unaware mode is equal to the + * bridge PVID. It should not be, except for a coincidence; the bridge PVID is + * irrelevant to the data path in the VLAN-unaware mode. Thus, the VID that + * this function removes is wrong. + * + * All users of ds->untag_bridge_pvid should fix their drivers, if necessary, + * to make the two independent. Only then, if there still remains a need to + * strip the private VID from packets, then a new ds->ops->get_private_vid() + * API shall be introduced to communicate to DSA what this VID is, which needs + * to be stripped here. + */ +static inline void dsa_software_untag_vlan_unaware_bridge(struct sk_buff *skb, + struct net_device *br, + u16 vid) +{ + struct net_device *upper_dev; + u16 pvid, proto; + int err; - /* We already run under an RCU read-side critical section since - * we are called from netif_receive_skb_list_internal(). - */ - err = br_vlan_get_pvid_rcu(dev, &pvid); + err = br_vlan_get_proto(br, &proto); if (err) - return skb; + return; - if (vid != pvid) - return skb; + err = br_vlan_get_pvid_rcu(skb->dev, &pvid); + if (err) + return; + + if (vid != pvid || skb->vlan_proto != htons(proto)) + return; /* The sad part about attempting to untag from DSA is that we * don't know, unless we check, if the skb will end up in @@ -95,10 +130,50 @@ static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) * definitely keep the tag, to make sure it keeps working. */ upper_dev = __vlan_find_dev_deep_rcu(br, htons(proto), vid); - if (upper_dev) + if (!upper_dev) + __vlan_hwaccel_clear_tag(skb); +} + +/** + * dsa_software_vlan_untag: Software VLAN untagging in DSA receive path + * @skb: Pointer to socket buffer (packet) + * + * Receive path method for switches which cannot avoid tagging all packets + * towards the CPU port. Called when ds->untag_bridge_pvid (legacy) or + * ds->untag_vlan_aware_bridge_pvid is set to true. + * + * As a side effect of this method, any VLAN tag from the skb head is moved + * to hwaccel. + */ +static inline struct sk_buff *dsa_software_vlan_untag(struct sk_buff *skb) +{ + struct dsa_port *dp = dsa_user_to_port(skb->dev); + struct net_device *br = dsa_port_bridge_dev_get(dp); + u16 vid; + + /* software untagging for standalone ports not yet necessary */ + if (!br) return skb; - __vlan_hwaccel_clear_tag(skb); + /* Move VLAN tag from data to hwaccel */ + if (!skb_vlan_tag_present(skb)) { + skb = skb_vlan_untag(skb); + if (!skb) + return NULL; + } + + if (!skb_vlan_tag_present(skb)) + return skb; + + vid = skb_vlan_tag_get_id(skb); + + if (br_vlan_enabled(br)) { + if (dp->ds->untag_vlan_aware_bridge_pvid) + dsa_software_untag_vlan_aware_bridge(skb, br, vid); + } else { + if (dp->ds->untag_bridge_pvid) + dsa_software_untag_vlan_unaware_bridge(skb, br, vid); + } return skb; } From patchwork Thu Aug 15 00:07:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764288 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 0D81847A66; Thu, 15 Aug 2024 00:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680600; cv=fail; b=EJdR/bqQ0YPLGnGABCeAHtHrkaiB1koPOL9B3Lxo8PpQes+9Tk+nWiJwYpmyyYFAmZQX0E6wJEe1aqVIzX77dyllwaoIP+Cf1+EmQkcYe8DF5d/RwMaR47sawM4kVQdKmvy00M5kkqELWkvNAWjftkXSTn2d0anhXnnHe7w0Ipc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680600; c=relaxed/simple; bh=gFF/32PFqq7ox3Pfmb1RYJpRHUxx1+OLIwbaEMzl+Zo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OWqCEgCRtDxEZiIBe1qTJI+zXZjJWK0xR/YiePovIyCe4uFR4UCUAdVmLAjdFEAVfWBYrCsMIoKa41JHKHRFko/zvyKSFEHtSFVbyWEYTrz5yN7Ll2Kq7A8hQ6PFjkw6UhV5vQlGNcw1W4GU9tY2itPV91QJp0MIKj6AFDag4+s= 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=PlY6gL9L; arc=fail smtp.client-ip=52.101.70.30 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="PlY6gL9L" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QNVx9ka1QypNb1oBVoXe10GzCcxsgkiPar/fL6NYeDN7GN4FJc9bHfIPxRJ1TyKvS+3lA8C/NXyGFjR9X3e1qmUo+WCfW9kNYw0JlAIO+noYaPoLyVDDP8a9hbbh/Ko2GZx30KAdPI1+xU9Zvy4Irj0FApDBysSG7+6SXZrCK43+sKDWCcoZAn+9YnKZGWScxSAHiPx6A1pFPLlfaQ4ypFHAnpAKGkopO0vn4GCh9aCXjlm4lJMj/93EYixRFVCVU8JDr+WGQvkvul3Zu2UrGDzTOjAixaEbt6nOujpbyWHbej5TJuHNPgH6YJMast6nuo1yQoBrK0qo5Uxc1uJAIA== 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=pCcgThH71i8kjAzpmGAIeoNjeTwQBNzNOh84iWzZGSA=; b=AKr5aTZ08ENdz0vnHCf45EP1mGjLnCQaWEdIBfqy94doYMLoOWdLK+UgrR7aT17Amir1Fh0kwSty232doYdUIHISM/Oc/MruJyG+U5Fpeb/yQH4EgaH30yRhD/eRkT8nB5ZOgaAOCA1SquL+6gGYin3941keiNaiM9mexWmL3Ck1a2wNTqItyU6otT4rhVmxXEmaQ6WmkEQRokMAlUxydI+4D7mYFhOL7iHpql/KKiFSk/3YJWsJQ86JQaYazp9Gm7pgOIZEtQJJH0SxrvkF61eRZYwfoaOFosplh11zrbP8DKGAgLnbWE48r8jirhx1a5eokfimnm92ILrsUQUwEg== 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=pCcgThH71i8kjAzpmGAIeoNjeTwQBNzNOh84iWzZGSA=; b=PlY6gL9LK3GeAqEuv9w9JbChaVqYn6MYnZT5tkugFTn7qyvBg6W/T/+8VfA5Cp9kyBaVhGbo3Yz1VVHiikqhwjRJCK0M/xzWzbYyQThiGP9lr9InSJq8Cuzq4Ic8syKFVkVYY0IlmfDD+TCr6rllKKMXUIIDkDBbpNGKZYigOrV2he/TWoAa3K76FS/V3eM4DnibGRyWLLtWRj4No/CPlSqZ8lJUL5mx+mmFKVqJ4qH9oLekfeLMciNeG6HSCjePFgKhaANqDA65MaaEnCsjazIdh4dGwYk7JaCTdSN/fI2IpRrctUlnxz+sBMi7hx+5AfhlB2La8wZEY0aHd4BHqw== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:52 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 13/14] net: dsa: felix: fix VLAN tag loss on CPU reception with ocelot-8021q Date: Thu, 15 Aug 2024 03:07:06 +0300 Message-Id: <20240815000707.2006121-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a7d7ed3-60e4-4eb9-b375-08dcbcbe95e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: p3YpmzZlvGM/oWcpZnfxkOXsBEU7lf8tCFyY11zs9o9GFZ/LXEFfoiD+uQfAcswnZgX16TZzR9lEZyr09nxhE5yarvs/fBMk2YpWEGH/dJRFLHz0Ejs+nPmLxFM5/2PInzwJ1HtvnhN90I8+DPguB/V+ugZ8C2GRx2y9YIh/4OGgsXAucIe0o0w5rDJTpwnKpE5LKeK4kgni/W9PJejwA0KoZ3pj1LEwtDjvJzYRw9Mcfk6mwefz5mtr1bxAicX3Ub6uyXmJQJgXBMVWb+YIrJAZ4wmrItskMuZMitqoP9PLNRleNQPQp/RxT9IlXoV3xXGMdVDTN6OfytM7HXYhW1b0LKIWNXWn0Z+7T0c0RGWMNQ8t+147P9L2ywgtP2uof/Q3JtIvEEaWuv50wWsNnwC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I;SFV:NSPM;H:AM8PR04MB7779.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s/qyxBMe1JeV83JgXti8yQb40b6nPGJ/Rimmr8uDk3aT5HgZNdKcQJST5tzdV98BPPQ70vl2nhlsbYf6K7RP9Y75hgkxgCg+AQe+NG22W/0hXb/XDJCiQq3v3f8SYV762GBJPB7Fr7c5w2beKT1uu6oI0ew3NmK6ZNdLVLmmBX7Hn39c5hS5wlJuq5KcuBEDmKk8Xl3O6ky3DKUg45YG7z1bUW1MGz/21ULj0Z2KWsXapSuFJdDexkquohOuB3nPnegJLdQLwlZGn57NQYCiLFWP9yhz9z/oPZU3JudYL7DrIQ2i7HHrlbKY0zcPJxI4V+sdvXqJMMeuNtpgIKCHhtEKXNouRkSOMPxcCN3cFw2ePIVwiTbmQl/63UoQupHjX05/YupLjHeUlZQ3T10NQvrZ5qA5BApR+UrpZlW4fPnBz8Bh8hqmEGIXwdZyC68F9zoPGEScvEWKyomofg/XoDxoz09zbxjrRPRCkqGeAICNE4kNsa/9kA6W4z+SwnEyBSU+kU03H7XRj7V5PTAhZUs0jqgKV6pIroYCy17ibTxFDibXapv4w7SCfTcGMqpdgq/fH35M02fprhL6Rni3H2Nf0Pa8SUq8TNHKzOieNUOItLjL+HPz88nXNMNveOp/mVCylFuaECkSXht1zvEBuANvOu0QQxyJ8pxMF7R+Vj8AiZ0tnSfFRctkLhVOxfV+bSPmEsR5iIFXmneo6Oxehate2awAWATYTGAtX1QEkppaqa2+0Yy7RSAd14rEQ2o45iAn7muYbKmzKVvV6KK1vodomYFA4ORHavLwSKTM08lXesQ30P3ybelsMIla9jJOHtTYbDZLpSn2XL9aGxRzD/j0LHTU9+wgLjbO8Bqp3aHUIE8lhF8yRtMYv/4lodeGnU2A4pYLDLpAdCS5cTPVoUEyoJBy6SyM+yuj4jaD0dvAUG9PyZG9NH5ocd7VXP+yTv476COl5jJgqC9G+wm6WZ+NjkHXXT8oOl51ykTuve95MRNkAojfLwt3P3sMm4b6fOsPu4ceG0buiUsdeJ9ipXgLCDdyyi25zjZoNZxDeZcNo2wh8jsiw23w5mnXu5kuYwv+CuZMFZeCBa3NeTLIAyYGFQ3x1AVLMbKQF6LOhaSjlf/aEr9sOXygn73kbPkvrRNx9nJF7h4yTJ/q0/JIdhPoQAv9wsBxDdARuhpma3kDhDvINE29z6xaSt0NAqdnzHESbP2Ob49057fG+FE2b0u6InCIy/kMYQoFXYkZlas+/MjfYxRuG47LSjz1wZoxOdU6pUC3lkhUkSaT2epcDY1dRR7VQ2VWnjJwjeVko1sT96X2rIwVZM2E/qhb0A01506JMDGOYFkmd5lrJV2DKhswEwTSdJirXad9n0za+ZVyI9A6ypfe5jO70MJBfZBOSO7sUXtNTzkModtiI1rz7GqFyNhzTmKs6Zdg5RTGxrtCiyTJWnJXLUP3AQExpF9GHdLYmfL5m9ZVzk5ZKkEWfamBNj9g66KHkgTqy9cR3hDplrKz8zBHtxo90xItlXBMJtIwhZ18ugboZtn56rdRTa3kesHzTG0nA0txj2Vzgqsz5CGN/xbXqcRwMkxbf8W2auDn4xGdm6LrqO0WUXlOmA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a7d7ed3-60e4-4eb9-b375-08dcbcbe95e4 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:52.5819 (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: QwgGa2mNQ+JZo8zTLmXV2UgNYOm5DRDBfJmYD84R5Ce93BJf64St0ZTj8c9ikmINwZRZHmRZqaRbJyZ2StpRuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org There is a major design bug with ocelot-8021q, which is that it expects more of the hardware than the hardware can actually do. The short summary of the issue is that when a port is under a VLAN-aware bridge and we use this tagging protocol, VLAN upper interfaces of this port do not see RX traffic. We use VCAP ES0 (egress rewriter) rules towards the tag_8021q CPU port to encapsulate packets with an outer tag, later stripped by software, that depends on the source user port. We do this so that packets can be identified in ocelot_rcv(). To be precise, we create rules with push_outer_tag = OCELOT_ES0_TAG and push_inner_tag = 0. With this configuration, we expect the switch to keep the inner tag configuration as found in the packet (if it was untagged on user port ingress, keep it untagged, otherwise preserve the VLAN tag unmodified as the inner tag towards the tag_8021q CPU port). But this is not what happens. Instead, table "Tagging Combinations" from the user manual suggests that when the ES0 action is "PUSH_OUTER_TAG=1 and PUSH_INNER_TAG=0", there will be "no inner tag". Experimentation further clarifies what this means. It appears that this "inner tag" which is not pushed into the packet on its egress towards the CPU is none other than the classified VLAN. When the ingress user port is standalone or under a VLAN-unaware bridge, the classified VLAN is a discardable quantity: it is a fixed value - the result of ocelot_vlan_unaware_pvid()'s configuration, and actually independent of the VID from any 802.1Q header that may be in the frame. It is actually preferable to discard the "inner tag" in this case. The problem is when the ingress port is under a VLAN-aware bridge. Then, the classified VLAN is taken from the frame's 802.1Q header, with a fallback on the bridge port's PVID. It would be very good to not discard the "inner tag" here, because if we do, we break communication with any 8021q VLAN uppers that the port might have. These have a processing path outside the bridge. There seems to be nothing else we can do except to change the configuration for VCAP ES0 rules, to actually push the inner VLAN into the frame. There are 2 options for that, first is to push a fixed value specified in the rule, and second is to push a fixed value, plus (aka arithmetic +) the classified VLAN. We choose the second option, and we select that fixed value as 0. Thus, what is pushed in the inner tag is just the classified VLAN. From there, we need to perform software untagging, in the receive path, of stuff that was untagged on the wire. Fixes: 7c83a7c539ab ("net: dsa: add a second tagger for Ocelot switches based on tag_8021q") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 115 +++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 8d31ff18c5c7..4a705f7333f4 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -61,11 +61,46 @@ static int felix_cpu_port_for_conduit(struct dsa_switch *ds, return cpu_dp->index; } +/** + * felix_update_tag_8021q_rx_rule - Update VCAP ES0 tag_8021q rule after + * vlan_filtering change + * @outer_tagging_rule: Pointer to VCAP filter on which the update is performed + * @vlan_filtering: Current bridge VLAN filtering setting + * + * Source port identification for tag_8021q is done using VCAP ES0 rules on the + * CPU port(s). The ES0 tag B (inner tag from the packet) can be configured as + * either: + * - push_inner_tag=0: the inner tag is never pushed into the frame + * (and we lose info about the classified VLAN). This is + * good when the classified VLAN is a discardable quantity + * for the software RX path: it is either set to + * OCELOT_STANDALONE_PVID, or to + * ocelot_vlan_unaware_pvid(bridge). + * - push_inner_tag=1: the inner tag is always pushed. This is good when the + * classified VLAN is not a discardable quantity (the port + * is under a VLAN-aware bridge, and software needs to + * continue processing the packet in the same VLAN as the + * hardware). + * The point is that what is good for a VLAN-unaware port is not good for a + * VLAN-aware port, and vice versa. Thus, the RX tagging rules must be kept in + * sync with the VLAN filtering state of the port. + */ +static void +felix_update_tag_8021q_rx_rule(struct ocelot_vcap_filter *outer_tagging_rule, + bool vlan_filtering) +{ + if (vlan_filtering) + outer_tagging_rule->action.push_inner_tag = OCELOT_ES0_TAG; + else + outer_tagging_rule->action.push_inner_tag = OCELOT_NO_ES0_TAG; +} + /* Set up VCAP ES0 rules for pushing a tag_8021q VLAN towards the CPU such that * the tagger can perform RX source port identification. */ static int felix_tag_8021q_vlan_add_rx(struct dsa_switch *ds, int port, - int upstream, u16 vid) + int upstream, u16 vid, + bool vlan_filtering) { struct ocelot_vcap_filter *outer_tagging_rule; struct ocelot *ocelot = ds->priv; @@ -96,6 +131,14 @@ static int felix_tag_8021q_vlan_add_rx(struct dsa_switch *ds, int port, outer_tagging_rule->action.tag_a_tpid_sel = OCELOT_TAG_TPID_SEL_8021AD; outer_tagging_rule->action.tag_a_vid_sel = 1; outer_tagging_rule->action.vid_a_val = vid; + felix_update_tag_8021q_rx_rule(outer_tagging_rule, vlan_filtering); + outer_tagging_rule->action.tag_b_tpid_sel = OCELOT_TAG_TPID_SEL_8021Q; + /* Leave TAG_B_VID_SEL at 0 (Classified VID + VID_B_VAL). Since we also + * leave VID_B_VAL at 0, this makes ES0 tag B (the inner tag) equal to + * the classified VID, which we need to see in the DSA tagger's receive + * path. Note: the inner tag is only visible in the packet when pushed + * (push_inner_tag == OCELOT_ES0_TAG). + */ err = ocelot_vcap_filter_add(ocelot, outer_tagging_rule, NULL); if (err) @@ -227,6 +270,7 @@ static int felix_tag_8021q_vlan_del_tx(struct dsa_switch *ds, int port, u16 vid) static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, u16 flags) { + struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *cpu_dp; int err; @@ -234,11 +278,12 @@ static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, * membership, which we aren't. So we don't need to add any VCAP filter * for the CPU port. */ - if (!dsa_is_user_port(ds, port)) + if (!dsa_port_is_user(dp)) return 0; dsa_switch_for_each_cpu_port(cpu_dp, ds) { - err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid); + err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid, + dsa_port_is_vlan_filtering(dp)); if (err) return err; } @@ -258,10 +303,11 @@ static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) { + struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *cpu_dp; int err; - if (!dsa_is_user_port(ds, port)) + if (!dsa_port_is_user(dp)) return 0; dsa_switch_for_each_cpu_port(cpu_dp, ds) { @@ -278,11 +324,41 @@ static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) del_tx_failed: dsa_switch_for_each_cpu_port(cpu_dp, ds) - felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid); + felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid, + dsa_port_is_vlan_filtering(dp)); return err; } +static int felix_update_tag_8021q_rx_rules(struct dsa_switch *ds, int port, + bool vlan_filtering) +{ + struct ocelot_vcap_filter *outer_tagging_rule; + struct ocelot_vcap_block *block_vcap_es0; + struct ocelot *ocelot = ds->priv; + struct dsa_port *cpu_dp; + unsigned long cookie; + int err; + + block_vcap_es0 = &ocelot->block[VCAP_ES0]; + + dsa_switch_for_each_cpu_port(cpu_dp, ds) { + cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, + cpu_dp->index); + + outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0, + cookie, false); + + felix_update_tag_8021q_rx_rule(outer_tagging_rule, vlan_filtering); + + err = ocelot_vcap_filter_replace(ocelot, outer_tagging_rule); + if (err) + return err; + } + + return 0; +} + static int felix_trap_get_cpu_port(struct dsa_switch *ds, const struct ocelot_vcap_filter *trap) { @@ -532,6 +608,16 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) ocelot_drain_cpu_queue(ocelot, 0); ocelot_unlock_xtr_grp_bh(ocelot, 0); + /* Problem: when using push_inner_tag=1 for ES0 tag B, we lose info + * about whether the received packets were VLAN-tagged on the wire, + * since they are always tagged on egress towards the CPU port. + * + * Since using push_inner_tag=1 is unavoidable for VLAN-aware bridges, + * we must work around the fallout by untagging in software to make + * untagged reception work more or less as expected. + */ + ds->untag_vlan_aware_bridge_pvid = true; + return 0; } @@ -556,6 +642,8 @@ static void felix_tag_8021q_teardown(struct dsa_switch *ds) ocelot_port_teardown_dsa_8021q_cpu(ocelot, dp->index); dsa_tag_8021q_unregister(ds); + + ds->untag_vlan_aware_bridge_pvid = false; } static unsigned long felix_tag_8021q_get_host_fwd_mask(struct dsa_switch *ds) @@ -1010,8 +1098,23 @@ static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, struct netlink_ext_ack *extack) { struct ocelot *ocelot = ds->priv; + bool using_tag_8021q; + struct felix *felix; + int err; - return ocelot_port_vlan_filtering(ocelot, port, enabled, extack); + err = ocelot_port_vlan_filtering(ocelot, port, enabled, extack); + if (err) + return err; + + felix = ocelot_to_felix(ocelot); + using_tag_8021q = felix->tag_proto == DSA_TAG_PROTO_OCELOT_8021Q; + if (using_tag_8021q) { + err = felix_update_tag_8021q_rx_rules(ds, port, enabled); + if (err) + return err; + } + + return 0; } static int felix_vlan_add(struct dsa_switch *ds, int port, From patchwork Thu Aug 15 00:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13764289 X-Patchwork-Delegate: kuba@kernel.org Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011030.outbound.protection.outlook.com [52.101.70.30]) (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 C0A6754277; Thu, 15 Aug 2024 00:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.30 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680603; cv=fail; b=RaePTJnsfSLlrfuwU3esFCtJhSmwowFF/FivkdmjFK/KMsuUc/dqyEFA/6D0opa8GNA2ky7t6S4Q7l4W9fLb8GKyEy1qa3NnsJITMElIoG5Qbb6DT9KuN+gh8cjWJvCTNarw2qIf6jsjZ7jXnGwiLT0cIrFOI/ANp3A24CK7WiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723680603; c=relaxed/simple; bh=VobV8zxIK4haQTU0UvzzwpFsZE7igu0yd2m4AF/1yd4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qcc2wMTsCL+qiIZD0reylOurPLJF182Ugsltk7VmNzuZIVJihfcIL5HobBuW1iCKvMXF/ambXxDneoZmyuEzdB2bpHJIIDOr8dtPaNcWv082ICrNv4fyMxbO9m1xexMrf9buZjHqQpm9h3CLM21fZGpynoTWT4h+EJ+RNwmHkoU= 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=iYbLRZPZ; arc=fail smtp.client-ip=52.101.70.30 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="iYbLRZPZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JfMMk05CrZ9UbkTYkzlFLnRKI/Vd3Qi4D122EpCFEnAkOAPU73KfJuCrRuHSKELBJwEmQsMmjDIlEf/D5kISsDMsuGvGxCpm+YPix335g/sM7BpvWvenCbvnk1oqseUyRWw0Omj2D1LMJve1xED/0xjI/HrnSOFjHBppw/PFfPdb/IqKNnZjNS+H7ECTo1NTlZgX2m6keAt+Tvh3mtSETCeIgW9WhJoXmUR8FsuZiwTCn8tW4L4OgH6yWOcjMh78C5X0EE9TiWwGJwYnHTeWS3l6tkfaN8INkl9pKVOS8/qjFBOPZsIwPtJDlJibojCeZmWoG1a+zy1fy5DKykbnOA== 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=/5q0zdh32mXUKBWKmZI9rz1YkceYSFMMd3l/VmSLWRo=; b=l4q9mEZYfxv+Z1ahH/uo06NWJsYUX1IgNWz19isIe6ok19M+YOmcLK0bwA/JjJ3zXahj4YEBQ7y58yCtoYoGe9cmjmPz6Q9/+6tLDZq/Ga7O2qrocqvb3OWnaDfvpgo2D2i5j7xTyrO0dSMzBHvKCqWaMn8ceq8zemes0OlR8pkPDsJEDE/ZiLKl9EMOPY8RSo5i+gCBRj6LiA/2I+AtcQG1tVBSQdDf5P/gNNOfvKGlmall+7LQ4/9/98Gyko7Oqm3ohkVG9Mbr0JlVzvuY2+db8owqTCsZvFLeoiOZ62HJN30kiO8RzgQC054Lo9t6kCKqWzclcYStQ6kUsgT5vA== 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=/5q0zdh32mXUKBWKmZI9rz1YkceYSFMMd3l/VmSLWRo=; b=iYbLRZPZ5SccNCV54eTg9U81HP/oYvF7r9PNM/rba3J8HJSKeNF0O+LkXtQX/SU/C7x0WSPbLgk7miBB3zPgtYGVHCpQD0w18RerKZuz848G+eAIM4FJym7nI/oC+ZWRxusXmMPDV3/h5dgh3dGczWDZ+Lg+zVFOnU44tpSgLWGlayWY1TjqR3rZ8ba0BNYavluw2bR57pn+kYyXw0j7iiY01ZRTEobs8ogvleFc5yFLV18GtivGIZcYuQ21YK6c94/WouGOdNVvR6hGlQNCJgz9Z1wa9kedFYsyCtMMMCozLJEJpEb5N+DGtZmjUtLCpwOqv0GZ5HIbV2dSco2z7w== 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 VI2PR04MB10285.eurprd04.prod.outlook.com (2603:10a6:800:21e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.18; Thu, 15 Aug 2024 00:09:54 +0000 Received: from AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2]) by AM8PR04MB7779.eurprd04.prod.outlook.com ([fe80::7417:d17f:8d97:44d2%4]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 00:09:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , Antoine Tenart , UNGLinuxDriver@microchip.com, Hongbo Wang , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Colin Foster , Horatiu Vultur , Hangbin Liu , Petr Machata , Ido Schimmel , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 14/14] net: mscc: ocelot: treat 802.1ad tagged traffic as 802.1Q-untagged Date: Thu, 15 Aug 2024 03:07:07 +0300 Message-Id: <20240815000707.2006121-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815000707.2006121-1-vladimir.oltean@nxp.com> References: <20240815000707.2006121-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: HE1PR06CA0143.eurprd06.prod.outlook.com (2603:10a6:7:16::30) 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_|VI2PR04MB10285:EE_ X-MS-Office365-Filtering-Correlation-Id: bc0aa76b-9d45-40fe-deec-08dcbcbe9726 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: 0mZc0oDh2ePfEMUNX3kVAhgne6A/V+16xmOKdJ9a2runsmoJacD1pUA8zPglbPxUil+5qST/N8XzdVOMPU49HFaGZ/b9RLLxSXpdcSirjg5kMsIdvwZlJVojGa/z1KfbhALpqhcrTv0LnbE2Q6F381xnsiwCHXz3YXzT/jUKrjB4BNxuCAMY2oNav8wtRMS4im6w7yd+bf38fx6lAiE+CmH4iUnd9reNytDFP47mECJhHFTcXGr+3G3DW0Crxb9knGulsZ+hqU0do5laNQCfpCKzO9h7DsY1yB/p66ZhkWMXDppZ0QC3c1vIMLjuynWuP4+TvapA9saj5tTO6+lZ+cI15S2fOT4F/lDpMK2NpZTYcu9YEcfVrehXVfyyev10EUaVLxFSXCQCkgp3m3jm+CBPTqEMUJWwTjNSj84A2xlIEN80NwAt0mLFG4BkBMmq3gVUQJVCKziY2t4Jsk4rsKYyfMfB3hbdA2i3JOT6IzA8Z90MrL70j1lVYmcNfukMt2hhLakCpUNh46M7WnMyGcg63q/zgQsh+giKCVGX/JK2WG+6heDJJF41iIjvtTHkgFWW9YolskBg1ejSLx0rUkuUDYK+aEV7Gr4wumQGuBSJCPHzG1Ai4rVNlb0bnUjT15kW3KDueNAJzqAHmlU1seeAwqHerRtuMIBC0ztUEiibCOtgv0z1VJl5gXHckcLLePiLwI/gGDqBrhirsJIVlZ1PbEyGyFJhm4hUEV9JATSaQlXb1/TmCvEotZfuV2mhauLIoADNiGCbdxX9Z6ksNizW+T1LSybtt+v4KBUZFlPVeOxg8zPV1SYEiDQJmMxBA2SVmuk3XlfXZ2hJrnfsKZXqpgiCqQ3MhH0yivbWxBtg2q4f6PAb8zX3+cJVHRewakqoo2acnYIXL1y77fk552nW6Yuw6Nm2BJ8Bz+HC3LpXg5jA5odIYYM1GgmcOXAAxtEnKA9ubfQfLAYNUOrkYZLM2qQTDwDDQ4q5Rv40SoNDDa5otQdvuSA452MGcABuUaQ8VudCTmcZX7Jd2hidj5oC/57EgyM9tCZeM/6ZYlGkGYAyW8ifFSB/Avi0aSjfmsu0AhrRKY4c1fcogS7TKKyIyRsbfY864eu35dSda8EkvFQgZf+haCdSkfedumPa8hUebuh1fjiiksLB1CLBlNJef4N5v6abgTIFth+rXSn29azR3ORmX4jSm0mHh462li72U+rh9JnuCDs87EGyH86BVRmRZiBzHjz+rdk9/lYKEk0V4Cnh7oe37VU4Y+1CaSZnxWSSuVcOtHIQUb+XHxJgSHWV7711PKak9784xDueazk97jdbwHCjtU96yOOAHsFzLAym2D03YCMCbKveX8OFrLexAcwKLiPZZnePKRhDt9tmfKoiKK6xq3UvQIEzUOyXovHjFyoxUXTWxmemhQ== 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)(366016)(1800799024)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LdYXle9AHj6RQGaWG3zKaiEfnsykRWIkxuFATDuE7Exm1QQczv9HICwe6tYFsQ1fdaqAD9y/aJxt52/nz7QKrPoG7r9+OBlqD9wGEHf5+XGVjHyvbVt9AfgwxQ5KGbIzi+LhLSQd9xVm6kONt62FPGRzYOsZ9H96dgm4GZ87f+aIN24hDBrb8TYVoxOKmg4bfQRkEasq5NEkTSYaBRwMSK+qaPFRemJdagEysU2j7jm97ilewTRvxWTaCCKWDewfLPYlxGDnm2x0EtkpdmtvgUxtqRif2w1RJByKo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WGx8iIf8lra1dZghh8CVSkgoWJRiUyWXS5J3GqXSYGX98JSlwQ8BYGTG1n95y/YqVVF8nhMBY0DLEZ2SXiQQN6rYoqBu6Z0xFBwe4J5vBg/cQjm4ItOhtbS8bXCkM05qTLqwkviDgzLCw+81q6n5CcsZlDxRwb2SjdRDCiZMyELZojv+n8+yXWbmZwm6W28QempnUjZcZ3/xUFt5IKqJTwrA9yziWEua2aEWu7qmDR679cQT7kA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc0aa76b-9d45-40fe-deec-08dcbcbe9726 X-MS-Exchange-CrossTenant-AuthSource: AM8PR04MB7779.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 00:09:54.6735 (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: ou02J6Kyp+e0j9M5ZY1n4UBjkyXrFYaVpaGaKXZXXHJdqqBHpGxoI9mNCguguXCOWiIBe6WWEI22GVxx5/06Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10285 X-Patchwork-Delegate: kuba@kernel.org I was revisiting the topic of 802.1ad treatment in the Ocelot switch [0] and realized that not only is its basic VLAN classification pipeline improper for offloading vlan_protocol 802.1ad bridges, but also improper for offloading regular 802.1Q bridges already. Namely, 802.1ad-tagged traffic should be treated as VLAN-untagged by bridged ports, but this switch treats it as if it was 802.1Q-tagged with the same VID as in the 802.1ad header. This is markedly different to what the Linux bridge expects; see the "other_tpid()" function in tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh. An idea came to me that the VCAP IS1 TCAM is more powerful than I'm giving it credit for, and that it actually overwrites the classified VID before the VLAN Table lookup takes place. In other words, it can be used even to save a packet from being dropped on ingress due to VLAN membership. Add a sophisticated TCAM rule hardcoded into the driver to force the switch to behave like a Linux bridge with vlan_filtering 1 vlan_protocol 802.1Q. Regarding the lifetime of the filter: eventually the bridge will disappear, and vlan_filtering on the port will be restored to 0 for standalone mode. Then the filter will be deleted. [0]: https://lore.kernel.org/netdev/20201009122947.nvhye4hvcha3tljh@skbuf/ Fixes: 7142529f1688 ("net: mscc: ocelot: add VLAN filtering") Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 188 ++++++++++++++++++++++-- drivers/net/ethernet/mscc/ocelot_vcap.c | 1 + include/soc/mscc/ocelot_vcap.h | 2 + 3 files changed, 180 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index f4e027a6fe95..3d72aa7b1305 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -453,9 +453,158 @@ static u16 ocelot_vlan_unaware_pvid(struct ocelot *ocelot, return VLAN_N_VID - bridge_num - 1; } +/** + * ocelot_update_vlan_reclassify_rule() - Make switch aware only to bridge VLAN TPID + * + * @ocelot: Switch private data structure + * @port: Index of ingress port + * + * IEEE 802.1Q-2018 clauses "5.5 C-VLAN component conformance" and "5.6 S-VLAN + * component conformance" suggest that a C-VLAN component should only recognize + * and filter on C-Tags, and an S-VLAN component should only recognize and + * process based on C-Tags. + * + * In Linux, as per commit 1a0b20b25732 ("Merge branch 'bridge-next'"), C-VLAN + * components are largely represented by a bridge with vlan_protocol 802.1Q, + * and S-VLAN components by a bridge with vlan_protocol 802.1ad. + * + * Currently the driver only offloads vlan_protocol 802.1Q, but the hardware + * design is non-conformant, because the switch assigns each frame to a VLAN + * based on an entirely different question, as detailed in figure "Basic VLAN + * Classification Flow" from its manual and reproduced below. + * + * Set TAG_TYPE, PCP, DEI, VID to port-default values in VLAN_CFG register + * if VLAN_AWARE_ENA[port] and frame has outer tag then: + * if VLAN_INNER_TAG_ENA[port] and frame has inner tag then: + * TAG_TYPE = (Frame.InnerTPID <> 0x8100) + * Set PCP, DEI, VID to values from inner VLAN header + * else: + * TAG_TYPE = (Frame.OuterTPID <> 0x8100) + * Set PCP, DEI, VID to values from outer VLAN header + * if VID == 0 then: + * VID = VLAN_CFG.VLAN_VID + * + * Summarized, the switch will recognize both 802.1Q and 802.1ad TPIDs as VLAN + * "with equal rights", and just set the TAG_TYPE bit to 0 (if 802.1Q) or to 1 + * (if 802.1ad). It will classify based on whichever of the tags is "outer", no + * matter what TPID that may have (or "inner", if VLAN_INNER_TAG_ENA[port]). + * + * In the VLAN Table, the TAG_TYPE information is not accessible - just the + * classified VID is - so it is as if each VLAN Table entry is for 2 VLANs: + * C-VLAN X, and S-VLAN X. + * + * Whereas the Linux bridge behavior is to only filter on frames with a TPID + * equal to the vlan_protocol, and treat everything else as VLAN-untagged. + * + * Consider an ingress packet tagged with 802.1ad VID=3 and 802.1Q VID=5, + * received on a bridge vlan_filtering=1 vlan_protocol=802.1Q port. This frame + * should be treated as 802.1Q-untagged, and classified to the PVID of that + * bridge port. Not to VID=3, and not to VID=5. + * + * The VCAP IS1 TCAM has everything we need to overwrite the choices made in + * the basic VLAN classification pipeline: it can match on TAG_TYPE in the key, + * and it can modify the classified VID in the action. Thus, for each port + * under a vlan_filtering bridge, we can insert a rule in VCAP IS1 lookup 0 to + * match on 802.1ad tagged frames and modify their classified VID to the 802.1Q + * PVID of the port. This effectively makes it appear to the outside world as + * if those packets were processed as VLAN-untagged. + * + * The rule needs to be updated each time the bridge PVID changes, and needs + * to be deleted if the bridge PVID is deleted, or if the port becomes + * VLAN-unaware. + */ +static int ocelot_update_vlan_reclassify_rule(struct ocelot *ocelot, int port) +{ + unsigned long cookie = OCELOT_VCAP_IS1_VLAN_RECLASSIFY(ocelot, port); + struct ocelot_vcap_block *block_vcap_is1 = &ocelot->block[VCAP_IS1]; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + const struct ocelot_bridge_vlan *pvid_vlan; + struct ocelot_vcap_filter *filter; + int err, val, pcp, dei; + bool vid_replace_ena; + u16 vid; + + pvid_vlan = ocelot_port->pvid_vlan; + vid_replace_ena = ocelot_port->vlan_aware && pvid_vlan; + + filter = ocelot_vcap_block_find_filter_by_id(block_vcap_is1, cookie, + false); + if (!vid_replace_ena) { + /* If the reclassification filter doesn't need to exist, delete + * it if it was previously installed, and exit doing nothing + * otherwise. + */ + if (filter) + return ocelot_vcap_filter_del(ocelot, filter); + + return 0; + } + + /* The reclassification rule must apply. See if it already exists + * or if it must be created. + */ + + /* Treating as VLAN-untagged means using as classified VID equal to + * the bridge PVID, and PCP/DEI set to the port default QoS values. + */ + vid = pvid_vlan->vid; + val = ocelot_read_gix(ocelot, ANA_PORT_QOS_CFG, port); + pcp = ANA_PORT_QOS_CFG_QOS_DEFAULT_VAL_X(val); + dei = !!(val & ANA_PORT_QOS_CFG_DP_DEFAULT_VAL); + + if (filter) { + bool changed = false; + + /* Filter exists, just update it */ + if (filter->action.vid != vid) { + filter->action.vid = vid; + changed = true; + } + if (filter->action.pcp != pcp) { + filter->action.pcp = pcp; + changed = true; + } + if (filter->action.dei != dei) { + filter->action.dei = dei; + changed = true; + } + + if (!changed) + return 0; + + return ocelot_vcap_filter_replace(ocelot, filter); + } + + /* Filter doesn't exist, create it */ + filter = kzalloc(sizeof(*filter), GFP_KERNEL); + if (!filter) + return -ENOMEM; + + filter->key_type = OCELOT_VCAP_KEY_ANY; + filter->ingress_port_mask = BIT(port); + filter->vlan.tpid = OCELOT_VCAP_BIT_1; + filter->prio = 1; + filter->id.cookie = cookie; + filter->id.tc_offload = false; + filter->block_id = VCAP_IS1; + filter->type = OCELOT_VCAP_FILTER_OFFLOAD; + filter->lookup = 0; + filter->action.vid_replace_ena = true; + filter->action.pcp_dei_ena = true; + filter->action.vid = vid; + filter->action.pcp = pcp; + filter->action.dei = dei; + + err = ocelot_vcap_filter_add(ocelot, filter, NULL); + if (err) + kfree(filter); + + return err; +} + /* Default vlan to clasify for untagged frames (may be zero) */ -static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, - const struct ocelot_bridge_vlan *pvid_vlan) +static int ocelot_port_set_pvid(struct ocelot *ocelot, int port, + const struct ocelot_bridge_vlan *pvid_vlan) { struct ocelot_port *ocelot_port = ocelot->ports[port]; u16 pvid = ocelot_vlan_unaware_pvid(ocelot, ocelot_port->bridge); @@ -475,15 +624,23 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, * happens automatically), but also 802.1p traffic which gets * classified to VLAN 0, but that is always in our RX filter, so it * would get accepted were it not for this setting. + * + * Also, we only support the bridge 802.1Q VLAN protocol, so + * 802.1ad-tagged frames (carrying S-Tags) should be considered + * 802.1Q-untagged, and also dropped. */ if (!pvid_vlan && ocelot_port->vlan_aware) val = ANA_PORT_DROP_CFG_DROP_PRIO_S_TAGGED_ENA | - ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA; + ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA | + ANA_PORT_DROP_CFG_DROP_S_TAGGED_ENA; ocelot_rmw_gix(ocelot, val, ANA_PORT_DROP_CFG_DROP_PRIO_S_TAGGED_ENA | - ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA, + ANA_PORT_DROP_CFG_DROP_PRIO_C_TAGGED_ENA | + ANA_PORT_DROP_CFG_DROP_S_TAGGED_ENA, ANA_PORT_DROP_CFG, port); + + return ocelot_update_vlan_reclassify_rule(ocelot, port); } static struct ocelot_bridge_vlan *ocelot_bridge_vlan_find(struct ocelot *ocelot, @@ -631,7 +788,10 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, ANA_PORT_VLAN_CFG_VLAN_POP_CNT_M, ANA_PORT_VLAN_CFG, port); - ocelot_port_set_pvid(ocelot, port, ocelot_port->pvid_vlan); + err = ocelot_port_set_pvid(ocelot, port, ocelot_port->pvid_vlan); + if (err) + return err; + ocelot_port_manage_port_tag(ocelot, port); return 0; @@ -684,9 +844,12 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, return err; /* Default ingress vlan classification */ - if (pvid) - ocelot_port_set_pvid(ocelot, port, - ocelot_bridge_vlan_find(ocelot, vid)); + if (pvid) { + err = ocelot_port_set_pvid(ocelot, port, + ocelot_bridge_vlan_find(ocelot, vid)); + if (err) + return err; + } /* Untagged egress vlan clasification */ ocelot_port_manage_port_tag(ocelot, port); @@ -712,8 +875,11 @@ int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) return err; /* Ingress */ - if (del_pvid) - ocelot_port_set_pvid(ocelot, port, NULL); + if (del_pvid) { + err = ocelot_port_set_pvid(ocelot, port, NULL); + if (err) + return err; + } /* Egress */ ocelot_port_manage_port_tag(ocelot, port); @@ -2607,7 +2773,7 @@ int ocelot_port_set_default_prio(struct ocelot *ocelot, int port, u8 prio) ANA_PORT_QOS_CFG, port); - return 0; + return ocelot_update_vlan_reclassify_rule(ocelot, port); } EXPORT_SYMBOL_GPL(ocelot_port_set_default_prio); diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c index 73cdec5ca6a3..5734b86aed5b 100644 --- a/drivers/net/ethernet/mscc/ocelot_vcap.c +++ b/drivers/net/ethernet/mscc/ocelot_vcap.c @@ -695,6 +695,7 @@ static void is1_entry_set(struct ocelot *ocelot, int ix, vcap_key_bit_set(vcap, &data, VCAP_IS1_HK_L2_MC, filter->dmac_mc); vcap_key_bit_set(vcap, &data, VCAP_IS1_HK_L2_BC, filter->dmac_bc); vcap_key_bit_set(vcap, &data, VCAP_IS1_HK_VLAN_TAGGED, tag->tagged); + vcap_key_bit_set(vcap, &data, VCAP_IS1_HK_TPID, tag->tpid); vcap_key_set(vcap, &data, VCAP_IS1_HK_VID, tag->vid.value, tag->vid.mask); vcap_key_set(vcap, &data, VCAP_IS1_HK_PCP, diff --git a/include/soc/mscc/ocelot_vcap.h b/include/soc/mscc/ocelot_vcap.h index c601a4598b0d..eb19668a06db 100644 --- a/include/soc/mscc/ocelot_vcap.h +++ b/include/soc/mscc/ocelot_vcap.h @@ -13,6 +13,7 @@ */ #define OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream) ((upstream) << 16 | (port)) #define OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port) (port) +#define OCELOT_VCAP_IS1_VLAN_RECLASSIFY(ocelot, port) ((ocelot)->num_phys_ports + (port)) #define OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port) (port) #define OCELOT_VCAP_IS2_MRP_REDIRECT(ocelot, port) ((ocelot)->num_phys_ports + (port)) #define OCELOT_VCAP_IS2_MRP_TRAP(ocelot) ((ocelot)->num_phys_ports * 2) @@ -499,6 +500,7 @@ struct ocelot_vcap_key_vlan { struct ocelot_vcap_u8 pcp; /* PCP (3 bit) */ enum ocelot_vcap_bit dei; /* DEI */ enum ocelot_vcap_bit tagged; /* Tagged/untagged frame */ + enum ocelot_vcap_bit tpid; }; struct ocelot_vcap_key_etype {