From patchwork Wed Jul 19 11:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318783 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 892958830 for ; Wed, 19 Jul 2023 11:02:18 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BD7718D for ; Wed, 19 Jul 2023 04:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VwxjEL+O3k2cIO7T9fbOaa/Lo+g2zyChw9pKLhSY5OMz+L7KSi2AgwavCEUjwI5ZFuRi7bNzwilJeDha5IBCTxCvL6fllkrZLNuxHP077hCStg7ooVhJLd7YE6rfSqrn6rmqb86Rw88aJAxf3fPbbxxnFjwf7RdmoYCnEQlaQiay9Q2OMFsNQVT8VeGm6dwgj/QMX0Fvzjvqs32xx2Vo7kpvfqzalAqwPTwy1EYU5tgyqHZpvLBJPXxh0lhEQMehAy4XOC1b8k8djPIB7yj1S65Ns7A9CFRGMQGX1uI+6v0tYYmj4jcfbqXcFFejr5gwOEwA13Hh//Kvk3+Wom93IA== 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=nDjQ80FxKDBMZsQI1GulWLm/sHgS9qG0CVg2VFDT9Uw=; b=W3jrCcR1FdOVpEOULO+RFfhHlv2vd7TCPZ0PzuL5P++ZnyFg5VC8RGK+tpLjHArXYkWjeG0Xio6dKcmdiMsP6cV7rqZROIMGK1hrBytvYoM3SRVf8QOesT1xYAmxhaZKgpm+qIHTo2prnJsnqr5zoU4kU9W7JRRHhK1pWNM9IH8hb8BTHJEAyjHjW/OYdsSSqGaHCU2O14aGSFkFm//tzbI2+3aor9SVc/DEqckXbPzcaCo0VofUHv2VxqzQb+rKZ8Q7xcHwWi7Ciu50hVH0FMVM8BWwaQ3D2ETxdsY8WBjNc9RTRdzOurTFXdYJd1ypkt2ExD5aVNoJnMRvT7LMWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=nDjQ80FxKDBMZsQI1GulWLm/sHgS9qG0CVg2VFDT9Uw=; b=Qefg1adAKoLOow2GJjS4SycoHYC4KDWKZzw3WjYK36stW62oZoUvOGByTklRa5YBilT/j7x+tjWErxJXQn3QpIpsI3oryW4Q8zRnDWpgYgzoESeNX7dUhE331jjWoMmDFrvUXQiyULtc98sGxQ0X2EcFsCFs/T/LGdn3n0k8KmSPK6wxk3p5noMLdEuf9KICgh1mINWzRdmkbSYvmyiRJT3rfOt75O84ET6jWEHouYBi0mjJIoxocxcRpWG2Rc+aDur6TiWk8awS9rTMXdq136+PYXEUh3ptobcg4UDsb1VShndpMGyyFVNQd1jaVbfQw633XXgGdgHQA+QAi4CGFA== Received: from BN9PR03CA0668.namprd03.prod.outlook.com (2603:10b6:408:10e::13) by DM8PR12MB5429.namprd12.prod.outlook.com (2603:10b6:8:29::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Wed, 19 Jul 2023 11:02:15 +0000 Received: from BN8NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::61) by BN9PR03CA0668.outlook.office365.com (2603:10b6:408:10e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT091.mail.protection.outlook.com (10.13.176.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 19 Jul 2023 04:02:00 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:01:56 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Subject: [PATCH net-next 01/17] net: bridge: br_switchdev: Tolerate -EOPNOTSUPP when replaying MDB Date: Wed, 19 Jul 2023 13:01:16 +0200 Message-ID: <009406289387d9d34b76085fa858b8cd4d287851.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT091:EE_|DM8PR12MB5429:EE_ X-MS-Office365-Filtering-Correlation-Id: bc44ff63-d99e-4d81-91f8-08db88479c37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BfWghTBCbM1hIzMNATIi3XqD5KxDex2zxAiyWY3Xq+PXPlUufs3u6IGYjPdU8UnR0uvruYi0L6njym7Kq/v1Qy792HNm8izNSf+5kyUCdgWUQK2JQmZnqr8HNWwfoDwwxCei4+tkz+rp5nK/FewTDiwIYc1X6hY0OudMDCWTQWLZPBLMF1JMoCPqXLVPl5EEsi30/V+JWmLXqX6KVzY5ywsjHnvdAzmwLbVEfDdLHWi/+RPdxRSSbVx3vOiX7kTpNjEzlDDWlRSAI5qvftFjbtsg5GlR4+lnT0PLXptPUSknFN+lydpqtX6ZH5ADfdIm8N3QYwbl1mtqdsLXKVAlcRRNnj8D11fVyEeAYjkkVZ3h7HRFRM6TbQKzD6upGvZFroGvq9qXYmjnw2duJRedRIbWlDR2qZvGXAHZk4dtMefuHNftz+CplBWyZMbDmb01bLBi14HLXbDT0eut/ZTbbrC1563hjyECyMfEKklkIASw8IiPKgJjvM+eA8edZ/muo8kgP2Mx1DQluvhaq7nBPllVUhrzDhY5q8FdT72Tdr5HNwZgMPeW886j5R1Fucwo+Nj2FEK1COwGg8ABnh6vq9gUpaRsOPtD/jfu/qkzO2Zz1zbcTA5PBv7pFfIsWQQcoWC5Lb0ywCJy06sg4O4b/EjLXDONasGeGPY+xcjYrgur4oGPMCOJ2GwfALm/sgyfrhAzmgSXXTQEiqmIOAnEsfdhcNFp8dJtJUotgkOiXMBn+Ozc16J/2vPqlBg2EgLS 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)(376002)(396003)(82310400008)(451199021)(46966006)(36840700001)(40470700004)(316002)(41300700001)(4326008)(5660300002)(8676002)(8936002)(426003)(2616005)(36860700001)(83380400001)(47076005)(82740400003)(86362001)(356005)(7636003)(40480700001)(186003)(70586007)(70206006)(26005)(336012)(36756003)(16526019)(110136005)(54906003)(40460700003)(478600001)(6666004)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:14.5969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc44ff63-d99e-4d81-91f8-08db88479c37 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: BN8NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5429 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 There are two kinds of MDB entries to be replayed: port MDB entries, and host MDB entries. They are both replayed by br_switchdev_mdb_replay(). If the driver supports one kind, but lacks the other, the first -EOPNOTSUPP returned terminates the whole replay, including any further still-supported objects in the list. For this to cause issues, there must be MDB entries for both the host and the port being replayed. In that case, if the driver bails out from handling the host entry, the port entries are never replayed. However, the replay is currently only done when a switchdev port joins a bridge. There would be no port memberships at that point. Thus despite being erroneous, the code does not cause observable bugs. This is not an issue with other object kinds either, because there, each function replays one object kind. If a driver does not support that kind, it makes sense to bail out early. -EOPNOTSUPP is then ignored in nbp_switchdev_sync_objs(). For MDB, suppress the -EOPNOTSUPP error code in br_switchdev_mdb_replay() already, so that the whole list gets replayed. The reason we need this patch is that a future patch will introduce a replay that should be used when a front-panel port netdevice is enslaved to a bridge lower, in particular a LAG. The LAG netdevice can already have both host and port MDB entries. The port entries need to be replayed so that they are offloaded on the port that joins the LAG. Cc: Jiri Pirko Cc: Ivan Vecera Cc: Roopa Prabhu Cc: Nikolay Aleksandrov Cc: bridge@lists.linux-foundation.org Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- net/bridge/br_switchdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index ba95c4d74a60..e92e0338afee 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -727,6 +727,8 @@ br_switchdev_mdb_replay(struct net_device *br_dev, struct net_device *dev, err = br_switchdev_mdb_replay_one(nb, dev, SWITCHDEV_OBJ_PORT_MDB(obj), action, ctx, extack); + if (err == -EOPNOTSUPP) + err = 0; if (err) goto out_free_mdb; } @@ -759,8 +761,10 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, err = br_switchdev_mdb_replay(br_dev, dev, ctx, true, blocking_nb, extack); - if (err && err != -EOPNOTSUPP) + if (err) { + /* -EOPNOTSUPP not propagated from MDB replay. */ return err; + } err = br_switchdev_fdb_replay(br_dev, ctx, true, atomic_nb); if (err && err != -EOPNOTSUPP) From patchwork Wed Jul 19 11:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318784 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 AF9FE125C8 for ; Wed, 19 Jul 2023 11:02:21 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A91186 for ; Wed, 19 Jul 2023 04:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JuKYlN6TJneneBLRBlmjueHjT3m9qKnYW4Gh5Z+YVM6R53oPaMUjZ7RI4Zm7jW/6sSni1JrtmGR7amtt29vLYHubxRja9r7ENRZrJPJe6ALMkZ9Iwh5pArefoT5eC+yoq5snUA2ebJehpVU3i/zC0V7mIK34bIaIhN3Su10Lryfuj+nrHOyODcjbRsx2bAU6EpI6F/gpH88iL1OgKh9QRU4+lObKJenPPaZyoHPNlmswX23ydGfr5g4qKB6ceAmHEf2/izkbEuPvWhsWklHJIPagW08RhklXYbfNl85oVxOiU49QHqvB5l9nV7oeDAN2JN+SsSjqVp+EHbAbep23kQ== 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=D1gyKFFp7ks8gh/utde57OTWL5Is0cFKvp/lBS9d6TI=; b=eD7fmGYxjSzO9dqxa6FwJSY6PR+GsRgqaAgxr9z07iB+EBL4+TLB1QLnltNV8Li8YNADkH2k7/6Z+YnuK9WgjVaxDW2BdZbzoxyo/oJQQtYZI22RkNluWy0Gtp19y3DQlOEsws/NOvIihXKFCnBcy/0VLWeI53CDfZ2Ku5Ss9k41utcHAsz/eZeH84NXbwKeQwrdhkMHrmkMh9bCP4Pp3qw6tSyGXksX+TNZqJBKlCNa0itZl16khcM4JMX3l1uynSwZ+nq6dW23H5LGQNrrBB4MLtDg+cgFPJBmggnT+0rnl+xJa5ZlYUxYBA5eLhWUQgS/habLy6FXyyd4F7IQBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=D1gyKFFp7ks8gh/utde57OTWL5Is0cFKvp/lBS9d6TI=; b=LVtXCGx0uUj3huOlJ+U56/rROPGYkqUZ99jPeQvfJP9B4c6tT3cyU3o79xqnV22KNETIJDqAuBtr93U2jLN5Tmiu5BhIPyqxad1S8dz74uHzQkWj6XJ+JyzDIsIgwR/0VuHPSSTphISkrn5N4nYrZ7aovozeEsopghVb8zPFyxA7kaz7rscNmTv8P8f2CwNOlvYtE+EUKfkAUt42VIdFu7TF5S50fh4E0spyarNaeB4DB2LXCMEsKOYYqyXmHktp3jfRAx1F23/GmFikdtHVn5pCNLWctMAXY6zCf3+qjreKLsZDSqAotgTvelXwYVDgGHtymKuXzMA62qVysHbQUw== Received: from BN9P221CA0030.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::29) by SJ2PR12MB7961.namprd12.prod.outlook.com (2603:10b6:a03:4c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Wed, 19 Jul 2023 11:02:17 +0000 Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::7b) by BN9P221CA0030.outlook.office365.com (2603:10b6:408:10a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:17 +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 BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:16 +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; Wed, 19 Jul 2023 04:02:03 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:01:59 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Subject: [PATCH net-next 02/17] net: switchdev: Add a helper to replay objects on a bridge port Date: Wed, 19 Jul 2023 13:01:17 +0200 Message-ID: <3145c726aa2290b82841a51590554e97f3c099b6.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT015:EE_|SJ2PR12MB7961:EE_ X-MS-Office365-Filtering-Correlation-Id: 08b81c1f-a2e1-48df-4b2b-08db88479d6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5j+pmV63227lSeg/guqbZGV+YVwap7MBZvvqhuJ39rtOEyXfrSay6hyvkD315++1lpp6Ppwd+jBVdsg7gkPWQugvI9tpTEj9RxOkaLH5uSxJQMienQ6h1+zj8LPDDodC+TqLyGNjOHwTr/pzlfggOLiIpoB/uxC5J8YvkbjGwaSfcOPJ+LwSYyXR9sGLf3v54zg4+IS9pSNRPqOHbqzt7uYFRJraV447FdhzN+8wHNsaAtu6Rkecv7qvR0KhJetNNZl7ggeT4am3zqQpVh66dO45PFLe3DFcpWTYfOSOG/8xINFhLDT19bHX84lIz7OEov3AjoRXTnbShZIqMIMDUKcuEbckKSkdxTWgxs38dYdMOSSnLCxMJeBT7Ej/nQpzNxDZLeRJ037IY0tJzQs77rQ+y5Eogtu0vqDnh0fGNOtHNJ5LCkxPZO3Z7Oiq1DE6eiyatzrNv9NdlkzEMDiqHm3t2NsFLrClGcdf74hzIX6T6Qn0G12dFn16KuZdS9SZXXWbaVjP/CkCu7ezj5BZ9qx4LuJPA1afm/V4RmjQCnm3qsP8iQq4ub+dPZLK2xNeOh8PmB2sSMKTQsm1E1dlkG4Z0adBxO8oN0jjTSLhYtO+q4PJN4k7ofQggwRMBD6hOTGLnFEKUP5xDAAYikkWn1kYV9Pf0L52Tk/G3WDOG2nzHQBvrB/NcWYTD+NXX0PWCPm3gRdzJezDXTqMA7D3yOgBOU5i7wYbvSIUGHBcr3KJlOXjSqVPaqK2jI6vZuDe 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)(136003)(396003)(346002)(376002)(39860400002)(451199021)(82310400008)(36840700001)(46966006)(40470700004)(478600001)(6666004)(54906003)(110136005)(426003)(36860700001)(336012)(356005)(2616005)(83380400001)(47076005)(40460700003)(86362001)(36756003)(40480700001)(2906002)(186003)(26005)(16526019)(7636003)(70586007)(82740400003)(41300700001)(70206006)(8936002)(8676002)(4326008)(5660300002)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:16.6070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08b81c1f-a2e1-48df-4b2b-08db88479d6a 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: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7961 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 When a front panel joins a bridge via another netdevice (typically a LAG), the driver needs to learn about the objects configured on the bridge port. When the bridge port is offloaded by the driver for the first time, this can be achieved by passing a notifier to switchdev_bridge_port_offload(). The notifier is then invoked for the individual objects (such as VLANs) configured on the bridge, and can look for the interesting ones. Calling switchdev_bridge_port_offload() when the second port joins the bridge lower is unnecessary, but the replay is still needed. To that end, add a new function, switchdev_bridge_port_replay(), which does only the replay part of the _offload() function in exactly the same way as that function. Cc: Jiri Pirko Cc: Ivan Vecera Cc: Roopa Prabhu Cc: Nikolay Aleksandrov Cc: bridge@lists.linux-foundation.org Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- include/net/switchdev.h | 6 ++++++ net/bridge/br.c | 8 ++++++++ net/bridge/br_private.h | 16 ++++++++++++++++ net/bridge/br_switchdev.c | 9 +++++++++ net/switchdev/switchdev.c | 25 +++++++++++++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index ca0312b78294..4d324e2a2eef 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -231,6 +231,7 @@ enum switchdev_notifier_type { SWITCHDEV_BRPORT_OFFLOADED, SWITCHDEV_BRPORT_UNOFFLOADED, + SWITCHDEV_BRPORT_REPLAY, }; struct switchdev_notifier_info { @@ -299,6 +300,11 @@ void switchdev_bridge_port_unoffload(struct net_device *brport_dev, const void *ctx, struct notifier_block *atomic_nb, struct notifier_block *blocking_nb); +int switchdev_bridge_port_replay(struct net_device *brport_dev, + struct net_device *dev, const void *ctx, + struct notifier_block *atomic_nb, + struct notifier_block *blocking_nb, + struct netlink_ext_ack *extack); void switchdev_deferred_process(void); int switchdev_port_attr_set(struct net_device *dev, diff --git a/net/bridge/br.c b/net/bridge/br.c index 4f5098d33a46..a6e94ceb7c9a 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -234,6 +234,14 @@ static int br_switchdev_blocking_event(struct notifier_block *nb, br_switchdev_port_unoffload(p, b->ctx, b->atomic_nb, b->blocking_nb); break; + case SWITCHDEV_BRPORT_REPLAY: + brport_info = ptr; + b = &brport_info->brport; + + err = br_switchdev_port_replay(p, b->dev, b->ctx, b->atomic_nb, + b->blocking_nb, extack); + err = notifier_from_errno(err); + break; } out: diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index a63b32c1638e..a69774131535 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -2115,6 +2115,12 @@ void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, struct notifier_block *atomic_nb, struct notifier_block *blocking_nb); +int br_switchdev_port_replay(struct net_bridge_port *p, + struct net_device *dev, const void *ctx, + struct notifier_block *atomic_nb, + struct notifier_block *blocking_nb, + struct netlink_ext_ack *extack); + bool br_switchdev_frame_uses_tx_fwd_offload(struct sk_buff *skb); void br_switchdev_frame_set_offload_fwd_mark(struct sk_buff *skb); @@ -2165,6 +2171,16 @@ br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, { } +static inline int +br_switchdev_port_replay(struct net_bridge_port *p, + struct net_device *dev, const void *ctx, + struct notifier_block *atomic_nb, + struct notifier_block *blocking_nb, + struct netlink_ext_ack *extack) +{ + return -EOPNOTSUPP; +} + static inline bool br_switchdev_frame_uses_tx_fwd_offload(struct sk_buff *skb) { return false; diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index e92e0338afee..ee84e783e1df 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -829,3 +829,12 @@ void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, nbp_switchdev_del(p); } + +int br_switchdev_port_replay(struct net_bridge_port *p, + struct net_device *dev, const void *ctx, + struct notifier_block *atomic_nb, + struct notifier_block *blocking_nb, + struct netlink_ext_ack *extack) +{ + return nbp_switchdev_sync_objs(p, ctx, atomic_nb, blocking_nb, extack); +} diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 8cc42aea19c7..5b045284849e 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -862,3 +862,28 @@ void switchdev_bridge_port_unoffload(struct net_device *brport_dev, NULL); } EXPORT_SYMBOL_GPL(switchdev_bridge_port_unoffload); + +int switchdev_bridge_port_replay(struct net_device *brport_dev, + struct net_device *dev, const void *ctx, + struct notifier_block *atomic_nb, + struct notifier_block *blocking_nb, + struct netlink_ext_ack *extack) +{ + struct switchdev_notifier_brport_info brport_info = { + .brport = { + .dev = dev, + .ctx = ctx, + .atomic_nb = atomic_nb, + .blocking_nb = blocking_nb, + }, + }; + int err; + + ASSERT_RTNL(); + + err = call_switchdev_blocking_notifiers(SWITCHDEV_BRPORT_REPLAY, + brport_dev, &brport_info.info, + extack); + return notifier_to_errno(err); +} +EXPORT_SYMBOL_GPL(switchdev_bridge_port_replay); From patchwork Wed Jul 19 11:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318785 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 173BB12B91 for ; Wed, 19 Jul 2023 11:02:25 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2063.outbound.protection.outlook.com [40.107.243.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA3B18D for ; Wed, 19 Jul 2023 04:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDijI8eYVZULHzEQy4v1Ceh9GbvzLZrlE+x2LaIH8CaaB568XjQqLzKW07v8VwxFXbUwggVJxcRojiCCf9CWh2q8ymY8fnbWQfa2KVk5NvFOeIJndRu1lL898qMFoB2qYfqCTZ8DrtjW6hBd1vvjGz3x9KZds/116oopMaOprIu3fe63TUXMlSKQ1bCYBHAaYOvkbOFz97lWNYh3a4nDI4WzMM3cVbz9TmZjk7fE6RnMlsopueP622FUYYeOKO0RbL2HnasNT037/39pVifg67Tze/zj3erbVd8pbdUU0I7rsAZn8zR/keazkPWSYwQlRUb1YYUpRfwTxva9QJ4hqA== 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=JVRK6/WFVJyg2ATW/obbYzbtr6e4fIzSd1Z8srULDLs=; b=XgP//C7yH7EZiCORyAd1W4ZB1wVPFzG6F/opBLiVUG5oyCasb0C62SG+APFfjMWhI5JG8HT1HzftxH7w6E8Vn2vrT0Hloj+Bg/Ul+xQe5hmsDCkVik2mm4NG81QcwzcJUd4jO2m6n90g1xpTDCkRz6YtvcWHIMExvwPBk2tvEHZLo1ibAAY7pkLWRkGhWIHyw+N+gZ34zOgADlPWEm+NUUln7CYIxpqc8LNOC5p8RHfWSBqGFX4AIbGKr3qVgfMeDqds4lT9DLwPA/er0ShiAXGa7akI678OqP82EdXVB5vS23zs+/pXMpgQYzg9G4fBuxBnCqLgiqaHAj2jakFBNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=JVRK6/WFVJyg2ATW/obbYzbtr6e4fIzSd1Z8srULDLs=; b=SQSKLgOGhzVamUfU3h6e9U4kp1ZTLJAqVmpocqUkp7jr5zZJUHUYWeTTeg+kmbEzOQMik9aQRO0CfYfym+UHORvtOPK5ps8CV5v+Tglyr+W8+iou8R+O05f3AkLki8eKjcpDnuZYdwd68bhHrBwOVkqM9CqkOPPqJ8w8Q++yYF5vtJ73v+R1MGAeG5kAfpkeohaJ5Bdp+xaEv171BAWztXS/nG405ZzQJ1UIFv0xFBqGc32RbcXA81twn7hPlIJ6wjnmMmRbXp/qri8/9wqps0vOV/4Fo3k+51QeVIMHFsYxS+joZDa3PbYC9eAdrSmZHC5TyJSS4C0kT+dt5c1MHg== Received: from BN0PR02CA0042.namprd02.prod.outlook.com (2603:10b6:408:e5::17) by SA3PR12MB7782.namprd12.prod.outlook.com (2603:10b6:806:31c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 11:02:21 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::d0) by BN0PR02CA0042.outlook.office365.com (2603:10b6:408:e5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:21 +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 BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.35 via Frontend Transport; Wed, 19 Jul 2023 11:02:21 +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; Wed, 19 Jul 2023 04:02:06 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:03 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 03/17] selftests: mlxsw: rtnetlink: Drop obsolete tests Date: Wed, 19 Jul 2023 13:01:18 +0200 Message-ID: <4d096f90f48cd8466156876ed18f9c8cdd4ece97.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT029:EE_|SA3PR12MB7782:EE_ X-MS-Office365-Filtering-Correlation-Id: 360e1c36-f5c2-490b-2a2a-08db8847a038 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DEfRI8MF2hgYqcGxp0Ifxjl8s2qdB2dNz9+BLT7dBikoIM7l9cXmy+tzT2EaOY5/9R5nmRq/ErCjeC1pM5OK5jYNBTRuFbO4tgrkCitR2lP33Op0of+U4crNs6G0z6xDTcM/z1OwS3Y+f9G/1hvOjdB7Hr2rzMCrgaXlJCLIZlCV5FKfTvXpb/mqcstzeIg/VQDAeHgZAD4/+6MNF9vUuioKv5l95ExrV1q/nRjBXnusQrhfvNzazeZ+AzsLbHf7vnDRcQY+6gjoqJKhNaFcwMImuqGWMZx9zpgTCVeS/b3A6upZ2/nhqbtuUSNKrPi/wcq+MB5itC29DhfGOOXSSY2kPDeK/gkHSeePXEm++d9cNemZKl+jlwQ7C4dQ6oIcrblSpGVxjN3bHTY6PNDV40pKEfzMs9DaVYNfj+c4NI3bQkx1Oijc/0gLCgKrICsY1C2iAN2lE1WIGxy3tH2mL0HhrhgunDh48JlJVdLLcNCNJMFVC++oDEtebqBAP/PkfGcI7yqzJCpQDUOQ1HbqfzpgG2Rtr7z45XisjGftwycstHgto1ivGQ0ikHjCeI6xCoKidiHOld++Z1fwD3HTJZUhwkQ1W2eRbKBJN43FZO7z6owA8leiz/ZyLHgKVlE2MspCXyqoS0iTdLd1DCjl3vW27S0MscF7kyR/0Dj7NYy3qI94FOiAP8NTJfWcMqKrtQXiaL3Hg7jIKFsRkNjpPTe5grlIbwlFpTG5rhiEN04= 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)(376002)(346002)(136003)(39860400002)(396003)(451199021)(82310400008)(46966006)(40470700004)(36840700001)(36860700001)(70206006)(40460700003)(6666004)(107886003)(2906002)(356005)(7636003)(316002)(8676002)(8936002)(4326008)(36756003)(5660300002)(82740400003)(47076005)(16526019)(70586007)(426003)(2616005)(186003)(40480700001)(336012)(26005)(41300700001)(86362001)(478600001)(83380400001)(54906003)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:21.3116 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 360e1c36-f5c2-490b-2a2a-08db8847a038 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: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7782 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Support for enslaving ports to LAGs with uppers will be added in the following patches. Selftests to make sure it actually does the right thing are ready and will be sent as a follow-up. Similarly, ordering of MACVLAN creation and RIF creation will be relaxed and it will be permitted to create a MACVLAN first. Thus these two tests are obsolete. Drop them. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../selftests/drivers/net/mlxsw/rtnetlink.sh | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh b/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh index 5e89657857c7..893a693ad805 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh @@ -16,7 +16,6 @@ ALL_TESTS=" bridge_deletion_test bridge_vlan_flags_test vlan_1_test - lag_bridge_upper_test duplicate_vlans_test vlan_rif_refcount_test subport_rif_refcount_test @@ -211,33 +210,6 @@ vlan_1_test() ip link del dev $swp1.1 } -lag_bridge_upper_test() -{ - # Test that ports cannot be enslaved to LAG devices that have uppers - # and that failure is handled gracefully. See commit b3529af6bb0d - # ("spectrum: Reference count VLAN entries") for more details - RET=0 - - ip link add name bond1 type bond mode 802.3ad - - ip link add name br0 type bridge vlan_filtering 1 - ip link set dev bond1 master br0 - - ip link set dev $swp1 down - ip link set dev $swp1 master bond1 &> /dev/null - check_fail $? "managed to enslave port to lag when should not" - - # This might generate a trace, if we did not handle the failure - # correctly - ip -6 address add 2001:db8:1::1/64 dev $swp1 - ip -6 address del 2001:db8:1::1/64 dev $swp1 - - log_test "lag with bridge upper" - - ip link del dev br0 - ip link del dev bond1 -} - duplicate_vlans_test() { # Test that on a given port a VLAN is only used once. Either as VLAN @@ -510,9 +482,6 @@ vlan_interface_uppers_test() ip link set dev $swp1 master br0 ip link add link br0 name br0.10 type vlan id 10 - ip link add link br0.10 name macvlan0 \ - type macvlan mode private &> /dev/null - check_fail $? "managed to create a macvlan when should not" ip -6 address add 2001:db8:1::1/64 dev br0.10 ip link add link br0.10 name macvlan0 type macvlan mode private From patchwork Wed Jul 19 11:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318786 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 717AA134B4 for ; Wed, 19 Jul 2023 11:02:27 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20627.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::627]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E296186 for ; Wed, 19 Jul 2023 04:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J0UkfdvgYmeAJkVM3Yj36f+p2aMksUb2ygv4fpdoL8pte1bofsIbsWA2/1IVUGlrbrtAdzpCnkbpEnT+n/L7q6IC8L6HHVMBLUxyQCIcn+sG/PbB56xacgdmVsgrLHJD98S1LHBG3VbFMmesnVomIGE01QbUldyYeObFgOReLMUdU2y88XawYFzdq3jhuKYVcMKM26AS+Qc//4sgUUqr+bYhsq9J819EF/02wwu7SSO0mPH9ddLOvQSzHx8g7Njlpq5RCeOfXDDv4mbLuEFMUrBCq2nMLuAYYOz/TEwLPJyBjDPiaXZrCtJjMQJ6AfXdj5W3pJvTyYtdIcztn9CPtg== 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=zB8e3fl+qH43yTbBUm903A/vvhYdYzAT8Rcgukv82M0=; b=ZsoaqvC7TiEFCpALv3Q8qLMoR3dyfvKKW6P3our2Ir8zJtu9+7zUKm3+DcX6oFywaGRl7Ff96tOvh18ba1/0HDGKFy/jVuFfpJC3PLmKaiK+wV2rqlQiH+S2UqpaRs+xwoBHFpSiWtJOtRWTX+yVzkkj759c/5i5qfHUjgqYpkZWTG5kzGFfHTNdFRH7zbWYwYY/agicd/vVEolMTXsGwpGPT61ZFdcQbK9mq2SB6PLPkI6qIOPXZm0lpzBWVAG3QaGfGo6goMm8S/N8jcyKZlzXd4z/ALZHBpIq2OigvYOTIedAeMQjtINtbSqywTvtpulHCWwG+JEgGUEMj5QNGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=zB8e3fl+qH43yTbBUm903A/vvhYdYzAT8Rcgukv82M0=; b=YPtKZranlYhhPWqbKTIbO1i7u2fLBT9fRwps8Szc7FegAl3yZgkPC1au9D56a918bBK/EdLreezmSpSYbJ/rZNRM6Et1of6Zqss63YOoNkFTTOmoOAdLP/BHDo9MPxatHTzovHoGtYc2PYWW52rUo2Ou9kt0xbSSajM6neyykvVdaZ7D0JB2aczcYR9XVfgrnQu44DYbwjwuXXfk1QtUCNdcjBtUyQC2dpedmoF3oEpYe1WqmXInJ8qGyUNXi+j261V9YObYCcJO5N+DvnEI1gkKz+YrKGUGz6f0Dh3mX10EFEoNK0dz7Y85b5vi7Ow83P4n3MKc2zYs6G2/NiGMCg== Received: from BN0PR04CA0082.namprd04.prod.outlook.com (2603:10b6:408:ea::27) by MN0PR12MB6248.namprd12.prod.outlook.com (2603:10b6:208:3c0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Wed, 19 Jul 2023 11:02:23 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::f5) by BN0PR04CA0082.outlook.office365.com (2603:10b6:408:ea::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02:23 +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 BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:22 +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; Wed, 19 Jul 2023 04:02:08 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:06 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 04/17] mlxsw: spectrum_router: Allow address handlers to run on bridge ports Date: Wed, 19 Jul 2023 13:01:19 +0200 Message-ID: <2f0e4e83e827bd0e55f6df1ebb53355d06374409.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT037:EE_|MN0PR12MB6248:EE_ X-MS-Office365-Filtering-Correlation-Id: 992647b2-7a95-4466-9233-08db8847a133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zy7ndKUR1fPPVVepBw9G4GeaX9NpkKgorseylAVM1GKBJ6RjqwSPIy5xs+BgyFqxnq3dKSMvQ0DjuJew9e4r/xzG4JurxPMph0CKMaX+DXjka867UWeyFHa4dur85syKC61s5D+rvXhZauj21/hTUwF0a+wDYg+WNkMF5QLOc/JHMwAanma/Yo+DE2/ecmy6kyvOAwl+hQA4+aGlKHgex7NQSW1kuV0IqOBeQr2pd632KhE396+9sEkaoUDzB2qc7nHNXp9hbHq9Z/Xx5Tzq5BeGmjVerMrFcG1GFqIxP2wwsYhhC5gE0SMDg8rXEIkc+wfou1w6N9rOTIycyeZVRq7xkisBULYwJwnMMEtwbNf4u7zXAvwsmRiFjHBF+fuin5wbAempEIvKS8eMAnot2aYR5/gVBahzc3KePtIoMJXxB5cTEPfkFlzuqGQMsDvU9vLbzrOEvCcMbokLqFvpI1DOXZc9y77pOEpLPK/ZLVhTgEhfMYZEKYrDT4voP/YH374EUyZ8DLXv4PSOMJECyzVt0W+hV1sNwTnqFHoGE0sBSMubIDCdDxtjQcenQ4Urad9GawP+ZswNEYWqH+fY3kEa0SZc6xUQeynLA8dLpb3wqCbHDoHFpKufhwkG2+kYX+Saop8C/lqeiw4lcSVn6mma0J1+qtzh/7VrO3m5x8CfU94YDh53Pp6MUo0y0wULi9UdGyh6AIaR5yrp+i3ZeZg9VMST6SKrP9XRiMLmwIXUok29nwPWdlAoq1IXvOOp 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)(346002)(39860400002)(376002)(396003)(136003)(451199021)(82310400008)(46966006)(36840700001)(40470700004)(4326008)(54906003)(6666004)(478600001)(110136005)(82740400003)(2616005)(36860700001)(83380400001)(426003)(47076005)(40460700003)(86362001)(66574015)(40480700001)(356005)(2906002)(70586007)(186003)(16526019)(107886003)(26005)(316002)(7636003)(336012)(70206006)(41300700001)(36756003)(8676002)(5660300002)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:22.9749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 992647b2-7a95-4466-9233-08db8847a133 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: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6248 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_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Currently the IP address event handlers bail out when the event is related to a netdevice that is a bridge port or a member of a LAG. In order to create a RIF when a bridged or LAG'd port is unenslaved, these event handlers will be replayed. However, at the point in time when the NETDEV_CHANGEUPPER event is delivered, informing of the loss of enslavement, the port is still formally enslaved. In order for the operation to have any effect, these handlers need an extra parameter to indicate that the check for bridge or LAG membership should not be done. In this patch, add an argument "nomaster" to several event handlers. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 109ac2db0d65..6b1b142c95db 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -8884,10 +8884,11 @@ static int mlxsw_sp_inetaddr_port_vlan_event(struct net_device *l3_dev, } static int mlxsw_sp_inetaddr_port_event(struct net_device *port_dev, - unsigned long event, + unsigned long event, bool nomaster, struct netlink_ext_ack *extack) { - if (netif_is_any_bridge_port(port_dev) || netif_is_lag_port(port_dev)) + if (!nomaster && (netif_is_any_bridge_port(port_dev) || + netif_is_lag_port(port_dev))) return 0; return mlxsw_sp_inetaddr_port_vlan_event(port_dev, port_dev, event, @@ -8918,10 +8919,10 @@ static int __mlxsw_sp_inetaddr_lag_event(struct net_device *l3_dev, } static int mlxsw_sp_inetaddr_lag_event(struct net_device *lag_dev, - unsigned long event, + unsigned long event, bool nomaster, struct netlink_ext_ack *extack) { - if (netif_is_bridge_port(lag_dev)) + if (!nomaster && netif_is_bridge_port(lag_dev)) return 0; return __mlxsw_sp_inetaddr_lag_event(lag_dev, lag_dev, event, @@ -8980,7 +8981,7 @@ static int mlxsw_sp_inetaddr_bridge_event(struct mlxsw_sp *mlxsw_sp, static int mlxsw_sp_inetaddr_vlan_event(struct mlxsw_sp *mlxsw_sp, struct net_device *vlan_dev, - unsigned long event, + unsigned long event, bool nomaster, struct netlink_ext_ack *extack) { struct net_device *real_dev = vlan_dev_real_dev(vlan_dev); @@ -8988,7 +8989,7 @@ static int mlxsw_sp_inetaddr_vlan_event(struct mlxsw_sp *mlxsw_sp, u16 lower_pvid; int err; - if (netif_is_bridge_port(vlan_dev)) + if (!nomaster && netif_is_bridge_port(vlan_dev)) return 0; if (mlxsw_sp_port_dev_check(real_dev)) { @@ -9132,19 +9133,21 @@ static int mlxsw_sp_inetaddr_macvlan_event(struct mlxsw_sp *mlxsw_sp, static int __mlxsw_sp_inetaddr_event(struct mlxsw_sp *mlxsw_sp, struct net_device *dev, - unsigned long event, + unsigned long event, bool nomaster, struct netlink_ext_ack *extack) { if (mlxsw_sp_port_dev_check(dev)) - return mlxsw_sp_inetaddr_port_event(dev, event, extack); + return mlxsw_sp_inetaddr_port_event(dev, event, nomaster, + extack); else if (netif_is_lag_master(dev)) - return mlxsw_sp_inetaddr_lag_event(dev, event, extack); + return mlxsw_sp_inetaddr_lag_event(dev, event, nomaster, + extack); else if (netif_is_bridge_master(dev)) return mlxsw_sp_inetaddr_bridge_event(mlxsw_sp, dev, -1, event, extack); else if (is_vlan_dev(dev)) return mlxsw_sp_inetaddr_vlan_event(mlxsw_sp, dev, event, - extack); + nomaster, extack); else if (netif_is_macvlan(dev)) return mlxsw_sp_inetaddr_macvlan_event(mlxsw_sp, dev, event, extack); @@ -9171,7 +9174,8 @@ static int mlxsw_sp_inetaddr_event(struct notifier_block *nb, if (!mlxsw_sp_rif_should_config(rif, dev, event)) goto out; - err = __mlxsw_sp_inetaddr_event(router->mlxsw_sp, dev, event, NULL); + err = __mlxsw_sp_inetaddr_event(router->mlxsw_sp, dev, event, false, + NULL); out: mutex_unlock(&router->lock); return notifier_from_errno(err); @@ -9195,7 +9199,8 @@ static int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, if (!mlxsw_sp_rif_should_config(rif, dev, event)) goto out; - err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, ivi->extack); + err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, false, + ivi->extack); out: mutex_unlock(&mlxsw_sp->router->lock); return notifier_from_errno(err); @@ -9224,7 +9229,7 @@ static void mlxsw_sp_inet6addr_event_work(struct work_struct *work) if (!mlxsw_sp_rif_should_config(rif, dev, event)) goto out; - __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, NULL); + __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, false, NULL); out: mutex_unlock(&mlxsw_sp->router->lock); rtnl_unlock(); @@ -9278,7 +9283,8 @@ static int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, if (!mlxsw_sp_rif_should_config(rif, dev, event)) goto out; - err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, i6vi->extack); + err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, false, + i6vi->extack); out: mutex_unlock(&mlxsw_sp->router->lock); return notifier_from_errno(err); @@ -9598,10 +9604,11 @@ static int mlxsw_sp_port_vrf_join(struct mlxsw_sp *mlxsw_sp, */ rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); if (rif) - __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, + __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, false, extack); - return __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_UP, extack); + return __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_UP, false, + extack); } static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp, @@ -9612,7 +9619,7 @@ static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp, rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); if (!rif) return; - __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, NULL); + __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, false, NULL); } static bool mlxsw_sp_is_vrf_event(unsigned long event, void *ptr) From patchwork Wed Jul 19 11:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318787 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 34A7DC8EF for ; Wed, 19 Jul 2023 11:02:34 +0000 (UTC) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7C0E4C for ; Wed, 19 Jul 2023 04:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q96J3MLbo+B3MlrYSom6o3ZwOKy2Wa/f2lAcF8Ou5YVUGOcp0GVoRQpXEu/U3Kv9hEg5s2t4ZfzJUYGWJEHEpSJKo0kDJxfNVhV0Xcs5YkNQx57nTnVzMqn106qGd067cn+NAp0B++areE+b+niDUuuTcRaPnU+8YoDC4awl2fYHYhEoDY7iym8okMI5bzmjfeyVIWE0rjqb4GftV/LAG5NPcjCB1M+wgG5nD016nXTxHf7C3RAOsMv3cPY28on+WApUkmmCYgjXrUFL+mPSqjnuFU9UTbfeFH/Bj48exXa8dX1/f/iehAI3WbP4xy/rnA8utb8CvFUCC0oCFonI9w== 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=+hXMsv2EU40EniQIDerpxIcD8XQKcwRsTa9MH6irV7g=; b=aTdz3bZiyZIZS6DBi7eojWKxQ6HE/34y72rxW0ULt4D4Cpf7vaEyOWJuHFpLSosEnrswkDr51Rc7l+F0/Yr6+aeYWX6R7LHctlMCln5ZSmkXB9lM7fIGYkjVRm9XfI2/B/P1zyas74vN+kAAolm4WAUM8VNTv6P4cCm89CiimLNvXjctz0/ain5m/bqtSW8nW3EPcgqjf9i+nVlrw3qjKTB5eBwwBy0o8FUKNcREXOoQedSrl1tGFN77dxTbzaywFD2f7/YK6Pg+CuRcqYLgoG0HE6p649YWdYF9lSXY/ce8iralf/mHcUqU92i0GMCsD1yFmJpvssW8Bs/8nudiNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=+hXMsv2EU40EniQIDerpxIcD8XQKcwRsTa9MH6irV7g=; b=hwnD2E9NXxyVbj6Hr/WuvcPaRgZ+X7JLygxse+6RJC+mMX/7RRD1lMzpVKMfhG6zuj/j6LSspm84Qf/3QAUFZTa/wiE03oIbC9PB8+XPIU6B17z6IsV/wVHD5ZpQvsQHuTBirEXLt4fubiMTQUnsrEG4KHvGZlcf7WhYNhyIq/uWX9OoAODMoMRu5uKaayg8Ep4GUtOsQUMHWMLNBmb4fLNcHt0pkK4iWITb+0YjfaLY7Xd8I+xbeAzsHFru5E893bTo8X17Zq8IDM9IU+/oVLdp+BJ144JlEtdrsTDiFq5nkTVb0pL4EiY0Ey0PrirqjERqAWnI+fkdxmr4FU6VjA== Received: from BN0PR04CA0075.namprd04.prod.outlook.com (2603:10b6:408:ea::20) by SJ1PR12MB6362.namprd12.prod.outlook.com (2603:10b6:a03:454::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Wed, 19 Jul 2023 11:02:28 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::5f) by BN0PR04CA0075.outlook.office365.com (2603:10b6:408:ea::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:27 +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 BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:27 +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; Wed, 19 Jul 2023 04:02:11 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:09 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 05/17] mlxsw: spectrum_router: Extract a helper to schedule neighbour work Date: Wed, 19 Jul 2023 13:01:20 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT037:EE_|SJ1PR12MB6362:EE_ X-MS-Office365-Filtering-Correlation-Id: cc820d44-237d-46fe-7ec6-08db8847a3d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ppyPRlf35q6lSmj7OEZ7Z6oQfHu8ykD3UwXvj3iBg+WYvYwEXBNAHncqJ+gj0EW+kd6hSLCksqYxA6Uu/4AN0l3UVWiIEyP9ehp0bZC8bAaPd+5cQCZbHR+rF/UgSipdqWYID9W7o8sA9lufngMN1yKk+1gWSD+t5GO8ci37tAjzIPdXq+vkgbGPXsgIeBZh0UPV8l/A+25hgYo7I0Yze4caavkzL18wcXNyxM2Bq+4QDDlPskLM9jRf96GUVmaXtEHc1aX/DARx/whZ2WtAkRu2WiWF/jxWDAxUfZa/LXGWEWWt7a+T7hJp9lclv/BKD6IX9mNB9/Vh5Vmv2SqhWpWr2M8LZrGNaR9sclVrEOYcWa3Suy+N9jC1B+ufK2782qcMf5cD+M2yzKNrAE6KQezX0SR/Mx5vQAehV7xaJSwQxZJc7GBF+lzS/Yndt5OnVVcQfhMQEdSvQD3J+d4UfE3C1AJK6IfTIom9RFYooO2iTHIhDDWJJMMggyCq6E8ouNREDXiVH3il6U2cPwBAbFeMr/7crG8XsBCocvuHTH69dfbAGz20QWz9IdywM9lyafv4l/mmVPfcEG8TnaJuMBGmeQk9kugj6ix++MsBaskAnK8WvraaqG3zEd+aucee+yANuJz7G3Z4RL/rZiWjWwRcisMbFAZrfuSkAcZFQAncQwqv+whDRda17G7Ro538pygsmGBcYvBco5p78kn1tLn+G1ZD3ed3Rud2IsCIq5MxM2a9ewqg40QteTVkyS+V3gVPyRHjLDC/2uJgIpgeTg== 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)(396003)(136003)(376002)(82310400008)(451199021)(46966006)(40470700004)(36840700001)(8676002)(66574015)(6666004)(54906003)(478600001)(110136005)(47076005)(36756003)(83380400001)(426003)(40460700003)(86362001)(2616005)(40480700001)(316002)(70586007)(70206006)(186003)(336012)(107886003)(26005)(82740400003)(16526019)(356005)(41300700001)(7636003)(5660300002)(2906002)(36860700001)(8936002)(4326008)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:27.3497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc820d44-237d-46fe-7ec6-08db8847a3d1 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: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6362 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 This will come in handy for neighbour replay. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 6b1b142c95db..18e059e94079 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2872,6 +2872,21 @@ static bool mlxsw_sp_dev_lower_is_port(struct net_device *dev) return !!mlxsw_sp_port; } +static int mlxsw_sp_router_schedule_neigh_work(struct mlxsw_sp_router *router, + struct neighbour *n) +{ + struct net *net; + + net = neigh_parms_net(n->parms); + + /* Take a reference to ensure the neighbour won't be destructed until we + * drop the reference in delayed work. + */ + neigh_clone(n); + return mlxsw_sp_router_schedule_work(net, router, n, + mlxsw_sp_router_neigh_event_work); +} + static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -2879,7 +2894,6 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, unsigned long interval; struct neigh_parms *p; struct neighbour *n; - struct net *net; router = container_of(nb, struct mlxsw_sp_router, netevent_nb); @@ -2903,7 +2917,6 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, break; case NETEVENT_NEIGH_UPDATE: n = ptr; - net = neigh_parms_net(n->parms); if (n->tbl->family != AF_INET && n->tbl->family != AF_INET6) return NOTIFY_DONE; @@ -2911,13 +2924,7 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, if (!mlxsw_sp_dev_lower_is_port(n->dev)) return NOTIFY_DONE; - /* Take a reference to ensure the neighbour won't be - * destructed until we drop the reference in delayed - * work. - */ - neigh_clone(n); - return mlxsw_sp_router_schedule_work(net, router, n, - mlxsw_sp_router_neigh_event_work); + return mlxsw_sp_router_schedule_neigh_work(router, n); case NETEVENT_IPV4_MPATH_HASH_UPDATE: case NETEVENT_IPV6_MPATH_HASH_UPDATE: From patchwork Wed Jul 19 11:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318788 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 37FBA12B6E for ; Wed, 19 Jul 2023 11:02:34 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BD55E42 for ; Wed, 19 Jul 2023 04:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4lPoGpJxkpCrjt7im4xaCMhxaAb9mN3SpILxyuFWcHUO5eHhZrHUuMnb6MdwIfI5RU9+e+riUiTaMTJgBpc0/GwED19gS1thTiLp6acJnEdAMGaf6c1RPcY33IjjIVmI0b0iYVuzlOEPOSxI6L8ZhiT6UPZfTFwHJGflt+pDZkG0vRvXXxRt4xYqQu4PDzOPownBkXHSfHP53ycdgxgnPoF5q/m+S7UshT05vgVq9Gp4U2IN2lmpVaXF8aUACDygd5GK5omnHil4X0b7xBT4ddEJy84L6DBH/9t0MjQhfEOiopNAd7LvLgICstKxot4PTuMVpi2ZTIZ8JBh8dxDEw== 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=BFiqUMPZYUeM+OZB5tTJsc4Sj2J9oLGRNtKxYJZx6b8=; b=FJiNHLvOlLo2ca0muXdvgFahC/DPdPYnBgp7Hs2Ur9oAQjX1+ObVoGMBwolWFcP4hBJWQCerdKS/zMx8udMsu2Tm0HJXIYPjZzR7vpVplEjAKwaSqBLmabIonA9VmbOd/kmbLofnD5YYNLitgg/UV3Ap+yERmL1MQQDWgrezGLXIbuncoI79C98W2kFCbf0Ta3g7+vrowG/oAkChIHibXQh0vicsFsyzW2WnoI4KyvM+o1axThr00G9nr2N8wgLTG3i4guHn4CRs/SnZl0vjXRzerjL+liQ3bvMjuU+qLnsp0bOUFwcjx9nhM906sdXt+Hkw4YDHccIylEwhv7azrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=BFiqUMPZYUeM+OZB5tTJsc4Sj2J9oLGRNtKxYJZx6b8=; b=U6LUIglaDUwShGAF/N0P7PXgxL0K6ruxvLTi4opf+jBEWA5JWt28u2VzhX6I1QK2UUg86xY3OYzMfXgtx2e1KTUUOCJEzhcMNATCqK8IDQegthgvwgbNzkkAq9WwE514O8QHdqhAzNz1KA40xnd5N8wZw/WNdeKLV5an8yfUoNlynXHrZXrKzh5Ct+sCFM4of27gEHyTQyzFT8PPxCDjY/eQlqOUzAccq9vgDIfUL5BaRLyaPX06Oadm58IDT50dqyCxDB2PlZEfMbJ6q0frDpltW1ovqCqb8SUDl7Gtfjn4C5nn2P4zG0tdZdth/lLjDitoyuPqXiQhzuVItg71/g== Received: from BN9PR03CA0045.namprd03.prod.outlook.com (2603:10b6:408:fb::20) by IA0PR12MB8208.namprd12.prod.outlook.com (2603:10b6:208:409::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 11:02:30 +0000 Received: from BN8NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::f3) by BN9PR03CA0045.outlook.office365.com (2603:10b6:408:fb::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT112.mail.protection.outlook.com (10.13.176.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:29 +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; Wed, 19 Jul 2023 04:02:14 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:11 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 06/17] mlxsw: spectrum: Split a helper out of mlxsw_sp_netdevice_event() Date: Wed, 19 Jul 2023 13:01:21 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT112:EE_|IA0PR12MB8208:EE_ X-MS-Office365-Filtering-Correlation-Id: ac629cb9-fc54-4329-d108-08db8847a55c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4hCk8+jAtm1tnrsmQ4LCMRxWIwTnJgJvkmN1cvAiB31PiPe/AhXUkFE0x8C2V7H7pf0BH8EzKX+lSzICW32lRI4IQLZwB4pMAYxQAuYLniqzwUhBOiDsZcXNB13GwQ5g7kWMib3MV6TJGr1Qs8TeRBAaLQjx4SSqqQSkdj82D5Y64BVqM6Q7mH8dHIAqvTOYlvHxg3D6+YlpXzFPfw/67Gpd6eCALoTgSbf1CNo2W3wzhh7ouu5RnSJdzM5AjInPqOxpzKNYtn5g/z5ZnUh73dUSzM3pVZUo5oQH4uZ/znzEC8XOEIBJIJukPAbIcS485aQmVHtaQrN6a4URxSAAbNiSQcS6LltUepScemTH43nhb1uzLulnFnfNp2Xuo3OgqId9eEfTIlvrSXnCcZP0AFn8Nk/GQ8ZZHDgTrMnRh3JPmXV2FToEp6YwYPb1jg5E8V2wE4tFq5euWn4g+3CatKaD/CvopFx+CyPJoR0up9vWsFdYcwdpVyLPqrAKBD5dPCIHug91Sf8LvbJIWeR4YJEf6CjDKu4Lbhaivop6KKnb+cQKwTt6MZu7gIUUc5urvGaeZmZvYadof50ov6/+45cus8gntlKoGb9wfup05owc3g1PK59yxvTFhaGlmZrXEBJMt+6KI7/X/x29cMWMcDK6HJkiq4/vuAiGTwkqltGS9wK3eITCtwjFCGLLrASy50c3Ljo+SYd13hiuOc0GR8TI/s8iVR6ELTlQePrLOSI= 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)(376002)(136003)(396003)(346002)(39860400002)(451199021)(82310400008)(40470700004)(46966006)(36840700001)(40480700001)(110136005)(40460700003)(6666004)(7636003)(356005)(54906003)(82740400003)(478600001)(41300700001)(5660300002)(8676002)(8936002)(4326008)(70206006)(70586007)(316002)(2616005)(426003)(83380400001)(336012)(16526019)(186003)(36860700001)(47076005)(26005)(107886003)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:29.9405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac629cb9-fc54-4329-d108-08db8847a55c 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: BN8NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8208 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Move the meat of mlxsw_sp_netdevice_event() to a separate function that does just the validation. This separate helper will be possible to call later for recursive ascent when validating attachment of a front panel port to a bridge with uppers. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 86e2f0ed64d3..0488fe5695bd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -5146,21 +5146,18 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, return 0; } -static int mlxsw_sp_netdevice_event(struct notifier_block *nb, - unsigned long event, void *ptr) +static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, + unsigned long event, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct mlxsw_sp_span_entry *span_entry; - struct mlxsw_sp *mlxsw_sp; int err = 0; - mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); if (event == NETDEV_UNREGISTER) { span_entry = mlxsw_sp_span_entry_find_by_port(mlxsw_sp, dev); if (span_entry) mlxsw_sp_span_entry_invalidate(mlxsw_sp, span_entry); } - mlxsw_sp_span_respin(mlxsw_sp); if (netif_is_vxlan(dev)) err = mlxsw_sp_netdevice_vxlan_event(mlxsw_sp, dev, event, ptr); @@ -5175,6 +5172,19 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb, else if (netif_is_macvlan(dev)) err = mlxsw_sp_netdevice_macvlan_event(dev, event, ptr); + return err; +} + +static int mlxsw_sp_netdevice_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct mlxsw_sp *mlxsw_sp; + int err; + + mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); + mlxsw_sp_span_respin(mlxsw_sp); + err = __mlxsw_sp_netdevice_event(mlxsw_sp, event, ptr); + return notifier_from_errno(err); } From patchwork Wed Jul 19 11:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318789 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 A964D13AE6 for ; Wed, 19 Jul 2023 11:02:34 +0000 (UTC) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2058.outbound.protection.outlook.com [40.107.212.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE56918D for ; Wed, 19 Jul 2023 04:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVtllsaV61zO1Uq8fAJwZ0c1NgzyPzMbrHsF87FIfRgjYqef/REZ8V1JWLmt2zrw2nhfT4drzSZuAHbXCvO1gzGad2Ciii1vec6Mdx5GUA50CKn7hsg3uGSZxOwmnMioMGn6zbYs9cZxXKI1SQFDmoiUmkfN6kIvOsnJ83dqLErqs1md+S61OnJMYpH408KBk2oBVD2OQP+F6cXvX3hTQSwsckIGdSKf+GjMgzBIncOK1ySxXIQcXX+l2GjMBmfL/8YeCBBIxlIwr6aQsV1yeMb4ISzHh+Yh6aEioyP0yOQg6N8xjz7HETuF5U596N0ntB8VBVFEYlLkdEv6z+Lnyg== 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=x5tnSeg9y5Bu8DjdrJ+TXcTzKepIqy5K4zDnOiaH0p4=; b=Hc/hi2IKCt8AKzD+P/vJDJFEKgfrmWhkdK168GjcK7jWTtWhQPin6Z/mdDsmnvIzQEa6tNZost9DlZhTkVEx8IXAE4Hu/j1Ff7AAwUA50iCKHL+zDiXXTeSdirv7hDyPQLHNC9rp4cZdiPyP6/SUpfFPS6davl3s7ojc0E9AHcmboPWzsDvoVZ3j/sstblXPq8Ux8e8+Z8K6XDA740byAPols9/sBxqbYR97XwtYSXzhlp0BUFXXfu4nYsn5Uslkt4u0/4gFgpW8TplWiZlANNztmrPF66EBxBKNGaJEWZG4ligMdKbUis4yZtAzAmtzhLxYvaQDRvPdTvufYqDvCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=x5tnSeg9y5Bu8DjdrJ+TXcTzKepIqy5K4zDnOiaH0p4=; b=rOFcLEmR3LawUtJYCPznrrZir3BHDrorP+11VQvzt78KtHTBaYirIAkuQ5P9d2j17DCYvRJef/X3mA0GE/src5I/qNCKZKYJ1nH9u1ybt7ZdHv7RNrHS4ehSJU1r01gKw1F6UCbHVw9N/tA4Nqp6i0XiyQkBzBj90HS8dK6cmB6Nua9VamUk1wX4SvNJcuckFil7h1BI7I5DjABhw84IszVKBZCoq2+JO2W8J+/hYQZlLV7FVgdjpQMbkMpCzIT8F8rGj86mEzl92JhW4GNgLfMLt5Z++2S+2V6heKQeDBX59YowPlKjmkSJ6GVCWsbTS8ksYLelf1ghqRPbuQRtiw== Received: from BN9PR03CA0203.namprd03.prod.outlook.com (2603:10b6:408:f9::28) by SA3PR12MB7859.namprd12.prod.outlook.com (2603:10b6:806:305::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 11:02:30 +0000 Received: from BN8NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f9:cafe::89) by BN9PR03CA0203.outlook.office365.com (2603:10b6:408:f9::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02:30 +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 BN8NAM11FT096.mail.protection.outlook.com (10.13.177.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:30 +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; Wed, 19 Jul 2023 04:02:17 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:14 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 07/17] mlxsw: spectrum: Allow event handlers to check unowned bridges Date: Wed, 19 Jul 2023 13:01:22 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT096:EE_|SA3PR12MB7859:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a15ae5b-7b06-4b29-5d18-08db8847a568 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fVdwYQKBk4OlSSgfLrvGFqE9CBCfF9NGNc5fXaxFFQIIck2rWajZQjlJBRFyGucL7lAIOQ4d2ZXAdcppfIZxJOklDRKVXpp8CDz+LXoi4DcWvo6kAD1eoUtzCmlOTnWbF9KrNXRZQ/w09cEN+cC+BMr4wIMEMC9sStxAl0bLug1DYzYQZJJTQRMK9wk3SgYEvYpUZotP/bcPbUDBRBEFSP1w+NKVAobKZoI89OV/jRVEZcNs/K3bwRj63Lv8tmyXEqJgDxMkCP1JWv/SoYDrTq6l2xG1Yf0/Nl+kt8EZKZlof2BEdC1e/odpa+8dA6b9GU6rpcBv2e0yFeTDMuGDlyL8LoIgUdBLw8fJHPXWibj54eR5GMLygmmZIiKasMa81RD39ENwoAg1nA+QYlflBwXVksgYFXp9KFCbNz1jYsx+55em7Kt5KX/1uq6KPWaIT+KGHPCpJEoJ3iDPXuet0shMIaKsdyrssniMQ2iXogm4gpmTdcbSN47PnLgwPBHYxA25u42Kpl6iH//Mg6TyjIps+ExAKdrSRnPAlthzV1qiziDgMIOMQoOSwk60SSJX5LoS8kM0Vj1jHvrxRUaYUpBsHa3sbJ3ivjVh6dy2dgWclJ3lWm/SN1HMkPb++nnVg1oFF9JsJGBgmWgkth965LiIVdx4MdK2YP0uITHSYXTM9UScRGqvpeQWomuWgXXBAReAdzcbVH++uShMjIrtFWOrQ0vRlB1GiEjbUwpOqbE= 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)(376002)(39860400002)(136003)(396003)(346002)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(6666004)(478600001)(54906003)(110136005)(336012)(186003)(16526019)(26005)(107886003)(2906002)(82740400003)(316002)(41300700001)(4326008)(70206006)(5660300002)(70586007)(8936002)(8676002)(7636003)(356005)(86362001)(40460700003)(36756003)(36860700001)(426003)(2616005)(83380400001)(47076005)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:30.0161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a15ae5b-7b06-4b29-5d18-08db8847a568 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: BN8NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7859 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Currently the bridge-related handlers bail out when the event is related to a netdevice that is not an upper of one of the front-panel ports. In order to allow enslavement of front-panel ports to bridges that already have uppers, it will be necessary to replay CHANGEUPPER events to validate that the configuration is offloadable. In order for the replay to be effective, it must be possible to ignore unsupported configuration in the context of an actual notifier event, but to still "veto" these configurations when the validation is performed. To that end, introduce two parameters to a number of handlers: mlxsw_sp, because it will not be possible to deduce that from the netdevice lowers; and process_foreign to indicate whether netdevices that are not front panel uppers should be validated. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 0488fe5695bd..3d1a045ff470 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4936,17 +4936,17 @@ static int mlxsw_sp_netdevice_lag_port_vlan_event(struct net_device *vlan_dev, return 0; } -static int mlxsw_sp_netdevice_bridge_vlan_event(struct net_device *vlan_dev, +static int mlxsw_sp_netdevice_bridge_vlan_event(struct mlxsw_sp *mlxsw_sp, + struct net_device *vlan_dev, struct net_device *br_dev, unsigned long event, void *ptr, - u16 vid) + u16 vid, bool process_foreign) { - struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(vlan_dev); struct netdev_notifier_changeupper_info *info = ptr; struct netlink_ext_ack *extack; struct net_device *upper_dev; - if (!mlxsw_sp) + if (!process_foreign && !mlxsw_sp_lower_get(vlan_dev)) return 0; extack = netdev_notifier_info_to_extack(&info->info); @@ -4979,8 +4979,10 @@ static int mlxsw_sp_netdevice_bridge_vlan_event(struct net_device *vlan_dev, return 0; } -static int mlxsw_sp_netdevice_vlan_event(struct net_device *vlan_dev, - unsigned long event, void *ptr) +static int mlxsw_sp_netdevice_vlan_event(struct mlxsw_sp *mlxsw_sp, + struct net_device *vlan_dev, + unsigned long event, void *ptr, + bool process_foreign) { struct net_device *real_dev = vlan_dev_real_dev(vlan_dev); u16 vid = vlan_dev_vlan_id(vlan_dev); @@ -4993,22 +4995,25 @@ static int mlxsw_sp_netdevice_vlan_event(struct net_device *vlan_dev, real_dev, event, ptr, vid); else if (netif_is_bridge_master(real_dev)) - return mlxsw_sp_netdevice_bridge_vlan_event(vlan_dev, real_dev, - event, ptr, vid); + return mlxsw_sp_netdevice_bridge_vlan_event(mlxsw_sp, vlan_dev, + real_dev, event, + ptr, vid, + process_foreign); return 0; } -static int mlxsw_sp_netdevice_bridge_event(struct net_device *br_dev, - unsigned long event, void *ptr) +static int mlxsw_sp_netdevice_bridge_event(struct mlxsw_sp *mlxsw_sp, + struct net_device *br_dev, + unsigned long event, void *ptr, + bool process_foreign) { - struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(br_dev); struct netdev_notifier_changeupper_info *info = ptr; struct netlink_ext_ack *extack; struct net_device *upper_dev; u16 proto; - if (!mlxsw_sp) + if (!process_foreign && !mlxsw_sp_lower_get(br_dev)) return 0; extack = netdev_notifier_info_to_extack(&info->info); @@ -5147,7 +5152,8 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp, } static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, - unsigned long event, void *ptr) + unsigned long event, void *ptr, + bool process_foreign) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct mlxsw_sp_span_entry *span_entry; @@ -5166,9 +5172,11 @@ static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, else if (netif_is_lag_master(dev)) err = mlxsw_sp_netdevice_lag_event(dev, event, ptr); else if (is_vlan_dev(dev)) - err = mlxsw_sp_netdevice_vlan_event(dev, event, ptr); + err = mlxsw_sp_netdevice_vlan_event(mlxsw_sp, dev, event, ptr, + process_foreign); else if (netif_is_bridge_master(dev)) - err = mlxsw_sp_netdevice_bridge_event(dev, event, ptr); + err = mlxsw_sp_netdevice_bridge_event(mlxsw_sp, dev, event, ptr, + process_foreign); else if (netif_is_macvlan(dev)) err = mlxsw_sp_netdevice_macvlan_event(dev, event, ptr); @@ -5183,7 +5191,7 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb, mlxsw_sp = container_of(nb, struct mlxsw_sp, netdevice_nb); mlxsw_sp_span_respin(mlxsw_sp); - err = __mlxsw_sp_netdevice_event(mlxsw_sp, event, ptr); + err = __mlxsw_sp_netdevice_event(mlxsw_sp, event, ptr, false); return notifier_from_errno(err); } From patchwork Wed Jul 19 11:01:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318791 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 C641C14267 for ; Wed, 19 Jul 2023 11:02:40 +0000 (UTC) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062.outbound.protection.outlook.com [40.107.96.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995D018D for ; Wed, 19 Jul 2023 04:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELvb5rKBMNg64hy9fRPQ+6AlW+kFC+5ijB7OKHiVgpx0j/iYjzITK0HG4EADwTfBqzz81XwtyiRzVBXS9ay1IOsk0oFHX2+Vt1HlUycKSq2DqA3gE7xoxSEoqKy+HWwpXY3KFf4UfX7z44QQ2tRRtcn+OibV12e4rbslsjjSRMIbePDjtfdB8h6SBbCI0UZEOO1XAOVrLOWzLc4Obh86EgKY/7gyHKLHVYPMgmsaOpF3Rfvvi5GVcwDcFF8OP7jm7J1e+sGGbAVk0lrC8bo5owfGBMOsf6k83MvOYLrM4knQdh2pZOP0i0kGM5qhLcPOMYIuIGHbJbHGhCNHRQk5pg== 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=b4VfrTBvmM+n6PhPjAZEOvqe1/im6TtTvJfrFCPM1Hc=; b=Vo3yJUyY+dk18F3L2h6777sfCgf7aNLxejmBLWGjucvjZvFJvITNlRYBUL3H8ToGc5HXzwPjbb2E8WFnok9L8KtFOSu76H3iR8XDsG13sepvPlHxkvBlB9TiFRoT+frTEB+AtYIuFaj4F/Z07Pvgc3eCCslKnUd2epIcP2rZstucxRTkcOWObHqadsJOYgSPVTvsxW+6dVBxNG8qM91nGtr+5NhBEAag7Q+ResGQL7z0plAt9Xy7MibxFZdbstZX6+EKyXLjD/YWXS6aONU9+w8HJkSwC7U+409cjvEPTxFW283qf6Vrs2m+Lq+PCxWXVaya+b5N21rmis6wZwFEvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=b4VfrTBvmM+n6PhPjAZEOvqe1/im6TtTvJfrFCPM1Hc=; b=FflWtcWBHcWDkNYUesGlHBNFJs4VJFw8BazYreES3gcvQDHD9f215YBZWSirsZop/m9yOrhIulf1EUJyLrCb4NWhSdXRxgE5xoLccASHvcD0RHpt+5mjcPuAQ0JBf+Wvqn6MutKqvYLdWEulEH3SzRjDYEhj2kTjeDzNlSEus6vghLNzOs1ne56NQNat44iGKYCpuCIyNbWdhqo2XKTy9SuEpObIbHh4e2ZuED1cZTMag4VF6vGUmtWEGlyaQFv9sivJn8/j54PuWjxcSMt6AeBqG6Q9OJxwEZ9mraRcjpqcG7k1wy+7td9kT13+a2CaivOwo3/1W3bgLJ6DbJdI/Q== Received: from BN7PR06CA0049.namprd06.prod.outlook.com (2603:10b6:408:34::26) by CH2PR12MB4939.namprd12.prod.outlook.com (2603:10b6:610:61::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.23; Wed, 19 Jul 2023 11:02:35 +0000 Received: from BN8NAM11FT115.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::67) by BN7PR06CA0049.outlook.office365.com (2603:10b6:408:34::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:34 +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 BN8NAM11FT115.mail.protection.outlook.com (10.13.177.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.35 via Frontend Transport; Wed, 19 Jul 2023 11:02:34 +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; Wed, 19 Jul 2023 04:02:19 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:17 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 08/17] mlxsw: spectrum: Add a replay_deslavement argument to event handlers Date: Wed, 19 Jul 2023 13:01:23 +0200 Message-ID: <34822af84ea869634e909f5cbac2915fa48acd33.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT115:EE_|CH2PR12MB4939:EE_ X-MS-Office365-Filtering-Correlation-Id: 88db0979-b5fb-43f6-cc4a-08db8847a7f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wNeh4eluXWB3EdzeQFIpLVKBPLhar71uPz88wKQp7TbjpEuxGJhaeysbljuz0W6jKQhqzSWrrVv2mCCe55mNlbGU1IYH9DZS8uDOCV62GHSx14jgdVaENurmUW0CJwhoVVtxrxBQQqCANSsho3dPmm2BQJMO+dX+8CHnzEkI+cCsxia9YaOU4zEg/kKX3UnHTE0LG8cFO2kQP2ju2a7nuO32JCkL+UEZtprM8q/pfjnMUWF84qokMKC3LS2DksbfnxZGyySHxZRalMrvtA6AGv8dWNkv0TWDu+rKmlLy1FaI0G8S6jwogEI9Ou398bRBxXVz8MX07drrB3T6NAknsr4jWJ1cdotOyCPwwigPywwBubUDNPtEPetxM9lb1Lww6DTK0khtLLy3Z2h9DkvhL5anda60m/z5hOkoMRazpQhSF9i3M88Y11WNObRl1J66wnVATYao0kbwzau9vi+DaBqD6CnPw75sRhUAMMDGKqB0wylAEiTmhJQwuDFLk/O4xEqXDOCVF96k0DPSsnJk1lf82HG8myWMHyK8F4oMHIQLCqLXiLx/W2XW75ABMJBlmZaoW0d8t1+9VrjwmnJSChEGBZkAx8Fin9fXEnkV3xyOj/7QLZsvnc1gokXX94DERWpYxwnMzJ/sGHfo15WUie3D72rxQVOxwnHpNUPXRxV7fdlmE/Mi5ni0hiYr3Il9STp1WGA1OwYZBfwLeYvD8cOvTB57d13u9T4gviNqbsY= 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)(376002)(136003)(396003)(346002)(39860400002)(451199021)(82310400008)(40470700004)(46966006)(36840700001)(36860700001)(41300700001)(316002)(426003)(66574015)(83380400001)(26005)(2616005)(107886003)(186003)(336012)(16526019)(47076005)(40460700003)(356005)(7636003)(82740400003)(478600001)(110136005)(54906003)(6666004)(4326008)(40480700001)(70206006)(70586007)(5660300002)(86362001)(8936002)(8676002)(36756003)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:34.3181 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88db0979-b5fb-43f6-cc4a-08db8847a7f8 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: BN8NAM11FT115.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4939 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 When handling deslavement of LAG or its upper from a bridge device, when the deslaved netdevice has an IP address, it should join the router. This should be done after all the lowers of the LAG have left the bridge. The replay intended to cause the device to join the router therefore cannot be invoked unconditionally in the event handlers themselves. It can be done right away if the handler is invoked for a sole device, but when it is invoked repeated for each LAG lower, the replay needs to be postponed until after this processing is done. To that end, add a boolean parameter, replay_deslavement, to mlxsw_sp_netdevice_port_upper_event(), mlxsw_sp_netdevice_port_vlan_event() and one helper on the call path. Have the invocations that are done for sole netdevices pass true, and those done for LAG lowers pass false. Nothing depends on this flag at this point, but it removes some noise from the patch that introduces the replay itself. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 3d1a045ff470..b9ceffe258bf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4641,7 +4641,8 @@ static bool mlxsw_sp_bridge_vxlan_is_valid(struct net_device *br_dev, static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, struct net_device *dev, - unsigned long event, void *ptr) + unsigned long event, void *ptr, + bool replay_deslavement) { struct netdev_notifier_changeupper_info *info; struct mlxsw_sp_port *mlxsw_sp_port; @@ -4815,13 +4816,15 @@ static int mlxsw_sp_netdevice_port_lower_event(struct net_device *dev, static int mlxsw_sp_netdevice_port_event(struct net_device *lower_dev, struct net_device *port_dev, - unsigned long event, void *ptr) + unsigned long event, void *ptr, + bool replay_deslavement) { switch (event) { case NETDEV_PRECHANGEUPPER: case NETDEV_CHANGEUPPER: return mlxsw_sp_netdevice_port_upper_event(lower_dev, port_dev, - event, ptr); + event, ptr, + replay_deslavement); case NETDEV_CHANGELOWERSTATE: return mlxsw_sp_netdevice_port_lower_event(port_dev, event, ptr); @@ -4840,7 +4843,7 @@ static int mlxsw_sp_netdevice_lag_event(struct net_device *lag_dev, netdev_for_each_lower_dev(lag_dev, dev, iter) { if (mlxsw_sp_port_dev_check(dev)) { ret = mlxsw_sp_netdevice_port_event(lag_dev, dev, event, - ptr); + ptr, false); if (ret) return ret; } @@ -4852,7 +4855,7 @@ static int mlxsw_sp_netdevice_lag_event(struct net_device *lag_dev, static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, struct net_device *dev, unsigned long event, void *ptr, - u16 vid) + u16 vid, bool replay_deslavement) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; @@ -4927,7 +4930,7 @@ static int mlxsw_sp_netdevice_lag_port_vlan_event(struct net_device *vlan_dev, if (mlxsw_sp_port_dev_check(dev)) { ret = mlxsw_sp_netdevice_port_vlan_event(vlan_dev, dev, event, ptr, - vid); + vid, false); if (ret) return ret; } @@ -4989,7 +4992,8 @@ static int mlxsw_sp_netdevice_vlan_event(struct mlxsw_sp *mlxsw_sp, if (mlxsw_sp_port_dev_check(real_dev)) return mlxsw_sp_netdevice_port_vlan_event(vlan_dev, real_dev, - event, ptr, vid); + event, ptr, vid, + true); else if (netif_is_lag_master(real_dev)) return mlxsw_sp_netdevice_lag_port_vlan_event(vlan_dev, real_dev, event, @@ -5168,7 +5172,7 @@ static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, if (netif_is_vxlan(dev)) err = mlxsw_sp_netdevice_vxlan_event(mlxsw_sp, dev, event, ptr); else if (mlxsw_sp_port_dev_check(dev)) - err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr); + err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr, true); else if (netif_is_lag_master(dev)) err = mlxsw_sp_netdevice_lag_event(dev, event, ptr); else if (is_vlan_dev(dev)) From patchwork Wed Jul 19 11:01:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318790 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 4A07213AE2 for ; Wed, 19 Jul 2023 11:02:40 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0846186 for ; Wed, 19 Jul 2023 04:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=my9n+kYX78DXdxVr/c7VKwx7g1X4voxTmZTknhTAERmmq26wHSUcU9vhw9hk3GtZe1g8ZgM6yMRrgH85vFUgRwDFPhfhGyqI1uFu1NjbCCD/W1nmyJSTZ8/hkhv4BzOxCQS7bk4IkOH/+1WcqEjTDUyByL1xojLVrfQHqVSfEa5kgTDz8dmXRVMcbKwEUG37tMESqTqIDomOACY6tiOdV6XA50xjg5Xc0T9bVD6o+ZTq4YYUSbat+qgMOabmytvcNblLxpdkgeJFbiv8FKQTKPiNxtCXTFiyiTXQMo4szLRsfZitzL422HQ/+RMpbjqqiGWwtwAsFCGmKo9oB0Mryg== 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=mU9QbTVQZGNS1nCOOT2mkq0w7JUJmPDBNvt6bmcbHbg=; b=EUPZwKVCYJ/yZZP9eynEtyi+fyb/pb7TpFbpDN3O6G+TXFMU+JQCw9hxmG6JJe0xe6FyaB1JbBwmptxaDbC/MmM1C/MXfVtArExmH0gy1fW3J5FLQFRSHdI92jm4dF2obofDwg4/NmBaaBC51YAxWleArTs9IYTM9Ru4GBOPLqtur6o1YaUk3efFVQjDwUpHYajsVxfx7JGzP45jZPqyCqNlmcXAWVfECxKe2akLDPe0Z/moshhdhQah9TVYw42HG3tDClHo4/gWmDkE0zSI3lojt3+UyVKM7gEuy7eYkDzPKlxjiOxRzQxvHrW5s8VaIrKgEvIhDt4P8BvquSeZiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=mU9QbTVQZGNS1nCOOT2mkq0w7JUJmPDBNvt6bmcbHbg=; b=Hd0Hns/rImVkTI9ZeTS7LXrAqBQS11HNqy+/7Qh/scz8N+3WW3K4cVYHfcOcCWhhpju+4BEdrNs5f5/CGK4NmY0iKD/98ilf27OIct4UOUHFkM74HA2Kmsrnt2dKWTWXe1WTcqmoCZDb2CI3a1Bzdr7y1ljL1A4Z1WcIgnG3yakRo63e6F6p+ar8vDFSa+Xpdi1P0W9SK33RzNDUF0oL1+2gM1JSFzjbUw4/ASofRtWjtKw6MwKndwZU0VLAJYcCYEyTIql96TUvDsYQMWHXFzTw98o29mP6w18pTZ6YbAFYF+1yZwuknkKZa5gfGbntc9PxQEYxQDAzph2OlzS/fA== Received: from BN7PR06CA0051.namprd06.prod.outlook.com (2603:10b6:408:34::28) by MW4PR12MB6753.namprd12.prod.outlook.com (2603:10b6:303:1ec::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32; Wed, 19 Jul 2023 11:02:37 +0000 Received: from BN8NAM11FT115.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::64) by BN7PR06CA0051.outlook.office365.com (2603:10b6:408:34::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:36 +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 BN8NAM11FT115.mail.protection.outlook.com (10.13.177.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.35 via Frontend Transport; Wed, 19 Jul 2023 11:02:36 +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; Wed, 19 Jul 2023 04:02:22 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:19 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 09/17] mlxsw: spectrum: On port enslavement to a LAG, join upper's bridges Date: Wed, 19 Jul 2023 13:01:24 +0200 Message-ID: <49e06d7bb6a139378ecba2b6b4e5f81706e934f5.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT115:EE_|MW4PR12MB6753:EE_ X-MS-Office365-Filtering-Correlation-Id: ebbd0ccf-fcf5-495e-8db5-08db8847a965 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k/OFvug/+QSvnS321oRtpglUvT38jE5ezTFEZLrIhCSCpPa1gQWzKIzNWnGpSRd6PF4VLfl3sNkeY69zyQFKbe5MiMr/3CLH74o8evagNzlirzwo3ALzRyEFrcDEhTpbSxTgS/EqYfli7hQGfyjUrNoQPaAzCfmtYXO1PUYxgS1v+P0528i+TTh8rdd3ej4xZiC1u1oycjGsfJrX8QYG6LMDGFtSAQZL5fssicAIxIRYDxFB11WMLkf8Dgff9ne0nFgCx0RSarfvme0uPwopvkuUU72/8WOPSUoAdc6O3GJ8LFn2edA2ZVG/G47RzIBwd4m1Y7Dc8qI+eGpNF6+aqfGgA8Tft6q/MJyFC36ZnHUvLFSmdgFsW0UWiybaUpkpnBxu/GTwRjpfKyiIsotecgVvgFWj6RO9WjWst5OA8xKqwFYMXdgAqTTNGpibDrWXgRLOzrEblt2LPy0Aup95Jd1YoNFdVDmPSXu1H56hw6Vsar3jBUWVS4P2eOHg1FnlT5B0Rm6Mnw1x5mQteiId6PYcxE/LOiGBRrb12kFAc/cOtdaPvMYs206heuKKSdjid5VjnjWIj3jgixbWWtC0Ok5VKUWooeaBw31o8j3lrsy069qP3YJz4TvmwpKLE4CSla0y4F42PWEsCVN8ydw0xPF7tJrxYmXVBryFLmfx0RjmuFSuu81KRuya3jJGZxAKqASLCJHHgOxtbxrurjy6Z4oMb4PS/YxSPq6HyY97eeqrI9LDLJVIzxPAPJvrjm/x 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)(136003)(376002)(346002)(396003)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(41300700001)(8676002)(70586007)(8936002)(70206006)(2906002)(6666004)(54906003)(7636003)(356005)(86362001)(4326008)(36860700001)(316002)(47076005)(36756003)(5660300002)(2616005)(426003)(40460700003)(186003)(336012)(26005)(40480700001)(107886003)(82740400003)(16526019)(110136005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:36.7242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebbd0ccf-fcf5-495e-8db5-08db8847a965 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: BN8NAM11FT115.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6753 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Currently it never happens that a netdevice that is already a bridge slave would suddenly become mlxsw upper. The only case where this might be possible as far as mlxsw is concerned, is with LAG netdevices. But if a LAG already has an upper, enslaving mlxsw port to that LAG is forbidden. Thus the only way to install a LAG between a bridge and a mlxsw port is by first enslaving the port to the LAG, and then enslaving that LAG to a bridge. However in the following patches, the requirement that ports be only enslaved to masters without uppers, is going to be relaxed. It will therefore be necessary to join bridges of LAG uppers. Without this replay, the mlxsw bridge_port objects are not instantiated, which causes issues later, as a lot of code relies on their presence. Therefore in this patch, when the first mlxsw physical netdevice is enslaved to a LAG, consider bridges upper to the LAG (both the direct master, if any, and any bridge masters of VLAN uppers), and have the relevant netdevices join their bridges. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index b9ceffe258bf..9a6e1ce4e786 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4337,6 +4337,88 @@ static int mlxsw_sp_port_lag_index_get(struct mlxsw_sp *mlxsw_sp, return -EBUSY; } +static int mlxsw_sp_lag_uppers_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, + struct net_device *lag_dev, + struct netlink_ext_ack *extack) +{ + struct net_device *upper_dev; + struct net_device *master; + struct list_head *iter; + int done = 0; + int err; + + master = netdev_master_upper_dev_get(lag_dev); + if (master && netif_is_bridge_master(master)) { + err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, lag_dev, master, + extack); + if (err) + return err; + } + + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + + master = netdev_master_upper_dev_get(upper_dev); + if (master && netif_is_bridge_master(master)) { + err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, + upper_dev, master, + extack); + if (err) + goto err_port_bridge_join; + } + + ++done; + } + + return 0; + +err_port_bridge_join: + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + + master = netdev_master_upper_dev_get(upper_dev); + if (!master || !netif_is_bridge_master(master)) + continue; + + if (!done--) + break; + + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); + } + + master = netdev_master_upper_dev_get(lag_dev); + if (master && netif_is_bridge_master(master)) + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); + + return err; +} + +static void +mlxsw_sp_lag_uppers_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, + struct net_device *lag_dev) +{ + struct net_device *upper_dev; + struct net_device *master; + struct list_head *iter; + + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + + master = netdev_master_upper_dev_get(upper_dev); + if (!master) + continue; + + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, upper_dev, master); + } + + master = netdev_master_upper_dev_get(lag_dev); + if (master) + mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lag_dev, master); +} + static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, struct net_device *lag_dev, struct netlink_ext_ack *extack) @@ -4361,6 +4443,12 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, err = mlxsw_sp_port_lag_index_get(mlxsw_sp, lag_id, &port_index); if (err) return err; + + err = mlxsw_sp_lag_uppers_bridge_join(mlxsw_sp_port, lag_dev, + extack); + if (err) + goto err_lag_uppers_bridge_join; + err = mlxsw_sp_lag_col_port_add(mlxsw_sp_port, lag_id, port_index); if (err) goto err_col_port_add; @@ -4390,6 +4478,8 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, mlxsw_sp_port->local_port); mlxsw_sp_lag_col_port_remove(mlxsw_sp_port, lag_id); err_col_port_add: + mlxsw_sp_lag_uppers_bridge_leave(mlxsw_sp_port, lag_dev); +err_lag_uppers_bridge_join: if (!lag->ref_count) mlxsw_sp_lag_destroy(mlxsw_sp, lag_id); return err; From patchwork Wed Jul 19 11:01:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318792 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 D889E14266 for ; Wed, 19 Jul 2023 11:02:42 +0000 (UTC) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2047.outbound.protection.outlook.com [40.107.96.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D35186 for ; Wed, 19 Jul 2023 04:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MRv708R5X3Bx6sGCDKWOOmLF9+oAEqXV+5iBUafRBu41Rha2ZMHoaX7V8tKfBeLaZiGB9VGmI1GvyYbZyMVkVwtphEh3jM7Px+hKxTyy8QwT9vXX+YJBnbVHLf1REXsORa6S44FcXqd+OaD3uNCt/xGIfnzSohEOU55DxAabDwAdg2DfSX52iRPj4K8Qx93+UbX4QB54wRIVVSq3HlLRh91M5tKYwzGN0bFP1gRE+sYw4GZEFRJPkxr3NGvlOW65YhS40M/5cwDyd6JFGztqa5o7INUsRm5yxS4vFgmuIqvLEkw+EnYvkewkIra9rUDmfo7h3X7RJ0Bi1hmgOCK3xg== 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=PcYBKqRriWfnPMj+mnpMJ1Pr0V53DKVNrqfKl/4kJnw=; b=ht0OyKULecfwVMjgE3Gl9KGTgF+2f3xEV+Gkkc6GMODSh3meuIpLqsy/FqyL00J2b7P0ff8vXK7nCqbtengQMquYyHNTntxU184LWFmaZr0IWh2gIUC72HZ6Wt7yHilQxrQEA4vdNlgXCVmZIUJtvjYKlKXC/yYblpGOJ/8qefFvYX8AjQH5vwIVM3gLgBLHoFT0kvL2L2K7gh6XPvFG3Wzf3nqi4gBODPFRUd8pZQkrT2FdPSXYPtx+QMk7BGaKfY3T6YOXKXXNvpRHZ94qB3lOulZIHlmAOtE+awZRTRRVYiOyaBkfISyowX+h3MIFpig0jTC/r7wty+r2YMerAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=PcYBKqRriWfnPMj+mnpMJ1Pr0V53DKVNrqfKl/4kJnw=; b=Id/pbk3o6gl5a1rLpIOe6bzAUYTdDq8ibQkMvfay1dG5HTad8OjM/jrfhrzmNh0Q6yt0Mh05RRjjmIdVXS9hNTJ6xayNeteQNr8N4gLx8P2aqTbwroski2Rn2FX8QlGuU0UNUTOMh6VimNeU1uVf16xVNbDfEzjHG30Re64z3aWe2y7mkpQKNLc1AthoSqMGjN5YoPh3aBltNpSbZK6VIrbGnhnNVS/OYW++rHrbcrbFaiH+P+Vhtz+oHkjfLWsxL7Zqc7lb33PJvxCwJvVNX5Bb+MX27EMbJGDvuiU+kBSW4fXZYEgvvXaQxzdWiYu0A5RjYzk3qU/VHoE2ame6ow== Received: from BN9P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::34) by CY5PR12MB6251.namprd12.prod.outlook.com (2603:10b6:930:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32; Wed, 19 Jul 2023 11:02:38 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::71) by BN9P222CA0029.outlook.office365.com (2603:10b6:408:10c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:38 +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 BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:38 +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; Wed, 19 Jul 2023 04:02:25 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:22 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 10/17] mlxsw: spectrum_switchdev: Replay switchdev objects on port join Date: Wed, 19 Jul 2023 13:01:25 +0200 Message-ID: <7b10ccf0e5faae9a324259ed0bb05ccdaecb2415.1689763088.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT020:EE_|CY5PR12MB6251:EE_ X-MS-Office365-Filtering-Correlation-Id: 811776ad-1dcf-42f4-937b-08db8847aa46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0a2dktdF/4EoktrPzqFQF6CMx9wz8YT0aD66d2WlWp7Le1GD44DmmJmyengueTDlgLKPyVz2KB05AyZ5g7DYlMGW+rKKndC0WIucwL76txnUcOCcsDY2jjBCeT0wj9XXqXRmpjeYRkJvqf3S6Kj9AtVHMoLDjYpgE+qnoLF9+Q7+05lMTLKpsTheja628zg9sISytMv3arJL7L1t97wQqce7zmt0SL/tFyD037fu62S8dJk3+6bKfz8pCajLq69h/koTIGVrpVyeAXVxwQQoYQ/MmGhtC4WMUKeQag58LNwjYrP0NVidy3xsklEKuOY/FVpgIETIprQA2GcOFLOvFjI8KFr+95e5buryZbb8k5FdQbax5Triv8QWypue7on/cbCpcqfFJ1shhli577zpXuowfFI39sN4Vulk56Y95RT25UalvTHVw8Ls+WDQE0KjBPzF2WG6SFd8DIasNKweyEW3/Z2DqRr7YQ20y5sxxL3JGMqA26yb9BT4WcevFvujoTKnZir+EVGeBA9Fo3Bv1Q841apUJHX/3pGOatGI9XuMVrmJqQL/iUndr/Thez/9wQ3Raf3p61EIpX8OCagja8/XdPpEUk93sgXYClcBBxBj4xYJevkYDrb87Khcyn2YdiZ4MZ6fqKYc9M78yxBhro+0KewNAp3fF/IN8PKxcynHRMOXKvJshLZCJOR/6L9WdC2khqHSePVb/UkW+NDKEjt3Mb26tTsl+DWtIwo38tC1+IbaBz+Epn96QOM0Il0F 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)(346002)(376002)(136003)(396003)(39860400002)(82310400008)(451199021)(46966006)(40470700004)(36840700001)(4326008)(86362001)(36756003)(2906002)(40460700003)(40480700001)(47076005)(83380400001)(426003)(16526019)(66574015)(336012)(36860700001)(186003)(26005)(107886003)(82740400003)(7636003)(356005)(54906003)(8936002)(110136005)(70206006)(316002)(70586007)(8676002)(478600001)(2616005)(41300700001)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:38.1364 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 811776ad-1dcf-42f4-937b-08db8847aa46 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: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6251 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,URIBL_BLOCKED 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 Currently it never happens that a netdevice that is already a bridge slave would suddenly become mlxsw upper. The only case where this might be possible as far as mlxsw is concerned, is with LAG netdevices. But if a LAG has any upper (e.g. is enslaved), enlaving mlxsw port to that LAG is forbidden. Thus the only way to install a LAG between a bridge and a mlxsw port is by first enslaving the port to the LAG, and then enslaving that LAG to a bridge. At that point there are no bridge objects (such as port VLANs) to replay. Those are added afterwards, and notified as they are created. This holds even for the PVID. However in the following patches, the requirement that ports be only enslaved to masters without uppers, is going to be relaxed. It will therefore be necessary to replay the existing bridge objects. Without this replay, e.g. the mlxsw bridge_port_vlan objects are not instantiated, which causes issues later, as a lot of code relies on their presence. To that end, add a new notifier block whose sole role is to filter out events related to the one relevant upper, and forward those to the existing switchdev notifier block. Pass the new notifier block to switchdev_bridge_port_offload() when the bridge port is created. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 4 +- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 + .../mellanox/mlxsw/spectrum_switchdev.c | 131 +++++++++++++++++- 3 files changed, 132 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 9a6e1ce4e786..8087da00f38f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1132,8 +1132,8 @@ static int mlxsw_sp_port_add_vid(struct net_device *dev, return PTR_ERR_OR_ZERO(mlxsw_sp_port_vlan_create(mlxsw_sp_port, vid)); } -static int mlxsw_sp_port_kill_vid(struct net_device *dev, - __be16 __always_unused proto, u16 vid) +int mlxsw_sp_port_kill_vid(struct net_device *dev, + __be16 __always_unused proto, u16 vid) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index c6231e62a371..65eaa181e0aa 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -700,6 +700,8 @@ int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan_create(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); void mlxsw_sp_port_vlan_destroy(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); +int mlxsw_sp_port_kill_vid(struct net_device *dev, + __be16 __always_unused proto, u16 vid); int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, u16 vid_end, bool is_member, bool untagged); int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 79d45c6c6edf..982eae6bd63e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -384,6 +384,91 @@ mlxsw_sp_bridge_port_find(struct mlxsw_sp_bridge *bridge, return __mlxsw_sp_bridge_port_find(bridge_device, brport_dev); } +static int mlxsw_sp_port_obj_add(struct net_device *dev, const void *ctx, + const struct switchdev_obj *obj, + struct netlink_ext_ack *extack); +static int mlxsw_sp_port_obj_del(struct net_device *dev, const void *ctx, + const struct switchdev_obj *obj); + +struct mlxsw_sp_bridge_port_replay_switchdev_objs { + struct net_device *brport_dev; + struct mlxsw_sp_port *mlxsw_sp_port; + int done; +}; + +static int +mlxsw_sp_bridge_port_replay_switchdev_objs(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + struct switchdev_notifier_port_obj_info *port_obj_info = ptr; + struct netlink_ext_ack *extack = port_obj_info->info.extack; + struct mlxsw_sp_bridge_port_replay_switchdev_objs *rso; + int err = 0; + + rso = (void *)port_obj_info->info.ctx; + + if (event != SWITCHDEV_PORT_OBJ_ADD || + dev != rso->brport_dev) + goto out; + + /* When a port is joining the bridge through a LAG, there likely are + * VLANs configured on that LAG already. The replay will thus attempt to + * have the given port-vlans join the corresponding FIDs. But the LAG + * netdevice has already called the ndo_vlan_rx_add_vid NDO for its VLAN + * memberships, back before CHANGEUPPER was distributed and netdevice + * master set. So now before propagating the VLAN events further, we + * first need to kill the corresponding VID at the mlxsw_sp_port. + * + * Note that this doesn't need to be rolled back on failure -- if the + * replay fails, the enslavement is off, and the VIDs would be killed by + * LAG anyway as part of its rollback. + */ + if (port_obj_info->obj->id == SWITCHDEV_OBJ_ID_PORT_VLAN) { + u16 vid = SWITCHDEV_OBJ_PORT_VLAN(port_obj_info->obj)->vid; + + err = mlxsw_sp_port_kill_vid(rso->mlxsw_sp_port->dev, 0, vid); + if (err) + goto out; + } + + ++rso->done; + err = mlxsw_sp_port_obj_add(rso->mlxsw_sp_port->dev, NULL, + port_obj_info->obj, extack); + +out: + return notifier_from_errno(err); +} + +static struct notifier_block mlxsw_sp_bridge_port_replay_switchdev_objs_nb = { + .notifier_call = mlxsw_sp_bridge_port_replay_switchdev_objs, +}; + +static int +mlxsw_sp_bridge_port_unreplay_switchdev_objs(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + struct switchdev_notifier_port_obj_info *port_obj_info = ptr; + struct mlxsw_sp_bridge_port_replay_switchdev_objs *rso; + + rso = (void *)port_obj_info->info.ctx; + + if (event != SWITCHDEV_PORT_OBJ_ADD || + dev != rso->brport_dev) + return NOTIFY_DONE; + if (!rso->done--) + return NOTIFY_STOP; + + mlxsw_sp_port_obj_del(rso->mlxsw_sp_port->dev, NULL, + port_obj_info->obj); + return NOTIFY_DONE; +} + +static struct notifier_block mlxsw_sp_bridge_port_unreplay_switchdev_objs_nb = { + .notifier_call = mlxsw_sp_bridge_port_unreplay_switchdev_objs, +}; + static struct mlxsw_sp_bridge_port * mlxsw_sp_bridge_port_create(struct mlxsw_sp_bridge_device *bridge_device, struct net_device *brport_dev, @@ -2350,6 +2435,33 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp, return NULL; } +static int +mlxsw_sp_bridge_port_replay(struct mlxsw_sp_bridge_port *bridge_port, + struct mlxsw_sp_port *mlxsw_sp_port, + struct netlink_ext_ack *extack) +{ + struct mlxsw_sp_bridge_port_replay_switchdev_objs rso = { + .brport_dev = bridge_port->dev, + .mlxsw_sp_port = mlxsw_sp_port, + }; + struct notifier_block *nb; + int err; + + nb = &mlxsw_sp_bridge_port_replay_switchdev_objs_nb; + err = switchdev_bridge_port_replay(bridge_port->dev, mlxsw_sp_port->dev, + &rso, NULL, nb, extack); + if (err) + goto err_replay; + + return 0; + +err_replay: + nb = &mlxsw_sp_bridge_port_unreplay_switchdev_objs_nb; + switchdev_bridge_port_replay(bridge_port->dev, mlxsw_sp_port->dev, + &rso, NULL, nb, extack); + return err; +} + static int mlxsw_sp_bridge_vlan_aware_port_join(struct mlxsw_sp_bridge_port *bridge_port, struct mlxsw_sp_port *mlxsw_sp_port, @@ -2364,7 +2476,7 @@ mlxsw_sp_bridge_vlan_aware_port_join(struct mlxsw_sp_bridge_port *bridge_port, if (mlxsw_sp_port->default_vlan->fid) mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan); - return 0; + return mlxsw_sp_bridge_port_replay(bridge_port, mlxsw_sp_port, extack); } static int @@ -2536,6 +2648,7 @@ mlxsw_sp_bridge_8021d_port_join(struct mlxsw_sp_bridge_device *bridge_device, struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; struct net_device *dev = bridge_port->dev; u16 vid; + int err; vid = is_vlan_dev(dev) ? vlan_dev_vlan_id(dev) : MLXSW_SP_DEFAULT_VID; mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid); @@ -2551,8 +2664,20 @@ mlxsw_sp_bridge_8021d_port_join(struct mlxsw_sp_bridge_device *bridge_device, if (mlxsw_sp_port_vlan->fid) mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port_vlan); - return mlxsw_sp_port_vlan_bridge_join(mlxsw_sp_port_vlan, bridge_port, - extack); + err = mlxsw_sp_port_vlan_bridge_join(mlxsw_sp_port_vlan, bridge_port, + extack); + if (err) + return err; + + err = mlxsw_sp_bridge_port_replay(bridge_port, mlxsw_sp_port, extack); + if (err) + goto err_replay; + + return 0; + +err_replay: + mlxsw_sp_port_vlan_bridge_leave(mlxsw_sp_port_vlan); + return err; } static void From patchwork Wed Jul 19 11:01:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318793 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 A53D612B6C for ; Wed, 19 Jul 2023 11:02:48 +0000 (UTC) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2080.outbound.protection.outlook.com [40.107.95.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03ED0186 for ; Wed, 19 Jul 2023 04:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3xCA0J/K6JpxPxQmhtFGFtTLV5Xk6AmlQqLPnZKWJPRa6zHj5/LkvuyyBchFkH+357WQELXEei2ApjA5Ot78jg/vm5zpx508hrQ5w4Y0tyodtjYBb80/xm4/L6bPx0CMQ6NNDwBjo5zX4aIxYxApdJavncLWzLSLQqeVdH3qHDw5lzFH64MjCrD8tHqkcN+WABRNTQh8gfBUvmq+PzG5gYJw7TL682uh3WtseawiR6miFM6ZFcqoCwW5qHiNA8G3wOjkt/gbhwdemhelFqVRYyBztUHzNq57fJ4T+vbuvAV5HF2sOR8riYZ/i0jXbZvABcljeRPGtmdU9f1FIn+fw== 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=CmKRnYM4W0ipdsOSHNPyqKhyLAH6W6bDsnvxGrmntvU=; b=SBfeJrngsNrLas+dn4WdxtLGTDDqf8wbX6+I8X4SayRe1wEDRk9pBroPJabE1WBGdukd9kqy8kjfEfyCC4yOhSP5tHZC6OeU6oCr35wYCIu3B6mwEVA8oxY8meS7+1eYMOP8uTS4ANPKo1W78VxwKutG4holz94/Q7Py82lXihpzfNrbnwP9ZBXu+O+zgYCj7N+ZvGz7ZntLepxlq2+2s95hM1xMcu73ZlMziTHn4q5V1STQqzPYl9QO3jck5Q/iZHmSmQl7tsr8vSaZY7XtYc508ONL1ge6j814F8CTpXTMZzx9cDtc6JnnaKGFnZ+CbHrm24rgV64sY6YvMB0BzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=CmKRnYM4W0ipdsOSHNPyqKhyLAH6W6bDsnvxGrmntvU=; b=bQd/5qoQp2OI8Ydi7SvyDZgNJyz65rvHZDp3aAyGyr2F1GxBKDbEOpes4rmYccMG/12WJD06OST5/zS/44Z21HfElo7pYNOEuH6lqcUO5U1jQb0Bcup5puDlvnn7hhckxf0wu27a+CsesVTrPe8/f7x26/8v13iWj9voYY4tJHshrLdhtI1+jv6eV15voV12OZ3tXz72Y95PCYsTf0t+OcLFpfSz6OP+60qy+QszupPERkIohpXPvaZloEsUZgad3HTIyZQ3pqoDrwgRtxlKYP6G50kwJ2o72gNzdqv5y4szRP2zjeQiy5+JNKTyEVflnLLUqNvJPXfMkQD+xlpnfA== Received: from BN0PR04CA0188.namprd04.prod.outlook.com (2603:10b6:408:e9::13) by DM4PR12MB5294.namprd12.prod.outlook.com (2603:10b6:5:39e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 11:02:41 +0000 Received: from BN8NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::94) by BN0PR04CA0188.outlook.office365.com (2603:10b6:408:e9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:41 +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 BN8NAM11FT086.mail.protection.outlook.com (10.13.176.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:40 +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; Wed, 19 Jul 2023 04:02:28 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:25 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 11/17] mlxsw: spectrum_router: Join RIFs of LAG upper VLANs Date: Wed, 19 Jul 2023 13:01:26 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT086:EE_|DM4PR12MB5294:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f23555e-eba5-4a17-1eb1-08db8847abd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nsXwv6leiRpOAys55Ebeq58qt+/UrnmfDCTigsrEgsQ2P4aGM2o1DctYRqzjwGDdcEi2ylDJ9w61j9dyaj/wWf1NYgN1nb+QqgTCu+rc5cb+MVpXOLn3lR6FJJW389op9wR4JMFZKHLnUuSxQwbPwTFxme00LJ4XbR5FOADBZK/X9gwqBfprZXOKotNHuFERJEmKFRGX6mGJ1094k17Cv6fVvltBoZm0qIsmh2OwBOTEG5+LqyL/F8hayMWvxSMh07UbtbgZ+Z1Cha1ho8+gLgvQ8oVlLWaBSQTt+AU/BGxeaAAKPdxxkwrBgIn51aw83SeSLK7suXaFR4bLlddW7k70JMFrU0hbPjQcmJX6U1gTt7aw8IBHs0z9ZLoMTv6OY2GuHOuNe9fxxzksma+diKGTQKyFuuzIovkUcWv0JAS/kOjNok0KccPtTX+7qjlLoafq7BxVY5rdq+w0eLaIctF2bPOspIQ3vMjp1ZGOffy3bMk5tlR/PDnanOPCPDxWtMLrx5+4nyjQnYJ4zG68mnpkJPrel8UUXy0XJzUxI9DMCaLQbk40sqFoWROfyd1ztqvOe2Uj19e6FIbj0fY8KbC/rbNJaV7WlSkyAUroNDwK7qJ1UrcEiIZzM2OYZvMT8+zNVpyaxy3RsSOtVO+qqneXDPCjvtf7ZKMgIvSor58Qjh+nKkc9eF1Ipn/ogEjvJVCyNUBltndiyRwAtQ0XYGZW0swtfsJWi6ZGm9+dfEQ= 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)(376002)(346002)(136003)(39860400002)(396003)(451199021)(82310400008)(46966006)(40470700004)(36840700001)(36860700001)(70206006)(40460700003)(107886003)(2906002)(356005)(7636003)(316002)(8676002)(8936002)(4326008)(36756003)(66574015)(5660300002)(82740400003)(47076005)(16526019)(70586007)(426003)(2616005)(186003)(40480700001)(336012)(26005)(41300700001)(86362001)(478600001)(83380400001)(54906003)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:40.7821 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f23555e-eba5-4a17-1eb1-08db8847abd3 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: BN8NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5294 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 In the following patches, the requirement that ports be only enslaved to masters without uppers, is going to be relaxed. It will therefore be necessary to join not only RIF for the immediate LAG, as is currently the case, but also RIFs for VLAN netdevices upper to the LAG. In this patch, extend mlxsw_sp_netdevice_router_join_lag() to walk the uppers of a LAG being joined, and also join any VLAN ones. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 18e059e94079..ae2d5e760f1b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9685,15 +9685,64 @@ mlxsw_sp_port_vid_router_join_existing(struct mlxsw_sp_port *mlxsw_sp_port, dev, extack); } +static void +mlxsw_sp_port_vid_router_leave(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, + struct net_device *dev) +{ + struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; + + mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, + vid); + if (WARN_ON(!mlxsw_sp_port_vlan)) + return; + + __mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port_vlan); +} + static int __mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, struct net_device *lag_dev, struct netlink_ext_ack *extack) { u16 default_vid = MLXSW_SP_DEFAULT_VID; + struct net_device *upper_dev; + struct list_head *iter; + int done = 0; + u16 vid; + int err; - return mlxsw_sp_port_vid_router_join_existing(mlxsw_sp_port, - default_vid, lag_dev, - extack); + err = mlxsw_sp_port_vid_router_join_existing(mlxsw_sp_port, default_vid, + lag_dev, extack); + if (err) + return err; + + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + + vid = vlan_dev_vlan_id(upper_dev); + err = mlxsw_sp_port_vid_router_join_existing(mlxsw_sp_port, vid, + upper_dev, extack); + if (err) + goto err_router_join_dev; + + ++done; + } + + return 0; + +err_router_join_dev: + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + if (!done--) + break; + + vid = vlan_dev_vlan_id(upper_dev); + mlxsw_sp_port_vid_router_leave(mlxsw_sp_port, vid, upper_dev); + } + + mlxsw_sp_port_vid_router_leave(mlxsw_sp_port, default_vid, lag_dev); + return err; } int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, From patchwork Wed Jul 19 11:01:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318794 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 7EB2414291 for ; Wed, 19 Jul 2023 11:02:53 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C051C186 for ; Wed, 19 Jul 2023 04:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f6rX4AZ44OKB20wr5hMyzg5zJvQa6u93U/0k34RG9pweyBNo/dS3wyQ4AI+L7ktva2WuH7+4RZILu3RZuv2ERz1f3YWQXh2Zo2rrot7O+N70ewkpuvSuaUdhEYOst53t64JqoGa6iajJ2UYHm4xm9BNPyoq2LGlAUDbUw4imkqJilJzU/eAjAxpNmLvwH2KqRxIkjdiTc+FhmlsUzH9IblNHr7EE+y5bvPunK/PAVHmqVyV7g2Qf2AQlwwdNXjpJk0YSsY2sSGDYdDGoIVZIEGIMWDpK991PtOJaqHVwGMX68DpbYcMjsHjqK9LbWKsBD3TOMc67qMfgkIavqFyHpQ== 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=xS5BCzz6HPt+RjcmZWP91Yybz1CdZRosy9L0UN5yq0Q=; b=XAr2k/NuSj+KEq4Gx6+fKeBqWD5AgMq9vy12dVFYgqDD3Op2GiaP1umzRKhytk86l8MnORNHjsWSRJS8DteaguoBR+DL0pBnCSGK+dtV5KSCO7QuI3Q4qyVxi6ye4VRh+8oD/PD+YWVvlsE0fvehvns+b9dLFlKsOxVtKBDQUUiofBeVwoJD5NK2o/o5qhJ/HkfOoExZg+dax2Tb7eB5La5st2eN6GtAE4jb5ySWX7Ctavh4BWSNkoFDAhCaH2/Tk9PK0QlgMbwBuySjsBZrsHzg22TKG+BRwLiyaeIlnNZF9FSievPiiKskDqLMlirdl22M3fyd8rLr1rZgmXmuPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=xS5BCzz6HPt+RjcmZWP91Yybz1CdZRosy9L0UN5yq0Q=; b=NftDvLM+zf48N8UdnjvrfbEO+B8lTR7K3/+/5aaIkkydV4tsTbiedJ8FOpVA5SSgSdCeas+MJ6vjjcZFQ4R0CUQ2S/R7/KTPg1+2wS74PO45SRO4ydXi8bM/XiYpFyK0LunXIhq4DW7tAYIEbj6wMuXgL6ry7lhm1p3QcVRDwu4mZD3nw8LklmoQKGpPCJcoouDiYZiK3333284rV5gSOQpctKKFNhJDSPF91FA06uMtQ4LAKfcJZm9LIrIP45LOx5oni62GmmcOj6v4wCTUFrzpHnScP+uNFqGuqRgi1o5l1qHgpED7b6W7O2J5FUTxNs9sopBPDUA1dG2oN+WBGw== Received: from BN1PR14CA0021.namprd14.prod.outlook.com (2603:10b6:408:e3::26) by PH7PR12MB6491.namprd12.prod.outlook.com (2603:10b6:510:1f4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32; Wed, 19 Jul 2023 11:02:46 +0000 Received: from BN8NAM11FT094.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e3:cafe::60) by BN1PR14CA0021.outlook.office365.com (2603:10b6:408:e3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:46 +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 BN8NAM11FT094.mail.protection.outlook.com (10.13.176.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02:45 +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; Wed, 19 Jul 2023 04:02:30 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:28 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 12/17] mlxsw: spectrum_router: Offload ethernet nexthops when RIF is made Date: Wed, 19 Jul 2023 13:01:27 +0200 Message-ID: <25880c3e71288cdcd4aeb86edb366361108a1ac7.1689763089.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT094:EE_|PH7PR12MB6491:EE_ X-MS-Office365-Filtering-Correlation-Id: 474bd3b1-c86d-4cc2-2388-08db8847aedb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zqd2Su0ErBHtpmHPRXaPGwE7LfNjLjcwC0b0Zrx/UB4cywASVYqQswuTTh2a+oABih6fsLXfVfahxFDusPKkil26hL9KKTTCIj2czwcSE6W2lHW1YIB7+Z3QKYsh/xylo5kZliFaMGACqQ9SVSo3WeEmF09dCzZE9/RONCIFWCxFV9WWVub6sKJ//2htiUet/BxBhreTm58ewmcK6MF18FlYnlvXJMJpWKvP9e2r5KsHFPmrJDV7S6wrP//vlFfdqGGvx1gXWz1H58wkRh6Uig0Mki5jMwypKrFCEN4GBSxRBknFYKRUgV6NXDyLCA7vNf4aPc8wAXWgVHWLNQC8I4lIYqZEIM/uAhyo0Q66kWlIJGdXNj0hG/efKLeY6X8EHIZPjIM+BZjtDuVOkePbLOVMDjlwB7Et3XA0VP1Wd1Z9CXYbAGMwGZnMpYwJvPFUdYmv7qZ/GkW0c93m8eAjAPLQmeizN9El8hhnUfKMeRH1MuuLGQZ4Jl3kle7WNYXgdDhgnYWAR3eks37mlCNL+ZdsKvxxpwWFqrmyjiJuaYJAHwdy5/GM909blfzU8HGZH1HRzr6BdgHrzSrUXu+KVpk0AmW9vYesBImWT+IlZPhmAloZfOef0yVD0iJgIX1PKjfcslGtKyuQEj8TG5p3eBq3VosmydQcAuKnPILI1b8KVufYW0JyjHq7tUebRGMm1A5WIDvO69O6I5uWxN2JmpDWksDmI7XA378ILcYkILwAbg3uxDkT8crLvRSoBD7g 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)(376002)(136003)(396003)(39860400002)(346002)(451199021)(82310400008)(36840700001)(46966006)(40470700004)(70586007)(4326008)(316002)(86362001)(70206006)(40480700001)(40460700003)(82740400003)(107886003)(478600001)(110136005)(2616005)(54906003)(8936002)(66574015)(336012)(41300700001)(47076005)(8676002)(5660300002)(426003)(26005)(186003)(16526019)(356005)(2906002)(83380400001)(36756003)(36860700001)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:45.8678 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 474bd3b1-c86d-4cc2-2388-08db8847aedb 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: BN8NAM11FT094.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6491 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 As RIF is created, refresh each netxhop group tracked at the CRIF for which the RIF was created. Note that nothing needs to be done for IPIP nexthops. The RIF for these is either available from the get-go, or will never be available, so no after the fact offloading needs to be done. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index ae2d5e760f1b..fe1855cc2c76 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -4404,6 +4404,19 @@ static int mlxsw_sp_nexthop_type_init(struct mlxsw_sp *mlxsw_sp, return err; } +static int mlxsw_sp_nexthop_type_rif_made(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_nexthop *nh) +{ + switch (nh->type) { + case MLXSW_SP_NEXTHOP_TYPE_ETH: + return mlxsw_sp_nexthop_neigh_init(mlxsw_sp, nh); + case MLXSW_SP_NEXTHOP_TYPE_IPIP: + break; + } + + return 0; +} + static void mlxsw_sp_nexthop_type_rif_gone(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_nexthop *nh) { @@ -4532,6 +4545,35 @@ static void mlxsw_sp_nexthop_rif_update(struct mlxsw_sp *mlxsw_sp, } } +static int mlxsw_sp_nexthop_rif_made_sync(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_rif *rif) +{ + struct mlxsw_sp_nexthop *nh, *tmp; + unsigned int n = 0; + int err; + + list_for_each_entry_safe(nh, tmp, &rif->crif->nexthop_list, + crif_list_node) { + err = mlxsw_sp_nexthop_type_rif_made(mlxsw_sp, nh); + if (err) + goto err_nexthop_type_rif; + mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nhgi->nh_grp); + n++; + } + + return 0; + +err_nexthop_type_rif: + list_for_each_entry_safe(nh, tmp, &rif->crif->nexthop_list, + crif_list_node) { + if (!n--) + break; + mlxsw_sp_nexthop_type_rif_gone(mlxsw_sp, nh); + mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nhgi->nh_grp); + } + return err; +} + static void mlxsw_sp_nexthop_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_rif *rif) { @@ -7892,6 +7934,12 @@ static int mlxsw_sp_router_rif_disable(struct mlxsw_sp *mlxsw_sp, u16 rif) return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); } +static int mlxsw_sp_router_rif_made_sync(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_rif *rif) +{ + return mlxsw_sp_nexthop_rif_made_sync(mlxsw_sp, rif); +} + static void mlxsw_sp_router_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_rif *rif) { @@ -8329,6 +8377,10 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp, goto err_mr_rif_add; } + err = mlxsw_sp_router_rif_made_sync(mlxsw_sp, rif); + if (err) + goto err_rif_made_sync; + if (netdev_offload_xstats_enabled(params->dev, NETDEV_OFFLOAD_XSTATS_TYPE_L3)) { err = mlxsw_sp_router_port_l3_stats_enable(rif); @@ -8343,6 +8395,8 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp, return rif; err_stats_enable: + mlxsw_sp_router_rif_gone_sync(mlxsw_sp, rif); +err_rif_made_sync: err_mr_rif_add: for (i--; i >= 0; i--) mlxsw_sp_mr_rif_del(vr->mr_table[i], rif); From patchwork Wed Jul 19 11:01:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318797 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 793AE14A92 for ; Wed, 19 Jul 2023 11:02:59 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD7F19A for ; Wed, 19 Jul 2023 04:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UKlnwjlEO0FYOR2LbW3fqOF0yXbx2J+h4eFUcj8cQGmyv2zy3liHN/qJ4BZYQtMF7wYO7Zr1n0Ww4KXEYVmL4nTwyJsulNxZcKR7Kt/VblsiVJahmUmamgtHEvBUKCkBHpwQFYkuL4jfygSowOKa7CFZBxEF/km8XaIk6wa1R//3n9r149jYm/SGYP+vhuLGaAjZtiZGLmqoDVudcJoQQxHWw1GOyYEI5GiqCI4YP9yf6UV9LdKpq+mlLIsmkUx/2V9gAbnwvzo/otCMV3Cny0Z3YFCjw53mYuLgYvhmS0kjIJvheoHEeG85IyQFRMMgBTP2pAsqXkCX5bu6n2atog== 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=0AKvmlslWDXzimHfINoD4lj32Ud0L0SOPbnVJuPFDco=; b=fXcTyGMNhKf3gv6Kp2rBWujO7OprEEkTffP/19FUpZ6zDNFKlneNGcf6Hkuj4Azpxmx81XSctW5QmdarwczECt2YR9joWt+aR+UmBI8bN0FA5M/KCtTcdmw3qyri2VV37q/lg0L/VsgOHX64p3WPh8/fGTvhYjkwFu2F47n8meCQU6y344PEaLDYwKoOixQK6+HDKBPZW7ZmPqaRPnXvkiHT0g3hHFn5FOx85sm7NFdSYu8hXS2hwN0+tOPf1dxciGoi3z5cRCc9XKs0WekTzDAeXFFJ+3Q1twJTTGmjNHY+yTi6lgIrTguU3xJgpl8CSgyCFyS7H1uzQvierAcycA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=0AKvmlslWDXzimHfINoD4lj32Ud0L0SOPbnVJuPFDco=; b=eQtnNtnOtveM3cH9q/zhfgTyRGjzwicZ2ssiZNlKW0SgrZJ8CaP4Tt4Zpp+Pl3d9O0h3LkD4hGflDR7OBbQe8EXFhpClYhF5kBEDFDTCd8aeyBCYlh/pfyECYn+44Vfjhufp4tmKMuc/ItlHfWu/E9rn1slHaEp7H2ePHjTzl6vu1BYcovL7rIGPCPfioGXnfpJTlbLkn3ezF9Jd3/diAthvKMTGUec7TN26lw6SzDn3IUbeS4EUSnWmOo7UHjjqe5+VvYvDusHvGtda3d2QWsO0eUYl/TNTy4Qc/L+uxL8LvXetODTVxt6QM83YroS0o4tyYuqAwe7qjA6LkwqsFQ== Received: from BN0PR04CA0010.namprd04.prod.outlook.com (2603:10b6:408:ee::15) by IA1PR12MB6601.namprd12.prod.outlook.com (2603:10b6:208:3a3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Wed, 19 Jul 2023 11:02:50 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::60) by BN0PR04CA0010.outlook.office365.com (2603:10b6:408:ee::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:50 +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 BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02:50 +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; Wed, 19 Jul 2023 04:02:33 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:30 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 13/17] mlxsw: spectrum_router: Replay MACVLANs when RIF is made Date: Wed, 19 Jul 2023 13:01:28 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|IA1PR12MB6601:EE_ X-MS-Office365-Filtering-Correlation-Id: eb8b7bc8-f276-4b35-7fd4-08db8847b161 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ldkXwHmN9BfwECWhdogS4QxVmfCqwPRJuisDkVGNnKjHHi+1QkUMfLCeQ+rEdYvNP+YQO+Cjalx3aqh5zITncQkbj1coQz/HyomAzAKTqXeDnNFLL4IYr+XaflzFrhkTG57xEnzqs3nw8xu6NxKqeBLQpsaV4o1VU7ZgaWBV7tR45vFRXngEAGsDj+whTAxbaI94xZCcrhoLPkHPy2GqE5474vL7TZDDc8cfS2O6cGSr6CDm4ypES8J2TUVa9lct4S3s3yrUeu0KG4ibu6sYDqUvIN94D65k2a6j2ivQWBGzLTbndJU516EX6Pk1mWe/pvJj5wgTRKvWpvvZ4oWDH3oxnBc4hI5ueqNY2Wf0CD0iMDMj45bVqe/hLHmP/1Y9N8GayfCLddQmegy0Spxv0RivtYj8IKUT4JH/RHJoAlIy0pP1OwOlZaH7DcdqHBYFMD21md+3gJKwfILlOojpRHUTiyvQQDXFpjFdDL8hvTdCNFjkxd4eKYOSO/+TPftMrUJfBG9Wpnu8qiBgqKs91TCmemzaiOrntCa634Fnd0akM812jHi49Ke3+wglqhtWk7MxXNP6QJr6J4jmFJ6iUXIGYOGNhLhwV8guRX1Ht1UAGaUSYje3Wrdi88uqg/Py6VfedECOu+nfQnQz8AznQPSor6IGAXqvLbAG0nF7H34Vu8w8l9fjK2homSfTK0KaQYFYFnqOmbvdWbYd9s9rI9NSCJzYshW43MsB2O/ZKRHBUzhzjcSDVUWNKT2/dVdp 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)(346002)(396003)(136003)(451199021)(82310400008)(40470700004)(36840700001)(46966006)(4326008)(54906003)(478600001)(110136005)(82740400003)(2616005)(36860700001)(83380400001)(426003)(47076005)(40460700003)(86362001)(66574015)(40480700001)(356005)(2906002)(70586007)(186003)(16526019)(107886003)(26005)(316002)(7636003)(336012)(70206006)(41300700001)(36756003)(8676002)(5660300002)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:50.1038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb8b7bc8-f276-4b35-7fd4-08db8847b161 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: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6601 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_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 If IP address is added to a MACVLAN netdevice, the effect is of configuring VRRP on the RIF for the netdevice linked to the MACVLAN. Because the MACVLAN offload is tied to existence of a RIF at the linked netdevice, adding a MACVLAN is currently not allowed until a RIF is present. If this requirement stays, it will never be possible to attach a first port into a topology that involves a MACVLAN. Thus topologies would need to be built in a certain order, which is impractical. Additionally, IP address removal, which leads to disappearance of the RIF that the MACVLAN depends on, cannot be vetoed. Thus even as things stand now it is possible to get to a state where a MACVLAN netdevice exists without a RIF, despite having mlxsw lowers. And once the MACVLAN is un-offloaded due to RIF getting destroyed, recreating the RIF does not bring it back. In this patch, accept that MACVLAN can be created out of order and support that use case. One option would seem to be to simply recognize MACVLAN netdevices as "interesting", and let the existing replay mechanisms take care of the offload. However, that does not address the necessity to reoffload MACVLAN once a RIF is created. Thus add a new replay hook, symmetrical to mlxsw_sp_rif_macvlan_flush(), called mlxsw_sp_rif_macvlan_replay(), which instead of unwinding the existing offloads, applies the configuration as if the netdevice were created just now. Additionally, remove all vetoes and warning messages that checked for presence of a RIF at the linked device. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 22 ------- .../ethernet/mellanox/mlxsw/spectrum_router.c | 59 +++++++++++++++++-- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 8087da00f38f..4346cc736579 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4786,11 +4786,6 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, NL_SET_ERR_MSG_MOD(extack, "Can not put a VLAN on a LAG port"); return -EINVAL; } - if (netif_is_macvlan(upper_dev) && - !mlxsw_sp_rif_exists(mlxsw_sp, lower_dev)) { - NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); - return -EOPNOTSUPP; - } if (netif_is_ovs_master(upper_dev) && vlan_uses_dev(dev)) { NL_SET_ERR_MSG_MOD(extack, "Master device is an OVS master and this device has a VLAN"); return -EINVAL; @@ -4979,11 +4974,6 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, NL_SET_ERR_MSG_MOD(extack, "Enslaving a port to a device that already has an upper device is not supported"); return -EINVAL; } - if (netif_is_macvlan(upper_dev) && - !mlxsw_sp_rif_exists(mlxsw_sp, vlan_dev)) { - NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); - return -EOPNOTSUPP; - } break; case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; @@ -5052,13 +5042,6 @@ static int mlxsw_sp_netdevice_bridge_vlan_event(struct mlxsw_sp *mlxsw_sp, NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type"); return -EOPNOTSUPP; } - if (!info->linking) - break; - if (netif_is_macvlan(upper_dev) && - !mlxsw_sp_rif_exists(mlxsw_sp, vlan_dev)) { - NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); - return -EOPNOTSUPP; - } break; case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; @@ -5135,11 +5118,6 @@ static int mlxsw_sp_netdevice_bridge_event(struct mlxsw_sp *mlxsw_sp, NL_SET_ERR_MSG_MOD(extack, "VLAN uppers are only supported with 802.1q VLAN protocol"); return -EOPNOTSUPP; } - if (netif_is_macvlan(upper_dev) && - !mlxsw_sp_rif_exists(mlxsw_sp, br_dev)) { - NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); - return -EOPNOTSUPP; - } break; case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index fe1855cc2c76..2322429cdb72 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9121,10 +9121,8 @@ static int mlxsw_sp_rif_macvlan_add(struct mlxsw_sp *mlxsw_sp, int err; rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, vlan->lowerdev); - if (!rif) { - NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); - return -EOPNOTSUPP; - } + if (!rif) + return 0; err = mlxsw_sp_rif_fdb_op(mlxsw_sp, macvlan_dev->dev_addr, mlxsw_sp_fid_index(rif->fid), true); @@ -9857,6 +9855,40 @@ static int mlxsw_sp_router_netdevice_event(struct notifier_block *nb, return notifier_from_errno(err); } +struct mlxsw_sp_macvlan_replay { + struct mlxsw_sp *mlxsw_sp; + struct netlink_ext_ack *extack; +}; + +static int mlxsw_sp_macvlan_replay_upper(struct net_device *dev, + struct netdev_nested_priv *priv) +{ + const struct mlxsw_sp_macvlan_replay *rms = priv->data; + struct netlink_ext_ack *extack = rms->extack; + struct mlxsw_sp *mlxsw_sp = rms->mlxsw_sp; + + if (!netif_is_macvlan(dev)) + return 0; + + return mlxsw_sp_rif_macvlan_add(mlxsw_sp, dev, extack); +} + +static int mlxsw_sp_macvlan_replay(struct mlxsw_sp_rif *rif, + struct netlink_ext_ack *extack) +{ + struct mlxsw_sp_macvlan_replay rms = { + .mlxsw_sp = rif->mlxsw_sp, + .extack = extack, + }; + struct netdev_nested_priv priv = { + .data = &rms, + }; + + return netdev_walk_all_upper_dev_rcu(mlxsw_sp_rif_dev(rif), + mlxsw_sp_macvlan_replay_upper, + &priv); +} + static int __mlxsw_sp_rif_macvlan_flush(struct net_device *dev, struct netdev_nested_priv *priv) { @@ -9879,7 +9911,6 @@ static int mlxsw_sp_rif_macvlan_flush(struct mlxsw_sp_rif *rif) if (!netif_is_macvlan_port(dev)) return 0; - netdev_warn(dev, "Router interface is deleted. Upper macvlans will not work\n"); return netdev_walk_all_upper_dev_rcu(dev, __mlxsw_sp_rif_macvlan_flush, &priv); } @@ -9937,6 +9968,10 @@ static int mlxsw_sp_rif_subport_configure(struct mlxsw_sp_rif *rif, if (err) goto err_rif_subport_op; + err = mlxsw_sp_macvlan_replay(rif, extack); + if (err) + goto err_macvlan_replay; + err = mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), true); if (err) @@ -9952,6 +9987,8 @@ static int mlxsw_sp_rif_subport_configure(struct mlxsw_sp_rif *rif, mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), false); err_rif_fdb_op: + mlxsw_sp_rif_macvlan_flush(rif); +err_macvlan_replay: mlxsw_sp_rif_subport_op(rif, false); err_rif_subport_op: mlxsw_sp_rif_mac_profile_put(rif->mlxsw_sp, mac_profile); @@ -10038,6 +10075,10 @@ static int mlxsw_sp_rif_fid_configure(struct mlxsw_sp_rif *rif, if (err) goto err_fid_bc_flood_set; + err = mlxsw_sp_macvlan_replay(rif, extack); + if (err) + goto err_macvlan_replay; + err = mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), true); if (err) @@ -10053,6 +10094,8 @@ static int mlxsw_sp_rif_fid_configure(struct mlxsw_sp_rif *rif, mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), false); err_rif_fdb_op: + mlxsw_sp_rif_macvlan_flush(rif); +err_macvlan_replay: mlxsw_sp_fid_flood_set(rif->fid, MLXSW_SP_FLOOD_TYPE_BC, mlxsw_sp_router_port(mlxsw_sp), false); err_fid_bc_flood_set: @@ -10200,6 +10243,10 @@ static int mlxsw_sp_rif_vlan_configure(struct mlxsw_sp_rif *rif, u16 efid, if (err) goto err_fid_bc_flood_set; + err = mlxsw_sp_macvlan_replay(rif, extack); + if (err) + goto err_macvlan_replay; + err = mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), true); if (err) @@ -10215,6 +10262,8 @@ static int mlxsw_sp_rif_vlan_configure(struct mlxsw_sp_rif *rif, u16 efid, mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, mlxsw_sp_fid_index(rif->fid), false); err_rif_fdb_op: + mlxsw_sp_rif_macvlan_flush(rif); +err_macvlan_replay: mlxsw_sp_fid_flood_set(rif->fid, MLXSW_SP_FLOOD_TYPE_BC, mlxsw_sp_router_port(mlxsw_sp), false); err_fid_bc_flood_set: From patchwork Wed Jul 19 11:01:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318795 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 657D514291 for ; Wed, 19 Jul 2023 11:02:56 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2052.outbound.protection.outlook.com [40.107.93.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC18189 for ; Wed, 19 Jul 2023 04:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b4ouNlvJkEg9l2vr2i+n0eDsQA85AAW/1/A9T04rPW2HsubOx4CvPoXTx0u3AFd7E1VkyUQrIdYZAeB9CTK/chLz1LDQRRG6ZK1UKTkDc6/ob6ut+Dw8pCiJ+d9VmHqwbdJdnyu6ZhZgn+sA7KLvb7nANKm3YODGDOVhc6b3AKarUycpFIBLH/T++d/hq0aFm7OLfsACydj/0oc4inj/9OjYHXeq3PokLlOs0YLozZgQGURSlAZIswSr1pFIow1EE3hJhnXjBv7iumuROM1AoZKAXIdH7caNX3UWLIUCBbYsA5uR7LrcyHjbAQHYddzSnRVjNLzhPcr0sOU9K7tXNQ== 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=4WzgnRxfmV8Us0G+JG50PX5lI7Lbx0EwgBYbUL4jkx8=; b=itJKUphla8PWn/IPMvbY/DKuSqeVQ/vHKaAmZQQPqQI+a8uJ9oW1YmooWD14b9oIoNZ3UDretVenhnfi4rBlXIYacglnC3bjtqZ3xFqhKVK5VyIQYPkNdLFEGoFd4w3IDrT7vEAkdHicQqPt/zdPeJH0o6yJvzTl7ASSY8yr7V0LQIFSs1pfKgQIGPLIczCf1gE9IENiCuxGOBP5xoqSATfzKbJTyUwHyJY/632lbItkU36RUrgneJqTqKHl9pP87f5bxnJfLdMxYEguUiq6jWFLJYWvOSQtPRFhAuRIocS2iMMC7JRYzDt5iEIqP++WUQmvOuDHxw7QV2TK0ceHyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=4WzgnRxfmV8Us0G+JG50PX5lI7Lbx0EwgBYbUL4jkx8=; b=T4CWTq3mAZf47MWl425CUK0jkSsMwabmgOfn6Q0DzmjSh8U+/U6kxEwcOt3j3RyILDaWsMWGiiwFY61Gz2fAnNBlzbcLLO0dcpdFBLxwdgkNVmeTh7uvcI2r9PhNY+6ZlIm7rb+1PwnCjz5HIV0BDJRhf6lHU1N1hDPKTRf3SPZaltnOoPeWStMH1hwDEC3F1XcdTTZv/Sx4TGM4jFn9qN6MUaipoXnC55k2/MLc3nC87Eo54/PrsADOlpSgD1uryH/uh2Fl8WUeA3QHYTZF+NIrzCGUigG77+BgCSVVJnPwZ00GDoQOEbABiGcK7QzjzGQvtFqWStZA3IeK/1JT+w== Received: from BN9PR03CA0777.namprd03.prod.outlook.com (2603:10b6:408:13a::32) by MW4PR12MB7141.namprd12.prod.outlook.com (2603:10b6:303:213::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Wed, 19 Jul 2023 11:02:53 +0000 Received: from BN8NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::c8) by BN9PR03CA0777.outlook.office365.com (2603:10b6:408:13a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:52 +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 BN8NAM11FT111.mail.protection.outlook.com (10.13.177.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.35 via Frontend Transport; Wed, 19 Jul 2023 11:02:52 +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; Wed, 19 Jul 2023 04:02:36 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:33 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 14/17] mlxsw: spectrum_router: Replay neighbours when RIF is made Date: Wed, 19 Jul 2023 13:01:29 +0200 Message-ID: <348ed6d1ba0ff56ecbf625f0927510b2712d375f.1689763089.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT111:EE_|MW4PR12MB7141:EE_ X-MS-Office365-Filtering-Correlation-Id: 54dd8d1f-0e51-41ec-4798-08db8847b285 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /x68Kmdqa8gbyWS8Jp6uIiECxEJ6HtoyccLTkvTsTEZw0XHeJclfGFEijEVCcoMxREx8sgxnx5Ee4Y8XyQJCgApRVKwRczUU1fqgdzbznqsKn0cfWR2Mfq2xQGRi3HCz0Hdsj0JE+BvsEtdPfkEufpR9eWLrCxbmq/bebu0zh3eqkDcwZGLT+stzgm2zFX5sR6IsL79P1m8P8sRVk8hQci7Ga6O9vaCe/bz34YJ5TpJ7LqYB+Mgkb4008UF6B672ijBy3wGqVE+rPSGB5qMBvLWIaxZbQJ1MeZ/SFr6U8MbzUyx5W9cmJP38vvcOXI9ur3ZX4FgJD65EgPRYADzQ4CCicJPfrT/T8LEAPAQ7gQ86y9zl/NPwv6bgPjl2mEJLOcqDX5xbMXNx7TFCUG+BgnNe8rN+PJc3iZ83V67PdgmsPcivQudu1JQS7Vn/GP+F5sRHVYOWJ4UulO+NYvT42MU11a/fWvmPJrkZwoVygrMelPZvMq7L/zKw5vpjGd3CVsC+ggXYO7+Z8H4s89gDFsy4YQswJWvDYP4xR6rn6ffKj0R75qBIjnHxa93XiZ8SE9aZ/k/7isugWCEYFd8XhaeMZsrV4RnUcPU6cyQpqFu5/LWvu0zZz+VutE3lY5Q8Yg636I7Ac/P8FKaU2V2sxVPBhz2CyRPG586Su/5FBft65OCXtrgiz1dAz9xEtuOGFS9iRMK6+38/z4/qy+JLH/3O9zdFEA0H9V93E4f+BqLO7KnZwTqhy++s1P6/X8R2 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)(396003)(346002)(136003)(376002)(39860400002)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(2906002)(478600001)(110136005)(6666004)(8936002)(8676002)(54906003)(36756003)(41300700001)(70206006)(70586007)(4326008)(316002)(356005)(336012)(83380400001)(426003)(66574015)(47076005)(86362001)(7636003)(82740400003)(186003)(16526019)(5660300002)(40460700003)(36860700001)(107886003)(26005)(40480700001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:52.0160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54dd8d1f-0e51-41ec-4798-08db8847b285 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: BN8NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7141 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,URIBL_BLOCKED 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 As neighbours are created, mlxsw is involved through the netevent notifications. When at the time there is no RIF for a given neighbour, the notification is not acted upon. When the RIF is later created, these outstanding neighbours are left unoffloaded and cause traffic to go through the SW datapath. In order to fix this issue, as a RIF is created, walk the ARP and ND tables and find neighbours for the netdevice that represents the RIF. Then schedule neighbour work for them, allowing them to be offloaded. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 2322429cdb72..9263a914bcc7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2983,6 +2983,52 @@ static void mlxsw_sp_neigh_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, } } +struct mlxsw_sp_neigh_rif_made_sync { + struct mlxsw_sp *mlxsw_sp; + struct mlxsw_sp_rif *rif; + int err; +}; + +static void mlxsw_sp_neigh_rif_made_sync_each(struct neighbour *n, void *data) +{ + struct mlxsw_sp_neigh_rif_made_sync *rms = data; + int rc; + + if (rms->err) + return; + if (n->dev != mlxsw_sp_rif_dev(rms->rif)) + return; + rc = mlxsw_sp_router_schedule_neigh_work(rms->mlxsw_sp->router, n); + if (rc != NOTIFY_DONE) + rms->err = -ENOMEM; +} + +static int mlxsw_sp_neigh_rif_made_sync(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_rif *rif) +{ + struct mlxsw_sp_neigh_rif_made_sync rms = { + .mlxsw_sp = mlxsw_sp, + .rif = rif, + }; + + neigh_for_each(&arp_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms); + if (rms.err) + goto err_arp; + +#if IS_ENABLED(CONFIG_IPV6) + neigh_for_each(&nd_tbl, mlxsw_sp_neigh_rif_made_sync_each, &rms); +#endif + if (rms.err) + goto err_nd; + + return 0; + +err_nd: +err_arp: + mlxsw_sp_neigh_rif_gone_sync(mlxsw_sp, rif); + return rms.err; +} + enum mlxsw_sp_nexthop_type { MLXSW_SP_NEXTHOP_TYPE_ETH, MLXSW_SP_NEXTHOP_TYPE_IPIP, @@ -7937,7 +7983,21 @@ static int mlxsw_sp_router_rif_disable(struct mlxsw_sp *mlxsw_sp, u16 rif) static int mlxsw_sp_router_rif_made_sync(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_rif *rif) { - return mlxsw_sp_nexthop_rif_made_sync(mlxsw_sp, rif); + int err; + + err = mlxsw_sp_neigh_rif_made_sync(mlxsw_sp, rif); + if (err) + return err; + + err = mlxsw_sp_nexthop_rif_made_sync(mlxsw_sp, rif); + if (err) + goto err_nexthop; + + return 0; + +err_nexthop: + mlxsw_sp_neigh_rif_gone_sync(mlxsw_sp, rif); + return err; } static void mlxsw_sp_router_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, From patchwork Wed Jul 19 11:01:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318796 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 CC6D914A92 for ; Wed, 19 Jul 2023 11:02:58 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DD7B186 for ; Wed, 19 Jul 2023 04:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sd3fLzIzlN/Si69kEwE+pvNmoBp1V96veNy1aVpycyxlLEGptg3Leis8Jp9g1LFBrGfnPz7wE4YqghqBjCSs3ehfc2k9S8aw1vZUXj+d9y1EFgWfVZjLEvAbUpK9EsmX+EU8rRZp3JqgicDxIA41xNkSVe4rOL1WP83U2UjyMkVy6WuhJoCO2JtwV96V/aMwXzgrNUWkSK9jRTwnltLQmrsqu8vggPnm9mGfyfAMylTWLo+tFc18WGKFjYI5ypI6NdAu8+RXMFeN5dIyArmdjztVfnpDLfYq0YE0hIvD53GGTjr8lXzd0+Pm3gbHujJkSHBWU/vGYv90gjOBx+FXKw== 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=2DFiNflvX/KmA1OHV2+0raRpx1n0Spqh79Ws/DtieP0=; b=O2fGbYeuZ3Kaw+HNddM2uKt+QZAkl4b61KsYwSB4V512wMHFkf6S3Rle9CovtpTCK+IXpp9GenLNYHzodlhtd8b1XxAZAX6I7L6QPoyLf3cNYetIGYbgqabh/2CkwS3JvlDcEDDDp9g6zyWyvec4lvOd0VLpzUnBRInSPDpUF2HrzbG2TeYdnI+jHQrwbla1rd3TmJ31mphnDIibZDc45r2AK8JJ17TBNrF6kmAmaaMD+tF3KPtoTOaHtrSoYoGOa1o8ZUwafkjxLsSKrdMZ+H9mCkWWr/IHbUEpYQ1Y5GI78Pi5KuKt+HUJfFqxChKeC7mF+nycnlu/L29p5jqZ+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=2DFiNflvX/KmA1OHV2+0raRpx1n0Spqh79Ws/DtieP0=; b=bpBjqizJsAioy+8Fry6fvNj6H3Vw5k6MsLk6CCqAs5kkmz2uim6GOm94LcktjCt94aLg1C5FwrBxMFlYfj1M2ld44QprmAIlueSHn5MJ9kdnf5yIZZw1AmzR0VCqcZbebsaybacpdC3hiM9Ez6oWj0yVsNQo7poJZgJP20XRh+u6cpoviIrv5Y7BRWzzYxe82k+vWw+RNQdyNDrKDoizGzWNO8TW2vMZTRGQ8+yL0Dh4k12ChFjfBpiGq09ht8KtuPzlRZkkvgL9agJSZYyjhALZtWOl/dNk6cVWyci8lusbtsbC80QmRP28naxGTB82lX4W4owQ+Q5E2IKxnRFkjg== Received: from BN0PR04CA0006.namprd04.prod.outlook.com (2603:10b6:408:ee::11) by BL1PR12MB5898.namprd12.prod.outlook.com (2603:10b6:208:396::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Wed, 19 Jul 2023 11:02:55 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::fe) by BN0PR04CA0006.outlook.office365.com (2603:10b6:408:ee::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:02:55 +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 BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02:54 +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; Wed, 19 Jul 2023 04:02:38 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:36 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 15/17] mlxsw: spectrum_router: Replay IP NETDEV_UP on device enslavement Date: Wed, 19 Jul 2023 13:01:30 +0200 Message-ID: <2d6e226cc1b5824251fa6bd89c47459d7d2e79b4.1689763089.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|BL1PR12MB5898:EE_ X-MS-Office365-Filtering-Correlation-Id: bb40f632-4155-4a8f-b8ab-08db8847b42c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XirvRUI53wnNKD0/GTSf3j7vq+9o5ozMDz9j4vanTgplou/N4vXNJhumTkLah1S9yqJKsNrtFkeImhf30bxT4qCKcM3qIf+6oUInmnGC+tUWaoy8HhwgM9uevVz4WwYsxW8iwR8/oJiDtmVB5K68BiM0JTJ2BXHUvb51ucW8jbdtIrxNeJ01rsH92M7aXazCVviibzLdlxsIku5vbJJXgrFAXTIy8SGRGtaclFmYrMMgVJ1W58mIjkSRVXYLf35D+K2ZjEy2nyeqEcHFsL6Z4poST7cf0c4PQn0S4vILzK/J96lOKyRbvAkkK4/NoGCFk/vEPmY/uDmvKz6nIKGEOWi//qhVjklNwDu7yjMdWPSLtMCPiy7QnbJFdNqZIpu5AHvDw04C2rnINr5Eby45iNSJ38QYSa7F2KXUAlYmSVxkEp5ZwrGktPYOGDHsX03Ly6nmAfRv993PgNM2qR1KKdlMtcDq9JpCpvNqEIMLzWXNTa1QYxkyBBaVlwNbJzlW9ueQSUpDuBrg+nVFCuJBvLPPOISHLpEh80PyggUnz2nJcN13GEAX5LRmpfN+wWdifjJWZceIicoNkS9DwhL9FFZCm0GGR6QaYw1VKTu/qGZS9Ynylx4hQ2sIDB1lNzQI9O29oHlrEvSlfaW07X7n2YzmzKrSAPoO6NipW7JrSf/JoQspdRiLPbUqHf2DxA1KjV/zrlvgUzLNimv6DhGbLSN4QJxM3pc/ckw8o3HSMJw= 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)(376002)(39860400002)(136003)(346002)(396003)(451199021)(82310400008)(40470700004)(46966006)(36840700001)(4326008)(478600001)(83380400001)(6666004)(110136005)(70206006)(54906003)(426003)(40480700001)(36860700001)(336012)(47076005)(66574015)(86362001)(36756003)(2906002)(2616005)(8676002)(26005)(186003)(41300700001)(107886003)(40460700003)(5660300002)(356005)(7636003)(82740400003)(316002)(8936002)(16526019)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:54.7911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb40f632-4155-4a8f-b8ab-08db8847b42c 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: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5898 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,URIBL_BLOCKED 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 Enslaving of front panel ports (and their uppers) to netdevices that already have uppers is currently forbidden. When this is permitted, any uppers with IP addresses need to have the NETDEV_UP inetaddr event replayed, so that any RIFs are created. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 6 + .../ethernet/mellanox/mlxsw/spectrum_router.c | 119 ++++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_router.h | 5 + .../mellanox/mlxsw/spectrum_switchdev.c | 7 ++ 4 files changed, 137 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 4346cc736579..0dcd988ffce1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4469,8 +4469,14 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port, if (err) goto err_router_join; + err = mlxsw_sp_netdevice_enslavement_replay(mlxsw_sp, lag_dev, extack); + if (err) + goto err_replay; + return 0; +err_replay: + mlxsw_sp_router_port_leave_lag(mlxsw_sp_port, lag_dev); err_router_join: lag->ref_count--; mlxsw_sp_port->lagged = 0; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 9263a914bcc7..18d1bcbb3fdf 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9781,6 +9781,97 @@ mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, return err; } +struct mlxsw_sp_router_replay_inetaddr_up { + struct mlxsw_sp *mlxsw_sp; + struct netlink_ext_ack *extack; + unsigned int done; +}; + +static int mlxsw_sp_router_replay_inetaddr_up(struct net_device *dev, + struct netdev_nested_priv *priv) +{ + struct mlxsw_sp_router_replay_inetaddr_up *ctx = priv->data; + struct mlxsw_sp_crif *crif; + int err; + + if (mlxsw_sp_dev_addr_list_empty(dev)) + return 0; + + crif = mlxsw_sp_crif_lookup(ctx->mlxsw_sp->router, dev); + if (!crif || crif->rif) + return 0; + + if (!mlxsw_sp_rif_should_config(crif->rif, dev, NETDEV_UP)) + return 0; + + err = __mlxsw_sp_inetaddr_event(ctx->mlxsw_sp, dev, NETDEV_UP, + false, ctx->extack); + if (err) + return err; + + ctx->done++; + return 0; +} + +static int mlxsw_sp_router_unreplay_inetaddr_up(struct net_device *dev, + struct netdev_nested_priv *priv) +{ + struct mlxsw_sp_router_replay_inetaddr_up *ctx = priv->data; + struct mlxsw_sp_crif *crif; + + if (!ctx->done) + return 0; + + if (mlxsw_sp_dev_addr_list_empty(dev)) + return 0; + + crif = mlxsw_sp_crif_lookup(ctx->mlxsw_sp->router, dev); + if (!crif || !crif->rif) + return 0; + + /* We are rolling back NETDEV_UP, so ask for that. */ + if (!mlxsw_sp_rif_should_config(crif->rif, dev, NETDEV_UP)) + return 0; + + __mlxsw_sp_inetaddr_event(ctx->mlxsw_sp, dev, NETDEV_DOWN, false, NULL); + + ctx->done--; + return 0; +} + +int mlxsw_sp_netdevice_enslavement_replay(struct mlxsw_sp *mlxsw_sp, + struct net_device *upper_dev, + struct netlink_ext_ack *extack) +{ + struct mlxsw_sp_router_replay_inetaddr_up ctx = { + .mlxsw_sp = mlxsw_sp, + .extack = extack, + }; + struct netdev_nested_priv priv = { + .data = &ctx, + }; + int err; + + err = mlxsw_sp_router_replay_inetaddr_up(upper_dev, &priv); + if (err) + return err; + + err = netdev_walk_all_upper_dev_rcu(upper_dev, + mlxsw_sp_router_replay_inetaddr_up, + &priv); + if (err) + goto err_replay_up; + + return 0; + +err_replay_up: + netdev_walk_all_upper_dev_rcu(upper_dev, + mlxsw_sp_router_unreplay_inetaddr_up, + &priv); + mlxsw_sp_router_unreplay_inetaddr_up(upper_dev, &priv); + return err; +} + static int mlxsw_sp_port_vid_router_join_existing(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, struct net_device *dev, @@ -9857,6 +9948,26 @@ static int __mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, return err; } +static void +__mlxsw_sp_router_port_leave_lag(struct mlxsw_sp_port *mlxsw_sp_port, + struct net_device *lag_dev) +{ + u16 default_vid = MLXSW_SP_DEFAULT_VID; + struct net_device *upper_dev; + struct list_head *iter; + u16 vid; + + netdev_for_each_upper_dev_rcu(lag_dev, upper_dev, iter) { + if (!is_vlan_dev(upper_dev)) + continue; + + vid = vlan_dev_vlan_id(upper_dev); + mlxsw_sp_port_vid_router_leave(mlxsw_sp_port, vid, upper_dev); + } + + mlxsw_sp_port_vid_router_leave(mlxsw_sp_port, default_vid, lag_dev); +} + int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, struct net_device *lag_dev, struct netlink_ext_ack *extack) @@ -9870,6 +9981,14 @@ int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, return err; } +void mlxsw_sp_router_port_leave_lag(struct mlxsw_sp_port *mlxsw_sp_port, + struct net_device *lag_dev) +{ + mutex_lock(&mlxsw_sp_port->mlxsw_sp->router->lock); + __mlxsw_sp_router_port_leave_lag(mlxsw_sp_port, lag_dev); + mutex_unlock(&mlxsw_sp_port->mlxsw_sp->router->lock); +} + static int mlxsw_sp_router_netdevice_event(struct notifier_block *nb, unsigned long event, void *ptr) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h index 74242220a0cf..eed04fbf719f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h @@ -178,5 +178,10 @@ int mlxsw_sp_router_bridge_vlan_add(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_router_port_join_lag(struct mlxsw_sp_port *mlxsw_sp_port, struct net_device *lag_dev, struct netlink_ext_ack *extack); +void mlxsw_sp_router_port_leave_lag(struct mlxsw_sp_port *mlxsw_sp_port, + struct net_device *lag_dev); +int mlxsw_sp_netdevice_enslavement_replay(struct mlxsw_sp *mlxsw_sp, + struct net_device *upper_dev, + struct netlink_ext_ack *extack); #endif /* _MLXSW_ROUTER_H_*/ diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 982eae6bd63e..dffb67c1038e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -2894,8 +2894,15 @@ int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, if (err) goto err_port_join; + err = mlxsw_sp_netdevice_enslavement_replay(mlxsw_sp, br_dev, extack); + if (err) + goto err_replay; + return 0; +err_replay: + bridge_device->ops->port_leave(bridge_device, bridge_port, + mlxsw_sp_port); err_port_join: mlxsw_sp_bridge_port_put(mlxsw_sp->bridge, bridge_port); return err; From patchwork Wed Jul 19 11:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318798 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 06D1A14A92 for ; Wed, 19 Jul 2023 11:03:02 +0000 (UTC) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2075.outbound.protection.outlook.com [40.107.96.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6102C186 for ; Wed, 19 Jul 2023 04:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B16RH+3IV4AqEncuZBg6HEFyjAxP7KcjNAb0UpmKCNyj8ARxlCzKqq6WyUXfw3venXoylAn9STlh9zTSvQjkRP1ReMBlk2clX7NB9W/FFgoRA8j4ue12ijuQKiT0mma4Z1eWGXuEKV6HnxnV/mnZqNvLpcrL93rN/OYsGFuhsRWD8Ei/7UgdEHdj3xfv7RddQoaeMg0jvel5LXzGEG8oiURjywCCEkG4aRSBbXDWCwDGqXIrlQcfxwBEe5Y0T94ncL4ru2n7su+IA4GLXqvntPKuMnnyzYXACCDgXc5xbX0+oWikQtcF/IjjDb6PNRZXsEgKflpVww7KErmAR2tYmQ== 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=dn1XTbjXqXt1qRvEhkhBvfejGGYJ+424vvw7awi/jRc=; b=IeKo7cs7DRCHl2F0ymfhLfl2zWpLrloK7YX/4pCeNuMffbrDk4qimbjCAFV01zi/sXqvbfB8a47WPGP7H8NySSjM0+65F1RTPL7aDjsrsCugrYXRvo8ocbeVTV5BeI+1oHnPGzBqHQFBcTu4qQwmIbJYVBKTq+TprNjMZtVLIB+IvuolOrHaDdLIKFlTDkGJpK0av48oPXg6eb6CsgznqXDwkZHi16XSQ+B6ZMMDuH+MzdYwUPyEDczQrvVLc+pIwAnuJU34Y5ZIg4ivozm2IcpxYJno2jt08DUYC777DuQ6rlPisSx7sM858SIS/4ax13QAfFhFf4M9HiOAtxLefg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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=dn1XTbjXqXt1qRvEhkhBvfejGGYJ+424vvw7awi/jRc=; b=FWRnzf5jOD+jMKUzSJdYASQqEvw34DGhagSNAlkyFPO6hOXbiQvWGyu8d9Q1hCi8aEOw4YcyOLlA+pOs9nOMHGro/ZaSc+CIIyLnajWdf8XhKqTFXQotafcgu4qysBei5cQa4vhlFBbjlCrclYZDqZRdNj+0v6J9fGtaD21cxwne7aRi9Blokx15ImweIjxISAaLUmpReYqUchw9qIB79YdCqDCRXQMNWkQNs5SdvlEuIB8x78b0gCu6E5SKUp9f4PwZ5XiqJ5SMD1u/FM8GbhwA/FKU3a2COxdc1Jyg6MS2yzY1dcvLuad6jufBEqlnT/hYrg6KDm157M4qd3OTjA== Received: from BN9PR03CA0166.namprd03.prod.outlook.com (2603:10b6:408:f4::21) by DS0PR12MB6488.namprd12.prod.outlook.com (2603:10b6:8:c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Wed, 19 Jul 2023 11:02:58 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f4:cafe::d6) by BN9PR03CA0166.outlook.office365.com (2603:10b6:408:f4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33 via Frontend Transport; Wed, 19 Jul 2023 11:02: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 BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:02: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; Wed, 19 Jul 2023 04:02:41 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:39 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 16/17] mlxsw: spectrum_router: Replay IP NETDEV_UP on device deslavement Date: Wed, 19 Jul 2023 13:01:31 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT035:EE_|DS0PR12MB6488:EE_ X-MS-Office365-Filtering-Correlation-Id: 389f39de-1205-488c-a4a7-08db8847b5b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pv9Nr/z83I6944V7AK+JhKT5h0rSUvanm8y9FwuEKVc/Qm4X8hMAQnUruy6I5RHZbk2K61xSBhB2wRGqM4U+mNlfxzDrNcKXh0pE9iLksvH96rrUZmZeTxtzyMGj8b0lWkZ0yIdqPiFDcP0WGhcHZOArYiSeL2mQCpjc5C9lW0Lua6UqpUn/XzgYpF2xGSRHjIePs8T3tzaP5sdtoTShio+BcxEggA3D2qjwDT1az7WFZWw8SSOINKOv4BdzuCF7QXFad7Y4SwRRvtZaT9hFYR0tLkfMQvW8XcbheZij5/gh9s390ZLTaXYKvjcF4xIMMv5T9FrkJOHB3XlEm+HY/hRb9bkgnE8hGJ4K6DXSKv3Djsvr6wbOKNMIqgY+Kev4B1tgT4LprjcuI93acvI6cixrff3LvNOwRoYNdrhDNPTPU9kVLN6CmUxgUNOPHFTyEpxTWBBcpU/YogQPWiU36Z5VAtjJoGPgE62D7RyfUV9W4IT3qxTGPo/y/wpoA8vwzjSXvapxfQrdA7prx4A3F5ZStWJLBj+Ra24mVkLuqTsJepD8Kbgbsw6tsUBEWvWtSI+UdlIws+LFJcVLoyyIyPb22FXUMx9DyW7Np4VXparCv++MzYXeMflShSmjJCAb1+fhthNLtGRRQXRbjntT+Nfp/SDkesQE48KwCoLJGEjyCULD5bgPfqJeAWyZp0v+P6GWfWUQ3FGFbJGTqWZpIQaeF6BmEsy/yiPJm5f82OM= 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)(376002)(346002)(39860400002)(396003)(136003)(451199021)(82310400008)(46966006)(36840700001)(40470700004)(478600001)(54906003)(6666004)(110136005)(2616005)(66574015)(83380400001)(47076005)(86362001)(40460700003)(36860700001)(40480700001)(2906002)(316002)(70586007)(336012)(36756003)(107886003)(26005)(16526019)(7636003)(82740400003)(356005)(70206006)(186003)(5660300002)(426003)(41300700001)(4326008)(8676002)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:02:57.3727 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 389f39de-1205-488c-a4a7-08db8847b5b6 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: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6488 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,URIBL_BLOCKED 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 When a netdevice is removed from a bridge or a LAG, and it has an IP address, it should join the router and gain a RIF. Do that by replaying address addition event on the netdevice. When handling deslavement of LAG or its upper from a bridge device, the replay should be done after all the lowers of the LAG have left the bridge. Thus these scenarios are handled by passing replay_deslavement of false, and by invoking, after the lowers have been processed, a new helper, mlxsw_sp_netdevice_post_lag_event(), which does the per-LAG / -upper handling, and in particular invokes the replay. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 48 ++++++++++++++++--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 23 ++++++++- .../ethernet/mellanox/mlxsw/spectrum_router.h | 2 + 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 0dcd988ffce1..b955511fe5a2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4838,15 +4838,20 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; if (netif_is_bridge_master(upper_dev)) { - if (info->linking) + if (info->linking) { err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, lower_dev, upper_dev, extack); - else + } else { mlxsw_sp_port_bridge_leave(mlxsw_sp_port, lower_dev, upper_dev); + if (!replay_deslavement) + break; + mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, + lower_dev); + } } else if (netif_is_lag_master(upper_dev)) { if (info->linking) { err = mlxsw_sp_port_lag_join(mlxsw_sp_port, @@ -4855,6 +4860,8 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, mlxsw_sp_port_lag_col_dist_disable(mlxsw_sp_port); mlxsw_sp_port_lag_leave(mlxsw_sp_port, upper_dev); + mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, + dev); } } else if (netif_is_ovs_master(upper_dev)) { if (info->linking) @@ -4924,6 +4931,30 @@ static int mlxsw_sp_netdevice_port_event(struct net_device *lower_dev, return 0; } +/* Called for LAG or its upper VLAN after the per-LAG-lower processing was done, + * to do any per-LAG / per-LAG-upper processing. + */ +static int mlxsw_sp_netdevice_post_lag_event(struct net_device *dev, + unsigned long event, + void *ptr) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(dev); + struct netdev_notifier_changeupper_info *info = ptr; + + if (!mlxsw_sp) + return 0; + + switch (event) { + case NETDEV_CHANGEUPPER: + if (info->linking) + break; + if (netif_is_bridge_master(info->upper_dev)) + mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, dev); + break; + } + return 0; +} + static int mlxsw_sp_netdevice_lag_event(struct net_device *lag_dev, unsigned long event, void *ptr) { @@ -4940,7 +4971,7 @@ static int mlxsw_sp_netdevice_lag_event(struct net_device *lag_dev, } } - return 0; + return mlxsw_sp_netdevice_post_lag_event(lag_dev, event, ptr); } static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, @@ -4984,15 +5015,20 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; if (netif_is_bridge_master(upper_dev)) { - if (info->linking) + if (info->linking) { err = mlxsw_sp_port_bridge_join(mlxsw_sp_port, vlan_dev, upper_dev, extack); - else + } else { mlxsw_sp_port_bridge_leave(mlxsw_sp_port, vlan_dev, upper_dev); + if (!replay_deslavement) + break; + mlxsw_sp_netdevice_deslavement_replay(mlxsw_sp, + vlan_dev); + } } else if (netif_is_macvlan(upper_dev)) { if (!info->linking) mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); @@ -5022,7 +5058,7 @@ static int mlxsw_sp_netdevice_lag_port_vlan_event(struct net_device *vlan_dev, } } - return 0; + return mlxsw_sp_netdevice_post_lag_event(vlan_dev, event, ptr); } static int mlxsw_sp_netdevice_bridge_vlan_event(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 18d1bcbb3fdf..57f0faac836c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -9785,12 +9785,14 @@ struct mlxsw_sp_router_replay_inetaddr_up { struct mlxsw_sp *mlxsw_sp; struct netlink_ext_ack *extack; unsigned int done; + bool deslavement; }; static int mlxsw_sp_router_replay_inetaddr_up(struct net_device *dev, struct netdev_nested_priv *priv) { struct mlxsw_sp_router_replay_inetaddr_up *ctx = priv->data; + bool nomaster = ctx->deslavement; struct mlxsw_sp_crif *crif; int err; @@ -9805,7 +9807,7 @@ static int mlxsw_sp_router_replay_inetaddr_up(struct net_device *dev, return 0; err = __mlxsw_sp_inetaddr_event(ctx->mlxsw_sp, dev, NETDEV_UP, - false, ctx->extack); + nomaster, ctx->extack); if (err) return err; @@ -9817,6 +9819,7 @@ static int mlxsw_sp_router_unreplay_inetaddr_up(struct net_device *dev, struct netdev_nested_priv *priv) { struct mlxsw_sp_router_replay_inetaddr_up *ctx = priv->data; + bool nomaster = ctx->deslavement; struct mlxsw_sp_crif *crif; if (!ctx->done) @@ -9833,7 +9836,8 @@ static int mlxsw_sp_router_unreplay_inetaddr_up(struct net_device *dev, if (!mlxsw_sp_rif_should_config(crif->rif, dev, NETDEV_UP)) return 0; - __mlxsw_sp_inetaddr_event(ctx->mlxsw_sp, dev, NETDEV_DOWN, false, NULL); + __mlxsw_sp_inetaddr_event(ctx->mlxsw_sp, dev, NETDEV_DOWN, nomaster, + NULL); ctx->done--; return 0; @@ -9846,6 +9850,7 @@ int mlxsw_sp_netdevice_enslavement_replay(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_router_replay_inetaddr_up ctx = { .mlxsw_sp = mlxsw_sp, .extack = extack, + .deslavement = false, }; struct netdev_nested_priv priv = { .data = &ctx, @@ -9872,6 +9877,20 @@ int mlxsw_sp_netdevice_enslavement_replay(struct mlxsw_sp *mlxsw_sp, return err; } +void mlxsw_sp_netdevice_deslavement_replay(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev) +{ + struct mlxsw_sp_router_replay_inetaddr_up ctx = { + .mlxsw_sp = mlxsw_sp, + .deslavement = true, + }; + struct netdev_nested_priv priv = { + .data = &ctx, + }; + + mlxsw_sp_router_replay_inetaddr_up(dev, &priv); +} + static int mlxsw_sp_port_vid_router_join_existing(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, struct net_device *dev, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h index eed04fbf719f..ed3b628caafe 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h @@ -183,5 +183,7 @@ void mlxsw_sp_router_port_leave_lag(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_netdevice_enslavement_replay(struct mlxsw_sp *mlxsw_sp, struct net_device *upper_dev, struct netlink_ext_ack *extack); +void mlxsw_sp_netdevice_deslavement_replay(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev); #endif /* _MLXSW_ROUTER_H_*/ From patchwork Wed Jul 19 11:01:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13318799 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 8749D12B89 for ; Wed, 19 Jul 2023 11:03:06 +0000 (UTC) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0D2186 for ; Wed, 19 Jul 2023 04:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCpQHspTK0R7N7q58amicWeihM6uOdhJNTDd3l5D/xnzUxpXGTF5HRBa8zJ+EMuEixJCANVRmNzGDfzPWIJ+gsAPe00LkCWqOWC1rYxDhi8P3cfDHqTBcz8qxUy7bZKiMZD7r7ppdDvSG4/5le7yITxl21SgwQlAjF+pynKfI5ClCnmep1lBPVn0zSQsSx4wWd8+Kl3MbLzEysORr6YuGrgO+F8GvDhnpOA6igmOqzbu/ZsHdvjkldFf2h7TJGsXLiYNJjIra9nVx/c0Fr4m6L6tynoLGX8JfxO6NOvMwI5845w1CWeDs+3Kb8ho4KGxh+2kDHkHv66NpWQRCwn91A== 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=wUypfBwwtTBFuAE60PZafIFUyJAGeoAtkYFOAC5DpuA=; b=Z6IKI2Zqz7RO8jGD90NwETDHwtD/zX8yGDfpCUNaUatc9ggvYig/RpR+UGiLrjFrSKK1NzXQVC3P9O26AgTso0Ai7Dxep409w//vaBhgBvTLHf9auaUe2Ah9QptpoiKIUG0t8bHBkiTtn5U2H/b+VoFFUl9O5f0mLaYWOo9+k1ShjXjOMm9dW+r8uSlhGLP15im7o3IFVv3KuFLQyjEU41ZaAQxIcWZ6m6D7Te4TKQeTHxK5uhw1gKv7sG3XQIJa7B1fYGE/HH0aMCXMcX+8PtEhwweeypQwVy51LuklE41TK3BoTtX5PBZhdRnL8ROsZUTkTX/PS4vFm/KZuEm6PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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=wUypfBwwtTBFuAE60PZafIFUyJAGeoAtkYFOAC5DpuA=; b=rbFQ0RZLO3uyPxy+yQQz/oECjduDx5AVRiXHoBK5L4M4Dzk3JrxjT/Jqapj8+7Twph90CDAfHh7VVBWu4fQ37pQUQFF/ludB2xSwcLzq/KXgDW9/hvToqTxUMG8pyp1k4N+U3vDwtz5KhdzZXBCXXubQed/XwhtwxXZFiC8xO8RD46+nZH1nwV6MQWfMeQ++wczDfAAOqnx5YVYOcLrRW0XEaLXNCnAUomcSv+Gd3AOcTDqMHun59xDhydYRaQqKPPX48YjoSdQjmH/HMrIxsWISU4tdZVEy1EiEVXvK0Ef897Gek87I2/yMkBtkUF+Q1s5e16831PF+AQG/9iQ/xQ== Received: from BN9P222CA0022.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::27) by PH7PR12MB7019.namprd12.prod.outlook.com (2603:10b6:510:1b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 11:03:01 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::14) by BN9P222CA0022.outlook.office365.com (2603:10b6:408:10c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 11:03:01 +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 BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.34 via Frontend Transport; Wed, 19 Jul 2023 11:03: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; Wed, 19 Jul 2023 04:02:44 -0700 Received: from localhost.localdomain (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Jul 2023 04:02:41 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Subject: [PATCH net-next 17/17] mlxsw: spectrum: Permit enslavement to netdevices with uppers Date: Wed, 19 Jul 2023 13:01:32 +0200 Message-ID: <7510e6128f06e24730bed870b7fa04ffc11fa154.1689763089.git.petrm@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT032:EE_|PH7PR12MB7019:EE_ X-MS-Office365-Filtering-Correlation-Id: fed639ea-336f-467b-6708-08db8847b79b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AuitTvd4iNmwTomIPRzucsGKp96dZk6ksu+iC7WlV15qbSjq5BbaTMonFbMWHibm7A4yTJX1OuW4ODVAw0kDgj/cihl9nYF5y7ppvgtMGn91NeTkFGJNKWWlNYWZMw0BaOsosiDTidWyNAxbKhpszc7wNPJuvB7TKYzGY8oB9Pbdg9Ama4yhraqqx+re4hkAyxD8UqSrZTt2hOYOe/CbJD2pOwp7fn0y5HLDZY6GipCanp2fMA2cFL5ruJMy+qQZLVrlmqJ0oJKmlx/EFt7Ec8rBDNX6jnV+A0FTk7w7iSOYe0FVv+pdhNZrHUOQAiME7xX24v2KGAYgbzYk8LWUCVVqQ6CJmCKsufXvVF2fFF9aPasSfX48Sd9dZkUpGET16Zu5vKMkqr4KGnHIPSDP1ETWJ1hOS75o7OA0ryQxN85inNMUIVQjxxIYO3RWsaoV7yb0ysroBMBeCaJf5qfkNtW1d71OdU+sfqrTUNZF80QbeYYNkRhy2ZPM66PuYb9rzgDKwwOYEyq/EAsSYk2ejjlc1E5g5bRRX1hXArDg3BIUAJ42JcOpkW2do5avO0LqyT59reWf54VGjDCfWNuorD62jIrZksIrvhPQV8UKvye5gyy52R8VJryI0JaGahbVBkxZi2G+VvbAaQeIJuMHrxxzpg4pFiDOvbI+Zf1CQJZdCHuBUlFEZ2fD0kLLN63Fow/5oytkWuffYQLwWPb2njdxp+xfAGagW5cV+2qr1Uc= 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)(136003)(376002)(39860400002)(396003)(346002)(451199021)(82310400008)(46966006)(40470700004)(36840700001)(107886003)(356005)(7636003)(478600001)(82740400003)(26005)(2906002)(40480700001)(6666004)(40460700003)(5660300002)(47076005)(83380400001)(316002)(70586007)(70206006)(4326008)(110136005)(54906003)(36756003)(426003)(36860700001)(8676002)(8936002)(41300700001)(16526019)(186003)(336012)(86362001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 11:03:00.5496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fed639ea-336f-467b-6708-08db8847b79b 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: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7019 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,URIBL_BLOCKED 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 Enslaving of front panel ports (and their uppers) to netdevices that already have uppers is currently forbidden. In the previous patches, a number of replays have been added. Those ensure that various bits of state, such as next hops or switchdev objects, are offloaded when they become relevant due to a mlxsw lower being introduced into the topology. However the act of actually, for example, enslaving a front-panel port to a bridge with uppers, has been vetoed so far. In this patch, remove the vetoes and permit the operation. mlxsw currently validates creation of "interesting" uppers. Thus creating VLAN netdevices on top of 802.1ad bridges is forbidden if the bridge has an mlxsw lower, but permitted in general. This validation code never gets run when a port is introduced as a lower of an existing netdevice structure. Thus when enslaving an mlxsw netdevice to netdevices with uppers, invoke the PRECHANGEUPPER event handler for each netdevice above the one that the front panel port is being enslaved to. This way the tower of netdevices above the attachment point is validated. Signed-off-by: Petr Machata Reviewed-by: Danielle Ratson --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index b955511fe5a2..f0f6af3ec7c5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4735,6 +4735,58 @@ static bool mlxsw_sp_bridge_vxlan_is_valid(struct net_device *br_dev, return true; } +static bool mlxsw_sp_netdev_is_master(struct net_device *upper_dev, + struct net_device *dev) +{ + return upper_dev == netdev_master_upper_dev_get(dev); +} + +static int __mlxsw_sp_netdevice_event(struct mlxsw_sp *mlxsw_sp, + unsigned long event, void *ptr, + bool process_foreign); + +static int mlxsw_sp_netdevice_validate_uppers(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev, + struct netlink_ext_ack *extack) +{ + struct net_device *upper_dev; + struct list_head *iter; + int err; + + netdev_for_each_upper_dev_rcu(dev, upper_dev, iter) { + struct netdev_notifier_changeupper_info info = { + .info = { + .dev = dev, + .extack = extack, + }, + .master = mlxsw_sp_netdev_is_master(upper_dev, dev), + .upper_dev = upper_dev, + .linking = true, + + /* upper_info is relevant for LAG devices. But we would + * only need this if LAG were a valid upper above + * another upper (e.g. a bridge that is a member of a + * LAG), and that is never a valid configuration. So we + * can keep this as NULL. + */ + .upper_info = NULL, + }; + + err = __mlxsw_sp_netdevice_event(mlxsw_sp, + NETDEV_PRECHANGEUPPER, + &info, true); + if (err) + return err; + + err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, upper_dev, + extack); + if (err) + return err; + } + + return 0; +} + static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, struct net_device *dev, unsigned long event, void *ptr, @@ -4776,8 +4828,11 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, (!netif_is_bridge_master(upper_dev) || !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev))) { - NL_SET_ERR_MSG_MOD(extack, "Enslaving a port to a device that already has an upper device is not supported"); - return -EINVAL; + err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, + upper_dev, + extack); + if (err) + return err; } if (netif_is_lag_master(upper_dev) && !mlxsw_sp_master_lag_check(mlxsw_sp, upper_dev, @@ -5008,8 +5063,11 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, (!netif_is_bridge_master(upper_dev) || !mlxsw_sp_bridge_device_is_offloaded(mlxsw_sp, upper_dev))) { - NL_SET_ERR_MSG_MOD(extack, "Enslaving a port to a device that already has an upper device is not supported"); - return -EINVAL; + err = mlxsw_sp_netdevice_validate_uppers(mlxsw_sp, + upper_dev, + extack); + if (err) + return err; } break; case NETDEV_CHANGEUPPER: