From patchwork Tue Nov 26 21:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 13886382 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.65]) (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 311021DF267 for ; Tue, 26 Nov 2024 21:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656851; cv=fail; b=PKoMQtKWMQRETAVIvzY8Pm++3CQEF+uBEPJCVxHHfqIeXxhv6CmQocwjJwgO2OC8ynpYOndh/4MCwixz/zpsSI5EM1Rgq2PipSpICtSxMdmQvuA5puTaZHay2F/lGsq6EabSNp2cgdwgpuxvO6ligz/hk6zRMdW2hDd2goOm+tM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656851; c=relaxed/simple; bh=AydVqt31YL+3WF7wTRqq2Q5Yx1EL0avl1G3sdO4PFnU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SW4ShrfbkcyYB1az9I7QteYE1dL6slrxkHMKeo9WocrCcCPTZaD8NcCPN2Uhgw+OP1BjfocVi6SGtB9x89KHmXjU0q5DHnWtDrJ8cvJjj0u2TN5PJKacR5VWpMEIJlhO2nt7NyEfg2h6fZt3+0lHceBg6k/heURgKV/E9qHqR44= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SR5uVoPx; arc=fail smtp.client-ip=40.107.93.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SR5uVoPx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z7NmpogbZAj9YgXrUlR9GPvc61JgGnoQ15vLKdjJww4ds35LYxrbQD8IPJ5WVZ9oONWyl9oNnecAaxxpqHq86SLckmgB8UV1kiXF+E+cVUHxEgDsoBKl08opB6bKdj9pDicZXA1fZE7cewteMqTgyjahHgYyVxhAaP70ox9NR3Hb1WQYd95mGwLYLVLxXlKDCjO/V2KIdCSHQ3oOmyg9TQD4yP766FTcRH4NllonqazB6KKRD4XewOf8TSN88z/fjTx1koKVIytEo07QWCFBIeHTenIzV5FOba5cpg+ltdSW6TWDnb2IfK1fdiwfJ3UkqaddCQLH19Q2xanTWahPxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tzOdvIkGpy0khqZE3gI2ud5rFjUNbRKpyZ33LUy3yuY=; b=b8k85kSj5cvcjjXnRekQ9oLcKOdzzbOhj6ZiSj02mNHwzKjIDCEXuGb+L13vNn7GxfLxkDRDOaOapqLQJjp50wyMW2dOWPjpGAAp4u+h/2M0ecQj/x/G3w3FvnIzrX08V0q0xY4ov2lit8oJbgTVv7W+p/sliYMDdNjm7F2/c3BMAGkHiUDnVNnUBCqo6Y4jn5p7o+j7WRnxmKwrvswpw1u7DYigqcQFaocE01AVASh0+IrJMWZd5R8qU2/YfHljCEK+eum7TwQqmLmGyQmk6FIDALitZlNuuBkA+w8idYn/e9JPIYxdC5Bui1T6p75daDmFwC397jzsaBPCCACN5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=tzOdvIkGpy0khqZE3gI2ud5rFjUNbRKpyZ33LUy3yuY=; b=SR5uVoPxjcjm7YTBpYmpcT9RkX5bL5uSUII8RAp1nIoGLeLA/+j9ik6uI0hwCYbFT7QeOH7asSAV/+KQXXvn3UXwY41x3KMB4UMkoaJZ7Euk1WOAP/dTYvtd+W89kdYqDPL9n+hs/n/SaytUoHh++oJZKfHVX+3RPs7gdG1G0NE4Rif7X+VFswb2WR0kr7I2Hl/625ybrFr46gLS1TvSsgnMQqjthJRJCMbfUrM1TGzgzImWWeeIMP8B5F/bBx+pViRW1w5Y67hiO6JvNGE8Hcfs4cv1dt1r343Mk5dwuTLE5m1Rr4ZawYL6paUbm9w60VG4WOoIxzEA47cdlf5yZg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH2PR12MB4858.namprd12.prod.outlook.com (2603:10b6:610:67::7) by PH8PR12MB7447.namprd12.prod.outlook.com (2603:10b6:510:215::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.20; Tue, 26 Nov 2024 21:34:05 +0000 Received: from CH2PR12MB4858.namprd12.prod.outlook.com ([fe80::615:9477:2990:face]) by CH2PR12MB4858.namprd12.prod.outlook.com ([fe80::615:9477:2990:face%6]) with mapi id 15.20.8182.019; Tue, 26 Nov 2024 21:34:05 +0000 From: Yong Wang To: razor@blackwall.org, roopa@nvidia.com, davem@davemloft.net, netdev@vger.kernel.org Cc: aroulin@nvidia.com, idosch@nvidia.com, ndhar@nvidia.com Subject: [RFC net-next 1/2] net: bridge: multicast: re-implement port multicast enable/disable functions Date: Tue, 26 Nov 2024 13:34:00 -0800 Message-Id: <20241126213401.3211801-2-yongwang@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241126213401.3211801-1-yongwang@nvidia.com> References: <20241126213401.3211801-1-yongwang@nvidia.com> X-ClientProxiedBy: SJ0PR03CA0390.namprd03.prod.outlook.com (2603:10b6:a03:3a1::35) To CH2PR12MB4858.namprd12.prod.outlook.com (2603:10b6:610:67::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4858:EE_|PH8PR12MB7447:EE_ X-MS-Office365-Filtering-Correlation-Id: cb9f534e-5cee-4d94-046c-08dd0e620d2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: CDqvr5iUaB77xb2OH1vQk+8TDE7HHSKKpPg2f+5zPXQz71lfBndt9gXOcS9v8sfo3hqrTJsTyKLbleuzpw+4S4eImw24pKQhmFr2dKDqV0EMKKjJZI2pi/7KzGB9LHRQ1z2hzyFJO7XJgwYWOn/O/x2NV+89FNE3L7qdbFZ+cqgKnMdeTYhUk/g+ERe+Ll3/BgpU4rJGpJshwb4VrIXiLzz8FutdPLHDLTkFj/Le1gkFcgnV7ZZrHdRG/RO/I66bO1haoJruf0noO3V7HrY1YJWHhEzaEyq+xbuUuPQEzyuCtMOgxdSlEqrzWPDkThTGrl9TcwmYJu5V0nhYSnIQCJZa6RfX9q8EbkVibP3Go/IdlIWI8EmArE1rWp+cDM9NRxY28mJc9oAXzEZjwDmlJeOvDpsp1ACsxedIR3+gYx3OHL4oEJq7HsuICI3/SGzscT9ZnF+fandg6/tC6cOuBTSDIgP+wqrlGfKu6mS1BBePx7fLR6xg3CQPaDMMIZb7d8tKChhk8CCBwuu2TuQnEIGyeNhGA5YD2xl7ewIsLHcQDI7oktBcPahHdCjq2odExTNsoiF9c/mkE+Vudx5B8Mr9A3Uvb/v1IWH/hA0U1CIRMPqThFdd2kEJ9QPgd1uoj+4G59MZsXxgZEEGM4hbXlrPSWb8Mxlu9aewsFpXA3CkAy9GbDVF/dAM/CE6paCpOcBpZyFDhDB64g3ukjsi5h00azeNep/Bye6ccJzyBBUYEW3yySWD1TV4XD2UkUArvj5GTm7xaODPN+AOY8wC5zS45IAXZYjkqied09uQatCxfBEl/W5xT26A0zkyc8HpZsdytK0rO1HSMw2+zxe5Fb6zfUZnmQSKAiNSIHf4v4GN+5MRK58kwkr2JDVxaypMxxB6XCP2wjjKuqvyKJUTSM5AO18ocIbHi7/yHE7GyDxReMOzDYlmRzvFZRG2/gb6PglKMnB0Fdjk4dcNU7ce7GW1ARe2ZEKzEAI+d8ReG6rMF9kFVS/SWmWXSFTh4PG3UfDlVoR7evUA87do6qhAa73e7fwRPPra3gYiDk7VWnY27R3NCsMPZGIb+ha6irK4Un+d7MBxxjgpU5PagQ7VL15Hymqnaeo1Fg1WZV0FEsms59VTn4M7sVhWZFeLp2pi0TeDX8bukdvXvINc13pQSfR+DLIfeoyNEWOliSUw9uregsdKDbnd5ppmOJcNSJOJdSJvxWkaOeO7l71Dd7ItLVP2YvSNlXCFPYhsr9D1Y8CGWrYoLCTNMoOWHyWXG3etOeqENfd8f3r7+l9w06pSvDQLDLnZBhGK+nYRrkFY14ZSA/ENZGV0x28CR4K6ANAgeIuLoRpLnoqYu9CBXoSS7g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR12MB4858.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;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IY7hY9ONolo4cSuSesAKah6sqTCwD1HfaeRyVTi/ARHnRJjHZd7RNItWSFe0po9CDkgWSAACsEblOVurdQfkcEvEdOuvD11g1LCQEZRM53WHeoRSvYn31y+aXHISQW5tJ63kfY+kKOaBFDcTd6UgKMA5lX7qfXyu1H/iQPthwqyuOYG/Mikg+mYZvmk244gTWVFiHTTVJ+fcvsZh0XZvAHK+vdjvQuFy/51AKKo2ujeoN5UNNDxlD2vmjRgy4/S5L1ed2rQkaJQNXc76gd/4sZQ0idpT73PcNYHw3sD8cFNJYI0e4P5wgikIUQS2CZAJd+QdVZAmacGVQYEZra76Ymevc3v37AFXLeZudUqSw2rzkzqzOHJYrwnTlOYN4Wa71V8UqpUVhXBuTfoSLyXBg0rPyLu+bpbTZKG+s5IzcvKIKWfj914D/PW+nHHVsE6PmtZQ61a4ki6+Tr87DrGlnSnYZOJeZVjrUfJp4ovE4abRYyXgoa1cd1Gpeg5WnL3myAm9hGDJHme/zNtN7sKvEk+5JMU+6sZur4dgHTo6BfhiU2SqhhPOWm87hYJHdnzv9Ry9DNPpQVeyrfavzq X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb9f534e-5cee-4d94-046c-08dd0e620d2f X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4858.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 21:34:04.9132 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xaBy7CyX3mrl64c8t3fp1ULl9GSX3ubex5mwEEKYySRJ5MHX1jyXLOB3TK2ahouL6tKS8pgqKmR24IqPiFSaeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7447 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Re-implement br_multicast_enable_port() / br_multicast_disable_port() to support per vlan multicast context enabling/disabling for bridge ports. The port state could be changed by STP, that impacts multicast behaviors like igmp query. The corresponding context should be used for per port context or per vlan context accordingly. Signed-off-by: Yong Wang Reviewed-by: Andy Roulin --- net/bridge/br_multicast.c | 75 ++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index b2ae0d2434d2..8b23b0dc6129 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -2105,15 +2105,45 @@ static void __br_multicast_enable_port_ctx(struct net_bridge_mcast_port *pmctx) } } -void br_multicast_enable_port(struct net_bridge_port *port) +static void br_multicast_enable_port_ctx(struct net_bridge_mcast_port *pmctx) { - struct net_bridge *br = port->br; + struct net_bridge *br = pmctx->port->br; spin_lock_bh(&br->multicast_lock); - __br_multicast_enable_port_ctx(&port->multicast_ctx); + __br_multicast_enable_port_ctx(pmctx); spin_unlock_bh(&br->multicast_lock); } +void br_multicast_enable_port(struct net_bridge_port *port) +{ + struct net_bridge *br = port->br; + + if (br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) { + struct net_bridge_vlan_group *vg; + struct net_bridge_vlan *vlan; + + rcu_read_lock(); + vg = nbp_vlan_group_rcu(port); + if (!vg) { + rcu_read_unlock(); + return; + } + + /* iterate each vlan of the port, enable port_mcast_ctx per vlan + * when vlan is in allowed states. + */ + list_for_each_entry_rcu(vlan, &vg->vlan_list, vlist) { + if ((vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED) && + br_vlan_state_allowed(br_vlan_get_state(vlan), true)) + br_multicast_enable_port_ctx(&vlan->port_mcast_ctx); + } + rcu_read_unlock(); + } else { + /* use the port's multicast context when vlan snooping is disabled */ + br_multicast_enable_port_ctx(&port->multicast_ctx); + } +} + static void __br_multicast_disable_port_ctx(struct net_bridge_mcast_port *pmctx) { struct net_bridge_port_group *pg; @@ -2137,11 +2167,40 @@ static void __br_multicast_disable_port_ctx(struct net_bridge_mcast_port *pmctx) br_multicast_rport_del_notify(pmctx, del); } +static void br_multicast_disable_port_ctx(struct net_bridge_mcast_port *pmctx) +{ + struct net_bridge *br = pmctx->port->br; + + spin_lock_bh(&br->multicast_lock); + __br_multicast_disable_port_ctx(pmctx); + spin_unlock_bh(&br->multicast_lock); +} + void br_multicast_disable_port(struct net_bridge_port *port) { - spin_lock_bh(&port->br->multicast_lock); - __br_multicast_disable_port_ctx(&port->multicast_ctx); - spin_unlock_bh(&port->br->multicast_lock); + struct net_bridge *br = port->br; + + if (br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) { + struct net_bridge_vlan_group *vg; + struct net_bridge_vlan *vlan; + + rcu_read_lock(); + vg = nbp_vlan_group_rcu(port); + if (!vg) { + rcu_read_unlock(); + return; + } + + /* iterate each vlan of the port, disable port_mcast_ctx per vlan */ + list_for_each_entry(vlan, &vg->vlan_list, vlist) { + if (vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED) + br_multicast_disable_port_ctx(&vlan->port_mcast_ctx); + } + rcu_read_unlock(); + } else { + /* use the port's multicast context when vlan snooping is disabled */ + br_multicast_disable_port_ctx(&port->multicast_ctx); + } } static int __grp_src_delete_marked(struct net_bridge_port_group *pg) @@ -4304,9 +4363,9 @@ int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on, __br_multicast_open(&br->multicast_ctx); list_for_each_entry(p, &br->port_list, list) { if (on) - br_multicast_disable_port(p); + br_multicast_disable_port_ctx(&p->multicast_ctx); else - br_multicast_enable_port(p); + br_multicast_enable_port_ctx(&p->multicast_ctx); } list_for_each_entry(vlan, &vg->vlan_list, vlist) From patchwork Tue Nov 26 21:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 13886381 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2043.outbound.protection.outlook.com [40.107.244.43]) (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 E12351DEFC2 for ; Tue, 26 Nov 2024 21:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656851; cv=fail; b=nTx/DnrPPUYGUhlEpOTcAp508p8l2QlMgKuRRPClO2iEbW4rvTPTzZ8ctFogNZ/yc7Vev2rOa71xj50DChmtYIdmQ1AlXEgeRvvXwwz3Io++imeygLp8EPXnFlXQC0/Qu7R1Px3qhHHO5fwm7n1arX5IgCZ6UIr9jERSP000pLA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732656851; c=relaxed/simple; bh=NK44iHdiaSKCV8Fc1HFEji1389NgNQRY1s4MrSeAmvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=t5YJf6nqAf77Q6VbqKFqOM+/bmjzxMEBo7dZxuJSquXZvchmX2IHc1VXvgRpGWqE2u2MPIu5cxLWgV/oTadamoAN0h2ImIXe2B2SJYOuMO3glAh4iax9MjzOR6TftTwNgQHUYoPbYxxdu23nVtFWS1znHre75kmjn5NF9X+6aRc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SCz8kx1m; arc=fail smtp.client-ip=40.107.244.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SCz8kx1m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iVF8GQ4fqiwg1/+q4wOExduk9MHEy+e4Uk77jKONSw3RcxEXKSz2jznMEG5y9dO50cGdCUh/gzlGHp81V549Ubkdkup5wvDI5aLvHB3J+2OCZjZpfxKr5boq39RJS/llqUjTOKDDog//u1n7lDabghqQLTavPlgCT/VsTIlUcUDxjW5UXmxiIqUnvWw7NfYFk00ongW35EG6+anZhg79fIujoI8iA7XE425Z/V1l3ah9Pc2q3PN8hZSiofjfWdlBz025UwGnBUAtCYbJ16Su8vflkkzKwLye9T2HX6tDDjVAfJPGCsK1wmJcpz6o22dosPccfkKLBOjN8wz9qh9TKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SLbD8pAehF9i+kNgm0yShNYN0hnOQEzQtRyjkptixkk=; b=TOTO1xYk0giZFhEfD2v/oinfUAFo5TEtvmDlcquuTYY47BBrNSI7mvXd/8i1b2p5gGXfDyCOpL6esxI1N2nm00KaP4fKolmBMORghFg2XVUWHRIZobJvC5KJnpd7LRbFRsVFLaAAtGdDMNoCTO9iSg3jg9DINu97E3ubnO64eYwo4ko0IJXMGCwyD8nN6RZMmoqGopWaMQdZ3y9OD87Y5kldO1SD/s1bUn0ZKM3cTj6mcw2FsnOo0ZIpEs2VDF04A37FuQriAEohDupo8f7Y1KJmXH4/vX70Sblp6VNthkgO84nxaruyY4wSF3iJev3D03qjWaba5tSLo5fCcuOQIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=SLbD8pAehF9i+kNgm0yShNYN0hnOQEzQtRyjkptixkk=; b=SCz8kx1mrfZmArSEysLb0ry9ziu24HkGATq/lbRKaATc5q+VEPkIXVQiQlh3ev5aqnITcaHRoEhWX9RAoxMUdOmjDRTiZJvn7/8dyINLm+MT5+ww3o0Yw72oZCCwQQrNzy+EJRRz2ijUlQuizfhtuz3U/kBxv1cHyBYlFV2YNlUA/nJ+PrrbieASzjSIt6EQuvBgVvhpiq1alLnG9rpLT5sOhc6bBjrCdW8BnEqT/dAGAVS/Gmt7ZdXkOJ24hwdZMaesh39+ldugxdQCw+vAgvKYkGKgmyrxj6H/OfyjHMNKAP2h4xgk3BnfemQuT3dY8riMj1PSpVCiy5O7lvB3Vw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH2PR12MB4858.namprd12.prod.outlook.com (2603:10b6:610:67::7) by SN7PR12MB8102.namprd12.prod.outlook.com (2603:10b6:806:359::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Tue, 26 Nov 2024 21:34:06 +0000 Received: from CH2PR12MB4858.namprd12.prod.outlook.com ([fe80::615:9477:2990:face]) by CH2PR12MB4858.namprd12.prod.outlook.com ([fe80::615:9477:2990:face%6]) with mapi id 15.20.8182.019; Tue, 26 Nov 2024 21:34:06 +0000 From: Yong Wang To: razor@blackwall.org, roopa@nvidia.com, davem@davemloft.net, netdev@vger.kernel.org Cc: aroulin@nvidia.com, idosch@nvidia.com, ndhar@nvidia.com Subject: [RFC net-next 2/2] net: bridge: multicast: update multicast contex when vlan state gets changed Date: Tue, 26 Nov 2024 13:34:01 -0800 Message-Id: <20241126213401.3211801-3-yongwang@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241126213401.3211801-1-yongwang@nvidia.com> References: <20241126213401.3211801-1-yongwang@nvidia.com> X-ClientProxiedBy: BYAPR01CA0040.prod.exchangelabs.com (2603:10b6:a03:94::17) To CH2PR12MB4858.namprd12.prod.outlook.com (2603:10b6:610:67::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4858:EE_|SN7PR12MB8102:EE_ X-MS-Office365-Filtering-Correlation-Id: a28fa249-4af8-4b28-0805-08dd0e620e19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: bCSsCMvjvGDBpc/cst/nOfV34BQuEZThDGt97TtNScFKG0BxBrBlpNd6mVRmJbc3rDwmvj0Zkwa8YCweTwwGdpHIxtTrYpkbobrKCzj0iT1WLNu7zjOOVU2r9eCzrJwE4njB3M0NUnPRKddPRZoCj3yL0rqq1g/4ZSwWM17WxPSFV1v6LL1WCdshGDxBhcC34VgODEZG3WIX46mpV42vlQzuDRaK7ehpKxFPNx6/PkfysldjYw0d5Mv/TUCBsJ6zduyIdOQFV1f8k7cWA44IvrtSsfL/jC/UYXKH0wcEbTrZBkmfsNiMWAYX9OdX1lcb7QbLw+LJplL6gak8vkzNmF95IlSLqBRKIDSDnCuKEa+k9Y5nVhf2P9TUKO96XvoPAnOccYa5BCTAJqX+I2e7RC9xCF+RtRY6vsPPksQgJOwn7nheZMGIgWBMqBQ5DitcVwRm75fw7zQ/tReVUwSE1NNB95jikoYMa97VGWCOJr727XhjNnDGlw2BPl4Tdjyt9pO47XTk1FaCnSq0+7/OkGyHsqtCZVlTMKGkKvFRo1urm0aCbh5OLAK6mnFMOI1ModHZW7eqDm6xcZGJaoCf+QJrAQa6TMByBX9Ch1eg9n6QnPcogV0H3Zk8dogpRsMAEQnty7sYKcGaT1Pj7ubnJc/txm8cyClo4F58OSc1srPAhrbRm37Mltl3QkAeOSEOe0PFxjqdT8ONBWEtbHuyOxaszTCa6KMX+ij7QYjgoRg8Md3JIvsr/mLYBp1kIYiOw8AOFe15NLgvIIHmbFtqciPN70gitLzjPjNvrQVGcotoaU7SxI78/WPOkncY4RDCSc229n3JDK2NRtuw9R4LVwrTL65brGPxRaBkmoS7hSdRY33T1EjfVQfBhGm3v5fYRI0u2Qky799rHT6iQED8a+cZirntrPJIMB2r0trvp4LfXrh3Bmxsf7s5vIuotaIZ2t4urUD7p10hw7Cd1daJTnsMygSzoZkmQbvLvNAl04AkmWsxUVYLINkAb/3AvoPHE8cNR7NWfzo6x0GobySVYYzAeIq0Aei/pLfA2d9u41QSiG5tglrg3HCMXEBTFfACLw0I3ZJ8+n7/u+Cp2BkjR1/75Fvmb9PpLAAuS03LTTdhAT/T2dO6VlbZbrWuJmKgPNL/wvWfv2pp4ZZhqBPFd3H0bIjc9P0y7VqYMHxqZGJM9BYApM9Jar+9Sy2d6HvFzLdqovvpMSW5drXmWD42I4emwaK/f2fu0zyRN+LvCnMz9cItAigxCSc5/Qt4yCf2KMEyIPhB6ZAcw39WXh/ClsypHGbUPEaFSE6/N831TqFH1VLZ0QrPsy5FxxcY5RppBaV46bA0lw+QcWZjvRimqA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR12MB4858.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VbnQqmoSTq7i0QBnS837tcVfpHtizMjDgnzqKIouNjCjm0TjPn25BssrRni3U3HiUB7SJIFevuJ6AgAgSQJKzh5LMnqFKYahj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nUw4NmcX9nOYm7h7h4XtU08nk7nxej/nB8gRwptFHl5IyVRXBOvfvmQojM+rlo633AfQarXt55QtYZO9cuBEUL6+tzwfyDVeKRQzCDvtRBvJZw/f3J518FjKi2wv70e3ar8h4jA5sQZL9uouJ51LhcwcUS0wA63LkbjZ1hQ0RjDJYUIdDIFhypNsuFqjWsoVIqiklb4+xfVWrUKWIc/87/1AEkxafNVPP/2CgHFWhl1psgiv5jX8Zeq5XroOWDR8hN5E2K3JvbRDBG+d6Sr5cBBylhq3Nuptl9w6aQVSkOOYt1mPM/7AvE0ffHCZJnCXEdJoWOw1DUZwmGwURHQ7X1MXoBtUWuIE4hRuQ6I0AOTRWvztJhGu2H4W7YyXwD8l2+lEI3sIXiNyCPzBWgFzW5E55Vil8Xfme2NfJlkT13r X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a28fa249-4af8-4b28-0805-08dd0e620e19 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4858.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 21:34:06.3909 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yvucSdtoahXkb3zqoz6YY7wbfJDFk0HZbtrB4ysYMfLCYmGWDu3WQuwJ5g3aNe2kO3vs9sukqjQwljofLANnqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8102 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add br_vlan_set_state_finish() helper function to be executed right after br_vlan_set_state() when vlan state gets changed, similar to port state, vlan state could impact multicast behaviors as well such as igmp query. When bridge is running with userspace STP, vlan state can be manipulated by "bridge vlan" commands. Updating the corresponding multicast context will ensure the port query timer to continue when vlan state gets changed to those "allowed" states like "forwarding" etc. Signed-off-by: Yong Wang Reviewed-by: Andy Roulin --- net/bridge/br_mst.c | 5 +++-- net/bridge/br_multicast.c | 18 ++++++++++++++++++ net/bridge/br_private.h | 11 +++++++++++ net/bridge/br_vlan_options.c | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c index 1820f09ff59c..b77c31a24257 100644 --- a/net/bridge/br_mst.c +++ b/net/bridge/br_mst.c @@ -80,10 +80,11 @@ static void br_mst_vlan_set_state(struct net_bridge_vlan_group *vg, if (br_vlan_get_state(v) == state) return; - br_vlan_set_state(v, state); - if (v->vid == vg->pvid) br_vlan_set_pvid_state(vg, state); + + br_vlan_set_state(v, state); + br_vlan_set_state_finish(v, state); } int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state, diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 8b23b0dc6129..3a3b63c97c92 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -4270,6 +4270,24 @@ static void __br_multicast_stop(struct net_bridge_mcast *brmctx) #endif } +void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 state) +{ + struct net_bridge *br; + + if (!br_vlan_should_use(v)) + return; + + if (br_vlan_is_master(v)) + return; + + br = v->port->br; + + if (br_vlan_state_allowed(state, true) && + (v->priv_flags & BR_VLFLAG_MCAST_ENABLED) && + br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) + br_multicast_enable_port_ctx(&v->port_mcast_ctx); +} + void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on) { struct net_bridge *br; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 9853cfbb9d14..9c72070956e3 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1052,6 +1052,7 @@ void br_multicast_port_ctx_init(struct net_bridge_port *port, struct net_bridge_vlan *vlan, struct net_bridge_mcast_port *pmctx); void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pmctx); +void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 state); void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on); int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on, struct netlink_ext_ack *extack); @@ -1502,6 +1503,10 @@ static inline void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pm { } +static inline void br_multicast_update_vlan_mcast_ctx(struct net_bridge_vlan *v, u8 state) +{ +} + static inline void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on) { @@ -1853,6 +1858,12 @@ bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_curr, bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range, const struct net_bridge_vlan *v_opts); +/* helper function to be called right after br_vlan_set_state() when vlan state gets changed */ +static inline void br_vlan_set_state_finish(struct net_bridge_vlan *v, u8 state) +{ + br_multicast_update_vlan_mcast_ctx(v, state); +} + /* vlan state manipulation helpers using *_ONCE to annotate lock-free access */ static inline u8 br_vlan_get_state(const struct net_bridge_vlan *v) { diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index 8fa89b04ee94..bad187c4f16d 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -123,6 +123,8 @@ static int br_vlan_modify_state(struct net_bridge_vlan_group *vg, br_vlan_set_pvid_state(vg, state); br_vlan_set_state(v, state); + br_vlan_set_state_finish(v, state); + *changed = true; return 0;