From patchwork Fri Dec 13 03:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 13906417 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) (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 53BB81531E8 for ; Fri, 13 Dec 2024 03:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734060959; cv=fail; b=M8532qxbT9qIG1Qc4P27hsdNqtkSh1xijiGpHA3poXUry7TvOgGJYqXOGbdyQ/CJEdMpTn5bgjbBvqW9vn6+RMa5LYB8arpETVEjK9CJWCLqAiVd4vbmnqgLY+rZeFZBzTxgposCL/T2H6YTvTJqNdENEJ88rCzUE80IN4b75B8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734060959; c=relaxed/simple; bh=ahfEBCXgnztk5rRFUmF4KNQKEYzuabhhl+GLfHS/w50=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=LUoGGCK681GHbq0yf/1rofTjEqitX8Kc6rAeOryyBXBVl9YXAi/RwBzIkOPMI/LypXijDWCLNTOpn5/qzU4HTVPr+iUIo5zF54+5e74i2uRYk+rH5tJrDFvXf2qJW2m7pGv4fo2ZjiElDhVJTgCglpEQ7PMXd71L7CXnAwd12/4= 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=qjs0dOAb; arc=fail smtp.client-ip=40.107.94.89 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="qjs0dOAb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OG8j5HpFUo5kT+lifPy931y1JWZBjnqabYW+rALhYyf5K0PRBq6w1YAVae4sqCr9UkUi4r5RGf8YqJ68S1sD186wt5n5olQFf4OIYRZZKwsxiY5QQ1RDvJL9iAzqQ74Q8wIcsprHE7rYY45exldmPISEvaeeIvThjgVePFs0o9g86yYkp5t7wLT7KcSJxaP/P1FJh03Oe53QhxHu+rKZLi1AFDDvQRHB4xWwJsXl+1WutP3HI+RfSBxbjZGmIFeEvHSA2pLm0snFSbdj0iquy4hWdUb0xyIOFvEWzhE7d1hRlQD+pMKZP0L6K9ZWNpOrCD/RjlJufnI4BpNqF0GK1Q== 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=XADcR/yHvBLJksM9kUsNpWKj9nc0eI/UQwLCV035sZQ=; b=zGl//Mj3hWA8hDoQ5RUfZYStm8tRwfOSdmzLfZqOB2nzWsRRdh9/4zEIWDSP7o+gKudfzCrRf27bj1OotfVYnReuXxGXc2ORr5EMQYMaNdVArp3ucXKR9/U1A6txWMbJlmv8TTguTY254kHmCZ4QZ4zeQvZHBGzO9yJuv+cXv91dqjlQLNpe6DeXoEFh0qAbT1cgcJFqSpIj3q8UqVw3xGTHEPyc1hDho3jy0+/bGr5Csbvh76M+6J3gfXyEm7jOYo12rwV3CecVT8BrubX2/eekFdauCPUQ/Gq/mBG1mX9XpUr4k6t0WiLTxPLnuAwAH1Ts3icT/Oeg9JzxerkmoA== 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=XADcR/yHvBLJksM9kUsNpWKj9nc0eI/UQwLCV035sZQ=; b=qjs0dOAbcHeiXhjHkRdkjRAnC1OHCJHS8vkuV8rUkRNzFgbJVKFaGwdUzMLhdBVN+oJmrNNvkWD0+CX36e8F4+dc17LDxqHfkxGJt+dQUhtsT4CtiN50S0mSPDxXbQSNiaGBjeaTkWEVn9iiypyVpZloOwfO7jv9goDe3iSDnNZXvR9kLVrI0SclASVq6pK6LQbqMoou0o9ukSt1DFH7FEGugR4ZsgRF3/ApnbYf3Ob13gFtb4HvtT7MPI2Sebtx1X84flNA+WVS3ySTYjlgK1Jfz+JZVC4LVDnk2zRh8cBns1fi7aRf0DIqbAHvJ6n9RlYtFv9o2LbPO1skLzs08g== 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 PH8PR12MB6890.namprd12.prod.outlook.com (2603:10b6:510:1ca::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.17; Fri, 13 Dec 2024 03:35:54 +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.8251.015; Fri, 13 Dec 2024 03:35:54 +0000 From: Yong Wang To: razor@blackwall.org, roopa@nvidia.com, davem@davemloft.net, edumazet@google.com, netdev@vger.kernel.org Cc: aroulin@nvidia.com, idosch@nvidia.com, nmiyar@nvidia.com Subject: [RFC v2 net-next 1/2] net: bridge: multicast: re-implement port multicast enable/disable functions Date: Thu, 12 Dec 2024 19:35:50 -0800 Message-Id: <20241213033551.3706095-2-yongwang@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213033551.3706095-1-yongwang@nvidia.com> References: <20241213033551.3706095-1-yongwang@nvidia.com> X-ClientProxiedBy: SJ2PR07CA0021.namprd07.prod.outlook.com (2603:10b6:a03:505::23) 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_|PH8PR12MB6890:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fc31b4f-fb71-45bf-1920-08dd1b273f98 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: 8I8AedppnAOSlxwEXSQ2IrXQ/6Kp4rCKfQbXs64X89jLC3E1rMAR/XPjK9t+y3UaZXuCFJlvZfx0dzypSP3mxHU3FvwJkCYC1/cgwgiL60fE/at/wA7DMaPmG81ft/uNnaWCLTpwKe4PFc8zTcGqgOp13N3h8MKwAvbUEryLLfkFIMxbHBVOykfeDz39/09AyyqJ5VlgvBsosixxVsHs7EW+1+VyfHPz1wOaoaSa199s3klWJKJOJL7dn8LnVOYochAQxwho1oNZieuSirkrVeX0FdmmnZQahqk5iwD4r6ALUnhLtW6/WkHI/nRWgyeMAatxGMnoNhnp+axVsDrIL9gcLRusFz0MlJAa8tucQ/FcoWDG22yM5Ql63K9rtqm45WT3eTRwe62Fa0vt+KjQdeRWlILiFGq6pVrdOasLINwQyJoJ3SBaQGfOzit0H1JQqoHykq/tpn8lgqpMKVpwxEuUKCRjq+Oy5PJHheUJNUy45DGcR0Ppomf0wBzx7xBPaJA2lRc8uKd9kTnxYvmqJp7dcXYEm5hjuUw53DPuvx7JufNadWMwd4fY6VI6P5shk8oFgM9NNvwJ6QPz5kHnnPJiuennYz1smkPo4S+E1ofAzL96vc+6tMXvWZx8Y2faEuCXIqu4TIJg8zwEP5qaJ9ux4O8lr554PFgdZ1MzXm53sxxbAi9X25VxfPfGuQfaWerffeks+avHMu2Sif4hcdvkymLWIrLycGqlx69bup2DEWexo492om1CFt2KNB9XoBMOk8b3yFidqdeNYvRHN6yItctXryeHsRQm4gKgl3pyD6Bs26mqSfP/QIAF0NCvLDkZD5x5d1xdCeJYt8SdT+RYJ/xpxVYGdUPIM8y2tBGJO1dlQkAoiLCbbTsFeCDXaj9mXeOQVaojjQyLswOYLga5qnKT/2hVSzfVlYIdR4ugNZzwcUHzyjNUeBWy15sIoEYdq1HJbLziGQPZC1Ep+I3v9wMGQ7zBVNkTtv0CaecNFL+J9Maa0JPnzsfYAzZQiqpXZ9t5dzMLeJVE0h9yEg6b3Ar0oVOehQn4ykQiGOHt3xNq0PmgK+Ago0XbhS8I44DmBO+/x/prl7ehZkJk8ny3uq2r7IIPKllWfW8SBqEBe4xuIRcIWcsXg8P37Zo3SWHXlLwAe/R1Ky93iNfkBZPLpklMzojcZJb05pxPE4IJZoTt+qXy9iXJele//PKCNxLdIV8c87FVJRLlKpl5vuYafk3XURcglF8+SbQpIcV77Yukhd26AOXCJ8TuxM/nRQEx2TC9x+IzXwgii9lCtJBhnlaBEoCjWMRrnDeVHR7MzxJOEe1LpTNJxUof0QOgY99OZZZBfR0EeEIOslSONg== 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);D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TEMxgGDCQLxRM8w+1VYFHY6PYTZw2/zmttMZJDuXtho16Xwn5G1WcveE7dCJc/R6rKN26ufBfUUJETfXkS/kaufTfPEn0IMtHcbeZTUHjr3MSqyvd+hGMzf5MwSJ+x3sUIosK4Et6NBqYwXuz9n5IjZKYFtFHjfaUB0Ff6xKtTDNDmcgKOAHJGA1UF7+BJvf+l8Dt2inKiiOQrGXx9kSfxoXYXJ3zY11K13sg9qs4ej4boc8ZMSk4mUqM0X/Vs8enregW/Wbpl8OHTkO53kOEyrwgcjdsJkT0acPIcFFvcRZq63t3YxIRDV2jRDHLFRRI5ibFWJuVKCqdGQlT0CnALVK0cWPiXvUfdGSaRkcVW4SJrIvaVmynI/KmX70tpxdyAShpA/H4JTWqieyIZ3OyffQXcHqNMOzwxmakrcmXS2WYtxsz/3Z2rjaZ4NddJIK/oCMA5Aj++domQm/Zyyk6uleoQ1t8w/Hve2tFwf6TltKbp90PyDNv/bOBkkB2e6kCJLNFfpJ8fn0UAWdq7LBYLZHf3AvT203qv0+lehrZ9wpfZcVOCVFKzF9oP2zB97vbn9oqYaB69BxbLPlPEeBHwj X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fc31b4f-fb71-45bf-1920-08dd1b273f98 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4858.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 03:35:54.2984 (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: b+zqseeL6H8b1YF3WYQVHJ/agyvg2RDQ1Jd5lvKx78sZ10yCL14jTEwLMtIzrGOdqF8dGzMoSstyltZjaERrfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6890 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Re-implement br_multicast_enable_port() / br_multicast_disable_port() by adding br_multicast_toggle_port() helper function in order to support per vlan multicast context enabling/disabling for bridge ports. As the port state could be changed by STP, that impacts multicast behaviors like igmp query. The corresponding context should be used either for per port context or per vlan context accordingly. Signed-off-by: Yong Wang Reviewed-by: Andy Roulin --- net/bridge/br_multicast.c | 72 ++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index b2ae0d2434d2..67438a75babd 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -2105,12 +2105,17 @@ 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); + if (br_multicast_port_ctx_is_vlan(pmctx) && + !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED)) { + spin_unlock_bh(&br->multicast_lock); + return; + } + __br_multicast_enable_port_ctx(pmctx); spin_unlock_bh(&br->multicast_lock); } @@ -2137,11 +2142,62 @@ 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); + if (br_multicast_port_ctx_is_vlan(pmctx) && + !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED)) { + spin_unlock_bh(&br->multicast_lock); + return; + } + + __br_multicast_disable_port_ctx(pmctx); + spin_unlock_bh(&br->multicast_lock); +} + +static void br_multicast_toggle_port(struct net_bridge_port *port, bool on) +{ + 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, toggle port_mcast_ctx per vlan */ + list_for_each_entry(vlan, &vg->vlan_list, vlist) { + /* enable port_mcast_ctx when vlan is LEARNING or FORWARDING */ + if (on && br_vlan_state_allowed(br_vlan_get_state(vlan), true)) + br_multicast_enable_port_ctx(&vlan->port_mcast_ctx); + else + br_multicast_disable_port_ctx(&vlan->port_mcast_ctx); + } + rcu_read_unlock(); + } else { + /* use the port's multicast context when vlan snooping is disabled */ + if (on) + br_multicast_enable_port_ctx(&port->multicast_ctx); + else + br_multicast_disable_port_ctx(&port->multicast_ctx); + } +} + +void br_multicast_enable_port(struct net_bridge_port *port) +{ + br_multicast_toggle_port(port, true); +} + 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); + br_multicast_toggle_port(port, false); } static int __grp_src_delete_marked(struct net_bridge_port_group *pg) @@ -4304,9 +4360,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 Fri Dec 13 03:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 13906418 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) (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 184E3156F3C for ; Fri, 13 Dec 2024 03:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734060961; cv=fail; b=WCFMMqkANlODuKxsIw1UoEsrOMy+v8TSP5G9rHxtsDEsiEvzjQOVde1y1ras3LgRwdNuL/6vu1LQx7aeH4ZlavKA0/uOvd+cl71dQhbN81KoRdiuVVz19wTzLSuyPZqn/E73bkaOJKFBMEO5m8+TNbjKrSsnMVS5IyBMtUlzSF0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734060961; c=relaxed/simple; bh=Il4gHPmG/46J75ufUCVxXs7+3Qs9IIC4Jufsv6ORwuU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Z9ibyj0qoTvEvOSzshOaqk+WK2/KfNU7ZKX7ycuXCom04DU5w2Q4V/Y9ZWODkPuIi/kHJdnsfAcUVQ63FwjuPisS0T9+dgszQfw83eT3h5FcTuw8kLFuxT8vqMpwwQoipYwC6jh1VM6qz6sAAPDVdH/27WY163beBC2jkyKv1oM= 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=btLpR2SS; arc=fail smtp.client-ip=40.107.94.89 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="btLpR2SS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aMjz2E/QoCHMIB+CwunbsI4iqFhFHoWzT1NNOK9z2jpxr47ke3v91YQIskalIaDDhmLFPOiIPAjNePa8B9gqUAzKy0u8vYFHaUZCA9o94mXwWFA2i7tUEpGVBte2ucTvLn1S2kOq1lsu41iqV+4RU1XlG3IK0WxUv4ZfIwG1Tbrdex9rEkdyoPAddj9Q8orsWEP7RDw/h4HWwtU8xDC1Cwx2ftdZLV1sCl32Pu/pCSsc/PcVMKT96/ZY4sK20OWgAApXwfgAzw0ft44POE4QpmL08JO4Wla96WOzgnyRm21hRpP2oil1pcpN/X81Wq8myFmTkd4jmhcwJE8JkKURzg== 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=wEBuSF2dViXRdbFMqU7P8ilrpj2whFDLF+S7yAKn/FM=; b=tmQVrm5RM+XarHFI2AakuRf9OFcfigdKiFXH2o3Xra2qZKZubY5h0n3g/wZvFNnWVXDwwzZYqgRwRq/OeN+XvU+Yfy4SKInuV7Ek87mLt6k+rdGr71WGqfqRzShwIDpmatXN3Zf7Tkox+qZd2Nqz7GPzVbf+qnenk7Bi1xLDMu2X1GA7LmG5EZ6rz6v2UoO1qXt5Y2WXZj6M+cHCY+mlSQ37O6jjDcaAxzkibssl+18maKQ/qTU5hriuksRS0tKFOURr5WsOopcVV1p7/iAcv11+sUoli9HkWjFQ1h0uR2/t8tnpS8KgMWDEjojIS+UUgOUawV8wvCPiHlOIfkrbRQ== 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=wEBuSF2dViXRdbFMqU7P8ilrpj2whFDLF+S7yAKn/FM=; b=btLpR2SSSAdAzH1dykkSJwGQLHUBGtY/tMTfqp3f0TJ9Srep4Oo48ebgA5C8GA0VlBC4YTHMUMJTNhf4MXIXfSe37quiPnM+flcm1icaA2FttDetV2EF59v5Jk1qVbNvEqu5DKTMr4tG1JtnUq2F6bj4qED7K/t3hhHVM2pxA0c0cjORACduVYn9FFVyb+tppMgS5gayN29tn6zyfVsQbbStizUrjpyj0lLpSjpVnogpm9ZGF945VEx6pB4mF4S+8rYJMWWhBQgcZiyDHctBa+4WkcLan+A9CocX5WpxzYi5T32MEHu27XHO7FLRB1KRxYwGsiqKkhZ0IFHa8cFg/w== 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 PH8PR12MB6890.namprd12.prod.outlook.com (2603:10b6:510:1ca::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.17; Fri, 13 Dec 2024 03:35:55 +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.8251.015; Fri, 13 Dec 2024 03:35:55 +0000 From: Yong Wang To: razor@blackwall.org, roopa@nvidia.com, davem@davemloft.net, edumazet@google.com, netdev@vger.kernel.org Cc: aroulin@nvidia.com, idosch@nvidia.com, nmiyar@nvidia.com Subject: [RFC v2 net-next 2/2] net: bridge: multicast: update multicast contex when vlan state gets changed Date: Thu, 12 Dec 2024 19:35:51 -0800 Message-Id: <20241213033551.3706095-3-yongwang@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213033551.3706095-1-yongwang@nvidia.com> References: <20241213033551.3706095-1-yongwang@nvidia.com> X-ClientProxiedBy: BY5PR04CA0019.namprd04.prod.outlook.com (2603:10b6:a03:1d0::29) 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_|PH8PR12MB6890:EE_ X-MS-Office365-Filtering-Correlation-Id: d14dabbc-e43b-44a6-677a-08dd1b27407b 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: HoaySfeUJJjmRxGJhF0mL1mu4hsci/KgB6e9bmjYR+tGvPUiVMcOBZ4P2avaYJ5AE4MtVi8/1YN8hGYA6fXpJzpacLMVYyQ0SqWTyvaT+qTHWTXAX1KQNcrrjI5waoOuyoncmgSp2VpKPXnDe/DZx6hrfUFPHesmHDU51WbJa52SkQIiMk2UC2iimj04gyohySl/D9FP2UwBEIEeHge8jzmaZZXCJMlp2nCmTwLhDXBtrJ+D/CbGC6PDBd1e4HkEgSN89XEzLOqXaFBga6UW2ZPr1SNLLhoD1Ut/nVAnD56KuQ4SA8XsHk6jl+v99Tii5bhHu9r1d7kA+R8T7zhUk7Z5UP5dWj7AsLc6PFjn5HW6raQY2geVxJ1IVXUxfUQ2xjdceJaWLNdXWtkDt7CoUWmF9r9s7Du6T6QzSfQD9T8wAqd1aAbahxpDY2VqyEm4gtOMAt1kNec6Iqkj5HT8qb5arUm9CI8mwrMggmjcToMq5BuvJBypPU79MoXOMoQliEHUL+mtI71qJcJC6uvyjSIFeufc5z6G3hDBcdFI/AhhM9hQ+rzPFwwDvHPfI+QXsSVmrQP4Bg0TizCUKHtDs1+AAoUcowj+poTEAAPPDlQR1zSk5aFWM+HuM1P7HUir4EOOC++T3eQPI6IHhwpmkQ9II1dazhcD4NfpBaJYArHOytBqXi+XS7B1tRFi80vAWma7RcnSolZImUvi7Qw1cM1HkQeaHn0E+9HnCJxZvig3cWSREz13PKHKSP7mTli8X+N8f4KAc+VfImxfZYcq1lUFM1AYClGNVM1XVrpFpW9jMaBzFvHWIMQ7O2yGZHhoomzI7GfoPKXcfqAfvbXsaNVKbab03FCN45Qo/scFmd4kCzZP9cJMPsAesaqsWwZt3KBHBY8JzpocvCpUO0NH7jklYjok7S7gFR/ygHkTT0jO7pnDRGFnoY93TL/baByYgRfNFyqIue1BJpbQZ08/pvOK6JtYkNGyTTGSo2cFDt5Cfzw10NgunpPZqeSiRh67hdzZTr3Vl2Dxrx0bxajMG+xEHkTOYHgQcZOWAhAUzuPprRSq+8q71oOWu7NuqXep8yy6hOTqEFvTTp58o9iqnbkNdVYWSSkyq7fbX+GZarQfmtR37qIgz1+QQNW7SiPwIWJ/H1ecQemfhF81wyjaj/WPkvXWDhtOmTq8W3Oz4JBD6TYbppa7izE4kwff4149us9AgIEiiUQm+zbtGFlt3lefGHikhThs7XsmSmC45vVutw9OhPp0+Z7o4TMD5s/Adsq2g1v83syQ6o5EylSnH6M9vziqTJNKFf9fj5xBKWTaefGLoM52TOZ1P1/RI+VwQ6zULhfvUq6+prYVVorF3A== 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;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b2iCpEi1XMs407PMFgXl66soqzAHXmXyMo9xbHHPkiZvO3oOqGgMe5ult4ZblADhW+BFKqrqrviim9aqCbRmXbx9lMJKF1/P5FT2AbhLU9htxfs1/5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GK3N0RffOh9m7NUPDFawkf2cdR2nODtR0kAUH68DVPe5Du/IzkavbbaS1RFGXEr/FyrnjA5oVvJLPYo+lBuHcntsIDHydSn5wrjU5Rm1gE67L8GiwuIGQSnfBaAkihGBo16shFjgnU2aZzNRSZaDCBq27OeZfFOitLic1PMLUJYLmEqbKa/sN6iNkU9/odekRDgUSHAHoPXMKRN7DLeUhcG27XuRcBVwurBWSu6xplgdgGD3gAgk7IDblHV0ot9slGP/V6T7TU74+vs09O/umhILKctyyw3KOeh6c/JNVq1ZK0hfE0pK4OgpMkoYhvyBgOUC1iYW16gm2fEle1Jj6kQ7YWp6azBqhJMWXRchAsUSVpZkzqKphR5GccYcQbrbojdky3+cxZSo541spTiRIv9Wn18Lf6 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d14dabbc-e43b-44a6-677a-08dd1b27407b X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4858.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2024 03:35:55.7370 (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: 27YVEbgwlMe9SOcqB9CSR3fuD/ASXMFzFZT5zUet5N94h70Wbv5WoA84BpVtRqgU/vVF/ceCyemG85/ewbD4/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6890 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Update br_vlan_set_state() function to enable the corresponding multicast context when vlan state gets changed. Similar to port state, vlan state could impact multicast behaviors such as igmp query. In the scenario, when bridge is running with userspace STP, vlan state could be manipulated by "bridge vlan" commands. There's the need to update the corresponding multicast context to ensure the port query timer to continue when vlan state gets changed to those "allowed" values like "forwarding" etc. Signed-off-by: Yong Wang Reviewed-by: Andy Roulin --- net/bridge/br_mst.c | 4 ++-- net/bridge/br_multicast.c | 24 ++++++++++++++++++++++++ net/bridge/br_private.h | 10 +++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c index 1820f09ff59c..3f24b4ee49c2 100644 --- a/net/bridge/br_mst.c +++ b/net/bridge/br_mst.c @@ -80,10 +80,10 @@ 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); } 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 67438a75babd..416c2f16cbe4 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -4267,6 +4267,30 @@ 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_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) + return; + + if (br_vlan_state_allowed(state, true)) + br_multicast_enable_port_ctx(&v->port_mcast_ctx); + + /* Multicast is not disabled for the vlan when it goes in + * blocking state because the timers will expire and stop by + * themselves without sending more queries. + */ +} + 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..b4e484de473e 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,7 +1858,9 @@ 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); -/* vlan state manipulation helpers using *_ONCE to annotate lock-free access */ +/* vlan state manipulation helpers using *_ONCE to annotate lock-free access, + * while br_vlan_set_state() may access data protected by multicast_lock. + */ static inline u8 br_vlan_get_state(const struct net_bridge_vlan *v) { return READ_ONCE(v->state); @@ -1862,6 +1869,7 @@ static inline u8 br_vlan_get_state(const struct net_bridge_vlan *v) static inline void br_vlan_set_state(struct net_bridge_vlan *v, u8 state) { WRITE_ONCE(v->state, state); + br_multicast_update_vlan_mcast_ctx(v, state); } static inline u8 br_vlan_get_pvid_state(const struct net_bridge_vlan_group *vg)