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)