From patchwork Thu May 18 11:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13246582 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 7F96019902 for ; Thu, 18 May 2023 11:35:06 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2067.outbound.protection.outlook.com [40.107.244.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F64EA for ; Thu, 18 May 2023 04:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5+siAzCthcTavXpUzTlRIfv9lK2vlxLYZOgC/sG/pHKeJL/OuV+kXbMc3ehlVa7C33MDn7EoA8qB3V3WpcpgXqvXuM6rTi+c7Zr2bl2CKaNDJX5alv0TCHDz6yT+8uXchzNWBYWJc9145HpOJHTxar4TE6xCqV2N56KywCcnwK2XpVa0p7uS8zp5qpCP3dBKM/MWczJL4fNmfqLKcQkMj9u2KMwSEN1PhxMt3wMvOg0AgABiMRzJsJfBl0uX/y+aEITJWP9TgpHKXvenZVqpYg2qtWOO6Ju29XQ9L96LeFCpnfNLjglWZV/gBI5xr/5jkUABtqj/Jq7ac4S+IeBkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=3U0gVe0IZp8tb/PBmr/db2c4m/Qqc+y3KMkhyWl8Pb4=; b=msPIRXUEDwF4EAS/HLmix9yIo+g8wjiF652qiTfphN7mEII70t8fqdECrZ7zOSHFMWOiQXyek6K5mpxmNxH4FDK9BqyCvceETMT6l/E0Y1d+jzR68o0qwGTOJYbTtRuMButRPfuqMI6EYycYpxeg7KsfN4EcishqnjbYC7Nr73LEXER8kkGiD5zvBAS8DpD/rhOIgq5DjNd7Gnj+wzjZKcAZM763UCMdmON5GVQWaUgyp/WHbUhCdKQhaieK/Cx4iC1K6JVB7RnIJ1WfqEJglZcHNppm6ecb56d6du5IZgx0QVzXldIDgcm6OGXYJ0fRCNIv55zNiKSMl413/oBYOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3U0gVe0IZp8tb/PBmr/db2c4m/Qqc+y3KMkhyWl8Pb4=; b=dD30uOvtgcboI6ksNr7TUMMsbNCzlt5uIstkhUrO6oWaD+vOhFlWT8Bj+PTH+Lprjndn5rfRrzp4aEtmwUlHHTdAn/qDQEq+Ua4mfPqXD3GHBWkutjzj4P3x7OSvn3/Yb36HgfkPubaMuMJTI6dchKm452xdtGOpT3lAEZ33Vw5VhYV4guAryeADz437Rc9AttELQ5keu1ela6zCiCg8UouPaQc/cC5Qdx474/EwEvevfL66yS8R+Ju/YDTgacQv0KE/1wLSpQTeTH/JtzA4NRUo3F0r2XbAcv/AKFS7o5AFRsyJVRnuf4hmQ6TC9jp8SIDQxPRjYprhh0b51Smh6A== Received: from SJ0PR13CA0085.namprd13.prod.outlook.com (2603:10b6:a03:2c4::30) by PH7PR12MB5951.namprd12.prod.outlook.com (2603:10b6:510:1da::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Thu, 18 May 2023 11:34:57 +0000 Received: from DM6NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:2c4:cafe::e0) by SJ0PR13CA0085.outlook.office365.com (2603:10b6:a03:2c4::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Thu, 18 May 2023 11:34:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT113.mail.protection.outlook.com (10.13.173.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 11:34:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 04:34:44 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 04:34:39 -0700 From: Ido Schimmel To: , CC: , , , , , , , , , , , , , , , , , , Ido Schimmel Subject: [PATCH net-next 1/5] skbuff: bridge: Add layer 2 miss indication Date: Thu, 18 May 2023 14:33:24 +0300 Message-ID: <20230518113328.1952135-2-idosch@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518113328.1952135-1-idosch@nvidia.com> References: <20230518113328.1952135-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT113:EE_|PH7PR12MB5951:EE_ X-MS-Office365-Filtering-Correlation-Id: 264d6f83-806a-48f6-0fd5-08db5793e869 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: laprFPTvKpNxUMZS3qdNJRjFAjijm70xsr8UBrn4pbMMhQyktXGRauGtNVUr6JzlJBnNCcVd9YEdQp5rbvu8cSZUrMLr/3vPa687KuzaatP81j6ZHJ0bxQnR9MWx+DLVqvDXhvXMJ2641+R6sqkUmf3uBTafRohC6Ef0sj+e3lod+bq7zkkO6bOIa7bn86FATKGYQpGQSnzBYZ7kuf3DWKvbPXGiotx16ZGVYx1K5+ga7ntmGwLyHnupHHfuHZ2m8hFc4T3Z0+J0x9Z9iURbsDW0XSHQZZlbpjddQRVsXJAaNHD2BQeG0sH+DigO6tqNfArgvRouUq2qkgX9X1ophKED8cx3wV34jTuBTV/r+1Tt1zyg4mDJDafOy1+TJK8HaKYSppE0vMcCe20gEcYe/R9sSNv4kpllfr+GWYWWHY5YpsUihfxt4qbko6duG4Nig1LLYmgo1tk/M1dzc9TsgopwUc6JDklP3j12GiFINyb3pky2IohNU6BWjZH4q+c+wTwqmV/Wts6KSGrR33qJioQbQmsadQdJFByFSMoSTguiNaoTsz4NXRtocxGn5NyOjEA9HTxqeXhkvKZPhCiXdhSCalZdVLcdYFLdkq2hRHcYtwMaNzjQPHayYnsEIOQdQu/zTR1ZUyw5DtAZF4scxOtxHv+bWeC7Lm7kWfbONoYyTl32KFz9zOu8U7DJsiUT93/h0VuhXjsyT989QFV+HeH44YIU86X7wQouds47TyuHreOOXOmDk8j+uXTjqW/VIYDg76ce017vEDYvVQ9E9Q== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199021)(46966006)(40470700004)(36840700001)(83380400001)(36860700001)(336012)(47076005)(426003)(70586007)(70206006)(26005)(8676002)(107886003)(2616005)(40460700003)(40480700001)(478600001)(54906003)(5660300002)(110136005)(7416002)(36756003)(186003)(6666004)(1076003)(16526019)(86362001)(8936002)(82740400003)(41300700001)(316002)(2906002)(356005)(7636003)(4326008)(82310400005)(21314003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:34:57.2659 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 264d6f83-806a-48f6-0fd5-08db5793e869 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5951 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Allow the bridge driver to mark packets that did not match a layer 2 entry during forwarding by adding a 'l2_miss' bit to the skb. Clear the bit whenever a packet enters the bridge (received from a bridge port or transmitted via the bridge) and set it if the packet did not match an FDB/MDB entry. Subsequent patches will allow the flower classifier to match on this bit. The motivating use case in non-DF (Designated Forwarder) filtering where we would like to prevent decapsulated packets from being flooded to a multi-homed host. Do not allocate the bit if the kernel was not compiled with bridge support and place it after the two bit fields in accordance with commit 4c60d04c2888 ("net: skbuff: push nf_trace down the bitfield"). The bit does not increase the size of the structure as it is placed at an existing hole. Layout with allmodconfig: struct sk_buff { [...] __u8 csum_not_inet:1; /* 132: 3 1 */ __u8 l2_miss:1; /* 132: 4 1 */ /* XXX 3 bits hole, try to pack */ /* XXX 1 byte hole, try to pack */ __u16 tc_index; /* 134 2 */ u16 alloc_cpu; /* 136 2 */ [...] } __attribute__((__aligned__(8))); Signed-off-by: Ido Schimmel --- include/linux/skbuff.h | 4 ++++ net/bridge/br_device.c | 1 + net/bridge/br_forward.c | 3 +++ net/bridge/br_input.c | 1 + 4 files changed, 9 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8cff3d817131..b64dc3f62c5c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -801,6 +801,7 @@ typedef unsigned char *sk_buff_data_t; * @encap_hdr_csum: software checksum is needed * @csum_valid: checksum is already valid * @csum_not_inet: use CRC32c to resolve CHECKSUM_PARTIAL + * @l2_miss: Packet did not match an L2 entry during forwarding * @csum_complete_sw: checksum was completed by software * @csum_level: indicates the number of consecutive checksums found in * the packet minus one that have been verified as @@ -991,6 +992,9 @@ struct sk_buff { #if IS_ENABLED(CONFIG_IP_SCTP) __u8 csum_not_inet:1; #endif +#if IS_ENABLED(CONFIG_BRIDGE) + __u8 l2_miss:1; +#endif #ifdef CONFIG_NET_SCHED __u16 tc_index; /* traffic control index */ diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 8eca8a5c80c6..91dbdae4afd4 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -39,6 +39,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) u16 vid = 0; memset(skb->cb, 0, sizeof(struct br_input_skb_cb)); + skb->l2_miss = 0; rcu_read_lock(); nf_ops = rcu_dereference(nf_br_ops); diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 84d6dd5e5b1a..8cf5a51489ce 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -203,6 +203,8 @@ void br_flood(struct net_bridge *br, struct sk_buff *skb, struct net_bridge_port *prev = NULL; struct net_bridge_port *p; + skb->l2_miss = 1; + list_for_each_entry_rcu(p, &br->port_list, list) { /* Do not flood unicast traffic to ports that turn it off, nor * other traffic if flood off, except for traffic we originate @@ -295,6 +297,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, allow_mode_include = false; } else { p = NULL; + skb->l2_miss = 1; } while (p || rp) { diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index fc17b9fd93e6..d8ab5890cbe6 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -334,6 +334,7 @@ static rx_handler_result_t br_handle_frame(struct sk_buff **pskb) return RX_HANDLER_CONSUMED; memset(skb->cb, 0, sizeof(struct br_input_skb_cb)); + skb->l2_miss = 0; p = br_port_get_rcu(skb->dev); if (p->flags & BR_VLAN_TUNNEL) From patchwork Thu May 18 11:33:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13246583 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 C96891951E for ; Thu, 18 May 2023 11:35:09 +0000 (UTC) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2054.outbound.protection.outlook.com [40.107.92.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2F51BE9 for ; Thu, 18 May 2023 04:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vaj/4nCQWxWCLLlR23EBbylC4gEViAzpqfUceDmKQaEq94Ct/kQBeXZCbdMU4G/XsfRuJI861SKH9Wl+JpEqPKGQyIPAeJxe16qEuGHMYO49fMqWkXg1oqM9VI9+1S32PYrqBvYAoLX3wXb0nBhzSsdaSETqJxg0lUKaKgPcU1mGfIPCwTFDJS+5jl63wmeqWO/3uZxyfd7b+gK3ct/g9yaUSgtU3pWGoGcxmIr7QvOYifoXv6mOmqsFA/UDJB55SNQrV2iSWJGVY8Kpi3JmS9OgGQj8J+3NX4aqUuasnCVkBCwnVcB4gdB163vrQqblpPIQ8wToltxe/hK3B6OLUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=+JC35ro7zE3aai5AM0voSy7JdBNhtLPukhKGob/b1U8=; b=MXamLXvqwJ4j+mbT8FaVOPDcBdeko1wqTo148DTXQMbduZhvLZqT44xZyTl63i4LAvGLnPAxGsFJKsvLgvdpcw65ZSFr/7kCChQiWD/9g2OaEAP1Mhx16MeGw9zqcnEJxqsaPMUnDNq+/CFQFflNcAQ0XsHH19MG+1pq4JHYmSlMuLkRiMj7w6j79zY4zmW1HLcq8gbzzFKTSna5ICWFZVzgpv+mSLATPsZYLEgqzuZwgdMbJwr++9fpsWk6RFtF93QnY4oGROZRzEMbYf53S5p2XAarJHjBYjVLfEVo+IEJY3Lzowu3z4hjmLgkg8x9FOB3V1cFldLEOHGH/iF4vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+JC35ro7zE3aai5AM0voSy7JdBNhtLPukhKGob/b1U8=; b=PD5KM6M5a19NG6lbjWIAEmCx78V/0EddY/sUNx8BhAklWblxipqdfPhEK/f4/bj/N6gQh1lVra1d40PaP7ud4IzIJR5azEy6GTI6GOC3+lcZ13lAahuObMnTs3ymu7xsABto5t/j2gNd8XMdEWymi/VzKTIHhjC3ChPFyxBg5gOVT4bUVEU3LmnQxxJ/U3s+DXHa5eA5ucU4A+LpylSBXVeNlLXF9TS9ye6iyq9vezIxQJFdNBI1iYHn5T8X+heGYp7Xj5bsa+Oqyx0BRhHBajjRikU4gj7LLyMDRSsmj5fQ7sGX7MYU205yA0QUccf90+zq7hqH0HaLQs91vZ3pWA== Received: from SJ0PR13CA0061.namprd13.prod.outlook.com (2603:10b6:a03:2c4::6) by DM4PR12MB6398.namprd12.prod.outlook.com (2603:10b6:8:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 11:35:01 +0000 Received: from DM6NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:2c4:cafe::e5) by SJ0PR13CA0061.outlook.office365.com (2603:10b6:a03:2c4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Thu, 18 May 2023 11:35:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT113.mail.protection.outlook.com (10.13.173.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 11:35:00 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 04:34:50 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 04:34:45 -0700 From: Ido Schimmel To: , CC: , , , , , , , , , , , , , , , , , , Ido Schimmel Subject: [PATCH net-next 2/5] net/sched: flower: Allow matching on layer 2 miss Date: Thu, 18 May 2023 14:33:25 +0300 Message-ID: <20230518113328.1952135-3-idosch@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518113328.1952135-1-idosch@nvidia.com> References: <20230518113328.1952135-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT113:EE_|DM4PR12MB6398:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a0027a2-6221-48b5-6882-08db5793ea4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eS3V7MrIuFpXJwdVrXpAJRgeN3LGcGJ0FnVGnBfi6iNPWhped8XejwGYxSneA92miCFhJEckvMmtyFVBW9KtJCpiuYQo/xFbqAnDCJL7aeUkTKWV6DTExMMhafxapSG6QN7SIoLO5ga5pGZDUoIWsJ7F9qOJM0NYW+dJDiaDSJIl6B01ylJ5uDZYvAEuIUFH1M0SjRWlXL1oCn2QkU8Dt1NP0EL1FYSHb3eo/bPeAnH6Da8kMoaw+eTrxPKdLeL7mHGuBNTwT0zeQnhoJsLMom8yNvJRxjr6ED/TFiw1yEqdet5IqgPJMhaLZsnUEmj0IMnYSB4GEJAUtVjbBIpRzj6P2wYPzf86yBPRfhCtfTFaa8MLp+eK0xPAyzs/iU9KDeCfn4q0e4AmaNq9bCmnyXostDUhzQ5fGFpqkALQRfzrbB+r7DH/+CplY4Ue1srnWUlesV0q9O0mTuLDA2OG/ZUr20nE0yP9W7GC2DSZU9Vz9FEHFFwSgsaaWXAcaXsx34qECskH3ykRWAbYM4zwQZb6QxOdgrTKkA2XY7CTzikpik/XTTCpRHyLopXNTz2Fe99FfqnZcraU5kmaDYXpi8lkvtzbsf1qK34rZ0wryGuemZAf65pkwbpxWiJB9FbFcZjNhE0fZGLxOhr3swZSGGscjo5HpEWh7tGqQzghnwRozY8biGS6jkpCVhHlM1hDRHRxCKs5q/P+tSUVZ3JTttecPeX2ICTo6c996INUAqH5VjYapOz5QKRcbHzQ+DH0 X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(70586007)(4326008)(316002)(70206006)(54906003)(110136005)(36756003)(86362001)(478600001)(26005)(83380400001)(47076005)(107886003)(1076003)(16526019)(186003)(36860700001)(336012)(2616005)(6666004)(426003)(8936002)(8676002)(2906002)(7416002)(5660300002)(40480700001)(82310400005)(7636003)(82740400003)(356005)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:35:00.4532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a0027a2-6221-48b5-6882-08db5793ea4f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6398 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add the 'TCA_FLOWER_L2_MISS' netlink attribute that allows user space to match on packets that encountered a layer 2 miss. The miss indication is set as metadata in the skb by the bridge driver upon FDB/MDB lookup miss. Signed-off-by: Ido Schimmel Reviewed-by: Simon Horman --- include/net/flow_dissector.h | 2 ++ include/uapi/linux/pkt_cls.h | 2 ++ net/core/flow_dissector.c | 3 +++ net/sched/cls_flower.c | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h index 85b2281576ed..8b41668c77fc 100644 --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -243,10 +243,12 @@ struct flow_dissector_key_ip { * struct flow_dissector_key_meta: * @ingress_ifindex: ingress ifindex * @ingress_iftype: ingress interface type + * @l2_miss: packet did not match an L2 entry during forwarding */ struct flow_dissector_key_meta { int ingress_ifindex; u16 ingress_iftype; + u8 l2_miss; }; /** diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index 648a82f32666..00933dda7b10 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -594,6 +594,8 @@ enum { TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ + TCA_FLOWER_L2_MISS, /* u8 */ + __TCA_FLOWER_MAX, }; diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 25fb0bbc310f..3776c7bdd228 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -241,6 +241,9 @@ void skb_flow_dissect_meta(const struct sk_buff *skb, FLOW_DISSECTOR_KEY_META, target_container); meta->ingress_ifindex = skb->skb_iif; +#if IS_ENABLED(CONFIG_BRIDGE) + meta->l2_miss = skb->l2_miss; +#endif } EXPORT_SYMBOL(skb_flow_dissect_meta); diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 9dbc43388e57..4eb06c6367fc 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -615,7 +615,8 @@ static void *fl_get(struct tcf_proto *tp, u32 handle) } static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = { - [TCA_FLOWER_UNSPEC] = { .type = NLA_UNSPEC }, + [TCA_FLOWER_UNSPEC] = { .strict_start_type = + TCA_FLOWER_L2_MISS }, [TCA_FLOWER_CLASSID] = { .type = NLA_U32 }, [TCA_FLOWER_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ }, @@ -720,7 +721,7 @@ static const struct nla_policy fl_policy[TCA_FLOWER_MAX + 1] = { [TCA_FLOWER_KEY_PPPOE_SID] = { .type = NLA_U16 }, [TCA_FLOWER_KEY_PPP_PROTO] = { .type = NLA_U16 }, [TCA_FLOWER_KEY_L2TPV3_SID] = { .type = NLA_U32 }, - + [TCA_FLOWER_L2_MISS] = NLA_POLICY_MAX(NLA_U8, 1), }; static const struct nla_policy @@ -1668,6 +1669,10 @@ static int fl_set_key(struct net *net, struct nlattr **tb, mask->meta.ingress_ifindex = 0xffffffff; } + fl_set_key_val(tb, &key->meta.l2_miss, TCA_FLOWER_L2_MISS, + &mask->meta.l2_miss, TCA_FLOWER_UNSPEC, + sizeof(key->meta.l2_miss)); + fl_set_key_val(tb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST, mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK, sizeof(key->eth.dst)); @@ -3074,6 +3079,11 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net, goto nla_put_failure; } + if (fl_dump_key_val(skb, &key->meta.l2_miss, + TCA_FLOWER_L2_MISS, &mask->meta.l2_miss, + TCA_FLOWER_UNSPEC, sizeof(key->meta.l2_miss))) + goto nla_put_failure; + if (fl_dump_key_val(skb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST, mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK, sizeof(key->eth.dst)) || From patchwork Thu May 18 11:33:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13246584 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 C58E219932 for ; Thu, 18 May 2023 11:35:10 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 451C219A5 for ; Thu, 18 May 2023 04:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hdt18Mbr3eNz6zJvtuUtShg/iXUwm9HFWkP7YrYbYiJ+wCg6y10cay4OBkltWeG+4Z6aWfsYxibDcuAPrtLjq3BcqJ0Uyprpeqxt8KD8xt5W+EqRyBCdp1c6Nw4oEFRIp2q4+y6ntpQcVVEKgKbsNN3P3OsjSs1nezxACBWxrTQHb9D1eHRiGB9+ILWz6Dw6y7PJcyLClN5AdEJWrawyowch8RqQU7f1jcTzp89SzeB99PUTymnYqVA/++ntdP/6KOoaGZQA9zmYF45y8VgUY/SzGmjOCcb4auZ6F3bZIa1pu7wJwlOjnn9M/j6RxaLyOaP5ktT7KWt6PZifOA/zXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=nruIgm4v7mpElLZK3vX2XDPG6wn+168Lo+vJlkqbJmg=; b=VGPWJf0ltDfOjrbnq6Xb3dY4nmw00Z4HgRWA1dCAD87rDrd2TCSF9e5bchEyaOVbQQ8bBRgzN2nvFTMt9DKrgO3fLWItyf1jq6IjQJcrOoyju7je7sjj/WFzckkhoCmX4bBUW9QcBHMrkXNRoJirt7uFEuF2q4viszYNDLtmio5WRSSdQF0RtJiSF8U1Zg7SJA4Glc9BE3DA+okqY5Fh+S2xgJKrrwALJwN84MqLTezM0frEXEf+8AbJqJLe3c4qSn/zj/6ZlKMNTjgHLTD5hPsIzXRcS2l3AjQ3N8ZNCSfIT6dEN05QcutT6OU0MrOyvD1DamgsyLYaPs8GYPnsLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nruIgm4v7mpElLZK3vX2XDPG6wn+168Lo+vJlkqbJmg=; b=WsFPXonT23gA9HSwHacsCmopa5QKKTeVP5pV65CwdmEY5phsDO5Z+gv5TzjqjM/b+KoeD5+4y3COMoslyvEsfaz8CCpdSUcVEKlzn2Z6z0YkNv44wA8O786hoeCv93LA2F58lvZjOnqTIv6NTa2HbjE4JTi01Lhv1RWyfd4jq6XZ33BpLPn7WZgkkEzkW9w8KwQaTRsXGs1+G2tVUvvoxCVDm/Enz4LbjZHyq0Dme5bvB7x3/dbKISshthgpELLNpCHy0JJ1cl7hxuYqJ/LX9NDOTHB4WFWaVVfYjVF4qT1Ylsb/tQj7QVb//uOEIT1m0eimXEDD0y8xTvHU2vPtrA== Received: from MW4PR04CA0195.namprd04.prod.outlook.com (2603:10b6:303:86::20) by MN0PR12MB5931.namprd12.prod.outlook.com (2603:10b6:208:37e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Thu, 18 May 2023 11:35:01 +0000 Received: from CO1NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::4) by MW4PR04CA0195.outlook.office365.com (2603:10b6:303:86::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 11:35:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT064.mail.protection.outlook.com (10.13.175.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.15 via Frontend Transport; Thu, 18 May 2023 11:35:00 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 04:34:55 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 04:34:50 -0700 From: Ido Schimmel To: , CC: , , , , , , , , , , , , , , , , , , Ido Schimmel Subject: [PATCH net-next 3/5] flow_offload: Reject matching on layer 2 miss Date: Thu, 18 May 2023 14:33:26 +0300 Message-ID: <20230518113328.1952135-4-idosch@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518113328.1952135-1-idosch@nvidia.com> References: <20230518113328.1952135-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT064:EE_|MN0PR12MB5931:EE_ X-MS-Office365-Filtering-Correlation-Id: 218a5ce5-770c-412b-68f4-08db5793ea6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q+9ymGGY2IWmaiKqPfuB9mYchsImiJ5qTU+1lLVcp6Kpsp5XvFxo+mCCNauGocafO1iLHIEcOcfbNp/e8YrAjg9F+9IRypVGq4NKyftW4UVQfGmT45wflNPb/lKj+BYcbafIngAh+W2lPt2y6lVsrvh6AhUWhsDs0UJttXQ+8pYkqFAF9L4A3f3A8wu/Vdl+ezwXrZc+OhkHzaUD5m53BDEmB2gchKASMFnPXfCc/aohv9nFfgmGOICjchfX9INhjcHbxvRvSXjLFdJI8Ux0YwNFF9MD/lryNLdoPEvnl+I9sJFZgj8/po8xw93e6H3I1UcTne9Kp7qSIWPelYKtRbQBp5DzoDMxNTkMbh1d/2/G3IC/AN5WPl81gO580Y+3hn+vmED67YpzNUAAyeINVVhP1N87VrG9dTIf+BKYuEdcLN33ntKCXAFtd1laOpgDJDtkeVxLVkrw2cWpUd94ecvhQIQOXVicBp+kd6RlU730yk3MF4NHHp6WFQE+KmkV+7gjpzvKCmY+28vSCizPouzxeBrTF39lUrv3ygukfPBhbBeHDp5za65ZSwyRBWeo18JPiSL6l6Jmv4patSrBi9j/pMRKHRGIiagCjIpxnwiCCyIs3Wfse1v9YCxcNWSD2DLhVACE/d+/UzXgZAoFZpETpjCgwCfmDMj383842j3eUZI3EaxNkPD3Vs0boXawOgyoCm2oKHXeLC/bW3QzTEEoKQ7HrfaBnfTPdH9v1XQdxufGyvLzRPj7eQ04EeQh X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199021)(46966006)(40470700004)(36840700001)(86362001)(356005)(40460700003)(2906002)(41300700001)(7636003)(316002)(5660300002)(8676002)(7416002)(36756003)(82310400005)(8936002)(478600001)(6666004)(36860700001)(26005)(1076003)(336012)(107886003)(186003)(16526019)(426003)(54906003)(2616005)(40480700001)(83380400001)(110136005)(70206006)(4326008)(47076005)(70586007)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:35:00.6146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 218a5ce5-770c-412b-68f4-08db5793ea6a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5931 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Adjust drivers that support the 'FLOW_DISSECTOR_KEY_META' key to reject filters that try to match on the newly added layer 2 miss option. Add an extack message to clearly communicate the failure reason to user space. Example: # tc filter add dev swp1 egress pref 1 proto all flower skip_sw l2_miss true action drop Error: mlxsw_spectrum: Can't match on "l2_miss". We have an error talking to the kernel Acked-by: Elad Nachman Signed-off-by: Ido Schimmel --- .../net/ethernet/marvell/prestera/prestera_flower.c | 6 ++++++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 6 ++++++ drivers/net/ethernet/mscc/ocelot_flower.c | 10 ++++++++++ 4 files changed, 28 insertions(+) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c index 91a478b75cbf..3e20e71b0f81 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c @@ -148,6 +148,12 @@ static int prestera_flower_parse_meta(struct prestera_acl_rule *rule, __be16 key, mask; flow_rule_match_meta(f_rule, &match); + + if (match.mask->l2_miss) { + NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on \"l2_miss\""); + return -EOPNOTSUPP; + } + if (match.mask->ingress_ifindex != 0xFFFFFFFF) { NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported ingress ifindex mask"); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 728b82ce4031..516653568330 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -2586,6 +2586,12 @@ static int mlx5e_flower_parse_meta(struct net_device *filter_dev, return 0; flow_rule_match_meta(rule, &match); + + if (match.mask->l2_miss) { + NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on \"l2_miss\""); + return -EOPNOTSUPP; + } + if (!match.mask->ingress_ifindex) return 0; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index 594cdcb90b3d..6fec9223250b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -294,6 +294,12 @@ static int mlxsw_sp_flower_parse_meta(struct mlxsw_sp_acl_rule_info *rulei, return 0; flow_rule_match_meta(rule, &match); + + if (match.mask->l2_miss) { + NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on \"l2_miss\""); + return -EOPNOTSUPP; + } + if (match.mask->ingress_ifindex != 0xFFFFFFFF) { NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported ingress ifindex mask"); return -EINVAL; diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index ee052404eb55..e0916afcddfb 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -592,6 +592,16 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress, return -EOPNOTSUPP; } + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_META)) { + struct flow_match_meta match; + + flow_rule_match_meta(rule, &match); + if (match.mask->l2_miss) { + NL_SET_ERR_MSG_MOD(extack, "Can't match on \"l2_miss\""); + return -EOPNOTSUPP; + } + } + /* For VCAP ES0 (egress rewriter) we can match on the ingress port */ if (!ingress) { ret = ocelot_flower_parse_indev(ocelot, port, f, filter); From patchwork Thu May 18 11:33:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13246587 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 64B1419524 for ; Thu, 18 May 2023 11:35:21 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::60d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEF271A7 for ; Thu, 18 May 2023 04:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdJq3WdxGqRi/VeZIZFMaTgy61vKF6Pp+RSejZkJp2so6wEvUpYKofy3ngVg/XZUpT1Q5PPz2JoOP+r+hMi+/0KBa3C9hZBT5S8zF8A7Yhv6q0caPWjDvnHJCa/8Tya63g4bKCOnoWfE3j4vWcma0eDiB4uBVgo7kP84oRVDJ7+Z5MF++qkcGG9nUuHycz1AoQO8DOw9s2ZLDjEedKNVA1HgyCsnPmcmTybWrv34wB3pqOxfI1wJWv/QgXRrciIZmzlBFqkNl9okNtd80oKuMgoynzo8Fm9oK1r+g7HQok7eSP2fWTpTg8w2NKWVemoPEkvD66pf+FoxHjsZ3ROWgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=HzVsWpsxg8gzs1LvHZ7mKUQ5piBodmCsbCSwsQDlS6Y=; b=Eggd82NA/LdYTWv8eVcTZ99Z31HiSItEWfjwp7B2K8qHJFTqBF0L7XuecgMMuUBbURGS0pqUoXjuJO/h8/Xs6gahV0KRi6IWccQ6QAnFr3mRNkMLH2jqkwuDRN5/S0wR6QalrLlrH3jhFwFrH+YmrFO8eDlpzk54vXPji4mc/k4rTI8OB+yDyhCpKlcRd30hzXT22skfL0er5iiAZbR9YDmFV12pTkzivabLSm+RsRzqMF0bbzCPPG60JPTEELyJaeyIPCupGlobGQ6Lj6Q7U9NTrSTmEK1sXixQoh3pId84NNhcCKE+EEtFxIIZHaYOlhG6w3nXc5Snv7Hl7h2S1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HzVsWpsxg8gzs1LvHZ7mKUQ5piBodmCsbCSwsQDlS6Y=; b=U4wXTE3h5yONVmdeqJFOLPThsze1TrirbUmCGMRcTt9NwU9pOhCX+27Ue1vr4cjGzR6Qy6hNESXaFq3+RoW/OyQ2Ml0PwQ+4QqjaO3/PCnhepvKb6nPqiFxr8OxLCpPUQ0Worc41QFu4SdRRzZNs6R0ewPAXGrRjBjfBId/YFsn3yvs0rx3CR+yGpakiTHzwabjSSENvUHwsjskZQ/g6FEAnY5nFzOQV3qckFRTSrMmqzb9kX9y1an1kxhwLcI2pnMnysO21BUTXTYS0QYryor6NnmZwrghtjPrZ+fe71BG/Qk56kitqVNl+noUvvmmdbUJXLrDfYdbCg6UX2m4HrQ== Received: from SJ0PR03CA0221.namprd03.prod.outlook.com (2603:10b6:a03:39f::16) by BL1PR12MB5062.namprd12.prod.outlook.com (2603:10b6:208:313::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 11:35:08 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:39f:cafe::fe) by SJ0PR03CA0221.outlook.office365.com (2603:10b6:a03:39f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.18 via Frontend Transport; Thu, 18 May 2023 11:35:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 11:35:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 04:35:00 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 04:34:55 -0700 From: Ido Schimmel To: , CC: , , , , , , , , , , , , , , , , , , Ido Schimmel Subject: [PATCH net-next 4/5] mlxsw: spectrum_flower: Add ability to match on layer 2 miss Date: Thu, 18 May 2023 14:33:27 +0300 Message-ID: <20230518113328.1952135-5-idosch@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518113328.1952135-1-idosch@nvidia.com> References: <20230518113328.1952135-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|BL1PR12MB5062:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d0b558c-3757-4106-eea5-08db5793eee5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RIEwtTVIrJQD81HYIRKiFqesgJF/tPqnJmCahcrmeHPcFMD+YNEX6BI54hDE/FEJ3A/kjJfjDMFFXNa7VQo29nNdlVGGI0PpM5pMhzgzhzFgj43PYuinBBiuHpcx7XxYEJqBDkhKdlg2Tq0GugDSW3dF67hxVMrl+p8x0wXFE9TxZOmSYsrYXbEkvaqKRo6qcLSEhc5LaDfNlSxSY+z1XLrDRnCty9TE5GRVUNSAk3NlTjRidiZZd93PTvXCuq6aiIItP0n2OI7wYegoYwfN+8qrXdpJNyPfFiiloYuzGKbovsZ46Wox6UXQNpseOt2APcoGzjp2Vn50NdSaMbGrjZ+tkZAmOSNZ69r+b2KdpKjEzRAq3vGld5OSzt/eSmnqx7ib1kyPFtDd1vLZ9wCUAPFhtbi9cpdniX86STMtDQ9JgrdxZZ8lqNdcRYeeRB9uP5s65bCb2tnMhBnZ8hUBkAjZg2TysRsqHuG4WCAgITqsd+uvt/eaHlWfvREXCIAgsG56iogxpzPC/OlnWZyLi1FlFW+1Aq9WP8xCQ8lZz1Q6o1BqAMyPg2+c3pfFXG4y3cKxnO7Kc7wK35zp+Tg8BFe70JxqaAl7dvxgDYCWjROAi1Uvz/eAI7vGYaEzqLzitsRkQZeKHCuGdjq8VuD0MNUQfijg4AJm1/SHlkRJAD/SZ072adpjjaftFXlDUbt4TJA84BkNhsqds4hudlpSRxJIl7wc2ufUs1i+arAkrmGWNHAePuyMgArDRvNN+LNG X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(8676002)(2906002)(7416002)(8936002)(41300700001)(5660300002)(82310400005)(70586007)(70206006)(4326008)(54906003)(110136005)(478600001)(6666004)(83380400001)(426003)(47076005)(336012)(36756003)(1076003)(66574015)(107886003)(316002)(2616005)(186003)(40460700003)(26005)(16526019)(36860700001)(7636003)(356005)(82740400003)(86362001)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:35:08.1349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d0b558c-3757-4106-eea5-08db5793eee5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5062 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add the 'dmac_type' key element to supported key blocks and make use of it to match on layer 2 miss. This is a two bits key in hardware with the following values: 00b - Known multicast. 01b - Broadcast. 10b - Known unicast. 11b - Unknown unicast or unregistered multicast. When 'l2_miss' is set we need to match on 01b or 11b. Therefore, only match on the LSB in order to differentiate between both cases of 'l2_miss'. Tested on Spectrum-{1,2,3,4}. Signed-off-by: Ido Schimmel Reviewed-by: Simon Horman --- .../mellanox/mlxsw/core_acl_flex_keys.c | 1 + .../mellanox/mlxsw/core_acl_flex_keys.h | 3 ++- .../mellanox/mlxsw/spectrum_acl_flex_keys.c | 5 +++++ .../ethernet/mellanox/mlxsw/spectrum_flower.c | 20 ++++++++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index bd1a51a0a540..81af0b9a4329 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -42,6 +42,7 @@ static const struct mlxsw_afk_element_info mlxsw_afk_element_infos[] = { MLXSW_AFK_ELEMENT_INFO_BUF(DST_IP_64_95, 0x34, 4), MLXSW_AFK_ELEMENT_INFO_BUF(DST_IP_32_63, 0x38, 4), MLXSW_AFK_ELEMENT_INFO_BUF(DST_IP_0_31, 0x3C, 4), + MLXSW_AFK_ELEMENT_INFO_U32(DMAC_TYPE, 0x40, 0, 2), }; struct mlxsw_afk { diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h index 3a037fe47211..6f1649cfa4cb 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h @@ -35,6 +35,7 @@ enum mlxsw_afk_element { MLXSW_AFK_ELEMENT_IP_DSCP, MLXSW_AFK_ELEMENT_VIRT_ROUTER_MSB, MLXSW_AFK_ELEMENT_VIRT_ROUTER_LSB, + MLXSW_AFK_ELEMENT_DMAC_TYPE, MLXSW_AFK_ELEMENT_MAX, }; @@ -69,7 +70,7 @@ struct mlxsw_afk_element_info { MLXSW_AFK_ELEMENT_INFO(MLXSW_AFK_ELEMENT_TYPE_BUF, \ _element, _offset, 0, _size) -#define MLXSW_AFK_ELEMENT_STORAGE_SIZE 0x40 +#define MLXSW_AFK_ELEMENT_STORAGE_SIZE 0x44 struct mlxsw_afk_element_inst { /* element instance in actual block */ enum mlxsw_afk_element element; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c index 00c32320f891..18a968cded36 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c @@ -26,6 +26,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac[] = { static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac_ex[] = { MLXSW_AFK_ELEMENT_INST_BUF(SMAC_32_47, 0x02, 2), MLXSW_AFK_ELEMENT_INST_BUF(SMAC_0_31, 0x04, 4), + MLXSW_AFK_ELEMENT_INST_U32(DMAC_TYPE, 0x08, 0, 2), MLXSW_AFK_ELEMENT_INST_U32(ETHERTYPE, 0x0C, 0, 16), }; @@ -50,6 +51,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4[] = { }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_ex[] = { + MLXSW_AFK_ELEMENT_INST_U32(DMAC_TYPE, 0x00, 24, 2), MLXSW_AFK_ELEMENT_INST_U32(VID, 0x00, 0, 12), MLXSW_AFK_ELEMENT_INST_U32(PCP, 0x08, 29, 3), MLXSW_AFK_ELEMENT_INST_U32(SRC_L4_PORT, 0x08, 0, 16), @@ -78,6 +80,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv6_sip_ex[] = { }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_packet_type[] = { + MLXSW_AFK_ELEMENT_INST_U32(DMAC_TYPE, 0x00, 30, 2), MLXSW_AFK_ELEMENT_INST_U32(ETHERTYPE, 0x00, 0, 16), }; @@ -123,6 +126,7 @@ const struct mlxsw_afk_ops mlxsw_sp1_afk_ops = { }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_0[] = { + MLXSW_AFK_ELEMENT_INST_U32(DMAC_TYPE, 0x00, 0, 2), MLXSW_AFK_ELEMENT_INST_BUF(DMAC_0_31, 0x04, 4), }; @@ -313,6 +317,7 @@ const struct mlxsw_afk_ops mlxsw_sp2_afk_ops = { }; static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5b[] = { + MLXSW_AFK_ELEMENT_INST_U32(DMAC_TYPE, 0x00, 2, 2), MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 18, 12), MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 9, -1, true), /* RX_ACL_SYSTEM_PORT */ }; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index 6fec9223250b..170a07f35897 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -295,11 +295,6 @@ static int mlxsw_sp_flower_parse_meta(struct mlxsw_sp_acl_rule_info *rulei, flow_rule_match_meta(rule, &match); - if (match.mask->l2_miss) { - NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on \"l2_miss\""); - return -EOPNOTSUPP; - } - if (match.mask->ingress_ifindex != 0xFFFFFFFF) { NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported ingress ifindex mask"); return -EINVAL; @@ -327,6 +322,21 @@ static int mlxsw_sp_flower_parse_meta(struct mlxsw_sp_acl_rule_info *rulei, MLXSW_AFK_ELEMENT_SRC_SYS_PORT, mlxsw_sp_port->local_port, 0xFFFFFFFF); + + /* This is a two bits key in hardware with the following values: + * 00b - Known multicast. + * 01b - Broadcast. + * 10b - Known unicast. + * 11b - Unknown unicast or unregistered multicast. + * + * When 'l2_miss' is set we need to match on 01b or 11b. Therefore, + * only match on the LSB in order to differentiate between both cases + * of 'l2_miss'. + */ + mlxsw_sp_acl_rulei_keymask_u32(rulei, MLXSW_AFK_ELEMENT_DMAC_TYPE, + match.key->l2_miss, + match.mask->l2_miss & BIT(0)); + return 0; } From patchwork Thu May 18 11:33:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13246590 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 5CD8D1EA77 for ; Thu, 18 May 2023 11:35:27 +0000 (UTC) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2044.outbound.protection.outlook.com [40.107.96.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E01519BC for ; Thu, 18 May 2023 04:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=COtAzs0ncf2hODap3uNF0WQ0DPQHfZtRmots5t9F0OSvXEy5Lbt//UJJu9L0V9Y1X/fo05ikQ66v3Xro5I6GvHTOqyQnh6qHLxZyj5VLufc9Z8GMShoIwYKCrw3BGJrGU+yst3dE4V8q2ir3zw9AYsL2TJWnGMVg9lY+ObPdEOozLvNXHPJQb55enYeJBMJYOycdTDgrGsdoimUMmSeqyba4N8aF0tIEYySqqmF272W2Fg/+zHWZS35uK86RtTRKEpSlCtgY5fLKeOw86ZrQvwnrIBePmG+SWoih5Hai4v6YJrhdXD+18gIGg6R1kc5cbb0ceWUgRegOjelIzzy9Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=mKdTRS0ZIQEdAbs+I0FkXntaP1eXB6RVCBy0Hb4d49U=; b=lMTQaBA3UvdCB0jRgEpnLQSsFhp0Y/ZHWdbQ8SZK3GAuCbBwEDkPsvnh6DKx42hwqBCCWd36CX2jkMzn9k9PhE50GiOm8kZCUhdHVRfUk6ZzIulSQ7WjaOAqoS/IZQEBKWf6oN/CYMhwVPqG0AEJIBGUbdieXf6m+Lij0MYL80AqD5CstZoqaIZkL/8M+J4NH/282BF5sML3Oy3xIeP0CS4FUP1NdzNovCu0x82as6ImRQXwQm65zrGdgij9vGHvFmpKWYbhSjyepsPB7nBj5ES46/BNI+spgaV5C51WwvWKJzU7mCH717cyGCljRN5l2FkggyVuKJyzAcUA7Z1DUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mKdTRS0ZIQEdAbs+I0FkXntaP1eXB6RVCBy0Hb4d49U=; b=FIsm4HPiqbwLcjyJJmFbNIsRNZevetLXuQFg/cFxkLgR7PWgWVsiSeQ5UbthQG2YDGqVeTihiYTS/Ml9AX26B61HNMUWUyN390cjq3HEJkAJRX6xFkNdYQC+GmkvQXGykbBYXKU/bESimo62zj0f1MOcrxttWoavuezorfka2Kr2f+3IqvG/YAldiFkBmNfmi91qQC7G3kZptcobp1ssA+ChqNfgwOnbF5r//+yemE6UkNsaNKqF36ZRyzrTjONz+RXJJZPsq8FMF+5GIpcL/UBsuZ7RYDwg9AQXJvjbWEDhZAgaaEcTJ76VY9tWzOSZp1B/ZXnbUHL68U+K58lcVA== Received: from DM6PR03CA0036.namprd03.prod.outlook.com (2603:10b6:5:40::49) by DS0PR12MB7779.namprd12.prod.outlook.com (2603:10b6:8:150::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 11:35:18 +0000 Received: from DM6NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40::4) by DM6PR03CA0036.outlook.office365.com (2603:10b6:5:40::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Thu, 18 May 2023 11:35:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT058.mail.protection.outlook.com (10.13.172.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.20 via Frontend Transport; Thu, 18 May 2023 11:35:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 18 May 2023 04:35:06 -0700 Received: from dev-r-vrt-155.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 18 May 2023 04:35:00 -0700 From: Ido Schimmel To: , CC: , , , , , , , , , , , , , , , , , , Ido Schimmel Subject: [PATCH net-next 5/5] selftests: forwarding: Add layer 2 miss test cases Date: Thu, 18 May 2023 14:33:28 +0300 Message-ID: <20230518113328.1952135-6-idosch@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518113328.1952135-1-idosch@nvidia.com> References: <20230518113328.1952135-1-idosch@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT058:EE_|DS0PR12MB7779:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d678617-ec55-468b-6375-08db5793f4c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kX8fL58gFEQbsd/if1ir8iXxjtA8I3rrN3K+BlHUQ8uNpyoqzX2eb0FKqGvsw/ascbBVW7De+u/QrOltLBKzBo9ltCHGQ94Whg51xLD7dVOBOu4fOKZMDyMqJTMdjQjJme9Cxlj555GndY/5RG1cb3YqNBglioyg8AQpiTUmJti9Y7TCqTjHtrNWBylRIhDbvHVfHaoLJQSnNGFWs4ZpCA5XZSalK+eHG3CqMT/ftOuwPgdNXfrOCKuZ1ZxmbEXsvghsTQkAjz/KcdSe0gB8wEcj146K6gN/4kJCZjPDx48GJqRfkPsjelBNUgndM3pDd2+Ydta6LakIP56+GIU/zruUmWDqsbFjmnZ00CjdzPq9KfEzwDmxCM/Vho4IjlcIyfVbru0cbvDoMShRZ6jmr/2/QXF5JBziW6KQKWtWdGnNYRYhsKrg7LOXgGhDkbavEqKl8Fw8Q5gmjHGPtn6ldnjXA62SgYhrmha83ZQfJqPJhP3cbP3XMyDGtsf9Kv3W05vJk5pUMzIRgWYo+KdZaFHJnuz+vqQS3SZvrz212CVO9+/tM8EKt/cr5nGT0Tp7LuFfS6aTiphdzyAuJaCcFrQoShPziA7sBgJP6QSvs17TaFC8Eq3j1vhq0o20kxtXfhcKL8UAT9p/7FHmTGf4cK7Z4jcYehM+guLBBXnLlzM9wQKfIjrg0Ge7wUIC7+9FOjBU9t1KnpY8gt3UdjJAkzA0BNQyN76j5Q6T497IZ4U= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(86362001)(107886003)(40460700003)(26005)(1076003)(36756003)(47076005)(336012)(426003)(36860700001)(2616005)(66574015)(83380400001)(7636003)(82310400005)(40480700001)(82740400003)(356005)(186003)(16526019)(54906003)(110136005)(478600001)(30864003)(2906002)(4326008)(8676002)(8936002)(70586007)(70206006)(316002)(5660300002)(7416002)(6666004)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 11:35:17.9986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d678617-ec55-468b-6375-08db5793f4c9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7779 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add test cases to verify that the bridge driver correctly marks layer 2 misses only when it should and that the flower classifier can match on this metadata. Example output: # ./tc_flower_l2_miss.sh TEST: L2 miss - Unicast [ OK ] TEST: L2 miss - Multicast (IPv4) [ OK ] TEST: L2 miss - Multicast (IPv6) [ OK ] TEST: L2 miss - Link-local multicast (IPv4) [ OK ] TEST: L2 miss - Link-local multicast (IPv6) [ OK ] TEST: L2 miss - Broadcast [ OK ] Signed-off-by: Ido Schimmel --- .../testing/selftests/net/forwarding/Makefile | 1 + .../net/forwarding/tc_flower_l2_miss.sh | 343 ++++++++++++++++++ 2 files changed, 344 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/tc_flower_l2_miss.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index a474c60fe348..9d0062b542e5 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -83,6 +83,7 @@ TEST_PROGS = bridge_igmp.sh \ tc_chains.sh \ tc_flower_router.sh \ tc_flower.sh \ + tc_flower_l2_miss.sh \ tc_mpls_l2vpn.sh \ tc_police.sh \ tc_shblocks.sh \ diff --git a/tools/testing/selftests/net/forwarding/tc_flower_l2_miss.sh b/tools/testing/selftests/net/forwarding/tc_flower_l2_miss.sh new file mode 100755 index 000000000000..fbf0a960b2c8 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/tc_flower_l2_miss.sh @@ -0,0 +1,343 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +-----------------------+ +----------------------+ +# | H1 (vrf) | | H2 (vrf) | +# | + $h1 | | $h2 + | +# | | 192.0.2.1/28 | | 192.0.2.2/28 | | +# | | 2001:db8:1::1/64 | | 2001:db8:1::2/64 | | +# +----|------------------+ +------------------|---+ +# | | +# +----|-------------------------------------------------------------------|---+ +# | SW | | | +# | +-|-------------------------------------------------------------------|-+ | +# | | + $swp1 BR $swp2 + | | +# | +-----------------------------------------------------------------------+ | +# +----------------------------------------------------------------------------+ + +ALL_TESTS=" + test_l2_miss_unicast + test_l2_miss_multicast + test_l2_miss_ll_multicast + test_l2_miss_broadcast +" + +NUM_NETIFS=4 +source lib.sh +source tc_common.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/28 2001:db8:1::1/64 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.2/28 2001:db8:1::2/64 +} + +h2_destroy() +{ + simple_if_fini $h2 192.0.2.2/28 2001:db8:1::2/64 +} + +switch_create() +{ + ip link add name br1 up type bridge + ip link set dev $swp1 master br1 + ip link set dev $swp1 up + ip link set dev $swp2 master br1 + ip link set dev $swp2 up + + tc qdisc add dev $swp2 clsact +} + +switch_destroy() +{ + tc qdisc del dev $swp2 clsact + + ip link set dev $swp2 down + ip link set dev $swp2 nomaster + ip link set dev $swp1 down + ip link set dev $swp1 nomaster + ip link del dev br1 +} + +test_l2_miss_unicast() +{ + local dmac=00:01:02:03:04:05 + local dip=192.0.2.2 + local sip=192.0.2.1 + + RET=0 + + # Unknown unicast. + tc filter add dev $swp2 egress protocol ipv4 handle 101 pref 1 \ + flower indev $swp1 l2_miss true dst_mac $dmac src_ip $sip \ + dst_ip $dip action pass + # Known unicast. + tc filter add dev $swp2 egress protocol ipv4 handle 102 pref 1 \ + flower indev $swp1 l2_miss false dst_mac $dmac src_ip $sip \ + dst_ip $dip action pass + + # Before adding FDB entry. + $MZ $h1 -a own -b $dmac -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Unknown unicast filter was not hit before adding FDB entry" + + tc_check_packets "dev $swp2 egress" 102 0 + check_err $? "Known unicast filter was hit before adding FDB entry" + + # Adding FDB entry. + bridge fdb replace $dmac dev $swp2 master static + + $MZ $h1 -a own -b $dmac -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Unknown unicast filter was hit after adding FDB entry" + + tc_check_packets "dev $swp2 egress" 102 1 + check_err $? "Known unicast filter was not hit after adding FDB entry" + + # Deleting FDB entry. + bridge fdb del $dmac dev $swp2 master static + + $MZ $h1 -a own -b $dmac -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 2 + check_err $? "Unknown unicast filter was not hit after deleting FDB entry" + + tc_check_packets "dev $swp2 egress" 102 1 + check_err $? "Known unicast filter was hit after deleting FDB entry" + + tc filter del dev $swp2 egress protocol ipv4 pref 1 handle 102 flower + tc filter del dev $swp2 egress protocol ipv4 pref 1 handle 101 flower + + log_test "L2 miss - Unicast" +} + +test_l2_miss_multicast_common() +{ + local proto=$1; shift + local sip=$1; shift + local dip=$1; shift + local mode=$1; shift + local name=$1; shift + + RET=0 + + # Unregistered multicast. + tc filter add dev $swp2 egress protocol $proto handle 101 pref 1 \ + flower indev $swp1 l2_miss true src_ip $sip dst_ip $dip \ + action pass + # Registered multicast. + tc filter add dev $swp2 egress protocol $proto handle 102 pref 1 \ + flower indev $swp1 l2_miss false src_ip $sip dst_ip $dip \ + action pass + + # Before adding MDB entry. + $MZ $mode $h1 -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Unregistered multicast filter was not hit before adding MDB entry" + + tc_check_packets "dev $swp2 egress" 102 0 + check_err $? "Registered multicast filter was hit before adding MDB entry" + + # Adding MDB entry. + bridge mdb replace dev br1 port $swp2 grp $dip permanent + + $MZ $mode $h1 -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Unregistered multicast filter was hit after adding MDB entry" + + tc_check_packets "dev $swp2 egress" 102 1 + check_err $? "Registered multicast filter was not hit after adding MDB entry" + + # Deleting MDB entry. + bridge mdb del dev br1 port $swp2 grp $dip + + $MZ $mode $h1 -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 2 + check_err $? "Unregistered multicast filter was not hit after deleting MDB entry" + + tc_check_packets "dev $swp2 egress" 102 1 + check_err $? "Registered multicast filter was hit after deleting MDB entry" + + tc filter del dev $swp2 egress protocol $proto pref 1 handle 102 flower + tc filter del dev $swp2 egress protocol $proto pref 1 handle 101 flower + + log_test "L2 miss - Multicast ($name)" +} + +test_l2_miss_multicast_ipv4() +{ + local proto="ipv4" + local sip=192.0.2.1 + local dip=239.1.1.1 + local mode="-4" + local name="IPv4" + + test_l2_miss_multicast_common $proto $sip $dip $mode $name +} + +test_l2_miss_multicast_ipv6() +{ + local proto="ipv6" + local sip=2001:db8:1::1 + local dip=ff0e::1 + local mode="-6" + local name="IPv6" + + test_l2_miss_multicast_common $proto $sip $dip $mode $name +} + +test_l2_miss_multicast() +{ + # Configure $swp2 as a multicast router port so that it will forward + # both registered and unregistered multicast traffic. + bridge link set dev $swp2 mcast_router 2 + + # Forwarding according to MDB entries only takes place when the bridge + # detects that there is a valid querier in the network. Set the bridge + # as the querier and assign it a valid IPv6 link-local address to be + # used as the source address for MLD queries. + ip link set dev br1 type bridge mcast_querier 1 + ip -6 address add fe80::1/64 nodad dev br1 + # Wait the default Query Response Interval (10 seconds) for the bridge + # to determine that there are no other queriers in the network. + sleep 10 + + test_l2_miss_multicast_ipv4 + test_l2_miss_multicast_ipv6 + + ip -6 address del fe80::1/64 dev br1 + ip link set dev br1 type bridge mcast_querier 0 + bridge link set dev $swp2 mcast_router 1 +} + +test_l2_miss_multicast_common2() +{ + local name=$1; shift + local dmac=$1; shift + local dip=224.0.0.1 + local sip=192.0.2.1 + +} + +test_l2_miss_ll_multicast_common() +{ + local proto=$1; shift + local dmac=$1; shift + local sip=$1; shift + local dip=$1; shift + local mode=$1; shift + local name=$1; shift + + RET=0 + + tc filter add dev $swp2 egress protocol $proto handle 101 pref 1 \ + flower indev $swp1 l2_miss true dst_mac $dmac src_ip $sip \ + dst_ip $dip action pass + + $MZ $mode $h1 -a own -b $dmac -t ip -A $sip -B $dip -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Filter was not hit" + + tc filter del dev $swp2 egress protocol $proto pref 1 handle 101 flower + + log_test "L2 miss - Link-local multicast ($name)" +} + +test_l2_miss_ll_multicast_ipv4() +{ + local proto=ipv4 + local dmac=01:00:5e:00:00:01 + local sip=192.0.2.1 + local dip=224.0.0.1 + local mode="-4" + local name="IPv4" + + test_l2_miss_ll_multicast_common $proto $dmac $sip $dip $mode $name +} + +test_l2_miss_ll_multicast_ipv6() +{ + local proto=ipv6 + local dmac=33:33:00:00:00:01 + local sip=2001:db8:1::1 + local dip=ff02::1 + local mode="-6" + local name="IPv6" + + test_l2_miss_ll_multicast_common $proto $dmac $sip $dip $mode $name +} + +test_l2_miss_ll_multicast() +{ + test_l2_miss_ll_multicast_ipv4 + test_l2_miss_ll_multicast_ipv6 +} + +test_l2_miss_broadcast() +{ + local dmac=ff:ff:ff:ff:ff:ff + local smac=00:01:02:03:04:05 + + RET=0 + + tc filter add dev $swp2 egress protocol all handle 101 pref 1 \ + flower indev $swp1 l2_miss true dst_mac $dmac src_mac $smac \ + action pass + + $MZ $h1 -a $smac -b $dmac -c 1 -p 100 -q + + tc_check_packets "dev $swp2 egress" 101 1 + check_err $? "Filter was not hit" + + tc filter del dev $swp2 egress protocol all pref 1 handle 101 flower + + log_test "L2 miss - Broadcast" +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + vrf_prepare + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + vrf_cleanup +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS