From patchwork Thu Dec 8 15:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068533 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55493C4332F for ; Thu, 8 Dec 2022 15:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiLHP3P (ORCPT ); Thu, 8 Dec 2022 10:29:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbiLHP3K (ORCPT ); Thu, 8 Dec 2022 10:29:10 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8783D75BE1 for ; Thu, 8 Dec 2022 07:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WISCq93bxGEJJNjggPRw7VGaVilDpNndgMmp7bvBD6tcEsmlHwX8iT6bno86sRgSNmB/SGV7D8sH5iKfyFRI5W6ZAHrjA/9hx8LevTeusdzGx00ntqMg5CMWtH6acxaHQshM+oFZWAJWU/F2qsI3LW5ce7gUsg3lw6T+PQd69BGVXVeuz6t9oCl65aYc2XikVE210CybzaOTXQ9A03lhQrIPv16mPvOaIGnb9Kmn0g52zZ7uCRymwln0ugF2PnRd8SayUtpybBnt2cq/AmElNQikVI28stFr88t7DHo/6OImqmJ0BgGrm6FD3juZV8Q/1i2z15eyObCIJY8GsgMpwA== 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=hPdHPL5S3hyLMtPnH/HReqGYYi8jUkUSixhyjE2KxQI=; b=SszVRR4Z9HvjPJkF+yA+0QfvicJn5Gg+gfPDW05gsDjXQQIoaBqwmPTFnkGLBulHJj1JeLXDj1YIBqYIFahDlpdd0x1pNupWw3sIdGrit6Q5inEBqOYt/ZAvdZD9MOaZKSMTE8tWWbFTa0Ef712IKxxOvV2VmIVXltyRQ/aMbzJZsxch3ESHTbHlvfWQtY8LK/UueJYUtc5rGG8ayvjpmKU3WPeYMr7/BhcbPH3kwGMEBX9fX2BoxlXqA+NmbrtXj7hmgsWSTqk4hsfEmVRjZC9Ub7+z1Bf6xBdxZ3dGBTlzGWsUoVjhfDLnSgHPi9TcY5JKgOa8BxWmNNu/eX+WaQ== 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=hPdHPL5S3hyLMtPnH/HReqGYYi8jUkUSixhyjE2KxQI=; b=Nb7jZa0mg+Gpr8lYeGxoGBWV6Z3NsrDFsqy5QPBSLam3ms5FlaYhBQk0j1WHFRDtCsU/GyxiaY1mcZ/xatH6ATH3NBXr4off+eZYKKxx+tDerjKh4HNSM/zaPfPrZKZbwypkzIM8/8xQpDwSlqa8Wrx4q9AIHn7Wm7VoOybCLO7Q5VvWtsLJYQDGFmI8Z1bTXSmqP68Iq1o7PHu8KsyKoXqkn2VowXlQfTH6V9MpWswbCF6vl2w0+AUFj5l3R9jHrbk+GvqOOw9gOx4HT/VDZJBGAW82kjDhAW7YHxb3CIc8oJLzSSnea0cql3EFMFJBGd7Oy+55R6VRrf3csJ2M6Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by PH7PR12MB6787.namprd12.prod.outlook.com (2603:10b6:510:1ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.16; Thu, 8 Dec 2022 15:29:05 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:05 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 01/14] bridge: mcast: Do not derive entry type from its filter mode Date: Thu, 8 Dec 2022 17:28:26 +0200 Message-Id: <20221208152839.1016350-2-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0114.eurprd06.prod.outlook.com (2603:10a6:803:8c::43) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH7PR12MB6787:EE_ X-MS-Office365-Filtering-Correlation-Id: 23008297-3bee-4687-dcdf-08dad930f0d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FWpzShRiSXbkrZ3T4BO8juFATTvhw7Gpt+tDI5kKKAVApASxDsnxBjjuu2Sq0Y2rvUN2KY5oKI32mpPdNYSGRaS5r6s1oxvqtTXylLdVgAJJ+UG0WuWEppdPxT41jTLfEn7CNUEtk5fLsPBDxWusb3PVX1iPKDoy/U76YVSkMVsA7uXGYDx2s6nueCFzwq8mVlNX9utFbSwm3obfEZFMdL8ge1teDWnX87t2wUulgeGg1/SQ2Vm1ArbCwhZAigspvC3Qbl+034ocUH1lZcZnMyhuq8iVjARyp6DTASb9fifEJ5M0IxupFDZhGZILx73G0gIFtaFXsoYWRMMSEX8ovvj9AIxJxHgCLWWcDG18ykIggkS5M7tvbKZENWg/a0RBuxbbGwIKmBaSB0BHHnVu7OiAxwMGm4gNd4Lu7RuMy6B79GqcCpgUzX2cdZ+SK8Yayvi+eoADSi+IkiufckUOh0KReaFFK70Ej6RVWIoqtJPrELRtbQ7ifLlOeJ4qtLyNXyX+sKpy6j8N1PqpfQpUv5heRRZsxIIVkH5ztRNiVmz4vYXbkEALasHSOwUn7VmCYTw9YMPifldI27UeyUUs94KJxtWdQi5VKbpdYCd246F2mnQsWmG6QF/7Bj4VCFc/NLOd5hYSB2NOHlq2I4O9yQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(366004)(39860400002)(136003)(346002)(451199015)(38100700002)(36756003)(86362001)(186003)(2616005)(1076003)(6506007)(107886003)(26005)(6512007)(6486002)(478600001)(6666004)(2906002)(66476007)(5660300002)(8936002)(66556008)(66946007)(4326008)(8676002)(316002)(41300700001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZMowrFr39UlGXUgIinvr1GL7PJoezuSOAA9P2MoA42fGU6oAcriyaQmaqLjpJkYcgkIS7bBfqiEtPm9zLkLBm9b+JcsT3/JPkcXaBzKDBsMX7DVqYZ0OU9zA/nYLK8NZCO16XxxxmCZFjh0smBWwOnIaHCTPsjMGl2I/eevZoNEE/vTQyG/oy7+E7aFVSfPbj4+XKufwdepELG53YPnd6+RqXUCNdWg0kU0+3oADN7aKod6cKDRfvvZOKSdhNfCpDXiF/2rrIWHaGqMJCb38uNTq9Rb2cAClyNhhKSRpkQCvoVKEr6Nf5TEPptXSuUXBEHCoYsksH1Edl9ggbQvtzXDeFouxpTKmbCnTRUp0e/oed8Zt9PcdGfZ31MDRfWZ6MBpNJ5OwX635pFxbQuIEnNfYUJCg6AAZSilyLbsvBoSStp8vidRrHIwfPfIZqzKXlnOzxd0BwX8aeJh/8Z3oPHpsaDCJ4Du7jCPmVx4NNY2+6AxdK410cTiWlCQGN7zKYogD/CU73L9NexKWTB20wMVGW63yCPnDcFIx9JWwojcMF6t2n0untIYrfevOMXo9EfiQx9Qm/antXDD1tQ+06Vo1uWVU9k4B/BZsSTMBSycNbrGuTBqjG88buiG1xnU1tWfhxq0aJcvpFn2bPIJysEuKQ1dd8poDBgkfHa8+ERlR/bUZABITE+uMf6+za9ZyWPOqCEwX4RTHiq+0fQHQr0jmqNQIqYKhB+71XQpLOUx2lB+9IPnTiWApZysC0o+WxxqvCloidz+CJLTh3mIJqXvPmRTE2en0X37pPwrXg7mJ/907LwRUgP2PGf4lCa9oGgEl5rvO0DdeDshdLICty4DNAL8ILPq06pkyoelmmhFTRB737+SrG2G0Xu0TPGFs84gxN6NuRuYeJc8ppl2F9TIiabY6ILiRcu7FbgziuAXNQqXRorSb/Hp7383pTpFeV4vK8s6sfeobDJEJdQJhfTFUBxKNZJ+V4pZg7Hqy4rdwn6cnPrIMS9As+5B6WX/1FMZjh8RYnv3LpoKbgEY6aCwQViN8IhDOSAXZuya1Y6QMX1jlDXL3oHdauKUqTpmKlma9NvsQofQJmMY79Wzh7qHpsa4S59ihY1e+JAdGNNkvcyuF38PUOaQfI8wVQx2S8j4YK/IoX+kimoGYz3Rk9w9vgj8ikN+IAtW614qBSqSQcPfQTxlleNOrEokloJB4vO+w7ZrOM/fNfaC+ZTIh3r+NuR25LQrh4T1983T/lYuaynFFfWCp6r+omenr++CYYq8jP04KyYJ4wnFSIM1QfQ7ZDPMOOGqQIm8L9hz121vKzMEzaVUOWiKR6B29P7iyZ0QNcKBCILJ1kPXd17lR97OdEv5QG8GC7d1qDneR8Px9NyE1zqALMrJGQieOjGQcPEfhABIFknE3H2H9Qqpwwo6hcpuDT7aE/CDHjJpdAd4Vl5QlL9zzn19ucqr4/8tCFtCO5x3VcrGDleuc3/UCcj8B6GUBWferA8O9qQAap3N7rFqOi1dr2o2xOcQ5OaU3Gp7NhY8LIF1oXaX0eT6Uay6R14cBPTysqK0rPebw2u3sMGy1Q16OsTOfmFwuvNym X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23008297-3bee-4687-dcdf-08dad930f0d3 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:05.1701 (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: Op4qwyCW3Na5ptF8QFvK5xJEX3wbb9pFQwLx0GVS++yxlZjiq18Oun7lh53KPLW+HgWJ5qfaEqtqnQubkqAIXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6787 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently, the filter mode (i.e., INCLUDE / EXCLUDE) of MDB entries cannot be set from user space. Instead, it is set by the kernel according to the entry type: (*, G) entries are treated as EXCLUDE and (S, G) entries are treated as INCLUDE. This allows the kernel to derive the entry type from its filter mode. Subsequent patches will allow user space to set the filter mode of (*, G) entries, making the current assumption incorrect. As a preparation, remove the current assumption and instead determine the entry type from its key, which is a more direct way. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index ae7d93c08880..2b6921dbdc02 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -857,17 +857,14 @@ static int br_mdb_add_group(const struct br_mdb_config *cfg, * added to it for proper replication */ if (br_multicast_should_handle_mode(brmctx, group.proto)) { - switch (filter_mode) { - case MCAST_EXCLUDE: - br_multicast_star_g_handle_mode(p, MCAST_EXCLUDE); - break; - case MCAST_INCLUDE: + if (br_multicast_is_star_g(&group)) { + br_multicast_star_g_handle_mode(p, filter_mode); + } else { star_group = p->key.addr; memset(&star_group.src, 0, sizeof(star_group.src)); star_mp = br_mdb_ip_get(br, &star_group); if (star_mp) br_multicast_sg_add_exclude_ports(star_mp, p); - break; } } From patchwork Thu Dec 8 15:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068534 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 610A0C3A5A7 for ; Thu, 8 Dec 2022 15:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229592AbiLHP3R (ORCPT ); Thu, 8 Dec 2022 10:29:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbiLHP3O (ORCPT ); Thu, 8 Dec 2022 10:29:14 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50E575BEB for ; Thu, 8 Dec 2022 07:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=of5s1aXiJqZyChqdSDKcNsEYb0slCa4gjmxGNCXqgfYknp69W+vfwFRB+MigXRW+JbqHO2nl21zFrwwFgrjK8uuxbzdJOx4+HKkrhPHP7heweIv6/gZuiYaONjKOK9pGDMlVo3I+7T9z/EzWRCGlU8MwIg6Vl6tS34x2ImQlIkPPzZEzinM0JUhWtbWYzKVEw8rLEh+5VZAXPXX9I6bZJOH7m/kcahouPRgkzaDov9BnRdDQak+9a1JRDgd1urXz5GLN+j8Yf2SUXUkvyPyRn7ld4J/xJB9lcZHzP09PDhigomYt+1aLG9qmnatMeXWxglpSPD1l1QdH1g4QLfin5g== 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=Vt01ult55jiY/aW4CW7jYZYpC9g6yzzc0A72kco8tHw=; b=HIm6/l678MsTIjb/zVhp9HQI1AI2bA6VwPGn0w157H1a0OLkusR4jhBCTvwMuE3h9h/p9XbS75LZ9fU3C7BA99cmmbN1xkXS1bdfz4H/8qsuMdl9N1ktZa7jcXChWY9/qbypQlz2Wkkpv+FvxyLe1xJUYr8CNiccMJ7UdN+S0Js5avxiGSKzhjBMCMM9ov53AJqMF9l0h3j/Ty/mL+fOcz/FtjFZa5dgRYBhKmnUhMuN3Lr+zQUkanadREdLymddfgVp7RPYmSjpZlyFg1IpjI9bmRmIOu5Okt4vT3ZGSWILte98bFaphjRWX7OKgWxaWsFcB7PtQE4dHC7R67Tocg== 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=Vt01ult55jiY/aW4CW7jYZYpC9g6yzzc0A72kco8tHw=; b=MVqxfc0DHT8doK23yCDKjGl4LVmJM3tm2qp/9xJTaoWWs4x9drPVJB0aJANrvkZHqifkLyvjq2LWHK23IuRRdDnAG50bMeBMNknN/3NaUUDEByQhBebMPjS0UbOUOBNH13iwicKtOZoIJzRS/FuGsCUlSc1+4Cf5Y6ERm5sU/azy2Tkf6k6R11aYJCklsu0gZk9uPGKuFzI0en8XsLdXeYTa9ok6EX5iS1eM/YeNJ0sO8D7rM6+1bDdv78fJ0oGZ0BliQwhgErLJI5RzrQtd5Fu5pblJ4959gdim5s+VpSjVwiXrmHUfakB+Vx9kHAEK5zIzQimPT/V6N+Lz/helMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by PH7PR12MB6787.namprd12.prod.outlook.com (2603:10b6:510:1ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.16; Thu, 8 Dec 2022 15:29:11 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:11 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 02/14] bridge: mcast: Split (*, G) and (S, G) addition into different functions Date: Thu, 8 Dec 2022 17:28:27 +0200 Message-Id: <20221208152839.1016350-3-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0136.eurprd08.prod.outlook.com (2603:10a6:800:d5::14) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH7PR12MB6787:EE_ X-MS-Office365-Filtering-Correlation-Id: 61187ac7-664e-4c62-a8c5-08dad930f46e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZTygKpAyUWkYUPeUc6FGO61T1WO0seS+a81EHQcIkDFwuuKG2zWQh2wExRQ2kuAA6NBl2UJmxAd6I4FIBeTmlNcNeTDPEfa8rYTQQIJgavsPWAwE4fvCfueAliLHnVe7a9dbMwFf7xzNNQuuxaVe8nmT08mw1td6Gz2hBqRcyDiPECyqJHPW2DheDErJRIIhUJBDKzfQniSpPhAfJH9zULmykYmuxyOb0Qj99EngTLhR9JHTOIzEs0KA8k6qG/Hs6zWkEv71YArVjuCkB0DPirQL/saJ827QKi/lblqi/HQs3mSOkxVQaSvXd3zTo008CDLvv0GFKve2A+gnr5NTl+rOIX+kwb7lpaYARDms5uDGaSb/5+rgg9fQAhYvMT/3ul2nwMymwWPaH0/6WcWZQM+/CyJ/i8XRXaYB8lPF8Zs5jGcbNHN37Ks1BDfSd4MoNk2Hpq+qpw/hL2QRJ+mu8wE/t6ll4TxV32sLsmslB+TwAuk1+q9/AJWO7Jok5+dItjK7nE8oHxLpQKuCxfpFcoNBt2NhKLZEbVuO2rGo7HqqTTO35Y2618SdKD1J+xNR2yvsDmmfaoEJNo57bscIPDadfeDcQzpT7yhWGlgF7ULPs7zcKfX2WjHbyl7v1EX/0GHkgFXukEKlysvepF3aw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(366004)(39860400002)(136003)(346002)(451199015)(38100700002)(36756003)(86362001)(186003)(2616005)(1076003)(6506007)(107886003)(26005)(6512007)(6486002)(478600001)(6666004)(2906002)(66476007)(5660300002)(8936002)(66556008)(66946007)(4326008)(8676002)(316002)(41300700001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ppqMZ5J3bW/LM1/3uMDS8s8FYKCHvQwY1wzJyItL1aeuj3sRXpTp5SOFKLB56fskT5Csf4NOM5xL1fjAvbRFBqcILMM5KSnKAObRqUQ1wusDJ1LZaGa0ZJWze6fKk+7KRyWOjCQ/k0H6In5E8dsdlJRnKTMr0z54FeiOm4zhXjCXHORQglCYKNH4F/acsEvBaM1h+SnHCnKX8OK95OZsUYIEIl0ZYbeA9dcPUNq9Vyo5/zi8Gwty/vnWBx5kwAQ4kzavg/zvbmzBp0j6Sf88/Dwc7pDPyzukqrsvCxkn+nKkibMLYgc4nPjxk7Dd2vu15/RDe6Sdm8CDPD6N5GzM6nNN2IKXOnN45omom4QlS57wTE4LfNxKmOM/CKZckPGAkcJphlyymb1OKwSsLLJjkWq62d4r4boMQW3u5Mfn15Ax2J0QptodBB55OI81f9aW4Pp0KdB+wapLmJqiaA0fE/5wd8bKewDMVYEF+N+czHxSwLjfPrnJjNKF4j4RB6ZjM4ypYJiDzecHCfSDrW+jjc9xmO+PAAycW72QOoE7siXhRwyNOGAdkoGijDoW6a65TAQX8iT8XhJPDTVP+40QYHKIycDit9gCbnUCiTI3uPvcDUZeFUClBmU0Eq+7u36DM0oqkI/LSWH/7KWoAPn9LgAL07xTapAVYZuEiZeR9iUngCnqGi4czHtJDzWPGov9P6xymGAKogDsDyvaGIs6lJhIFYCBohNkruZbd39RFNGMWSkEioy7U7vsaMbEU/anaIOeJw0GGwfCuudn6YXM/cTpZ3XShCCkpspaAVj5zQ43fg4OjWC7LwpQsetwB6YilPg+dgH6ExC+QHgqY56nS7H3Cnv4rR7Zf1f9JTHdqvmdRRSnn08hWmqgXTZquMpWTwwZ+2NC0fDB0HaK1qA9GoZtB4+EpWws2GT+4ccZg4HPMr8AFo8nLLHA+9qbVfzfDg92nndYWuaIdqiLyiTcCVxSGufr+13G7c89mZA5+fbxA2HqcEOdDOab29ns7PBdvGXvZCYB7D87Ven4KbR/7kYu3ZsrXgzsDrtjXTIHMo1w40PIz5jQijdce556s1DU0+wOdvVQdl8IkrMb1bEUa395AeREc5HZswKNwPyN8LhzRCuXXG3r64qs1brpSGAK1G+01s49GtSF4/zxbMWX8fxo3JxnEbs/lM+e+CEhJUikKhOfU2P9nApWiqdib5yz6s6HDic85J/hPjQ197HS41CF0F2zfhvlLLEflsMcl+FTtAmnvlgQcdWOkGt1k7XvNf8rpn8qN34r9fjsQeP8vLbJ3pTw+PtpPUq5Oz9hlManojBid/IBsFiQCQ8VaMyRbH5TPN06IkRcLwFUAVRc3KFeMQrbdedSIgspq79OAqPMDpQJ6DLdc8HrKxCh5XRiVTaojUswVaEQswUxbIrRV7nwP5OhSsON0d2JuNmT6ZhuDrTE2y0HwiB4swfKCYWfg3PsP+SMpHPsULabiFeXI16MJ0qT+I/sGb+j+NkQiVdfBsEYgPLhS4kn5JelIjYLtfITBHifFlLGJa4OUdAiinXA9KdKNZ18OsLvj03PgroHNYaxYKhLEnAOjxFNgxBp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61187ac7-664e-4c62-a8c5-08dad930f46e X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:11.1084 (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: /hGGIehjcAXn4Fr2znU6PCOuJTsLvyTjBFuFXLApjSnIgPGaEZLrjyowfqcs9GuRe4wC33SG/gbGpoEvFsChfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6787 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When the bridge is using IGMP version 3 or MLD version 2, it handles the addition of (*, G) and (S, G) entries differently. When a new (S, G) port group entry is added, all the (*, G) EXCLUDE ports need to be added to the port group of the new entry. Similarly, when a new (*, G) EXCLUDE port group entry is added, the port needs to be added to the port group of all the matching (S, G) entries. Subsequent patches will create more differences between both entry types. Namely, filter mode and source list can only be specified for (*, G) entries. Given the current and future differences between both entry types, handle the addition of each entry type in a different function, thereby avoiding the creation of one complex function. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 145 +++++++++++++++++++++++++++++--------------- 1 file changed, 96 insertions(+), 49 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 2b6921dbdc02..e3bd2122d559 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -786,21 +786,107 @@ __br_mdb_choose_context(struct net_bridge *br, return brmctx; } +static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, + struct net_bridge_mdb_entry *mp, + struct net_bridge_mcast *brmctx, + unsigned char flags, + struct netlink_ext_ack *extack) +{ + struct net_bridge_port_group __rcu **pp; + struct net_bridge_port_group *p; + unsigned long now = jiffies; + + for (pp = &mp->ports; + (p = mlock_dereference(*pp, cfg->br)) != NULL; + pp = &p->next) { + if (p->key.port == cfg->p) { + NL_SET_ERR_MSG_MOD(extack, "(S, G) group is already joined by port"); + return -EEXIST; + } + if ((unsigned long)p->key.port < (unsigned long)cfg->p) + break; + } + + p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, + MCAST_INCLUDE, RTPROT_STATIC); + if (unlikely(!p)) { + NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (S, G) port group"); + return -ENOMEM; + } + rcu_assign_pointer(*pp, p); + if (!(flags & MDB_PG_FLAGS_PERMANENT)) + mod_timer(&p->timer, + now + brmctx->multicast_membership_interval); + br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); + + /* All of (*, G) EXCLUDE ports need to be added to the new (S, G) for + * proper replication. + */ + if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) { + struct net_bridge_mdb_entry *star_mp; + struct br_ip star_group; + + star_group = p->key.addr; + memset(&star_group.src, 0, sizeof(star_group.src)); + star_mp = br_mdb_ip_get(cfg->br, &star_group); + if (star_mp) + br_multicast_sg_add_exclude_ports(star_mp, p); + } + + return 0; +} + +static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, + struct net_bridge_mdb_entry *mp, + struct net_bridge_mcast *brmctx, + unsigned char flags, + struct netlink_ext_ack *extack) +{ + struct net_bridge_port_group __rcu **pp; + struct net_bridge_port_group *p; + unsigned long now = jiffies; + + for (pp = &mp->ports; + (p = mlock_dereference(*pp, cfg->br)) != NULL; + pp = &p->next) { + if (p->key.port == cfg->p) { + NL_SET_ERR_MSG_MOD(extack, "(*, G) group is already joined by port"); + return -EEXIST; + } + if ((unsigned long)p->key.port < (unsigned long)cfg->p) + break; + } + + p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, + MCAST_EXCLUDE, RTPROT_STATIC); + if (unlikely(!p)) { + NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (*, G) port group"); + return -ENOMEM; + } + rcu_assign_pointer(*pp, p); + if (!(flags & MDB_PG_FLAGS_PERMANENT)) + mod_timer(&p->timer, + now + brmctx->multicast_membership_interval); + br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); + /* If we are adding a new EXCLUDE port group (*, G), it needs to be + * also added to all (S, G) entries for proper replication. + */ + if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) + br_multicast_star_g_handle_mode(p, MCAST_EXCLUDE); + + return 0; +} + static int br_mdb_add_group(const struct br_mdb_config *cfg, struct netlink_ext_ack *extack) { - struct net_bridge_mdb_entry *mp, *star_mp; - struct net_bridge_port_group __rcu **pp; struct br_mdb_entry *entry = cfg->entry; struct net_bridge_port *port = cfg->p; + struct net_bridge_mdb_entry *mp; struct net_bridge *br = cfg->br; - struct net_bridge_port_group *p; struct net_bridge_mcast *brmctx; struct br_ip group = cfg->group; - unsigned long now = jiffies; unsigned char flags = 0; - struct br_ip star_group; - u8 filter_mode; brmctx = __br_mdb_choose_context(br, entry, extack); if (!brmctx) @@ -823,52 +909,13 @@ static int br_mdb_add_group(const struct br_mdb_config *cfg, return 0; } - for (pp = &mp->ports; - (p = mlock_dereference(*pp, br)) != NULL; - pp = &p->next) { - if (p->key.port == port) { - NL_SET_ERR_MSG_MOD(extack, "Group is already joined by port"); - return -EEXIST; - } - if ((unsigned long)p->key.port < (unsigned long)port) - break; - } - - filter_mode = br_multicast_is_star_g(&group) ? MCAST_EXCLUDE : - MCAST_INCLUDE; - if (entry->state == MDB_PERMANENT) flags |= MDB_PG_FLAGS_PERMANENT; - p = br_multicast_new_port_group(port, &group, *pp, flags, NULL, - filter_mode, RTPROT_STATIC); - if (unlikely(!p)) { - NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new port group"); - return -ENOMEM; - } - rcu_assign_pointer(*pp, p); - if (entry->state == MDB_TEMPORARY) - mod_timer(&p->timer, - now + brmctx->multicast_membership_interval); - br_mdb_notify(br->dev, mp, p, RTM_NEWMDB); - /* if we are adding a new EXCLUDE port group (*,G) it needs to be also - * added to all S,G entries for proper replication, if we are adding - * a new INCLUDE port (S,G) then all of *,G EXCLUDE ports need to be - * added to it for proper replication - */ - if (br_multicast_should_handle_mode(brmctx, group.proto)) { - if (br_multicast_is_star_g(&group)) { - br_multicast_star_g_handle_mode(p, filter_mode); - } else { - star_group = p->key.addr; - memset(&star_group.src, 0, sizeof(star_group.src)); - star_mp = br_mdb_ip_get(br, &star_group); - if (star_mp) - br_multicast_sg_add_exclude_ports(star_mp, p); - } - } - - return 0; + if (br_multicast_is_star_g(&group)) + return br_mdb_add_group_star_g(cfg, mp, brmctx, flags, extack); + else + return br_mdb_add_group_sg(cfg, mp, brmctx, flags, extack); } static int __br_mdb_add(const struct br_mdb_config *cfg, From patchwork Thu Dec 8 15:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068535 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0D6CC3A5A7 for ; Thu, 8 Dec 2022 15:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiLHP3c (ORCPT ); Thu, 8 Dec 2022 10:29:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiLHP3V (ORCPT ); Thu, 8 Dec 2022 10:29:21 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2058.outbound.protection.outlook.com [40.107.101.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041F075BEA for ; Thu, 8 Dec 2022 07:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oAOoGNpVu6G8xFroyJ7atX2IOdih+2O/gvl2JAdLpUtg/8cgCcWey6Cahope+cAjt7HdBiBDaDaZCKTKr6IbJmsX++FNgOVaKCYs8pFojFta3rck1Luc/blh91kgw1viOha2JOkg0L37T2gYcM1CgeeEWmZJifQHv4dsKnxclMGfZ55lWy7IgVvC7PxymL2sZNmkXVSDRLo505RlKMUMlKYZWQ2C0wj/J4VDYQhN4nuntkC3QAUhhqIzqz82dHKun90LPZNR6WdAFJkVAT/hkSVbUKN1M431g/M0mFPwFOMWlcxjgg/0g8IoeIQHgr7h0UNkfz8/LjwelML3/9yAvA== 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=01Xwoh/eJJghknkS0pyoMisV7jmbkbgBWSMvMVm8e0E=; b=bP96eXdQD0JJFMdKGZlbnHs8hZvhPxmoqsPZDBhtQCypdg7Cg1zecMaqpcuGuQWBaOxTDUl+BclX3tbvHJ/98j2u+u62xBuvAeUGPqTvXCEZnzK0cJlitczjNLmpuKt70wct2QdXDsKvITGd/veKnMQQrg0IY+AOboOTERIydsfFJDh3JK8YehZ9KUH50B/b4F7Mi3I+7LRSIRHHdG+y2Q2QT5Q23dmc3pm0B/VuquWRwZ17iBTon1F1BOT3O2+Tq9VmY2g592O2g3QDUVD3o75b6IH3WcKr2d059R7xZIYR05/NpTrXqszkPTc6hKvaCxUPXRZ8FFB9n4LHNLxKLQ== 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=01Xwoh/eJJghknkS0pyoMisV7jmbkbgBWSMvMVm8e0E=; b=alwPXdr1dOHrZh7pZ1d04Oe5NW503/xK4ZxAMLN7Zr2ilj+xOuhgT/l6nyBoLERjaTUjzM7XARILqhwxQWlxw8T9C4KtdCxSij/+N4f1QXh3D5g7aIXWj5HVVB+Z+YUIcidmI8amq7ktnrZsaYd+AKu9ZW4osv/2WVuTuZNXGVcjfQNdz4o3TQt/9urGkZjGyMFephWiR0wcZ2U4iGlkyhMzY6DgKSy2HapS+NStzuTbbI2kpi3lN7jR3QyG8KGEpNXN59NUlGGXYo7Z05SXxwgW+9DtauziGx5lwvZMjmLU4VTIxdKDjL0Gs7ZbknGKyKMvVfBccZWGfNxP25AUuA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:16 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:16 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 03/14] bridge: mcast: Place netlink policy before validation functions Date: Thu, 8 Dec 2022 17:28:28 +0200 Message-Id: <20221208152839.1016350-4-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0136.eurprd08.prod.outlook.com (2603:10a6:800:d5::14) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: dd23a24e-4190-43bc-a739-08dad930f786 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rtIylok8ZvoR5/SxyCSDCV1xym7Tn+wKzQ4g+zyagm2O+GisnBOlJGit688VCH3qn2ZK03Cf2hkFmpKjkARM3snCbUTlJCzdCoAVIDIikLJ/C1kNWjur2/Cv9Iksbwbi9uFgHuqIdR5DDgnQVGFt0QMxOTMQQcdWidRQ/gZrfCAegL7xZEzPyv5+5yCgjor3fJqAe/YLH7mVqcRSLPLM2ekifAVVHBaMyV10toQMjFIDIcsCDoigJoAbnfahLeNVlI7IqAZsm/WhfwtOQYx16W+t+Zv6xqEZvV5PwWViF6uPslaiKccFhxY52Fqss6KfGACj+mKOl49BinAjn1siQI65J7aHJ/LP8/g+df9TaHxz3SZ1P5Wde2tNFgwCOOIKgTwq9fVeCYLSaw9zp7yHi50qEee0GIk4lYMy/XYB5qNuh4GV61HnH790UXBjaBjCJFo1mLhhXVsEbuIVe275qbWP5JNJj6QzYNeA4W6WGlMkPh004ax0xo7v7CKJxSOC3XwpESigwlVSlM/QYVsJBfNxcz0D4xg/kUgHA8qErHETvpsxeLzutRL8I8BEZP2gvQQc/jLBu9ucb3FyLrbesnFcGkxG3BpyHKxHPBkXc7ixkT0tF2nXp9yXRAGIk2smcS5ke2fQbiLIPokkegynPA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(6666004)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VHa0yGDa0x0tQxKsPs4Q5WDc8ZTFk7FxcA0o3Dc+mHSKcW+2hEB7GDr7nm/KtdM0ChwyAKWiMB4bwMPxz5w8zpbMq8Uygjd116qYNlneXEO4ZK9ADmb/EvMYBVa6PLVNGAhDNLFD3wpSiHzWVEqaSF6McMc+cHY5R6qwUZYJd+La3ej+jzYWZ7c/b7IKKWNup67DBHDCakg0udl6I1DsF2HfIbiEtZ4dtvrg86muWod1aWW9qZiSLW1XiaYrVhlF4BFZco1Ao+duPniMF4t7zi6Vr4MaxxT7O8dKlQRO6VOumT2FwPAD7ChRPHScCa/tfopfzldbGy2chaVEAVJccLtVWplo/NF6lCtSjQBA2w6xP8c/zusKFx7cb5JajEB6oOimPutB+Uo/3NQbW2BAi25c9Aah5LFcEFb5l5GQsX4TaMgDsLIZ0AGjpKLV5WnsGlDpZjfEvw5JHlzgPhLhhC7WCDNOmNEANhWh31uTpEf6chkRjbt5M7L5UAERutBkg7G6Rydww7AoL118+ZR8HF500TQkQu6TxyrLX5NJJICLiQyzoeinFEELAduQU2HB9pVRFtlPlUD58oNh+fHXIuKIaQslYPUe/yj7rwfB+ugLCD6pyhotus99sb7tCQMjI4MnZOtG/A7zUGqBV8Al3rqLLEnx9U1zujO8Oep6cTV3+2NDD3NJeuJvsf/CWXN7s8iBdFYS11q92oPCeEGgdf3GeeSrEHqszRe9cGNGIXvZ/eb2m1GSHK2Z/HYQ5Cl0RtMmpkTRjOnBGBs1/fgrSj11rgB3dJzUIyOFYXpdXIk2o3K88gLticPvCkqvRtQaGbzeqtvxjw1KtWGUnONJpTXb9/wPHAbJlsm3B+y6DbR7sfK6MJwivKVgPkDqM2IrdA1exyueCRM+iJbkXBm6awmUiQlvAwXGoliIvPARsS+k6MCWjJeIDjXN6eS2qYCdxSga4eu592ZyhUgponejnDiD/0Mt71qFnVDlz1FOMmEONRpTue7cFkhAG/wExjGzAqw1k7/2etKt9s2nSdGrpD1vO5x1P06MkYAY4Knkw34BXCwRMRToQiS6ZCfIYRmdrYuEoi7TxCW3AIj82YvxO/yfQcwne47bPlR2n4lXE/3f3P8paNJ3G6J2L5QFvtuT7TAsWmk4KghuUV4R/s0pUWcRd/tZHrIDzqu6gzuZ3yVOPC7t8p3yudgQ+ru46WrC3vcy4iWKwZQAufDezbX6iJSdOiXLdp1uyD2s8osQ5BP+JYt9jFJ18cvfytK3hCjbrBS5R1HgjfUszP1FfZK7IsrimFofvR+ijg2uN0eoGfSWhruOJudz5v2nAmOricP4XoLwRsoh/rqINLqrCCQzM/OQg9ttmezXpkwrTJlkfU0dV7vxW8dPBX/SEo8/VgKipQscdd2tEeyAgC6dT9z/5Bby7nkjyzjipRBKJH+AcwcJYYFg6KgYEHdHqR0ChC/VfzlfUN82jJIieLL/eAyWTCWUqLRhHACuve4qV+m3DEGoUQaexgx5krVrBrxKFPoB+WWhEPAC375r7UX+1/N0Wy3qHKmhtQmyIWf2Fivk58+rwhZIgMC9T5tU0v2c/TAE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd23a24e-4190-43bc-a739-08dad930f786 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:16.4706 (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: JobeUu7cUP9cskOGTbvgQTYdBZ42oCyxlfev8PXOtzyjxEbAfOp6WkjrCUau3hoTs0nsETh0yjq8QvJg3rUJXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Subsequent patches are going to add additional validation functions and netlink policies. Some of these functions will need to perform parsing using nla_parse_nested() and the new policies. In order to keep all the policies next to each other, move the current policy to before the validation functions. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index e3bd2122d559..fcdd464cf997 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -663,6 +663,12 @@ void br_rtr_notify(struct net_device *dev, struct net_bridge_mcast_port *pmctx, rtnl_set_sk_err(net, RTNLGRP_MDB, err); } +static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = { + [MDBE_ATTR_SOURCE] = NLA_POLICY_RANGE(NLA_BINARY, + sizeof(struct in_addr), + sizeof(struct in6_addr)), +}; + static bool is_valid_mdb_entry(struct br_mdb_entry *entry, struct netlink_ext_ack *extack) { @@ -748,12 +754,6 @@ static bool is_valid_mdb_source(struct nlattr *attr, __be16 proto, return true; } -static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = { - [MDBE_ATTR_SOURCE] = NLA_POLICY_RANGE(NLA_BINARY, - sizeof(struct in_addr), - sizeof(struct in6_addr)), -}; - static struct net_bridge_mcast * __br_mdb_choose_context(struct net_bridge *br, const struct br_mdb_entry *entry, From patchwork Thu Dec 8 15:28:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068536 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F30B2C4332F for ; Thu, 8 Dec 2022 15:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbiLHP3e (ORCPT ); Thu, 8 Dec 2022 10:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbiLHP3a (ORCPT ); Thu, 8 Dec 2022 10:29:30 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2088.outbound.protection.outlook.com [40.107.101.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3E0178687 for ; Thu, 8 Dec 2022 07:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gvSLn4xYkT/twtGRQJPSFTPJdUB/x4RL9muoTqhHDa1NnY19oALGiYlB9pOuG8LvBXUR2tBesHc6qutR28pDGAxu+bz0TY+2RvjSVoCziA3XkKkXPWUoOK8jl2eA/t4QIOPMc18XF3OSbqUCdCq1GmQO74obGS9j2k8jqjrzOBoOQQ7K0xaWmwNtTVzY/Cp9NUgdJcqj294rIqWk7iyIDlZ66sY/zsGUVs9y7BbpN85Oqd57vIYW5gDkrU7fSJeMeiRQ70d85kp8nGxjZaqXWCk6uURON/YXGKlh/JNdBKCBclyLHp1RiLkapvPr3z6nOCZrh7eLIUb9NS/z0fgEdA== 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=wOZExATRF4+USKA0DlWjLy2NSrwE0vQTjwz2rrwFRqo=; b=cXObwVTg/MS8t0BO6bv4aUz8dklFhAN+cBuvcxcNGImSgjIEJhUN82YEE3nN17ERxGxt4LZx5yp5zCeKA9FH/FxupwRT/Ynvh2YtAlJs4GkMlpM3HZuU5n1pjPSkZxQsL26a8QdIVdHloU0kbqlDvjlkTR659dnv7lWFkd64dH/p46yvrP0ktfeLKr/s+2K0+Af35bK+uU1KAeaoyMWspiFnczJVlzo72GLHkXlM1h8lbr1Uy2K0InSMZU+xUQNwtjlSI9Ak2F+ak2CylFgUEkcH0GnAdwRHA+zLyxY84CXT3fxr+29z9UDSQbC3HWXnPUozzvaiE/0BJey5ivdA3w== 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=wOZExATRF4+USKA0DlWjLy2NSrwE0vQTjwz2rrwFRqo=; b=WbO0U13G/2/vLLg73TV+UaIUjCS+i0/SeiyIOUN6CuLq6E437oCk1Pc1gZAE4D3N44Wf4vG6gkVKsR+YhcFdHqO2KRpjGfEcm4U2rZAHozgzwE2gYskzHXV+buSGkvBDdnT1xjSh1YNZaEExHoGRMfJ7XsE5HgVdip0Qbn9YHw3UfhPlVh6UlnIxH7bcPwMp24xR6hyccguL+87kjXbfkSZvxJhebhfKu4dPESBMo49/xtSb1f6lrouPISwYWsq+XNCIp5vf8S8aZRbmoTa1SnHWlRnowWdQyhP9ckrW0cxLY8O2QiB/H/jfLCAXphXk7JjwqiwxreyffAkqmVHJqA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:23 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:23 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 04/14] bridge: mcast: Add a centralized error path Date: Thu, 8 Dec 2022 17:28:29 +0200 Message-Id: <20221208152839.1016350-5-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0199.eurprd08.prod.outlook.com (2603:10a6:800:d2::29) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: 430b382f-7c60-46f0-f5b3-08dad930fbb7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dhMrLCjpfRDSVcbyv5h0mcqlO2+57wkUQoBJlpZX1LsKjcCvdb34quGafQ8eGO9m8mLnU8vnGV0aGUPVKvE9NtdiZ6XpjyKRlxazfojnBBdalKour7lLhkeNcfPoUfwl/+QLKBEqIwdJI1msVNLLGJjjQFIk4Ba6ujufShjtw3h7EmCgbqr2cLojdFbnNBjOeeEA2GcSN3Fxl7H9yTy589FfDaWCTZgakbyp8tBMNEjFYgtIrP+LLURMdOaPZREUnFqa8Ph/5RWv7/zTtRKi3SYzBQhW5GVdmucFfugyee9kCmtjHB/4AtzPr8CAAG45gDoJzeLzpCyeS2vlA56R0i7WPJ8h9UaZtoN5TcfGyHHHXJvsualk+lF8Lf2gNYAqJs3AyBlMzpin9loIaGu1+OFTjbW+Wc293xsnAJg9JIY5DtCKZJLY6Ade1evmpyu0mBQ1ag4KlnKBJWcKa/LOOabCHcvmppMR3JLxtColSJOU5K8T/ArotyBpBx1iKbO/FRezFnjNf408wTkEFkCCO2CT8WMVNEuhxp+1VKofm9PFiWJGCeS09ZArIFMj+RY6pk+ay7PcvGgT2Z7Xx7rwc1DFczSIc2/hcS8zZs24YsOz2aOMMuju3J1zxR9NJ7XARZkjFeIBnQLwMcX0SGQFBg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GnsTj4YRPaWePZqzMVv0KCE4F9OaSDzQa6zDqOmlwgxB/r3fIFcA/YoGqSo/UO6Q4ecBKxsI6ywECIOQT389c1bUUH/F9GcpXhUsk8RcRCkggHxRuWRmcf0fBpk01+7sUdbwI9sJdSnAHEaJvR50N2M8z26NTA5hI6FHh3TPttssrK2kMKCIeVSrEWFtMNR68VQZfyX9sLfJy5ujs7VwxqPkb2BwNfQt9QEJuHq3qwEwunAia4DhPSUr9jIdU1wnxLSxxt58X1E7wcBYAUsCJFusdxOA2lze7fhzIUU5UxAvp6IiE6kAGysbb8JaSGXPB9CV3Wz7llBq1UoZzdwEfN117RUwPigxl5lvNwSU0H4/w6I3LCcBZX8DxjqjeBnfZg3z+h0H8tHzSTRbq3aqfreChvMGExt+AKGTZZaNF/aBYpnOGAwXi2WisW15GkLiOu01Uoj0ySauu0IUpPQIwSJ64932rmQ0XpsLNE5sVD6DX258KHNtbwmh4qJSXjwbjItsnj6JKFKuX1ChnTKk9S4U9GgRB/qnN2khACDLSsToqhRWEyiKXuvTXaVk/S/hIAekFZVtqunwx9tSXm313gXzPYgA1ez+XtF4ea/7LvM6w5rIUXwt0b/Wi/bNoqEZQEvf41XfvlnBv0L16ns5FIW4h9FOLfitBU26SrQO02tn96EhiWxzEpu+D0Ng7656jylS1L4+KZl8+jfLtO9T38wwLLpUdD1GU2Kxfv0YVnZz9cVdqkL0MazwKsSqzwEhadBRtzAwcaGzaYsFZNoMF7pxNBAe2sM9ERtX/Cr7Dyesak2ecpakltGkO4FJr1Zl4tWL6a7QSf7s+J5+wG8/zQT9CK6mNVQrbnkFf7UkqSyeraEWrTMLWajuBZ28fuMEfbNkab6L6nA4dDVVVVylxqXPAKG30R3HzsIbknh0XzYWTG3o/GiFCKfSYALRmY2rR3DaeVUd77Q2I8uXZ/ytowfTN14O2qY2UzFLKQDwxdJJLKDH0aZtYY27WfQLa3hm5VD6YTZBvzC1GHGW22x6NQi0wgoktUIs0qVzIu4mx4GRYKrnoFMesE2vhbr+gyldhe1767mEf+Tx20/LqdvDxi8Q0Mc5v4Xhxw65L7dLEc71Z0ShA/F2OsUAk8MhK2uXE/7tHJ791xO0iUge+IDH0Tapwlh4reo1aRSjTI/DuQHF9ci9tuJNh27I7nVLhw28qJoeA04EtVOztCavc3Wj2koO2OTm/EfOFjzYgHgivFXhqRWFzM8XDF9RkUGB1IKKGUAU3+xLjgJ13y5FDky+VFjeKgQsl+iAphpDeY4ZSRwXpn6gSmLOZdKN7Zeen7TiACuUsazMIuHAptUpFQZ1Hxg0govB3KEOYkP+G1iOhWfnOrsQGekgi4/AiJ2/8LoBuN3s7InTurX9qI2JOs6YBW6VhDg8PTOGywdk+Jpgwd2MBvkkaq+NE+Hc/b1QsspokZKaG5FX0e0bBzp7hmFKMjbnmqvRPqjfBY3G9mVrqLMSiljEOv1UwqJAbkKYxA+PQsuthZYUnfezi79WS065EB8kIT42ELwLp7hGQrivKQsBsR7nuyHb8UiHv4e069rD X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 430b382f-7c60-46f0-f5b3-08dad930fbb7 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:23.3640 (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: Y7F5hv2APn92LPgBeqJfFLdcoWhKzcmCgOytRSGSuAiYqAjbEbUSsIY8psDm+aWpGHjKbP9lFFLD/23rq4WjSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Subsequent patches will add memory allocations in br_mdb_config_init() as the MDB configuration structure will include a linked list of source entries. This memory will need to be freed regardless if br_mdb_add() succeeded or failed. As a preparation for this change, add a centralized error path where the memory will be freed. Note that br_mdb_del() already has one error path and therefore does not require any changes. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index fcdd464cf997..95780652cdbf 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -1053,28 +1053,29 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, if (err) return err; + err = -EINVAL; /* host join errors which can happen before creating the group */ if (!cfg.p && !br_group_is_l2(&cfg.group)) { /* don't allow any flags for host-joined IP groups */ if (cfg.entry->state) { NL_SET_ERR_MSG_MOD(extack, "Flags are not allowed for host groups"); - return -EINVAL; + goto out; } if (!br_multicast_is_star_g(&cfg.group)) { NL_SET_ERR_MSG_MOD(extack, "Groups with sources cannot be manually host joined"); - return -EINVAL; + goto out; } } if (br_group_is_l2(&cfg.group) && cfg.entry->state != MDB_PERMANENT) { NL_SET_ERR_MSG_MOD(extack, "Only permanent L2 entries allowed"); - return -EINVAL; + goto out; } if (cfg.p) { if (cfg.p->state == BR_STATE_DISABLED && cfg.entry->state != MDB_PERMANENT) { NL_SET_ERR_MSG_MOD(extack, "Port is in disabled state and entry is not permanent"); - return -EINVAL; + goto out; } vg = nbp_vlan_group(cfg.p); } else { @@ -1096,6 +1097,7 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, err = __br_mdb_add(&cfg, extack); } +out: return err; } From patchwork Thu Dec 8 15:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068537 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3FD6C3A5A7 for ; Thu, 8 Dec 2022 15:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbiLHP3j (ORCPT ); Thu, 8 Dec 2022 10:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiLHP3c (ORCPT ); Thu, 8 Dec 2022 10:29:32 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2046.outbound.protection.outlook.com [40.107.101.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0CD71256 for ; Thu, 8 Dec 2022 07:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FdwvGCNOMw3bpwHv6DQ8DjD/mv/zMATnKUpZZgo52hb027olJ8eEPFVEbBThNGnJMzW2t/pJeQ2yjkouF3zmW+CH2HNjZaEcyyg2uv02Vn2PNmrxrBcsXg9nAC7M9MldUVVt22sugHoAndYrG52YM+kb1gN2cpR+fNf3978C9e9ClXo7dXg8zKwX9po+Y7pMp5mupH8nSTQR0KxKEGagS31Lt8i9ON7uXpFboFdGBEN4NozzuwDsiUg2idJgmCRqc62pHWjikh96CGcgOLCXUqdByykF+X9hQNRdpxLQi9d7TkjTScBTf3y/CUPVtvjeScCUhn26TnJMyGCkALEUyA== 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=LXjyfGzARL5VUfAnf+q3Hfg+kM6Y8m4Y6sTv0rjK888=; b=cDCiEjgdCE2XV7Cq3sefTTU3A174E/ZYYz/D7r/stJ8bv3m3wTYcLfu0hpxrS9qtqJeSibFhc4bdN9xmQfARN8FQR2JZGbdYid5HRGpUW4la5802hCKjZiGJCF1y+N+8/XK/EKNOSnRFWOHRibubWCt90TKeD8o+Ts8sDC+UTBAwt8QGtBnT78bdYctS04eciPfxJRceAcQqkDxauo8VHOYmNZAYPBNT5V4Hh8X//+tmwuOgzE9URkDbWEkkVNJ0Lj78GBdD4dPDfKYTb/0hQwz0ansepFDVkO86ud9eKX4vuKdXVpNR+EnZxzglfFPP3NIcV0DtqwVUGlzH/huyIA== 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=LXjyfGzARL5VUfAnf+q3Hfg+kM6Y8m4Y6sTv0rjK888=; b=VBVGzCy7BIA7jOUps4YQ4XS65nr+0BX8NE5A44SUgtF0UWm2Ru7oguDEt9UArZ8MCnos7s86eLXH+kPvYH9E1CcCTPaIFtMwNTaIF4KEiQmpNb7QlBfJ+yzwUM6/LpXUu7iUh8dHnnucAPn84LMUzhi8loT2jNSwoqwQ4CJp+ZEwVzKqm1twVPmKEKYYm6LHZRijR0z8z8KTutLgM8ESqI/hqiJNcbdHl21kZDsNA0IKXAQ4yoHA/xRivWkYSzPIbyBlNWefUj9C3JUNqOxfGHKA1f/zJIM0Xkhxr+JYHNOi2SGsf7K6ZoH//tN8S6j0Txt6fSl2u3tCnZCWkr4TMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:30 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:30 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 05/14] bridge: mcast: Expose br_multicast_new_group_src() Date: Thu, 8 Dec 2022 17:28:30 +0200 Message-Id: <20221208152839.1016350-6-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0181.eurprd08.prod.outlook.com (2603:10a6:800:d2::11) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bf8f0e1-b179-4f11-f69d-08dad930ffef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KmnwTEpBiCkbkvJ8JRgua4ngbv4S8YnskuAYefrMxo4c4ocVQ0R1fl4RSzuD7bqDZj3RRifRCtt7rPkpZefu588Nd2ErQmG04eHlVRtVNloTClnnn4WqCdyjA3iaZI0pbyZ0UjCKP2UqV9OaCurerduCXYG5u4cgt8XW+8HLsZ5dP6Y75A5bMiIcufjstxsiOplXHo2hCDdZbJuJM5GGEELlMidR4T9ziaEUk26AA4Umxha8qRqvGfv60tEMyuhHNN6wJwdHBbRXQbSFINwqRBH+3OF9XoXXe7jGVF8N65FL2BVapLOXG7U7SjoLFusgomcLI1Cdjikhqd02xgg7FrZKEtSU06LYFIuVQJ14FmltbBVb5fVVMHObr6WZjqNVp37SwkDD8IB72vk9vCvIQgViUEUoap3yu2y6yE8yGIKh3MF+S1aHpbBYWsJs1EpbuE04UHcONbzh6mNBivynLP0jsBnX9uTEXuqFwHxuyCEf0Lch1EF9ip0tABZ+/RK8Oy15gz1C4v1aN2YQ3GQogrf0fZxmGAjCppD4oM21N9TdwdT1Kcl52BtXVHQzYsQTh1aIn8iaI5UF/y6+7RWwwMVURVZFjPamHYGQkF71NVo1sLEqk5ce/et/7XSzxKCb66n87AK61hJp9vLj4M1F9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AyGP0XyWyM4G6nq936jDMGYXQUnEWZPZBW0DRXcbB55TNBiO6ZG9kMDDE5mjeYPJ+g210mbz3EBLmwk8vAJnSdLjLoner2nyxxsFwQv3sp6P2zfwzBZGOb0gtCIWPn7/AMG48xgHIgYxMAf9C6CLWQaEjwcE5Nw6B5vvZYUxCjYhW8392z697MqW0NQswZsiaMA9RCtYRbaNlzdlJ6kpKFbN70IG7OIUr/Jhl7k1t354JkNSwYi6DUGigG9utoAYFb/38RlHyZuSEyAdCMOddND8XgI6Rs9T2CGeoC8NDdNWmtiamPQv3V8Sl3k5BW58qTmZuHxfOwg5UHMcJ/4qn4l11RA6PFX1rWgM/SyG46GOr+P+yuQ5JUXYlBUKwo/tSCh+Pccg9e7NbUWi6ke17RFppzsuC98lpfuWIrDVznfcX38jQgWP/sr2Ma32u/UuyZ+bRS3tWvEjL62We5pVmtxPWaCL+5YzBPc6OkIL2KLLBWNeQE4Pave/JSwaRUhO/dV+WkbQAW17es5+Rvcbsi3627H0g+b6l4p3989H6ikSmCTSKDCs812guD1S03J4MURxhwL9U6PICx+dMrjWC/TafvZ6EJN8dqU1LbecMhiTXEbFbuTTboSHL3jqPs/KP0m4d61/JMxQCeg+H4ikXztSoDBunLWy7HQ4JV2hvBIRoDuCWWukWQsTjymkJn/yI7vcsihoUwcwUoZf/Pz0Y4QUJdh3PA3APVOdt0IR/zDQDzcNItaAzwamu76FaDYw3LkoxR4zYZerYAycgbtdm0Hr3mXCfchcwzLeLNIQe+BP5USKZ4TEm+59ODC3ZZZYLXQPP1mqIlOb4o9jB1AuuMy/C6uzc1W5NRLqNn3u7D7FZkjcPE5xnj3HkDZ3M442YW6rUhZfOT0Jh/i1hsDBntWmFSdFa15nZNU2odb3eJiDjxNycmn1V0N2thtiDKVTsDJITYAGMZxlQR1UMirA6OPcmd0IcpjK8BoUMGj0XX/wUh3yvyiWMI69k/IX9aGWcJMKNN4IrYMT1dC+WPrL1nq1UCZmGJB13mw4/Hwv9Wp+RI280m2q5Sq/Vjdx73ZCgQZCAc+Y8jVQS7M4fiFMvpw/ExwZFX9PRqUH6MNnxd815fSOnhHZOQC5oIMmgAXx7HY6bDbr8QkR43PylcjV0kYmETVbH+hKUOqCxaNNrlCUtqhLoH8RgnqpnIiDdq1f8/eBiqqv4JLOgbqQJmA/60pKtBAFkHYLElWMYT1RBeayOcqqfcriB1Yva25nb31UwlfbpTP4GCtPpcwwgxv1EFJ+wIZ4Njw3D+vwFD1Gns4T7Xnnl+Ffe7IlLXH7BdYuKKzP6vZOAMW6bieWkRJoDd81sT8gbaMTXkaZOeZnuftnEQjFB6T2zgxT7rigelmdRBpeqUuHE1n5MswhoDiKoUnco9whHDksVs6ef9oHwMBZ2dCaMltHpYntDuOhVab7jX9m88kx7R72OvRpIiSPjtnJAEZ58FHgrPvvrxm7dzWzASNExhZFytbzY+L4znGTIDI5xqkp18hh9FpQAq42uVAj725w/aOcNxSPzIbj6lp+q28ZLkZRSsM9qiQ0KvRJ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bf8f0e1-b179-4f11-f69d-08dad930ffef X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:30.3638 (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: sX35jGhO0TKJDqlVlPFa36/tAWbsQk3UohSPrBOeCEqCCs0rkHXP1ZNxJZAsLDt1Qp2ezf1+VYGxNtoHzpNvDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently, new group source entries are only created in response to received Membership Reports. Subsequent patches are going to allow user space to install (*, G) entries with a source list. As a preparatory step, expose br_multicast_new_group_src() so that it could later be invoked from the MDB code (i.e., br_mdb.c) that handles RTM_NEWMDB messages. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_multicast.c | 2 +- net/bridge/br_private.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index db4c3900ae95..b2bc23fdcee5 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1232,7 +1232,7 @@ br_multicast_find_group_src(struct net_bridge_port_group *pg, struct br_ip *ip) return NULL; } -static struct net_bridge_group_src * +struct net_bridge_group_src * br_multicast_new_group_src(struct net_bridge_port_group *pg, struct br_ip *src_ip) { struct net_bridge_group_src *grp_src; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 3997e16c15fc..183de6c57d72 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -974,6 +974,9 @@ void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp, struct net_bridge_port_group *sg); struct net_bridge_group_src * br_multicast_find_group_src(struct net_bridge_port_group *pg, struct br_ip *ip); +struct net_bridge_group_src * +br_multicast_new_group_src(struct net_bridge_port_group *pg, + struct br_ip *src_ip); void br_multicast_del_group_src(struct net_bridge_group_src *src, bool fastleave); void br_multicast_ctx_init(struct net_bridge *br, From patchwork Thu Dec 8 15:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068538 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F070C4332F for ; Thu, 8 Dec 2022 15:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbiLHP3t (ORCPT ); Thu, 8 Dec 2022 10:29:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiLHP3j (ORCPT ); Thu, 8 Dec 2022 10:29:39 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2060.outbound.protection.outlook.com [40.107.101.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735E175BE1 for ; Thu, 8 Dec 2022 07:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CX5WLbQpuSvJ+CU4F4f0Lh8rHGU3HskQjNH11RoNGsu00WJvsLU4ZYCkLYTJv+NPmfcs6p5FsyXxwCh1pReTV8DIyC7aRfeV+qxyLY9ncurDFKL+Q/stMiGsh7W9a0Kl1WMRwGGwnTbIxVSaxkkNNHtjdB6blWO7FUAWrpdacIrOqJrABcshFeSoHMetrrptoq4P7aTEJGPm+G0ScxBUVq/UVFoUbZWeOK7KVPVSdx4tTMvWVoK8tzPUI3JxshHWg7pod4icb4/pEtxX8SoSDZ8xkVnAnCNnoX0auhososKrlmn1+qe2PbUAJ1+FltZ3KFwmsjDMM6yJIiSttwlBmg== 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=PP7f+3IMbnf2HQwE4RvEho0oODh0ZQSUtULC6WZo7Lg=; b=JUZR7wC5WlHhQhM97yox/Sj/1tJthytebqqlLrrdDBR2FQ7oygxkz6CTy9JhTSpXV0LdjtG7fRtkbzPZn1TnEtheozO5VOattwUV57A7atbpSN556I1If5KD+sdSbCTeYgNgPjrZXa6MqDTB6pj2H96oSb7K0tvPeTscoFxNddG+ftxthI5VMRfgh2CQbN2++DRVmFiZ9YlVWVlGw/Hw7zWzS8Bdrfr/e4FpQF72x3sDiTrG8KivSzSkbsBe3XPMuGQ3GHDEw5Fg5OUNewY9c2XBjHzdj5txXPQwAM6Eh7TwS4zRYP9TEV9bXZfY/LgSHwv2fGdp49CBbjBoUVzb6g== 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=PP7f+3IMbnf2HQwE4RvEho0oODh0ZQSUtULC6WZo7Lg=; b=Z02Nr9SXoMI5AkZY8i11gsMip6VVur+Bynh19XmSAPni9OdvQ6Y1/vDLUXAMMftGgCiX1r5csGfrdGdScrAHFn9eaeN7LE/uOPzVDxDBiP+i4gYfyimLcPFvCZR34cpvWZHSgKEJ23JiNR4rYRIUy+Qadeq35xHoB8+Qr2Y9ZOscBkiDnhKbhGKaFX6Ndbv+C6iqlHIzUkcVmuzw0mu+FGoqYCIK21OdCqxvP7RR/h7gSbvMLHTi/j8DCPOvNj9LolBh4o5x5Wk3XMUwctuMwPf0vYqJ1EHsD4LcVD6k/GbJZuxlXPOYgzHA66vyx0Cy4K0DAfIZ+FTYt/z6Wamkwg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:37 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:37 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 06/14] bridge: mcast: Expose __br_multicast_del_group_src() Date: Thu, 8 Dec 2022 17:28:31 +0200 Message-Id: <20221208152839.1016350-7-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P190CA0038.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1bb::9) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: 08700fad-9675-4410-92ac-08dad93103d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nBxy+qxOdl5AZ/XMBOLms5VuUCa/1hFtb5eSiJjWanVq2W2vv/1HbSjYc/6y5Rv4eRl7MEykMKHxUIdp4YN4qy0MINDEm5h3wsFTSsaWSKjKTGDV1Ka6ub+9H1T7P5CB1rSh6H0iacQX1NZdVuEkM9KqK42MLhdwmuSBmMrvtrnR6WGBJbbnHhvkzr6IhZi55YddywDFO+MqJQFGLNNmtgZHI/g1wmkX7+5nR6qRSeW4N6G/dd8Fj8C9nCSd8sb0/H2PYgZ8+YvjvfIDcdh+dY6n0JcMZ9WdWcUGfnS2zNigWg+EBcdHgRH1p+Izu6N29DL4epLJIT2Yxgq/e9fW60EVyITekze1DggZQQQbVzC3ukcclDof2eAm5qcAi5qg8zd+mUGo/59jiQP+1NyIcrXZwVS/2xfc0wgvi9XU/HelN3Y1kSZZx5Uj3+Lod8M14VNE8j0iS0HXxFUc6PEbsXXljk6+q6CFQmcTZ6LIysiYIfQ1FNXJs+yNjAoIDYDX+JSAy5ONa9v1+Ngn3yC3a7nxbcL51XGLTTBlz5AVWzIOyteJpZFj9yyfeWIG5R48xckPagjBf7avtk6myDnlJEEQ3cAVbCb7OM+Z5oY/aP1479W3vptbXYbRzvalUTN3x9H6TjCOe+wpssMDOmIGBA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(6666004)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nbHWh64E/Rh6l5yJhDypW85QQ0e44+kakPQZ/04x+PE2CmarBjQYeFH+ZwjNdup4r/zGFBCni1eJRrs7E8mp0+2USv+R/AhsHjuDpeZWXNzPAMKvglyjmrFgr+pm6gKeN8C4NmNTJA3ibtju4OK/g686r1ABsexfmiXj1NxuWjpgvsbID9zIws0YbxngBAC26PwNxyllCjzMSOqaifMK8z6T/pAnej23J4W+CJyCgJA7YHtK8v/pH3iZ6yNFk2woOKGcppcihzjJumQnOowyE4cUvfX8TfmVLjOhHCv0GGeq3lCB6dY7Kg11bSpq71mPJvV3tefotlJrGjKzAZi/ORgP7hUXoZKHsq2udzPSr/S2jhAEzGkQ6jWfOoYBYeqdEAdUcnCJG6i0833VpWt91yOsmXn0EE8pS+oby6M8VCtezUtXLC/RGCXrSmExdN5TN1oQCTCONd+70wrTL9kFU5YlhB+JI6anu9wJXCf1k67GqxTeHFJJ7eTLJskEkCCpkmKjsR/E7AbDKre5x6x+7QJlARWK/rF70ubVcVpqWYXadOA+YqCjvFwSz2qd4aFpn0whLzMUHl8iDdW3DwqnM/dvz/zS+EfeDUkK+6elh+4Cms5hJ8cR7ycuCf7GocN5A7UFleLRRQDKno0OkBEq2tIw1Zen6WcgIEOsN0bzjlSKqNtfGyzXXY9rcTUmqkqmj8P8SIC2D7+GvUyhMFahg7cksytBpwE8zeDcrS4oqs9uMmVSz64InLYAwjn00ThLBjfHnckiFtnKzHYf6AIUuzl+tVVCWB32bpQ/h47s0AtvsB5+i5th7TJScXdIowJ5IgYNxg09zKyTPgh9RnjQkWrnYewoGcxuZJ9DR0rIvuodl1tQ//pN0erWBascJ9mNSzWR3XL69iyMH/DsVSnRUwVnth9fS0hewxVAGvcTI3zktFQSyxBNCLoUFyzj8qRXL0HZYq0/ycedkmUlGy9rOCJyaW9cOqVoWJXV1hNqsMU8oS+/w2y3iNC252ii2YULBCa7OBw+zoWhjpNSmJUdFvxOOLB4dEuZsJILeNTsS78L36Plil0eeqZMGcT+r/xHng40+DdH5HfFxjS1LYFGhdXRCbdIukxMH9kSxoOSleIU4NDq/rpJx0kDOzIcYWrZ4A9dnAPDN3OXkYY5Ck3pqa1h4MY7eHbzGyNyfzLOnDjbqZef+MJrFOtIMJXyIaOgWcD+CfZVX4cs4TwAGjyvZVYh3ES5ZLdWn0VLSsrnJKaC7ndndEeznrWNdbj+6dquxsGdRbLjVU/dWauzv6HF5lbsLxlKks4pzAmOGWPKzIWwKt4Mqpi7Fy7JFoTxcgNtT/oIcTN3p2aU3WWVllIgLNfycvwcE6qRl/XNZvYhCpRyrixEgSqVt1kGRLuyJ0NjrPaKJl5IOAIQUvGUxApJik/DpQDZ2umbxei/EjeT4j0VkASzQfxmXUNiQ2PvBHfd9XEWPiOhF606fTl9GooTXA/ZWSg7qCJW7Ie/gXipfZPrEi0ZrX00NaZpwgVsWPb2mL9yKqnv3yaxlEg+wtHCvZTnlQQQGFyRVzbcKSDQF13GhOug+sFMOaAVquFwB9TE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08700fad-9675-4410-92ac-08dad93103d0 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:36.9159 (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: qrefQS0mFuwncvB3x6Dnd6Nqh5oej5EAlLq1RfmUXvLygEQ5TB46TXjwNHjjymhw4ae4N9vVa8Il3Tw6Pm7voA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Expose __br_multicast_del_group_src() which is symmetric to br_multicast_new_group_src() and does not remove the installed {S, G} forwarding entry, unlike br_multicast_del_group_src(). The function will be used in the error path when user space was able to add a new source entry, but failed to install a corresponding forwarding entry. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- Notes: v1: * New patch. net/bridge/br_multicast.c | 11 ++++++++--- net/bridge/br_private.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index b2bc23fdcee5..8432b4ea7f28 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -650,18 +650,23 @@ static void br_multicast_destroy_group_src(struct net_bridge_mcast_gc *gc) kfree_rcu(src, rcu); } -void br_multicast_del_group_src(struct net_bridge_group_src *src, - bool fastleave) +void __br_multicast_del_group_src(struct net_bridge_group_src *src) { struct net_bridge *br = src->pg->key.port->br; - br_multicast_fwd_src_remove(src, fastleave); hlist_del_init_rcu(&src->node); src->pg->src_ents--; hlist_add_head(&src->mcast_gc.gc_node, &br->mcast_gc_list); queue_work(system_long_wq, &br->mcast_gc_work); } +void br_multicast_del_group_src(struct net_bridge_group_src *src, + bool fastleave) +{ + br_multicast_fwd_src_remove(src, fastleave); + __br_multicast_del_group_src(src); +} + static void br_multicast_destroy_port_group(struct net_bridge_mcast_gc *gc) { struct net_bridge_port_group *pg; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 183de6c57d72..a3db99d79a3d 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -977,6 +977,7 @@ br_multicast_find_group_src(struct net_bridge_port_group *pg, struct br_ip *ip); struct net_bridge_group_src * br_multicast_new_group_src(struct net_bridge_port_group *pg, struct br_ip *src_ip); +void __br_multicast_del_group_src(struct net_bridge_group_src *src); void br_multicast_del_group_src(struct net_bridge_group_src *src, bool fastleave); void br_multicast_ctx_init(struct net_bridge *br, From patchwork Thu Dec 8 15:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068539 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85CD4C3A5A7 for ; Thu, 8 Dec 2022 15:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbiLHPaJ (ORCPT ); Thu, 8 Dec 2022 10:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbiLHP3t (ORCPT ); Thu, 8 Dec 2022 10:29:49 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2071.outbound.protection.outlook.com [40.107.101.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A91B786B0 for ; Thu, 8 Dec 2022 07:29:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mYrqpPs0UASbxKBCwD7wNeXPh8uoFRGmUEOdtQhbPKQ89G5xf0s6NafLwX/qGcUJDUI06k9BloTGODypuAQ28E0LRYxSyrqmTxQ0FtsMjnCJQb8cZ6FtJBm3Dy2x1lEqwn+Bgzfl/wt5dI17yQh/9rcStJNbtxVA0l7arTGf3EEAfv00uQ4Fb+hpA2ID5oM+TVyw2Lc5jgfmPzl0zSIp4D2mcSuPpOTgaKE2eHhcGIaDp4dbFeOTCnPU8hldcxTQJNl7pvk3eJpwuHmOnTrHIDHsCzNFjj14dHLvcUOdi5IOPDOIJB7/+vPzRF99+sBSMs9ocIvQoTXztKcMDLT01w== 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=Io+ImuS3b07MnnII6pXyXtb80xF9L+WnhTul4DWibg4=; b=El72bOtt5hyB8Y+i0pX9+wLdSHq1tWpwmyIVqWDd6/2jSptfGb2z/oNigJluZjpYmceFbr2CiP44T4MVLn7jbB/EY/IuP591xkwWVL8Ev7ulHOnLTOS5393OfgUD+GpPvvxmCb29M9ET/nFkgzn7btbCKCIh75ru+pOlSbfKOMcHBm/Zw5I8zJ4uZJJudohOa+79fZCQBgUWFo1oCkIyF49P1T5LcJDOo0w+rVRTgmnTQQab+3VFErl4mi2AMC4MTJyPnwfxFWqR8a6WIJdjv4PR8R8O2Ssqbjii/tF6Yyqh++vBI8c4kDpTSC+JFFvePmq0B97UFBFj5CFZ0FgjcA== 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=Io+ImuS3b07MnnII6pXyXtb80xF9L+WnhTul4DWibg4=; b=tDgHJ9ZxdmPZjT9l6ris9R6nbmAI6vr/FqcCe4O/7OKW31Fes2gT8YfhP8qM3v6chF4qmdreZvsVsgKWk9NovTgbp/+EK6QxRdeHTIgZv5WnwV7dbZZGb/8A3l4uOCZUZq7pXoDcnZYykfqK6W6kHW+KkHvKpQmsp8Njn1Wm5dm/bJqTfIcfPGcHgS8L9ju4RJnABljdMYd6sAFZoQvTD69DWGId7KS8NShqmuZuEj/wGRXwWJZF7Jj54cTI3s3seLV9bAaySgp93KQ9e3JCv39szco3lGHFm49V6FdVMOpCl5hyi/ebtY2VmtbwogJlT9w3oTW+SZ+sFp9H0S9/hA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:44 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:44 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 07/14] bridge: mcast: Add a flag for user installed source entries Date: Thu, 8 Dec 2022 17:28:32 +0200 Message-Id: <20221208152839.1016350-8-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0248.eurprd07.prod.outlook.com (2603:10a6:803:b4::15) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: faaa67d7-aa87-436e-627f-08dad9310804 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TFtDCHjPCIuaH4bGMOZu6utbMvtsSCRzsr8ZdgD0yk3OihEHnzZuk0KrRQhMKcJT5vQTA0dI43iIFl1JFmZ9YUcDYxBi367PXcDz7EHkyaRUElRob8uEli4PURdvHbJ2uhLkhLteZZpbl87F0rFVsZKUjBJ4DSF/5ZvjN+rSEOdPUwsztZvx3gSQVDfqjnUpQp+QaJmjKQE+tl5jPPdbwi7w7wyU3UibYEuOtEewHcaLr0mHT2XCikRIGHBtSf5FCZCgHofoFsi8iYls8QX+RG+yCw/SgUU0xj3QSDHuXpLZT6dD79M++2dQ0rp7Vhh33uAoI1epZwUf1Ywh6ERuW5swe/7PL2tMhIKmav/aPvVZs9g8nRG3XkmYIiOyC47rfzZ40ir5fSRj/hVNtQnEFW59K7cW1Cvr8X7KZmpVYYmp4d813mIeQdSuimJpxTupYi260Vx//mLceCEVwkQGmMxobVzOU5n3UgxeGNKwWOWuFlEaKMF1Gjt6QexJIqp7jruzYjV2MPfpdp23vcS7+fq5MsI/oqDeZdxILv+eJAql0PMXMeUux0egYH+Hxp/JV+SRRggo9pfr5cMwAk0icECQeGVUQgEtKoEIPXC4Iywa3nwyziVDaGsO1elQwUeAXtNtAa7LXX16KiZvjb3oZg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(6666004)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rn4MCVa+jWL8n/OzTxrvsthQSVRB/svEutQBJ8u4o2cfy7Mbe01ypcKjzacD1G7DTuwX+BZ38ycrovuwLhIF43A1T4uStnREjfTNf2UHgTMv8MaiuBfDgOJC3pkCz5b9M7Yo1ie361E8tzLzuiOW56lCUeC25hTYXit8+66gcdWbaOEXLFcyc/Pow03P3SW6jvrGwVEltD2a/5TjJpoiUcNEbiQGCLBRoSq6moc/KN8HKPfTleGGEVSDAMK8m/WcNKdPS0FFz7RpmnqNQbv1QNroIf9IGqmrKxt7KnVe071ALGp63d1YClSaWMKibB6rzMUmPJdLewLR3L4xkcKMWNYft2w7kYcMHyrZ9QAD9pPhwpu1EMj4e2kdWbZKpN3m5qFzu1GxwoGtcadMbpnexvTpILOVnggYAz3fo8c20uCxVn34DfN1ZLsucXhtGuv2NlX2JDgSJM5ZCIJsXu+igc+2SA7erXe5hmI6OFZxpFSU97fRNTRn2J5LrNHxbPajKKVoQdcCk2iLh9K7pgyGpwgbC6jKO3k3WDy+D9rdRGiuWOT8NTkSro6juSDaQgRw0UG92Crm8iq7u8Ox88qSW4ejcaGXzG+CFHhBMQM4Mhehzmr9xEqg0FcHGX0nbqs0oFC85SkPJLsoKTIkmZBRdafG1QrWiNJ65C6yBaCiy+JvDFuG9I+ph6JC57x79gb0Q8AEwja6FTkjog5pM9OVGHsu6I1ZCRBIq456StypTkF5xYujcw2kj0Gwce8MvDFUXoGKOGdc8KXNmKlVSD3HCb6fuavxn0SJmYS4sIwypynienKmNfIT2q9XY6Jn29pclkl1oTDIVU9cV0uLfRGEC7nRyNu82Q4Uu617NOtAXSpswU9M0Rpg/8EaViJyhB/8jY7YspXFN7vBLElSuxnivMWngSkSirFqZMesPvLWR1EXFcI7RBnclxD28nwgzTGNvU+PV+PVmlapL+KHjaRbYhLiCs/k6aVXzuag8KEUWsKJDuK/fq1T/hvZTdR5lVZCa1HR+dFKjEOMXrGy9gl42JFqmqjuwwYl/xewBceqUNVRU8NStIKQZD3x7SmSSRr6ShslQFcKJu3F+fCTMli+peq0liA9HVUeWnT2ZGlP2pUF3Fvlp1cJcZToJPDz5mwZdkzyJLjsgSpln99wWlMjb6UXVjjyZHrrjIeGV7TWRvOjif3py+gfnWVUa2pVELLF+J5JdveGz2u+OecLa63eMiW+vCheg0EGFoeT8G5y0xs4vyz+rnqfX/6kgnNVWoElJ23lZsBl6FceLUlasCgC1Zh69Kz2FVtPooNFr7XJiRShDHkC2iQdbtiKzxBvZvtrTGD1jkSCar+N2NcqLljVvTDX4P1Ihy7NlOsq0qYNQ+m5cgqx6jY0+EhJyZD5ehA6h1hcUTbiphhswcVIfkSInJKzQFPZvH9uBIQX9ZVEEZxKn5MTEWagCP/TfCoEHXnn+fKznECy97dwINp8ZJpDRCyONUJqDZV/rAp+ODTiGpvvD1Vtlp0bJwOKlBdQNOM6MF66WQA953fByWTw708ifi9HNZ5nbsXBPvmInoajeA364ref+HhoetIfdNuphjcc X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: faaa67d7-aa87-436e-627f-08dad9310804 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:43.9351 (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: pbUbDFAw+l54spojQf6OcMqTdaez55/7OjLD6VxKk5IgrGJD5k9W2o7L8qBSe+/q5OpMtD/OJIfrCwtq94IdVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are a few places where the bridge driver differentiates between (S, G) entries installed by the kernel (in response to Membership Reports) and those installed by user space. One of them is when deleting an (S, G) entry corresponding to a source entry that is being deleted. While user space cannot currently add a source entry to a (*, G), it can add an (S, G) entry that later corresponds to a source entry created by the reception of a Membership Report. If this source entry is later deleted because its source timer expired or because the (*, G) entry is being deleted, the bridge driver will not delete the corresponding (S, G) entry if it was added by user space as permanent. This is going to be a problem when the ability to install a (*, G) with a source list is exposed to user space. In this case, when user space installs the (*, G) as permanent, then all the (S, G) entries corresponding to its source list will also be installed as permanent. When user space deletes the (*, G), all the source entries will be deleted and the expectation is that the corresponding (S, G) entries will be deleted as well. Solve this by introducing a new source entry flag denoting that the entry was installed by user space. When the entry is deleted, delete the corresponding (S, G) entry even if it was installed by user space as permanent, as the flag tells us that it was installed in response to the source entry being created. The flag will be set in a subsequent patch where source entries are created in response to user requests. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_multicast.c | 3 ++- net/bridge/br_private.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 8432b4ea7f28..48170bd3785e 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -552,7 +552,8 @@ static void br_multicast_fwd_src_remove(struct net_bridge_group_src *src, continue; if (p->rt_protocol != RTPROT_KERNEL && - (p->flags & MDB_PG_FLAGS_PERMANENT)) + (p->flags & MDB_PG_FLAGS_PERMANENT) && + !(src->flags & BR_SGRP_F_USER_ADDED)) break; if (fastleave) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index a3db99d79a3d..74f17b56c9eb 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -300,6 +300,7 @@ struct net_bridge_fdb_flush_desc { #define BR_SGRP_F_DELETE BIT(0) #define BR_SGRP_F_SEND BIT(1) #define BR_SGRP_F_INSTALLED BIT(2) +#define BR_SGRP_F_USER_ADDED BIT(3) struct net_bridge_mcast_gc { struct hlist_node gc_node; From patchwork Thu Dec 8 15:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068540 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1449C4332F for ; Thu, 8 Dec 2022 15:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbiLHPaP (ORCPT ); Thu, 8 Dec 2022 10:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbiLHPaF (ORCPT ); Thu, 8 Dec 2022 10:30:05 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2088.outbound.protection.outlook.com [40.107.101.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A5C7E414 for ; Thu, 8 Dec 2022 07:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7nsl5BIaE5ouMSVMyLJv/tNMdssiQsufTXK7aUsdWBa3GUSQVFlYreQu2Nx76gvOm6FQn5Ye6ow/6mApUbUpWpiX24s++ov3KC+hBlFAi2TdLU1KHOxCiYRJbIR/OMNiWpkVgMfoxJswvZB/by3D0XpTtN8cOIiyrFKQxg2PfUdZUl8x0l6zm7UVRJAZwdGU2629R4Gt4nvkbgn2P1lj//hayoWp+B0Wqz6LRc75SpT9vwZbsTF81DaFA/VyciW+T7SRlSlZdsJjma/DeKVOXWhujMdDfOP3Xef3WE6x9e1OBBuct7k1bq/kyJ7pNmXOcOZMSZOuy9qqfSnUewq2g== 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=mGAdrMfjbxvwPcFkMLK7vIWLclDlIPR8xC0JST0wvtg=; b=U5+HEiUBiUcFODdtf0lt8DRc6IR8xsOXn8gopiYP3PIuqyakWxbzl6UI5T3wYkXiwTBRShQug+X7GAzqygSxWdkXd7hBKAoT0p7JPxFdNCtAlZVcuPGWlDGarzTqYKcWd1gsxj9rBjPkqHB3MdZFm5Ikf5pa5DrP/S7J83O+HzH2wb9u4QeQFY93zWpKnV0GYoCrWBUw8ISAuuK6fM4G1/SzHD01qmou+WWqGueXDRJCQ6ncq7Jo/SfFY4za4omv9hwFWNpZj8wW/qECnFbsn/aVvuDZQLNQf4tgM6oI+fcPrOmeq68g7HXxltGAp0wb8e0+cqBqefuPRmwMUedBpA== 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=mGAdrMfjbxvwPcFkMLK7vIWLclDlIPR8xC0JST0wvtg=; b=ZpX9KeWkheyij490KLQvvbvBtEDgb/AeNMpSyHzb7D2G4a3nMHP7N9A000ASM9ylJWyxdM8oTC07p2Wd9pvl2Bm4ndrZeWfoB0Z/JK44xgTiMPreXknF2UD3hILB0Xp4ASxuAPomUUr8kyA4Und89DjFcUZwbwGbKd6XlX8UmCR+2PDPSQcr+KNkW0BzACHaWDqZqKc5npFCJldliOxnVWDobQUPbeO7EOWR0jlOVCDkjyagCmXyU2d1nkDFe8TRa8Bj2/Jo2jMWypTB3pWdT4RDR4wZdqttF7NWLd+KBSJouUbEHklll2XcTCe1sxg3PdGE83bNO2hJ3Mi4lTlS3A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:51 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:51 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 08/14] bridge: mcast: Avoid arming group timer when (S, G) corresponds to a source Date: Thu, 8 Dec 2022 17:28:33 +0200 Message-Id: <20221208152839.1016350-9-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0501CA0017.eurprd05.prod.outlook.com (2603:10a6:800:92::27) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: 45fc47eb-47a9-444a-b12c-08dad9310c18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dtkjdG+FE/ZQvhH5pzpq6p4abQOVVRonFL58nGFLfhXvKaDjTsAC7D3VHdRtmWzsbfSqktwDFZNqi0Fij60+8IfWluTJ1nLmQWbER8Hz5SG62fbNRQuJ7DsdaIMMz5MQpHE6IP5kRW4n96hHWO9CT7nW78vmqdMz2eJY4jlGHF0s586JQQ56q+tqd2ntrDfz1yw/6q4g+qwVEhoyW2sStecWtGgXlxPjKdqjriS3HqI5VCr0V9sav3yb6hdMwrNci63jV01qOLZvp5xeEJETGvuSi2uXqDOrI2QtHtiWtS7dRLwjMKz60p4EUjwe968/Tecv3q0VfyMdxs573fFaRZm95NIhc3u4fNf0ngVrBtKJ6USgC+uuPNCjugmtIWTLoWNH5L3E8jrbYNAkbzlBAYVQTyN2LMx3B728gHsJbFo8CJ8oD6FUNi2hE7DBGaWHjdz/ZHWa2bkDLLYpP/4AwLocv7lWwgGAkbXzU40YOn+r0MAndmX1z0My7Y0QkHGuMhIkzjuRvKuO+aHmemlPyTEPs1I7fv9LeHqgVQHdGdcSHIeXGLLBiKSKNqaDB+IC/qjEyu8IiVzAcyB+VZ2gBs4Rb6H773pGX/Rvm3mRvkHlStmGAolmMsZmSN8mRHammnmN3smAC1g96puEEZdc0w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(6666004)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qEJdGxCeDG9Hj0qtgDAFLAgCceEA1cOYqcSwoeHc6eEJ62BpIjxfrLcIX/Xcfbk5jiA8XaLGkI/lDU2pddcJ79Hk+bTcSuu8JTosEdvXv5YRLwTzoLHU6qXlTe6ZfmHULv8mLMPy6Y/qQWbDCe5agNjW+5E1+SGAHxNR6ZVkFHKe9mQAPpkjRNUquJEIxuKv65mhDdEe3yUyxj30MsEw9JzJtaxqtXn1jsSe4B9wCq+4ErS3xLAZpeijBjkT8p/2qghb9X5ERNSNA2SdgmmAT04AkQqzOOVK5dohqShJd3+NW8nF38AUUXu5dRKg42GJFyC7XLUkMNeXcPhh8pWw9pmKSvFFJKsp4HmskJXucSy0txMNsrbM7FiZawBWoSqGCAIDKjWROFFBx+QigLlS/XsUat0PkNWzEz59cETjaKqMM/jNAsaVqIiEMGI4kDbPSANCsSqng554y4aLdr1A9wjaywlBH3CNs4eyI3OFDkcT4oBSPYYYREj2P7gKwGbKj1trXlJZyr6yLA6bgu3/E9VD/tlY5nm3vQJj4zSg4qwayXVqHNs9r6uoQGIfWI7ruYbqfEoSFa2XQDJcW3B8m80kh52UhPJAP8ZinEMDIyOOX9a3QMESmg9YnWMt9rC6Dflev7oKU4AiSe77UKO58ztuYzvSuarryKPdFCPxAqNqM44DN++z6GPNtTuuWFntj/GPxwDqzxn6iTSPokwGMGImO7SrrGsjSWNP7nchItghrC/sCSWwOeFsPeV8Xv31mmpJ2B5S61TUOGSDveuguf8pEY8zvow32dEVnibbc+b68WGpbZArNLZb77yztns95xN/SENS40HUX1MPCTzK9oN9fb11W8W4g3ZpTiZfXkS5iAx5q/KO1UGThzJkyP86CpYX/D5ZEcgKHEIDGSTp9TXr39WG4ODrPYr6FkhTkThoGVKsLQk/221rx+Vab55LuUdQl7ypEupPD4Si43SVXHX6zcbLFPUrlKOnTTb1ANXkKyN3YJPxGwgXeTIcTS2CtCMC9skQSs1q6VnaA1jibWqt8sB/jCFaapElK/pJOaopj8qWfV3t8JFxsFeQ9+AVQFGbBd7qCS3QjGkUmrA645TGFlGFV8lt/ZyVTsgsS9znhRslUiH8QeBlV+b73N5hKPP+0N8Lh8LoG8wyriIc9Y44bs0FofLy4niQXwfyc0S8vUzO0WK2Aml0lNIwW+W2GJv5mldlBq/bZ1/d1tN7V3b7uP2itclLsGXprt7mYLbMKp2VSZFpGswiXrtFMax+f+XEaP68pJDlIlrw2qD2zfI0UpKiEJaXT/0nyFsLZybbD2HW7OwKJEVhLL2Ofl6NctSnD+X/DdMXpoQaW7rNmuIyEexgIs45MGJa1wkluHCHTCHEypmVEsyMRGlfdlpOhs/9VgbSbZVCvdeA2hSMQD3M/ZJCcBt1P//7NfsDpdEJdgDiuF/R2L1lLd7du1RfMZuw/uwL18Re+SUvrgygQkfLLiJSoFCrqzBzXWqjZT9DtLK+cYYqHUSWBY0ApTuLSXcuEy0yPqygoLp57ka7gJt1vtUerplhPt+1JRN9LKrSf5X7DQ/wMaAr8WZoWyhS X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45fc47eb-47a9-444a-b12c-08dad9310c18 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:50.9196 (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: Sz17NGmv/2iNWmcOr2DMIX4GZpx0DF/L/sWj8UbZqetHWel576wehsfwa8yTwtc38ZkvQ2cNrGk/G5lgQnCgjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org User space will soon be able to install a (*, G) with a source list, prompting the creation of a (S, G) entry for each source. In this case, the group timer of the (S, G) entry should never be set. Solve this by adding a new field to the MDB configuration structure that denotes whether the (S, G) corresponds to a source or not. The field will be set in a subsequent patch where br_mdb_add_group_sg() is called in order to create a (S, G) entry for each user provided source. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 2 +- net/bridge/br_private.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 95780652cdbf..7cda9d1c5c93 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -814,7 +814,7 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, return -ENOMEM; } rcu_assign_pointer(*pp, p); - if (!(flags & MDB_PG_FLAGS_PERMANENT)) + if (!(flags & MDB_PG_FLAGS_PERMANENT) && !cfg->src_entry) mod_timer(&p->timer, now + brmctx->multicast_membership_interval); br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 74f17b56c9eb..e98bfe3c02e1 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -98,6 +98,7 @@ struct br_mdb_config { struct net_bridge_port *p; struct br_mdb_entry *entry; struct br_ip group; + bool src_entry; }; #endif From patchwork Thu Dec 8 15:28:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068541 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F310C4332F for ; Thu, 8 Dec 2022 15:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbiLHPah (ORCPT ); Thu, 8 Dec 2022 10:30:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbiLHPaH (ORCPT ); Thu, 8 Dec 2022 10:30:07 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2071.outbound.protection.outlook.com [40.107.101.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4A17DA73 for ; Thu, 8 Dec 2022 07:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LdSjIqKFuRKyoiEjSmPVzdulwrtsijOhM+hbwuWUgKL9zJttYD6s2zb+/SuLl22JyOs5JN2+UTBV25WykeDAEgqtgvJmSJTjFo9LIQui9Qyqppx9ZN7eGqDLrz33OxHvq8ZiMuX4acBQITh4/5PCzUa8kgw0O5GRR66m67JKfMpFsv79FNbEO872uvV09K/eIXkLg3dgo5GSY2tDektSzTpJixByr2kvP2OAblA8MsMAjb69fDGUgmstnvzMwW+mfhryyoIitRDrMZL8IKKwtnz0hmHS6qjWOq9lOh8OlIxczIP6MLaQrzbE6fvAx42fnT9iuI8mXEEK72Ce4o+4Og== 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=2jMfAlXe8vULAdku8vXtTSWvRV7w9CPQoCwRB5XuwB0=; b=iK4QKGNTwRZdttCdW+t3RuTmi3oyo5wYTauUKu/mnnlTGpsomCtv7ZEkeNU8o4QYQTBrkmaXhrReybyli3atDY3bUDOV2BooyiUsomIFpLav88A9/QDS4uXKi8IaWzIlvG/4gcjeUWSsCz+TIU0u6ImaBLP1WGwa+PYxc/bIbYL/oEGRphkd6KVKG0lgSmWiSt+EU4wTbgFkOjrSOLCOpHA7rmQNWT+zO1+jqr1K9Yl5Pmu4w6LtU3F4ycyAEzBodUnW7kUpe7QY+zLFuNH2IjAgxLaMuDEOjmXz8uva7xVyOlZ/gUCuiuZGjYiyk5b8gC2YrIP4W+7CEgIi3fbofQ== 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=2jMfAlXe8vULAdku8vXtTSWvRV7w9CPQoCwRB5XuwB0=; b=Zl9sC6Bamh30DOnLWj+gTmk4M/zRjwOJ/oJrXmtSh/ggljAzN40X7tXuCki7jKVolw1KqVLDQso9vOFXyR4Y/5sMUt9oL5CD4FZ7wL5o8WDwMofHhZtZYRLLdMo/XzJVjWHNBKOEU/PmjKjvcFb7bthk2MBS7jAkly/hvsT1bI5Lg6ho3xxGaT1GhZ7ZktlqYko3jkMPRViqF00tuF6eHocj3xWYXkclBp0w63vDIOXPgvjc9mDkR7+7pXTWNHxbbIBJA/0kURG+bnCVDis3+ueOaSnDZJOioevY7Nk76mc5C9DHBT6omJa/ZLeqWrk17pUJHXoJSlKFqrfkSqIv4Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by IA0PR12MB8207.namprd12.prod.outlook.com (2603:10b6:208:401::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Thu, 8 Dec 2022 15:29:58 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:29:58 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 09/14] bridge: mcast: Add support for (*, G) with a source list and filter mode Date: Thu, 8 Dec 2022 17:28:34 +0200 Message-Id: <20221208152839.1016350-10-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:802:2b::23) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA0PR12MB8207:EE_ X-MS-Office365-Filtering-Correlation-Id: 79ae8b78-ec95-4d47-c4c6-08dad9311074 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HngDaoiY/c/c9JjiuTstcj0A204s23YV7d+xsRfn/CUlf4kYHAqAZvpGDSy/LT+xO8QyIH2MdZd2XU6j/cpEgVXu14dt23ELD9KR54m5PUVmrGV2/n5lH79P6Zry2avSXjIUd+srxh/442BHvtIT7ADHsnZal7QXQtatwkx7G92JR/SPC0hwptnTU8sbSjQJUOUc4iHRtd/yBkPAlHKANaHWMjvmmyGjdc91UBHiv6897spKWK+rvABUJVK6kwqkkdopKpBiSYfOx8b6HjFNVXF470f2+PRXJ31amkTHW8OtjZhdC/ujNh22xc3XGkcmrmHEtcr8TH0dVjgzyCPrBFbrnkLPz4isPqiohduLeqSTSin2fnle/PAbuZ2pb8mxZRXgoM0hz6JwMyQroLMwhaZ/PX8hcPD90gRrkHypVF/yxiamveCqXcR1obs8apSzDHAbb1slZHur0hylFj50GPKGTM9TkWNnvDNXbvLK4h/npEZzNZluH6IYYy1yMIS9sK4jFc0RLRcNzAxwp+4BiUtrRLmSswYvq70OmVRv38eFoxXvNnDQvRY0ZQ/7MwwPKsVe9JA0mKacTv2Ryd72v4oKp474QGaBYFzYA2m8rq2RBrgnK99reHzy2Yc/y9JDk+iZtLO0jtQ4KiBh4VdERA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199015)(2906002)(83380400001)(41300700001)(36756003)(1076003)(186003)(86362001)(5660300002)(38100700002)(8936002)(6666004)(316002)(6486002)(6512007)(478600001)(26005)(66476007)(2616005)(6506007)(107886003)(4326008)(66946007)(66556008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ch/QW9w/mLRZwGBHNS1Ipxfyuc7OuiCXDJGwuAqup8+gc6+B2OUmecjeLvsPcgSu45412KNrkX2d2QAgs52IdbEP8HrUODMFkvlt21rAZKME7QOgUVGPchBpjtNFt6JHe64dXLNqxzAifLzMqnG1atOyixPrABqhteWdcTZShYExxMqL5LhhKxuXg/z1hgZ6PSckSC7ZEcnrJD1YMhmpfNNRHcL5/uqRWCnlqi4OvjqER20wN79U2Sw7L5uFHXuAfNtn9gNidod4G+gmvDdqPZRe+7iuuukvDxZQJR6j4HPUVpxo3qsIzYlYswL/tqvhEY1tNTtdvMrx9NuTbF2BYH+CTVAJ/pK/FRCnkPhExkPGDGCqN4NXlQyPZurZjzaei0cnxPsNChzPpkK5tgErJ7oDEBtmtCdJh0q8TGA13b/1/nWi/8Y3GSuFwQlPpoaeRx/x/OBP1UiYvkBThalZKbdzFQ9glAEmsuaSUvk51cTSokwZO456VnfAPU4IbvddM147Z5SquIlEAJDxuCWmFFqfCDbvMbspFN/PiaeWSk/4+4J8DxUHjfgifYiEH/v3DarbARVFr1HRIlKOC823tuCH0oxDiDvWIqD/Z5MGXlIuYkJYjmWD3lKQufbpPWPt8EaTJgyDwi3VPQv3i1dDSPRjsz5BggXa2sSR5dQ0w18KEIY+p/h432fS9wjijwwldspgIco71Ln4ugmCUznkqF9xAxHkH83HDQbdrwf0SnPALC9XX+xJcCYvD4wUS9yKWPZq0ojYkTsc+AapcGwCnnZNAxDuU1YbjRxbSistMrRTFt6z3U2XQm8lHVFz33INB4fVSR8XOBjKb4pu6zpz8XxMQU/1Q+Rk26Fdlnhuj2MYqMsHBZOab5VzkaJbI2heFf5ShgklexTIfutgLMli6aS9CoweVyj+8YjbP1cO5b1VsltErKmjQ7Lovxi1pG4omvnJ46A0qUWN2U9DM0wRiPOQjMHQnUn+vbeFJ5DjtbbC2CbdlRvkA/aX1NtX2Rbhbt8T6A+ElGgoxNjaaQ83pHKL92iYv3X+z3WUwunHGCzq4oteYUMYbXB1ViJZrRc7V5mLDUb/LhYKXI9A0CAT9YFBEAUkb7amyl15bcvuKru3QvI1oaYGmCo0sNTrLXfpo17/2V8cyGh6Kj1OVDP/ySy+aF45vkr7owKD5duyhDf70kZD0SSKZ8CpVU78nxcP8Pfu7P+UzlRS8jjBYvZfskzpD6/VuFhxqvG8KsO623OYqp41fk3sKCzL2eybm8/LomF7nc8wIdKATujXV1+fhv1j8zldaDrYd/oLRNAKrFIiq1bPcOxCRqhATKel9ObORfg1148UUvQJcr7AAXRR0NvpH06Qi0uFIAK6ekqOmqwGNrxcqV6tMLJLSz+lyZ1bnUzSh6INXwArImL7vnWn+cN9J/kTaJBa86+4eCmKBCPnpkJ2E8zpQBZl/U/M5BFDbQZNBjMJoLsqfM0N5sqaiUzkwg7AVzyB59EJ39pDtuK6EXc0W1L7yi9yt5ZTq3rFXjU9zbWVHGYZq/gF3VCtcKqpLIXanzWygWye4JZKH81DTt2gR10pHumIa8aTTygt X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79ae8b78-ec95-4d47-c4c6-08dad9311074 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:29:58.1884 (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: Zt8o5Xx9mprAs0cjcVBJjRbN2TuhR4+iHvmWWSOn7G6Xm6GDGy5Aj7mZbzopiBKY15TQgqiI5NgQXQpd5sHZnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8207 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In preparation for allowing user space to add (*, G) entries with a source list and associated filter mode, add the necessary plumbing to handle such requests. Extend the MDB configuration structure with a currently empty source array and filter mode that is currently hard coded to EXCLUDE. Add the source entries and the corresponding (S, G) entries before making the new (*, G) port group entry visible to the data path. Handle the creation of each source entry in a similar fashion to how it is created from the data path in response to received Membership Reports: Create the source entry, arm the source timer (if needed), add a corresponding (S, G) forwarding entry and finally mark the source entry as installed (by user space). Add the (S, G) entry by populating an MDB configuration structure and calling br_mdb_add_group_sg() as if a new entry is created by user space, with the sole difference that the 'src_entry' field is set to make sure that the group timer of such entries is never armed. Note that it is not currently possible to add more than 32 source entries to a port group entry. If this proves to be a problem we can either increase 'PG_SRC_ENT_LIMIT' or avoid forcing a limit on entries created by user space. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- Notes: v1: * Use an array instead of a list to store source entries. net/bridge/br_mdb.c | 128 +++++++++++++++++++++++++++++++++++++++- net/bridge/br_private.h | 7 +++ 2 files changed, 132 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 7cda9d1c5c93..e9a4b7e247e7 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -836,6 +836,114 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, return 0; } +static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg, + struct br_ip *src_ip, + struct net_bridge_mcast *brmctx, + struct netlink_ext_ack *extack) +{ + struct net_bridge_mdb_entry *sgmp; + struct br_mdb_config sg_cfg; + struct br_ip sg_ip; + u8 flags = 0; + + sg_ip = cfg->group; + sg_ip.src = src_ip->src; + sgmp = br_multicast_new_group(cfg->br, &sg_ip); + if (IS_ERR(sgmp)) { + NL_SET_ERR_MSG_MOD(extack, "Failed to add (S, G) MDB entry"); + return PTR_ERR(sgmp); + } + + if (cfg->entry->state == MDB_PERMANENT) + flags |= MDB_PG_FLAGS_PERMANENT; + if (cfg->filter_mode == MCAST_EXCLUDE) + flags |= MDB_PG_FLAGS_BLOCKED; + + memset(&sg_cfg, 0, sizeof(sg_cfg)); + sg_cfg.br = cfg->br; + sg_cfg.p = cfg->p; + sg_cfg.entry = cfg->entry; + sg_cfg.group = sg_ip; + sg_cfg.src_entry = true; + sg_cfg.filter_mode = MCAST_INCLUDE; + return br_mdb_add_group_sg(&sg_cfg, sgmp, brmctx, flags, extack); +} + +static int br_mdb_add_group_src(const struct br_mdb_config *cfg, + struct net_bridge_port_group *pg, + struct net_bridge_mcast *brmctx, + struct br_mdb_src_entry *src, + struct netlink_ext_ack *extack) +{ + struct net_bridge_group_src *ent; + unsigned long now = jiffies; + int err; + + ent = br_multicast_find_group_src(pg, &src->addr); + if (!ent) { + ent = br_multicast_new_group_src(pg, &src->addr); + if (!ent) { + NL_SET_ERR_MSG_MOD(extack, "Failed to add new source entry"); + return -ENOSPC; + } + } else { + NL_SET_ERR_MSG_MOD(extack, "Source entry already exists"); + return -EEXIST; + } + + if (cfg->filter_mode == MCAST_INCLUDE && + cfg->entry->state == MDB_TEMPORARY) + mod_timer(&ent->timer, now + br_multicast_gmi(brmctx)); + else + del_timer(&ent->timer); + + /* Install a (S, G) forwarding entry for the source. */ + err = br_mdb_add_group_src_fwd(cfg, &src->addr, brmctx, extack); + if (err) + goto err_del_sg; + + ent->flags = BR_SGRP_F_INSTALLED | BR_SGRP_F_USER_ADDED; + + return 0; + +err_del_sg: + __br_multicast_del_group_src(ent); + return err; +} + +static void br_mdb_del_group_src(struct net_bridge_port_group *pg, + struct br_mdb_src_entry *src) +{ + struct net_bridge_group_src *ent; + + ent = br_multicast_find_group_src(pg, &src->addr); + if (WARN_ON_ONCE(!ent)) + return; + br_multicast_del_group_src(ent, false); +} + +static int br_mdb_add_group_srcs(const struct br_mdb_config *cfg, + struct net_bridge_port_group *pg, + struct net_bridge_mcast *brmctx, + struct netlink_ext_ack *extack) +{ + int i, err; + + for (i = 0; i < cfg->num_src_entries; i++) { + err = br_mdb_add_group_src(cfg, pg, brmctx, + &cfg->src_entries[i], extack); + if (err) + goto err_del_group_srcs; + } + + return 0; + +err_del_group_srcs: + for (i--; i >= 0; i--) + br_mdb_del_group_src(pg, &cfg->src_entries[i]); + return err; +} + static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, struct net_bridge_mdb_entry *mp, struct net_bridge_mcast *brmctx, @@ -845,6 +953,7 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, struct net_bridge_port_group __rcu **pp; struct net_bridge_port_group *p; unsigned long now = jiffies; + int err; for (pp = &mp->ports; (p = mlock_dereference(*pp, cfg->br)) != NULL; @@ -858,23 +967,35 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, } p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, - MCAST_EXCLUDE, RTPROT_STATIC); + cfg->filter_mode, RTPROT_STATIC); if (unlikely(!p)) { NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (*, G) port group"); return -ENOMEM; } + + err = br_mdb_add_group_srcs(cfg, p, brmctx, extack); + if (err) + goto err_del_port_group; + rcu_assign_pointer(*pp, p); - if (!(flags & MDB_PG_FLAGS_PERMANENT)) + if (!(flags & MDB_PG_FLAGS_PERMANENT) && + cfg->filter_mode == MCAST_EXCLUDE) mod_timer(&p->timer, now + brmctx->multicast_membership_interval); br_mdb_notify(cfg->br->dev, mp, p, RTM_NEWMDB); /* If we are adding a new EXCLUDE port group (*, G), it needs to be * also added to all (S, G) entries for proper replication. */ - if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) + if (br_multicast_should_handle_mode(brmctx, cfg->group.proto) && + cfg->filter_mode == MCAST_EXCLUDE) br_multicast_star_g_handle_mode(p, MCAST_EXCLUDE); return 0; + +err_del_port_group: + hlist_del_init(&p->mglist); + kfree(p); + return err; } static int br_mdb_add_group(const struct br_mdb_config *cfg, @@ -967,6 +1088,7 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh, return err; memset(cfg, 0, sizeof(*cfg)); + cfg->filter_mode = MCAST_EXCLUDE; bpm = nlmsg_data(nlh); if (!bpm->ifindex) { diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index e98bfe3c02e1..368f5f6fa42b 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -93,12 +93,19 @@ struct bridge_mcast_stats { struct u64_stats_sync syncp; }; +struct br_mdb_src_entry { + struct br_ip addr; +}; + struct br_mdb_config { struct net_bridge *br; struct net_bridge_port *p; struct br_mdb_entry *entry; struct br_ip group; bool src_entry; + u8 filter_mode; + struct br_mdb_src_entry *src_entries; + int num_src_entries; }; #endif From patchwork Thu Dec 8 15:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068542 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15F0BC3A5A7 for ; Thu, 8 Dec 2022 15:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbiLHPaz (ORCPT ); Thu, 8 Dec 2022 10:30:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiLHPaL (ORCPT ); Thu, 8 Dec 2022 10:30:11 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2084.outbound.protection.outlook.com [40.107.101.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 762EB786B5 for ; Thu, 8 Dec 2022 07:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DBVvLtMRMUENAXWIvbn310TaAwGAivn5s+JOYk4jibFDyZ1P6/Wfn7nxYo7C02VOM8Gfhm9zcRv/myV04KpPmWh7YLnWpi8t3lny5Ng3dw/PLRi00r810vviRbzEbe+ndyooOVrLN6h5uov9fTJUm2zX6MKzYWwdtE6BdvlMeELPih7mvgEP+SOoY5xTugg+bBIB4P0iRBD12JKgMrUEtDjA/jZY7t7JwrHubiorkhLP0JzjBhzeD2JYGVmMlJmabNkpIUHwPilxIJ80yvgXcxDTACHkuKFEQ4mbN1XuwdueySmTpBy//NyK+IlXCYy+xvqhisnw1SaKpeHROxKuZw== 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=nm0nGdTIaY0iPhJEbacVPosa63k+O8ffNGAof5QYF6Q=; b=iy624Klyg6erjCs7r8jPbKnNQa1//rJ2a3HRQFTkuH0VRehHyUCc6lnsB1GVlX+TUXJA5jcJh9skvnHo6FZjFpX9cPO1rDlw+prHQHGnZy4CHpL/MUQlTbSbqvAko4WA3D+uZpCreGn2e/sdoHBoWsD2ZZvA7UmjY2Jh4mn0/FV20eQyB1lF/1TuETqwFXLOzn0unoLOAItMZdqYjXTqsXwtZStz8t/QJvjWWAIaM+gzc6Pv7CCmIgXbj98hVTn4dk20wzS9TGqqlSqJH316B2odaFpzDxN8wUDaWnw/HH9t6nNPNcFcS1oZpvUEEKZUqQUwZt+HQzcU903YuzGNfg== 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=nm0nGdTIaY0iPhJEbacVPosa63k+O8ffNGAof5QYF6Q=; b=oYqpBRIqbo1geD0UeETYjkYKX1oIt0Rb+XehdK3roHaqpauuPH2Gk4z6qbevxXn86TTMA5ipYzDflsggLKJEZ4n0Gvz/oh9o+LAZ3Wh37G+f1ijt0eZuA8iYZO50o4Rs2HraKWAGqLsmTJ8lEvb0GDmdFi+kS3af/fJ/mRf5bn5brTFIaXeV2VdpU8UBv6op09CAQRAGZG+f6Cbe3vpQo9k6TufCd19p92wpnhPNmCTnjXzNPewQN/0ZDRhR5/yq7QsPWkKLu9k4A6bsV5SXFItns34Etimh+34BSX33XjtjUt5jZOMT65XP+jEVdczuLmpPN4Sm/bWi41fLiwUjzQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by CH0PR12MB5370.namprd12.prod.outlook.com (2603:10b6:610:d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 15:30:06 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:30:06 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 10/14] bridge: mcast: Allow user space to add (*, G) with a source list and filter mode Date: Thu, 8 Dec 2022 17:28:35 +0200 Message-Id: <20221208152839.1016350-11-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR03CA0067.eurprd03.prod.outlook.com (2603:10a6:803:50::38) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|CH0PR12MB5370:EE_ X-MS-Office365-Filtering-Correlation-Id: d444c916-c998-42c8-dc0d-08dad931153e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QRrRAp8+oeMRvsWM72qne+X7bLPqrY8LbRioQ9gyuZUmN4umACkC7FmsgRQfwiNuBUkVoeDZqrV/o6ThuG1TYgT+Ow6GqavnJzV99AIEewiPTBlfL8nco85YAv1vpmy4o4NXCMRjjppGb6vPgUj5bnaUIfI4d1flQbWjkDzRPTOGzEsUcED8WHu80g/ddxWDTWvDaZpfJAADfN1J4lK+iY5MkDb76xfFtamOC0P17Mw1UbO0Py7XjjcB9BzyYjfr/0Rp1oWCUh+Lm68TYc3N3RC7giEiGtY9aQkrzKCB0EhjhpIGDI5Flczu1/l/MBiW+BrWa2ysBgNpowCT5LLG7MvzqHaJQlCXLPldOHGybtYGJdLLTvIVXIHdm5ElPgq7f+/Y5oLBfj06mv+o94RU5cuD2elN/tGgSZYWKT42VRrg1kd+Fz5TmEz9O5rWhvRYkf/YJwT08TcaOAvaIOxi10Boy0PdIhx+4XLPMXry60u5IiaILugzmg1FoucI60eg4P0WGognQ7XsAUeS1Ub605OL8XFsSHkKaslN3ztwxsjKHU1uScEBqIrolrM4Ww7yuKvqJ+lYQww8W35FRqeo48GwveZ4hKpe7YjRAbZDauKHU4faH7S9btvT2Q4cLd1YvVVCB9/qD4Thr+dNFxoSyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(136003)(376002)(396003)(346002)(451199015)(36756003)(86362001)(41300700001)(8936002)(66476007)(66946007)(4326008)(2906002)(66556008)(8676002)(38100700002)(83380400001)(107886003)(2616005)(316002)(478600001)(6486002)(1076003)(6666004)(6512007)(5660300002)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ur6jZOFt6tED7xVVH1USgmz1d0hFVQthXJOtGQ5QOgCJ5vGPVW9apXszXRUBfCOMDf8bhPSne4VumftIRo5pOf9iHnrXV+cQZ4jmncYC4xosOF2qjGd5HqXPnBbP0g+moYaxH/2cqPb4zP8zn4HI/EAP93gnsxekmcJgoSRUIxKjWgrvcLLbnPzmdTOz3+/fw/t78552uFP61oivPOzUxrR5em2W2tcmHltad35vGYvJKooCBWoqjh/LUP6qQiIpitcEx/NPXm7XHpSijTcRyCuuXFo5rEgnbT+wCg4yrgXmaNPETWjlxhoZY4A3YhKbOE4wazz5m/X014dulz0YpSQcNw6GaxIA4FSfIf+fMo3AWTCPtEGbWfsa1L2EouYcmARCrLldN8U7JOL/uE75Z13TfocRzi7h5iSSJYg94KpK8vYSJFzyfB/h/vlhDcdvosMR0FSp0jZeqa83Og/QT0UtN6De2KRDa6jtwvXqTdYY2xeQETwV9SZCPp7GYCPIl45KMD57+8ISxUk9sOneWZvTwlsDV/1ZYs8wLIVm66+6bGlStW+nNiZjtPwlKrHDSVx6cusSptYahF1RVmyWaoYA0NenwYEXDJ3CGC0eHV/suZ6vlMDztszkHZTJ/Pr8jLQIYGm3Kzlcy9yRMMg5UEPlRUteATIUVT1E+zWl/GmUd2/3WakQbH0SQjbzaXtsGbhNCMAhpR57QeWbO+YceYYM8MLB9eLn3s3WwTeM828gSFVMHGeur0HCjFE9m3UVeHR5EqF23x6QGfF/T5OK/N91A7LwJBjQe+7/r2/9+jPjpmJKetyiLpy42v5ni5YlcwEbkqVfb4yzu5mCXhnA3UXiFUTqK0S9B1yDzBuW0ArHrQt7qad61nMOwcj/TWOjZJpg7FETWyFvFZP1HgxW7eaz+tmlF1mzJn8wBXCO+dc/SipPsiTIvOXUiaoHkqeQSKTsMzquc0NVW6Ov9MI0LkD963nCb318h/XaR9QFekBbdXaITP7UBH9rfO2fLrxgMa15/HvXMOcPG9BK1P2MmIurFsJ1+8uPQZsIlBvEIl6/T9/bfKtJbeQWwDt7kr0rB9UUMqpYK/e69oFR90M3SgMxWf5NhiaYzMVYC6g7zd+/EuzIqwrzi1F7fljpO9MbpJcJoSQOH2V5vE32VBn6YyNne33Q9vniiz9c5SgcFrDpgHolFtmoIsNDF9TpETTH9LYz8gsOYBBuv4BC2nUT245gll0Ay1JnnqfBoapIoJ1p46se/zbv78zuW/iwTp2xkq+0XF03yN1qHSWcmtZRnD/Dr9im0mUq9S4remtQOQplIKnjNIruSHVqALL+fTylXvUpjRcruRSPpJx8lJW10EA/kkve4rMOM24t8hDMRV56tNM44BgFeVqr5zPAKjFZDbIasUxaaPUAzX9rCib8GRZ+6UyrRsWVlj0Jp/Jj2Mwk4l0W+jvf+t7U1R47+HgbBs+MPIVRYDuXs9CBuftwELgxM5ze92YY9zDuJucUtEA+IO6o0ZqTxFGuLoGHGQX8Bw+NP+UMBTUDPFAioP+Yv6nY3krh7Tc4SQdHry7koA33KdiJq+5Rxa2KZdtHG7sY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d444c916-c998-42c8-dc0d-08dad931153e X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:30:06.2549 (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: joX0+B8/G9cT/UCnjhDvFzwaeF9iQfMIYt5CnAiR7R2omOVzCGmNidr80RNhOmIT6rCgUKgQqz/+BIlXzyIpvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5370 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add new netlink attributes to the RTM_NEWMDB request that allow user space to add (*, G) with a source list and filter mode. The RTM_NEWMDB message can already dump such entries (created by the kernel) so there is no need to add dump support. However, the message contains a different set of attributes depending if it is a request or a response. The naming and structure of the new attributes try to follow the existing ones used in the response. Request: [ struct nlmsghdr ] [ struct br_port_msg ] [ MDBA_SET_ENTRY ] struct br_mdb_entry [ MDBA_SET_ENTRY_ATTRS ] [ MDBE_ATTR_SOURCE ] struct in_addr / struct in6_addr [ MDBE_ATTR_SRC_LIST ] // new [ MDBE_SRC_LIST_ENTRY ] [ MDBE_SRCATTR_ADDRESS ] struct in_addr / struct in6_addr [ ...] [ MDBE_ATTR_GROUP_MODE ] // new u8 Response: [ struct nlmsghdr ] [ struct br_port_msg ] [ MDBA_MDB ] [ MDBA_MDB_ENTRY ] [ MDBA_MDB_ENTRY_INFO ] struct br_mdb_entry [ MDBA_MDB_EATTR_TIMER ] u32 [ MDBA_MDB_EATTR_SOURCE ] struct in_addr / struct in6_addr [ MDBA_MDB_EATTR_RTPROT ] u8 [ MDBA_MDB_EATTR_SRC_LIST ] [ MDBA_MDB_SRCLIST_ENTRY ] [ MDBA_MDB_SRCATTR_ADDRESS ] struct in_addr / struct in6_addr [ MDBA_MDB_SRCATTR_TIMER ] u8 [...] [ MDBA_MDB_EATTR_GROUP_MODE ] u8 Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- Notes: v1: * Use an array instead of list to store source entries. * Drop br_mdb_config_attrs_fini(). include/uapi/linux/if_bridge.h | 20 +++++ net/bridge/br_mdb.c | 130 +++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h index a86a7e7b811f..0d9fe73fc48c 100644 --- a/include/uapi/linux/if_bridge.h +++ b/include/uapi/linux/if_bridge.h @@ -723,10 +723,30 @@ enum { enum { MDBE_ATTR_UNSPEC, MDBE_ATTR_SOURCE, + MDBE_ATTR_SRC_LIST, + MDBE_ATTR_GROUP_MODE, __MDBE_ATTR_MAX, }; #define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1) +/* per mdb entry source */ +enum { + MDBE_SRC_LIST_UNSPEC, + MDBE_SRC_LIST_ENTRY, + __MDBE_SRC_LIST_MAX, +}; +#define MDBE_SRC_LIST_MAX (__MDBE_SRC_LIST_MAX - 1) + +/* per mdb entry per source attributes + * these are embedded in MDBE_SRC_LIST_ENTRY + */ +enum { + MDBE_SRCATTR_UNSPEC, + MDBE_SRCATTR_ADDRESS, + __MDBE_SRCATTR_MAX, +}; +#define MDBE_SRCATTR_MAX (__MDBE_SRCATTR_MAX - 1) + /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */ enum { BRIDGE_XSTATS_UNSPEC, diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index e9a4b7e247e7..61d46b0a31b6 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -663,10 +663,25 @@ void br_rtr_notify(struct net_device *dev, struct net_bridge_mcast_port *pmctx, rtnl_set_sk_err(net, RTNLGRP_MDB, err); } +static const struct nla_policy +br_mdbe_src_list_entry_pol[MDBE_SRCATTR_MAX + 1] = { + [MDBE_SRCATTR_ADDRESS] = NLA_POLICY_RANGE(NLA_BINARY, + sizeof(struct in_addr), + sizeof(struct in6_addr)), +}; + +static const struct nla_policy +br_mdbe_src_list_pol[MDBE_SRC_LIST_MAX + 1] = { + [MDBE_SRC_LIST_ENTRY] = NLA_POLICY_NESTED(br_mdbe_src_list_entry_pol), +}; + static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = { [MDBE_ATTR_SOURCE] = NLA_POLICY_RANGE(NLA_BINARY, sizeof(struct in_addr), sizeof(struct in6_addr)), + [MDBE_ATTR_GROUP_MODE] = NLA_POLICY_RANGE(NLA_U8, MCAST_EXCLUDE, + MCAST_INCLUDE), + [MDBE_ATTR_SRC_LIST] = NLA_POLICY_NESTED(br_mdbe_src_list_pol), }; static bool is_valid_mdb_entry(struct br_mdb_entry *entry, @@ -1051,6 +1066,76 @@ static int __br_mdb_add(const struct br_mdb_config *cfg, return ret; } +static int br_mdb_config_src_entry_init(struct nlattr *src_entry, + struct br_mdb_src_entry *src, + __be16 proto, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[MDBE_SRCATTR_MAX + 1]; + int err; + + err = nla_parse_nested(tb, MDBE_SRCATTR_MAX, src_entry, + br_mdbe_src_list_entry_pol, extack); + if (err) + return err; + + if (NL_REQ_ATTR_CHECK(extack, src_entry, tb, MDBE_SRCATTR_ADDRESS)) + return -EINVAL; + + if (!is_valid_mdb_source(tb[MDBE_SRCATTR_ADDRESS], proto, extack)) + return -EINVAL; + + src->addr.proto = proto; + nla_memcpy(&src->addr.src, tb[MDBE_SRCATTR_ADDRESS], + nla_len(tb[MDBE_SRCATTR_ADDRESS])); + + return 0; +} + +static int br_mdb_config_src_list_init(struct nlattr *src_list, + struct br_mdb_config *cfg, + struct netlink_ext_ack *extack) +{ + struct nlattr *src_entry; + int rem, err; + int i = 0; + + nla_for_each_nested(src_entry, src_list, rem) + cfg->num_src_entries++; + + if (cfg->num_src_entries >= PG_SRC_ENT_LIMIT) { + NL_SET_ERR_MSG_FMT_MOD(extack, "Exceeded maximum number of source entries (%u)", + PG_SRC_ENT_LIMIT - 1); + return -EINVAL; + } + + cfg->src_entries = kcalloc(cfg->num_src_entries, + sizeof(struct br_mdb_src_entry), GFP_KERNEL); + if (!cfg->src_entries) + return -ENOMEM; + + nla_for_each_nested(src_entry, src_list, rem) { + err = br_mdb_config_src_entry_init(src_entry, + &cfg->src_entries[i], + cfg->entry->addr.proto, + extack); + if (err) + goto err_src_entry_init; + i++; + } + + return 0; + +err_src_entry_init: + kfree(cfg->src_entries); + return err; +} + +static void br_mdb_config_src_list_fini(struct br_mdb_config *cfg) +{ + kfree(cfg->src_entries); +} + static int br_mdb_config_attrs_init(struct nlattr *set_attrs, struct br_mdb_config *cfg, struct netlink_ext_ack *extack) @@ -1070,6 +1155,44 @@ static int br_mdb_config_attrs_init(struct nlattr *set_attrs, __mdb_entry_to_br_ip(cfg->entry, &cfg->group, mdb_attrs); + if (mdb_attrs[MDBE_ATTR_GROUP_MODE]) { + if (!cfg->p) { + NL_SET_ERR_MSG_MOD(extack, "Filter mode cannot be set for host groups"); + return -EINVAL; + } + if (!br_multicast_is_star_g(&cfg->group)) { + NL_SET_ERR_MSG_MOD(extack, "Filter mode can only be set for (*, G) entries"); + return -EINVAL; + } + cfg->filter_mode = nla_get_u8(mdb_attrs[MDBE_ATTR_GROUP_MODE]); + } else { + cfg->filter_mode = MCAST_EXCLUDE; + } + + if (mdb_attrs[MDBE_ATTR_SRC_LIST]) { + if (!cfg->p) { + NL_SET_ERR_MSG_MOD(extack, "Source list cannot be set for host groups"); + return -EINVAL; + } + if (!br_multicast_is_star_g(&cfg->group)) { + NL_SET_ERR_MSG_MOD(extack, "Source list can only be set for (*, G) entries"); + return -EINVAL; + } + if (!mdb_attrs[MDBE_ATTR_GROUP_MODE]) { + NL_SET_ERR_MSG_MOD(extack, "Source list cannot be set without filter mode"); + return -EINVAL; + } + err = br_mdb_config_src_list_init(mdb_attrs[MDBE_ATTR_SRC_LIST], + cfg, extack); + if (err) + return err; + } + + if (!cfg->num_src_entries && cfg->filter_mode == MCAST_INCLUDE) { + NL_SET_ERR_MSG_MOD(extack, "Cannot add (*, G) INCLUDE with an empty source list"); + return -EINVAL; + } + return 0; } @@ -1162,6 +1285,11 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh, return 0; } +static void br_mdb_config_fini(struct br_mdb_config *cfg) +{ + br_mdb_config_src_list_fini(cfg); +} + static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, struct netlink_ext_ack *extack) { @@ -1220,6 +1348,7 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, } out: + br_mdb_config_fini(&cfg); return err; } @@ -1295,6 +1424,7 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, err = __br_mdb_del(&cfg); } + br_mdb_config_fini(&cfg); return err; } From patchwork Thu Dec 8 15:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068543 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0C37C4332F for ; Thu, 8 Dec 2022 15:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbiLHPa5 (ORCPT ); Thu, 8 Dec 2022 10:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiLHPaP (ORCPT ); Thu, 8 Dec 2022 10:30:15 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A990D78691 for ; Thu, 8 Dec 2022 07:30:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PCEToS4rZl7BKG6/o6udh5t/bssbbiP9mvSffJrrV6KxeVZqACzeP4t01cOkcwc4mlhrdMEsIMY3/cq9v9xUrTLtTKolTyI7sgg/wrl09EYxpihE3quxIxfKImUy6x/oRYgq68SdvQqym6G/h8UoII1lXuDyoN5j2j0kuzenTvAQHaeJE6l3ym4630J4V3g9S5HUibvkvOgr5m/GTentRT5/NX/tGXp5KV/tPTILFIB0QIBWbk04QyipeftYNsMkv/F6bNWAs0lrXczIvhfkPWGXcPIlPLUc71hl8srk7m+yVIo4ze7WN2hdSwSMDiDIIczcR322YcSaF/K2S82vWA== 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=j9o/bF6xuTdH6T3TYMYoUxE4lUviYjclDl822kTUzak=; b=EC8Op3hwF5TuXbDZUIcpTL6hkthVd0sZXanxc2Jb0SMPNqedcdwK1oaDNdVI8fLe36/UV0JaqlyqBhy2KIt4a7hP/Nb+uTplW1t7HnueIfzNKv62juyVq90mWNO43dq7urIH72m/xkM8xD76lRUeB554WXCi0GCu+1z8Qry771v9OthS0J7sZCfK9CJOhXCQcefDnTeUKRnaa9ebifnVX5814Z2QRlV2PHK6iXHqpfJXq97D1B7+0r9LY5ZbNxa/OaO1YPxddOsN4haLodLAzjVXBuIKwxqcZwc+IJ0hz9IlBHpaVaOqEiZmdBrHowjRlyJgXeFbrU6t1xUiy5zjKw== 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=j9o/bF6xuTdH6T3TYMYoUxE4lUviYjclDl822kTUzak=; b=fBZE7WZFS4WYMZTPz8e2UcgJ3vbMCDjpi1HKPpyS15K25I0a3bMu++3FyG3g5QPvuek2pu7Yhhi74EyeSDGfBQMKKPJgWI5ohYoZ/a07/Y1hULcC0c0q7MYnGujJIWEJl7oIjVfm0kAatn+1L+dsxI+yknDzgfOEo5MkNwx4yBOjaHLDf6P2zOcPoStKnvbgKMUh7F5Se+qg59aRRluAjelcAaki9rtttqnyvDmX+yQqkEj5m+aRg2/I93QT/GKY8rFxEYGMeX31Dvenj6S7DOwS2FFkSM/NICIHvmAc0m5NM9YFqQGEmvE7CAZDt0CDhCjCREW8++k57LCcJ1F5ag== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by CH0PR12MB5370.namprd12.prod.outlook.com (2603:10b6:610:d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 15:30:13 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:30:13 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 11/14] bridge: mcast: Allow user space to specify MDB entry routing protocol Date: Thu, 8 Dec 2022 17:28:36 +0200 Message-Id: <20221208152839.1016350-12-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0701CA0026.eurprd07.prod.outlook.com (2603:10a6:800:90::12) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|CH0PR12MB5370:EE_ X-MS-Office365-Filtering-Correlation-Id: 81d685b2-db5c-44d3-0a2b-08dad931195d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v7M9fyOyagwe8Hse2vfAg8e5OmMg+nkn584X2InzYCgF+ktA/nwD05S8QlMWyUDkLYX9Vyq7ZZ/ravZzGLVaa9rpKhQMyQCm5V+5AXu9hjzCHB0Qugpj5OiJT9sqW48xjqt+doqUcD5CuvquGl6PrhiJ2Czt+7uveTpwDufmN6FvcrhvMBbCSnVJH30JN9fBCKj837qLuNwoQi2FE1kj+8fz6I6nqEZy7OAW4fxmaPJq8tDHn46dCdLfJlFYOaBcUUXlK+dkqgNOSce9LPItYNPf1FL/mishSEs1j1a4hzEaS2AJ8Z4iI928M3fZdvzKHYumbD5GfqApaGBmPN02Yu43nRIbYKPgjSX9PdUN759R7D/c2orSje1sq9EaIOM/Fj2/Geoh1QkID21WN2TZLNeYRdo0z+yFSPna3CPtlSG3NkM/f7UA6bgDG6DI1bKhYBMt4l0fu6XIZDiQ9Fg2x7oc0bCxBEhow7MW+exRBrA5PQcVpuUzDsjRsPBR+lAmNcY4K2MkS7jxMfpZ5BQGZaNJQk3UkzzCpGEOMv2cWkFuek08+zXXBgixtjy7YnCEpAAqIG1LGdCsKvoXfWcg6aAYUmUuRSrjto7GSEltJsaj1LY1QeljYlLnFnfF2jnVznZkDw/S3AK5JxBikMr47g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(136003)(376002)(396003)(346002)(451199015)(36756003)(86362001)(41300700001)(8936002)(66476007)(66946007)(4326008)(2906002)(66556008)(8676002)(38100700002)(83380400001)(107886003)(2616005)(316002)(478600001)(6486002)(1076003)(6666004)(6512007)(5660300002)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hL9AhsqCjzrQmvgS301vmOA3I/ssP95IhzPBaJBuslaWt7clUc/qAI33YMDfC1+2XeaY6bUwsr1F55fS9eVtosf6T+L9NSstYSSlvxR3AmUw5xQYtHtaLr1J8p6QMNJ5fsDA08ukeJ/Opi1tMclxl7i/a8yX9e8gQo5hi5rldsAU5ob86apnd3uxpPjli7YUEq7WjWuhXDPpuG+mFATXgrITzydk2/4lPJ+FTuZlMwSQ9NiBZdpQ25g5gVFVmeRkhE3hlpFAt5ye6rN4lwry4HP1fmczkYyYgNuKUASBWJAclLFUWOXxv105HGaHhq5M8l9JpdwJKa9CKIj0oWiY9DdnmtaZ5SXnGTHrcGhAW+nOGwDo/LZdlQXkWgQSGuqPY2ANU3Wy6wLCxmOrSYCKHhgqkEX3xw3cWVdS+hCwMve/M7+EYqHzpaHLy2kUpXgN/LE3LFsvwFBC65Dg6MYL/9L30cLLQAHHB6RI/XuoYP0vjke9PBUvu/tQyDpPU+zXzlymazL9XEwp1+VefnSlkH9Uf05Bhzm7WHUJR4a1gWRrs1vDb8RQ7ThAhV4++Q7GkS7uZZsSgOchvCOzlY4RN1Zm3MX3qwyYhEYMTx4BlepgT8IDYioJjujlVFZidDD7XpFVUFzBz4nJQrRTiukuTCRsAt/A51FHUJ+mGFM9KYnrcLIw4jwcXkuwaEUKP+TLnHQz35qdDYKD++gUxy9XNz02T55zDuHj406cfDPUz73eHvCOaGmSgM90GoUJp/cYKGefI4w+51zzW9OAzSVt0IPP7iQw8HzCNlGLliSvAgw4262kN3dSobK4o42UUBqvVZjX1cSscrrult0cTNfuw4ckdGs2oRE4QQfOmbNyaEoUtTODRJ6FfOK0E8yyr0Ttbi+MA0v7XpM63ahqbwHPxSzKlfd2VAZYm9+LBpvsJhe1jrzlFXPNGXvRUCDCV0s8r6rrnbj/gwNswccgjNHYVISHWjmtgt/N7OPgcOD8jdBsORQ4pboPrP+Hzxf98K9yBOoV7WkGT8qcxp3H4CXcXDPV5inKlxBkLnqGB5BLN+7RIDsMOX4vNhmYy2mG0ZZs3qIXOtmmO4/dFsS3uqKPzhR02MxYSCy+ZVD+2qYWCZ6l+NVxKH1JpcN6gFVIJXY1xTbE9/QrlaP1Hx9cKaA7LlXziL9C94W5Cy2n1fUPeiS+eUdCz96f8bDNLkIm/1oc9i9aI2tyBKfzjhFhS2Nh6cJ3z6o52+FLIYva93IFd8UCRwEjfQp05d31QBJE9OIDCKxqlfzYRHqHCC0z8AgQzXsKWY5bzudxMjH1+FBN1veU8JpwXwJmMkLG/fOn2LKbDEzVAoPQTtcBW8DSEIMUSxh++E4exfufxQR15p+YSL2oLikThYNjk5/VaN6roRfqe4a3KFh7IwrjanyEkVOiwK5VCi9jSKC8RkbZQJryP45Q9mOT3j7/cBThgTTpDOX5RWaCi90L2JzR4u6Gr3RZBlGchVNbb1WAHaQeuNWnwANszd4IlKuVCFaahpAUiJvdJH2gYImfHqZtOGo0totuADGsETHAbh9WVnqbdhGnTUOYhPyvYD/C5HWerRGdIXT2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81d685b2-db5c-44d3-0a2b-08dad931195d X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:30:13.2260 (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: bthkLPrugq0xdajcRlH+oWagenLReZbMgFNmmvftF0g2Lo8XmPxNoRrE1ulrg1YdvgrQB9480ROdvQFgsliI+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5370 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add the 'MDBE_ATTR_RTPORT' attribute to allow user space to specify the routing protocol of the MDB port group entry. Enforce a minimum value of 'RTPROT_STATIC' to prevent user space from using protocol values that should only be set by the kernel (e.g., 'RTPROT_KERNEL'). Maintain backward compatibility by defaulting to 'RTPROT_STATIC'. The protocol is already visible to user space in RTM_NEWMDB responses and notifications via the 'MDBA_MDB_EATTR_RTPROT' attribute. The routing protocol allows a routing daemon to distinguish between entries configured by it and those configured by the administrator. Once MDB flush is supported, the protocol can be used as a criterion according to which the flush is performed. Examples: # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto kernel Error: integer out of range. # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto static # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent proto zebra # bridge mdb add dev br0 port dummy10 grp 239.1.1.2 permanent source_list 198.51.100.1,198.51.100.2 filter_mode include proto 250 # bridge -d mdb show dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.2 permanent filter_mode include proto 250 dev br0 port dummy10 grp 239.1.1.2 src 198.51.100.1 permanent filter_mode include proto 250 dev br0 port dummy10 grp 239.1.1.2 permanent filter_mode include source_list 198.51.100.2/0.00,198.51.100.1/0.00 proto 250 dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto zebra dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude proto static Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- Notes: v1: * Reject protocol for host entries. include/uapi/linux/if_bridge.h | 1 + net/bridge/br_mdb.c | 15 +++++++++++++-- net/bridge/br_private.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h index 0d9fe73fc48c..d9de241d90f9 100644 --- a/include/uapi/linux/if_bridge.h +++ b/include/uapi/linux/if_bridge.h @@ -725,6 +725,7 @@ enum { MDBE_ATTR_SOURCE, MDBE_ATTR_SRC_LIST, MDBE_ATTR_GROUP_MODE, + MDBE_ATTR_RTPROT, __MDBE_ATTR_MAX, }; #define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 61d46b0a31b6..72d4e53193e5 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -682,6 +682,7 @@ static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = { [MDBE_ATTR_GROUP_MODE] = NLA_POLICY_RANGE(NLA_U8, MCAST_EXCLUDE, MCAST_INCLUDE), [MDBE_ATTR_SRC_LIST] = NLA_POLICY_NESTED(br_mdbe_src_list_pol), + [MDBE_ATTR_RTPROT] = NLA_POLICY_MIN(NLA_U8, RTPROT_STATIC), }; static bool is_valid_mdb_entry(struct br_mdb_entry *entry, @@ -823,7 +824,7 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, } p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, - MCAST_INCLUDE, RTPROT_STATIC); + MCAST_INCLUDE, cfg->rt_protocol); if (unlikely(!p)) { NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (S, G) port group"); return -ENOMEM; @@ -881,6 +882,7 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg, sg_cfg.group = sg_ip; sg_cfg.src_entry = true; sg_cfg.filter_mode = MCAST_INCLUDE; + sg_cfg.rt_protocol = cfg->rt_protocol; return br_mdb_add_group_sg(&sg_cfg, sgmp, brmctx, flags, extack); } @@ -982,7 +984,7 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, } p = br_multicast_new_port_group(cfg->p, &cfg->group, *pp, flags, NULL, - cfg->filter_mode, RTPROT_STATIC); + cfg->filter_mode, cfg->rt_protocol); if (unlikely(!p)) { NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new (*, G) port group"); return -ENOMEM; @@ -1193,6 +1195,14 @@ static int br_mdb_config_attrs_init(struct nlattr *set_attrs, return -EINVAL; } + if (mdb_attrs[MDBE_ATTR_RTPROT]) { + if (!cfg->p) { + NL_SET_ERR_MSG_MOD(extack, "Protocol cannot be set for host groups"); + return -EINVAL; + } + cfg->rt_protocol = nla_get_u8(mdb_attrs[MDBE_ATTR_RTPROT]); + } + return 0; } @@ -1212,6 +1222,7 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh, memset(cfg, 0, sizeof(*cfg)); cfg->filter_mode = MCAST_EXCLUDE; + cfg->rt_protocol = RTPROT_STATIC; bpm = nlmsg_data(nlh); if (!bpm->ifindex) { diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 368f5f6fa42b..cdc9e040f1f6 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -106,6 +106,7 @@ struct br_mdb_config { u8 filter_mode; struct br_mdb_src_entry *src_entries; int num_src_entries; + u8 rt_protocol; }; #endif From patchwork Thu Dec 8 15:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068544 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94ED6C3A5A7 for ; Thu, 8 Dec 2022 15:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbiLHPbD (ORCPT ); Thu, 8 Dec 2022 10:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbiLHPaX (ORCPT ); Thu, 8 Dec 2022 10:30:23 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2041.outbound.protection.outlook.com [40.107.101.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9114675BCE for ; Thu, 8 Dec 2022 07:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C7qodJh+1CthwB8/8bm87PKgZyrjWQ2GRSfGC4hx70ph178YP+eyfCICXHscMD2/rleIyU+LB7vTXbnLq/cxl4vHNQoSi+W5/eOZkKwEDITRsXPkFmlwZuTFihree5qhgzErPbcKlj8ZP8H7CLYIESfMLHBqxR5GO6qQnJc5K1P5dK/aKhlxyCfXkpRFeUCq3Ph4q7Mo3Bjl2RYJuZ1fJfqiMS/sU5K8zvCgCZ5mlYVSRN7tfCNALYeEVpBjdsdnjkgVJNBWjyuvbUvPSxVMp89/A9Iblv1LFWkP+aLfcIIjDsYvbMH46E0zop//HLAI7hIpCs9FU/DhWbpHfCrKKw== 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=4soViMJUb22F2vazP9wlvyc2PLRw0/kLOnzMWY0GrJA=; b=LyWDgA37IJm5U3vyh1zCkyN1zzMsC5pAkWGtqWfJYuELZbrJSOLB8+sRUSL1Vcdtkv30GW5emxJ7kkG4WjfFsCm0Fiqkg4/XbPntD2rHPkoO2NYuEldjssA1vdpcMtQaYeKyhZU/vmB9RjlFwPZMBa0gpicSGpRCBwJuiCMV/SdFwJ2qYdCMXstQds2MjdzT2NPH8ywo5RxQp/ti6iZFnve3/dVRjvpU6wrEhnz1vADyKjLALRagw5Pu4fr0V/RDZH67Y/bnvLapwn/A42X4TxxZFRpLYwMXaW/kxjO3XnmxI8E2/DoK67DOWp2ZvGSAD7FJukGd2FX6wpv3LoMtnw== 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=4soViMJUb22F2vazP9wlvyc2PLRw0/kLOnzMWY0GrJA=; b=hGBaRyGo6FfD2FkwM65FLee2e3Tv4viau/4RD+4Lp6RpHCtPpbfIcsCZR8hgw6Gsv2IIee0ya8FJZDRp3vkl3KYJNcwUZZZ7r+oMYQxq9iABhbaWVhEhnbbPeLh286pjXkR7SQHhDUwCyNLgpI+PcoqyN1kkE5w6Ni2NVzQlaABqRoTLUg9IHlg1tzI6I5OS4OlbXKJ2NctempMosUZ+fLuwI//pF5K7rovFCGoOpppRidsLAxEMj3JZ+VlfpVXJPU11v6bSOF5Miv8BHWTNcO62inzI25q3AHEPcIXxYA0p61MBfV7xgFHYvvtMM4PrZu9BUIfihc4uat0SSbaT8g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by CH0PR12MB5370.namprd12.prod.outlook.com (2603:10b6:610:d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 15:30:20 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:30:19 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 12/14] bridge: mcast: Support replacement of MDB port group entries Date: Thu, 8 Dec 2022 17:28:37 +0200 Message-Id: <20221208152839.1016350-13-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P190CA0043.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1bb::6) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|CH0PR12MB5370:EE_ X-MS-Office365-Filtering-Correlation-Id: ff5bb8cc-450a-4f37-ac32-08dad9311d33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P37+4rkFvLrAwXL2i7D074+dOXg95dONnK+G7D8kjxCYJ31DoGTLTkn7/UlwhP3cig8pP8GUzCL93dOWyB0+7Pwc9fOACKU2mekgh+vJgfUiW41B2COZgpjtnibwdJqXHtR8o0yKchXmsZblPWQjkBPiImxM1aMjvSyGQcH74B371HNP29pOF9asfb1r4SnNQ4sVg1RzLJ4vJ7S9UnstB+Jojc/LlyzGdcjc1eBBDgqlrG0kHotjK56Qt77uHxHHA8gW6dhOuSt5c9pyfb9VzIR9JoHvKRgxongwfAc0hyQa2D/SvavV1AmjDo6rbvOTcpEmKMhhbb7vHvqhLxH2ZHZPNWZjo59KiNwj7TptOHLlCCJ7pFI3EpZu/4heqVOxjKjwmKg78LEdlxcOhIIZ+J4bCFDHFocU9kuZVVzglIvqRnCkmGKVoq7TwzRvdKSJq7jzFJfpc9staFxsXDLuyFqJrkH+sQUYYL97prsFFvBUrwjgtP3q1eQ3pgtcjyy3TiKcb192qSOiIlJe4UVwabD7KUEGBUO1bb2CmVZzyQE0AcckjZdT2T9ML9feZQstqmLUI3G6SNBtxZLJTRBLh+bjVmYPrUlGo/cWSruLjgi1VeHgwOVASm2H2SCuPZSeG2mdkkJDZitxFCDXUYzGvA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(136003)(376002)(396003)(346002)(451199015)(36756003)(86362001)(41300700001)(8936002)(66476007)(66946007)(4326008)(2906002)(66556008)(8676002)(38100700002)(83380400001)(107886003)(2616005)(316002)(478600001)(6486002)(1076003)(6666004)(6512007)(5660300002)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YXgU75Bx4tgOW0QInmxq8wgnhC+P2DesoJjCQ2fWQ04lu+GS6SBGSTcan3T4nwgx3bnaxyZDxe6d1sPywBOjAbfkFb3w5lAH2uieLJ/gm9QLALBVP41Cz+noFMa80O9K7N2+lDNYaw2aKwQ2dbJkLi6cjr5NDZu0X3L/Atvyt/3S0Um+0Xz3/JZRLqiWE7onYSTguyU8A7tnsHXh/H6DYqkkh3KrGmHOKjQUJZE8896MPxKuRGgfz9ISe2vsmhtzM3KP3HN2JG67T+Uk5vxj62qVdQzKGb6GOse6SVR3kQoRXo9hH3bTidQQzlkngwrfdEVlKKPjEN5HrTFlhL9Zd9eJjVJFdsp9KMwk21Vvkyzwifxl4qBjGCROr3LvUwpiinORo0W7hLS6pNxuG0nnEp7MlQWkxqj2+OXatGw4JUskdW1rlCl0tYziOwfEsjN+WrefJd681LVxgu1YrSOpvJGCjdrlYdZMzUEbyII1tOGPZa7cqV+5v4GEXXnRVvvic8Z+MDnDEuWTrwv1bHcdeeEJWtTiRAyOCWqm2F5L9s772+dTnrpS4dz+6d+URrfXKVM4o6jf8OyCYBlus+Jy15iwxe9Y/AqMRhtYec9aoMrigFifCaVSl23Hda+u7Cu+cggIJnqidEpgbxqUPWrUULF2PzWID2JH6c2hQoz4Zk2XvB4s9HbcjAiR08o57vK7SO256nNEHgshIwvAriIeB/uQKkWUfW9prc3Rdukf4nJblv/t1KYG3x/duzmgn0LariBYt1Wb7KhfMu0RE7i97lmAelvR0ht8B6+LCVeeTn0AJ3wK5Natx23qBkH22DwRQTTbPDIZ6ba9BQNPC8yYLeswsx9e4VJy9x2998m9+hfQFTPpdUYN6T5hKDuy7usk1O/99DKvVx9s3+doFAJ3xr/x1l9jiFvB52V1jWPR6SEcDKKAMWNc+h2m3+e55xACyEHY2QvNmd+5FUNBaSc5Wlew3cmEpAz2rA+wvmbdoktcDNg3JbDrnKxj9sXOSjucIIMpYGfDNGbfbROA10+lDezaguRwol+Laq1uJGWmP9pOU7TnjR9D0ohGwvpptIDk2MTgTlVDXFofKgk0LotJQmE40wBFfxCM5tfRNT7J0HLmh6TZasoYn30/fV3I2CDEsBobupAnVDVVprlFCtzNw4UR7L31/GFuOxGQx75b4IX0JqDwNHGRcfk33+IoXfbb4/CeRtwAkQhkADOAoYzpZdXa1pH6uO/SjHGCAy/thj87YPn0esnoBqa/HoLLcP+oc3FFjyUGsUHcoqDQ0h0jNOGgIo/QfB3GzfnWXA+sxpkfT2rB80L3lYwsLUK3gIzTC9BrYfgnml/K51ZsvPpquGAFX+49b1CI6wI0Y92dl8t1KLnInhGPxOdNbAa8PDk9aZNl8DtFg0dDiVWf9W0KR5ZOKDGy/so/HY1VfbwJE7QLr/Y9vlkTh3cruEnReJSevs4lwzdkjJK88XNe2Sz1NmsCVw7tUi0xdHRg/m40Pvg3I/exDL8cJlivWjNODQpPvyNVIlNt7SYL6TfXrUkn5gcRHPzR5Xh1PpRjTioyXTXHia5eMehIzV4TJw0PyomY X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff5bb8cc-450a-4f37-ac32-08dad9311d33 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:30:19.6177 (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: uCFgsqnlXx+Vu6vMIuz37lGU2N5J4ekpO9nn6goW1pvadykaqUyMIscSU9LWLbAPHkzaVwl7tc8qcg64yfsCHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5370 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now that user space can specify additional attributes of port group entries such as filter mode and source list, it makes sense to allow user space to atomically modify these attributes by replacing entries instead of forcing user space to delete the entries and add them back. Replace MDB port group entries when the 'NLM_F_REPLACE' flag is specified in the netlink message header. When a (*, G) entry is replaced, update the following attributes: Source list, state, filter mode, protocol and flags. If the entry is temporary and in EXCLUDE mode, reset the group timer to the group membership interval. If the entry is temporary and in INCLUDE mode, reset the source timers of associated sources to the group membership interval. Examples: # bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 permanent source_list 192.0.2.1,192.0.2.2 filter_mode include # bridge -d -s mdb show dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.2 permanent filter_mode include proto static 0.00 dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto static 0.00 dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode include source_list 192.0.2.2/0.00,192.0.2.1/0.00 proto static 0.00 # bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 permanent source_list 192.0.2.1,192.0.2.3 filter_mode exclude proto zebra # bridge -d -s mdb show dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.3 permanent filter_mode include proto zebra blocked 0.00 dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.1 permanent filter_mode include proto zebra blocked 0.00 dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude source_list 192.0.2.3/0.00,192.0.2.1/0.00 proto zebra 0.00 # bridge mdb replace dev br0 port dummy10 grp 239.1.1.1 temp source_list 192.0.2.4,192.0.2.3 filter_mode include proto bgp # bridge -d -s mdb show dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.4 temp filter_mode include proto bgp 0.00 dev br0 port dummy10 grp 239.1.1.1 src 192.0.2.3 temp filter_mode include proto bgp 0.00 dev br0 port dummy10 grp 239.1.1.1 temp filter_mode include source_list 192.0.2.4/259.44,192.0.2.3/259.44 proto bgp 0.00 Signed-off-by: Ido Schimmel --- net/bridge/br_mdb.c | 103 ++++++++++++++++++++++++++++++++++++++-- net/bridge/br_private.h | 1 + 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 72d4e53193e5..98d899427c03 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -802,6 +802,28 @@ __br_mdb_choose_context(struct net_bridge *br, return brmctx; } +static int br_mdb_replace_group_sg(const struct br_mdb_config *cfg, + struct net_bridge_mdb_entry *mp, + struct net_bridge_port_group *pg, + struct net_bridge_mcast *brmctx, + unsigned char flags, + struct netlink_ext_ack *extack) +{ + unsigned long now = jiffies; + + pg->flags = flags; + pg->rt_protocol = cfg->rt_protocol; + if (!(flags & MDB_PG_FLAGS_PERMANENT) && !cfg->src_entry) + mod_timer(&pg->timer, + now + brmctx->multicast_membership_interval); + else + del_timer(&pg->timer); + + br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB); + + return 0; +} + static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, struct net_bridge_mdb_entry *mp, struct net_bridge_mcast *brmctx, @@ -816,8 +838,12 @@ static int br_mdb_add_group_sg(const struct br_mdb_config *cfg, (p = mlock_dereference(*pp, cfg->br)) != NULL; pp = &p->next) { if (p->key.port == cfg->p) { - NL_SET_ERR_MSG_MOD(extack, "(S, G) group is already joined by port"); - return -EEXIST; + if (!(cfg->nlflags & NLM_F_REPLACE)) { + NL_SET_ERR_MSG_MOD(extack, "(S, G) group is already joined by port"); + return -EEXIST; + } + return br_mdb_replace_group_sg(cfg, mp, p, brmctx, + flags, extack); } if ((unsigned long)p->key.port < (unsigned long)cfg->p) break; @@ -883,6 +909,7 @@ static int br_mdb_add_group_src_fwd(const struct br_mdb_config *cfg, sg_cfg.src_entry = true; sg_cfg.filter_mode = MCAST_INCLUDE; sg_cfg.rt_protocol = cfg->rt_protocol; + sg_cfg.nlflags = cfg->nlflags; return br_mdb_add_group_sg(&sg_cfg, sgmp, brmctx, flags, extack); } @@ -903,7 +930,7 @@ static int br_mdb_add_group_src(const struct br_mdb_config *cfg, NL_SET_ERR_MSG_MOD(extack, "Failed to add new source entry"); return -ENOSPC; } - } else { + } else if (!(cfg->nlflags & NLM_F_REPLACE)) { NL_SET_ERR_MSG_MOD(extack, "Source entry already exists"); return -EEXIST; } @@ -961,6 +988,67 @@ static int br_mdb_add_group_srcs(const struct br_mdb_config *cfg, return err; } +static int br_mdb_replace_group_srcs(const struct br_mdb_config *cfg, + struct net_bridge_port_group *pg, + struct net_bridge_mcast *brmctx, + struct netlink_ext_ack *extack) +{ + struct net_bridge_group_src *ent; + struct hlist_node *tmp; + int err; + + hlist_for_each_entry(ent, &pg->src_list, node) + ent->flags |= BR_SGRP_F_DELETE; + + err = br_mdb_add_group_srcs(cfg, pg, brmctx, extack); + if (err) + goto err_clear_delete; + + hlist_for_each_entry_safe(ent, tmp, &pg->src_list, node) { + if (ent->flags & BR_SGRP_F_DELETE) + br_multicast_del_group_src(ent, false); + } + + return 0; + +err_clear_delete: + hlist_for_each_entry(ent, &pg->src_list, node) + ent->flags &= ~BR_SGRP_F_DELETE; + return err; +} + +static int br_mdb_replace_group_star_g(const struct br_mdb_config *cfg, + struct net_bridge_mdb_entry *mp, + struct net_bridge_port_group *pg, + struct net_bridge_mcast *brmctx, + unsigned char flags, + struct netlink_ext_ack *extack) +{ + unsigned long now = jiffies; + int err; + + err = br_mdb_replace_group_srcs(cfg, pg, brmctx, extack); + if (err) + return err; + + pg->flags = flags; + pg->filter_mode = cfg->filter_mode; + pg->rt_protocol = cfg->rt_protocol; + if (!(flags & MDB_PG_FLAGS_PERMANENT) && + cfg->filter_mode == MCAST_EXCLUDE) + mod_timer(&pg->timer, + now + brmctx->multicast_membership_interval); + else + del_timer(&pg->timer); + + br_mdb_notify(cfg->br->dev, mp, pg, RTM_NEWMDB); + + if (br_multicast_should_handle_mode(brmctx, cfg->group.proto)) + br_multicast_star_g_handle_mode(pg, cfg->filter_mode); + + return 0; +} + static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, struct net_bridge_mdb_entry *mp, struct net_bridge_mcast *brmctx, @@ -976,8 +1064,12 @@ static int br_mdb_add_group_star_g(const struct br_mdb_config *cfg, (p = mlock_dereference(*pp, cfg->br)) != NULL; pp = &p->next) { if (p->key.port == cfg->p) { - NL_SET_ERR_MSG_MOD(extack, "(*, G) group is already joined by port"); - return -EEXIST; + if (!(cfg->nlflags & NLM_F_REPLACE)) { + NL_SET_ERR_MSG_MOD(extack, "(*, G) group is already joined by port"); + return -EEXIST; + } + return br_mdb_replace_group_star_g(cfg, mp, p, brmctx, + flags, extack); } if ((unsigned long)p->key.port < (unsigned long)cfg->p) break; @@ -1223,6 +1315,7 @@ static int br_mdb_config_init(struct net *net, const struct nlmsghdr *nlh, memset(cfg, 0, sizeof(*cfg)); cfg->filter_mode = MCAST_EXCLUDE; cfg->rt_protocol = RTPROT_STATIC; + cfg->nlflags = nlh->nlmsg_flags; bpm = nlmsg_data(nlh); if (!bpm->ifindex) { diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index cdc9e040f1f6..2473add41e16 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -107,6 +107,7 @@ struct br_mdb_config { struct br_mdb_src_entry *src_entries; int num_src_entries; u8 rt_protocol; + u32 nlflags; }; #endif From patchwork Thu Dec 8 15:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068545 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6324CC3A5A7 for ; Thu, 8 Dec 2022 15:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbiLHPbf (ORCPT ); Thu, 8 Dec 2022 10:31:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbiLHPah (ORCPT ); Thu, 8 Dec 2022 10:30:37 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E517E424 for ; Thu, 8 Dec 2022 07:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mq+U6EU26m093p9Hqbk9PdSw83xBggz1EleLQRiu3wjN/VOeop0r5EZaO64WRrBocfgffnPQvKFqlVzy+uhGcfuhCyKSJszomoWKOiaknTq39Gy/u1fsfZvfU4x8hI1ImOCLv5dAX6xP2I0A1jYc2IxTS6s0up0s7BT/Y6zafmlz1Io2DW+ZZvD1MamsLe+JbCuKzccx5bR6h/fef4UdjVq/ueGc7vDnk/FY8dLgIJInH3qPrgCmL9/IJrfp5GyhSYqRYvnddaIKCxeW9I/9pQ8EmKuhvLNauv0v/n0yAnejkEmSgdF2ToDXQJ4qoZJS+ATr57SgEwIi+LnW85cd6w== 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=kNmsK5IkkASjagA6QjdaAqEuxMxVK4sv+e6YBuGv4SA=; b=DBk4+rUFCxNAP/ADN5BSSO6GE9nFiHyFByBAl/Z3eL3C1dr9ksj8HDBxFEnsxg8OtHWzhACQNhSfon4qSf59aIMd61sgLlo2bpJ3Fj6Yh2qv2/Vty1+q6G7Dxy6ZWDDzWVH9NY+SCoL2R+ffc+nzSqunicgEnyC+3qkOV1xGMbP5PIRcNH+omxVYbgFdD2scZ1xtpYG858Qv0IvRDU2w9ujO3Kgwezn62/IQ9T15q58HRz02i0falnJHR6X9jLPcJ3zuZaPmn4+YSylzFCj2xn/1VAhgNYbQruFt88mgCU1wDxdj2D8Qj5cNBM3rkYvcsJ4yuJ06gsvs/acDr14PYQ== 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=kNmsK5IkkASjagA6QjdaAqEuxMxVK4sv+e6YBuGv4SA=; b=IeWbtCqA020HrWrrjgf/T/Jm/xI8sWGpA5A8zgspsKp46tUXjGrwcj/EOGImQjVOZccj//pFuxIc+Z2Y2vlShz5dxlxRTGejqupg2djb+YxAqLa+6QEXsK3TG50EjmhCsYxFpaUk5FQIB5Zzl1l4lZ0GUrXKHFq1AVP/wsLsNZUc1H0YHa6qMXeEDfMgONW9bdbM7uU+4e0LGqc7+BBXB8Ags53wJQIT8z7QCu09YwbmltfNXckysC1N8L4fJFwL6wYYXcdUxZppoD3fffma2mPtlvuYXVtX7rCHrZvw82c+O3ONw0jQvgIsmbFot3dOadnTAHNiO5eiOagl+d+/+Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by MW4PR12MB7216.namprd12.prod.outlook.com (2603:10b6:303:226::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 15:30:28 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:30:28 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 13/14] selftests: forwarding: Rename bridge_mdb test Date: Thu, 8 Dec 2022 17:28:38 +0200 Message-Id: <20221208152839.1016350-14-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0218.eurprd07.prod.outlook.com (2603:10a6:802:58::21) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|MW4PR12MB7216:EE_ X-MS-Office365-Filtering-Correlation-Id: a641092d-0df8-498b-2016-08dad93121d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GVTVFCL2Kx1LUj8X+OuWeKFQAQGt09NCismwNuRSF9ERMvegaQiuPboik+9VALsK7mq8hmYHIvfJNIWgQyV4CvXgp95Inc4bk/rZ3r/HzWIqUcAGqxTWId3MTbD05nKOflW8ZSQ58u1cfm/RuJNjH0H2TNjl8LvCvEZGYB52vsBpBZSm+vbQRuS1w3qa1vsFVpfuvlkEivT4N5VndGmKLw/uBXXhv6svbmCQSRIfbC4wZuwwwd35z9DEB90gHYt+xpSz1MxzW6X66qjB116//KUD3s2pfCzSg7SE6k3a9fy2PpNV/rCWip1YuCAGUyov6j6OpSs3XdN+zso6ztjAlqG3Kw7fwnx/1Tt/GQYdDq9BxiKFmAheGm78awqKMfhed0WV3c2wylHTg5At5R0+7hDODsHV7vCLYqJ5QUVHR7FEDHxc102A8x+vyx8HM7tJxcvPfzGO7jrNhWZjgaeONDs+bxo+4Hi3g6syhSDxlKIp1oq2G5Ha9R9fiJKwZwybpoUaETYuPfbh23/x8iC6hm1P4bx7JQz/51si1vPPRlpHeR3sFVRUPqWYeBWBiOYzcScuyLEMCLfq1ID+2BXIswNboNHBWGH9YBKnG96ac/QRImh+Zf+peij3Q+hmNsNXlTvytggUkbyA+I+GH9JYsg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199015)(66946007)(66476007)(66556008)(8676002)(4326008)(38100700002)(6666004)(107886003)(478600001)(6486002)(86362001)(2906002)(186003)(6512007)(26005)(6506007)(83380400001)(36756003)(8936002)(41300700001)(5660300002)(2616005)(316002)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KVd10qVsjSxb0Pob4F6fSRzmwlj/WIajta/9+RY45qtLwEjcMqTqrfvddPSFlvAWWDEZtCWk54HDMSf7EumMz5etyk9CKaSfcaX5ov+CJePj2INkzy2z+A2iMJzbh+jC7S0hIMzoRtehdgVJBRrAm/pik+BwoK1RHLpBNW3y6i8KYaTuI818rnrUcuSzM97EeegfPGxcERb7783oSI31xEX/NZ/bTQYVhZK5QAMTFGSXwyYPssTgt8uj8z+JuZW7fUSQUd9zn2Iiz2bQUHQcOzU/38KucGbEXvjUem27eFdQNDEWFr33OWqNrDhdkraHO+KwMcVS+uDv2pzOIW4/T3apNcnpN8KGJUZz6j0c4OG69Ac5U/sMamiKX6ST4V8HYZWQLZ5lnyyRyDQYqC3MFySS1iSAA2m/N5kPejcwkQ3/CutEBHHx0+x0CMdyXKbzdkbfGqmSV3rtpNTTFFEWaSoBWqdjC+ACyzp5EFO1qOLgjdFY8jnOvikMQ4MB0N0hS/jivQz32lxa9Sf73oYlINRnLsqLW3e8rV4RdS7Hs5QQMacUok6Td6P3HFKvQ4XvP4hH6bh3FXLRKDakAwcn4VdrQLFkykX1uGsoFCSspO53lPmHq6xwnX7ylHb6WE8DMkULM8yKkKrkCQn/hQwhU7glccrXoRZj+s4Fvue0kIhJOAsZ+bxRswgq9qtPgYiAnRF9B5OAqK4/yFNrNhrcY9NcHaApq5oa/HKR8inG3kv5kDT5chHjlMVDpIgA4DA8hHCR+RxyguUcreY/Zq5e3jHU7NwU2EfWv6j//EmKySF0BQuLWO6aDds4EdfLWXN9bGdi9yV7p48Uf3iWkYqNJlQt8TTbjshj1TKRv/1JjEvmgc0Ga7RnMCVhbZ+EIX/son6M+RyNu4xtCMnRlLqKxZwoFRuQWYW1A2m4yakrPiraXB2tjGlOom2svDa5QWaKhQMuH93O5FvatQWvxveij5ZTN6bTxOn3QNTKo/l0JqyzCEPqwMxA5+SHp0WzGYl8skPt9MoQGMFi5C23/94nN2dRFEr3oaqzWdNhx7UuN9kk82hlEF3P0ai54732tckFU/D5GvvhvFLMk0TGTbq+dK8bbmsJlMLJ3TDDOHd8EFYUBuLmexk3QLXYPbODqQ4Lh5AjFCWEw3aUKdt+MH1jPjhg5BjyTBqg5tw5pZbya9gToW88UfAcq/1jQDLxPCm6lsXprWxWGSdr+ius3+amiJGP7uTWIgEkRNaV5Ky/KHAbUcfmpPaCYK6XqSafsv6pNxfZDLw6RJ5g8ft4wvnNNgrS+hmal+Zb4EkhQyFu3Q+G0PBWErjWiO5Nl+Zp2o5JzV+o0RGvItRUHCIQEJOxAjLapXnndF8abnhSIWKFilHlmukVaLHCPclUa0ONudivoByTkvJZehPCZcmS38x8gYLExYyz375GdG5mhdVbaXmvp9FsijQMs0/Z3EOOjLs0kJchK+jhdL4sC/NyITDQCnyLmcaHp2LQblVsdeRKVR9omdFm/DWLoiyiclhHbraiG+x6yxWOjLQOrp5x0O7QBRtNSBN10O6mXrJYMx+Ql5f4yqyfBV1ih68j57y+jjcN X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a641092d-0df8-498b-2016-08dad93121d0 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:30:28.3550 (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: CtT4mD+Bab/F/pvBIV4/rD4VT1urQV5LHnmYnXkYMfBOc6XuV9al/JNVsP3HZipYjKX6YsqwTSVc4ySGm0wWqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7216 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The test is only concerned with host MDB entries and not with MDB entries as a whole. Rename the test to reflect that. Subsequent patches will add a more general test that will contain the test cases for host MDB entries and remove the current test. Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- tools/testing/selftests/net/forwarding/Makefile | 2 +- .../net/forwarding/{bridge_mdb.sh => bridge_mdb_host.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tools/testing/selftests/net/forwarding/{bridge_mdb.sh => bridge_mdb_host.sh} (100%) diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index a9c5c1be5088..f2df81ca3179 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -2,7 +2,7 @@ TEST_PROGS = bridge_igmp.sh \ bridge_locked_port.sh \ - bridge_mdb.sh \ + bridge_mdb_host.sh \ bridge_mdb_port_down.sh \ bridge_mld.sh \ bridge_port_isolation.sh \ diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb_host.sh similarity index 100% rename from tools/testing/selftests/net/forwarding/bridge_mdb.sh rename to tools/testing/selftests/net/forwarding/bridge_mdb_host.sh From patchwork Thu Dec 8 15:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13068546 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6DB5C4332F for ; Thu, 8 Dec 2022 15:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbiLHPbh (ORCPT ); Thu, 8 Dec 2022 10:31:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbiLHPam (ORCPT ); Thu, 8 Dec 2022 10:30:42 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA4EF7F8A0 for ; Thu, 8 Dec 2022 07:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofgvGiNZgdE3gvToPPcFQn5UFnK/63NCblXFBlYVeqFsiaqoB1amQBQLGl2b2IpoDD664CbRm7mN90RExnH6ayR4gE8RQDFtlY7Vf4/9X6rETyuZ7n0K6Mt/hEmEozFMi0ePEA8TC//KEpJWKJN+e6CP6YAR9Ass7pCSyWuJ9L0sPmrMunIWWoveo+OHujNbvcasA3Nhb3DFQOcCqa8ycZglM+wXCHR9GXeSybnaGBxBaD1IERmhxej8yiqVLELRIuoc/dzYe7SB/iI/cq53+d6JEq44SJ6bczIVD+lT3pDhiVKAP95+U490t6ogbwX2Ddxi5lld03C2G8Pg/sDjRw== 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=Q8lhTzo510AWbiecDzLNBhelTS9ihWvXGIrkGkedIis=; b=kI8H5KeJS4zX9ySX4DixC7eSpOqB5mebynCjuFxPYnyqaCV49y8I2r75IvebqZNU8iSAnkzyKLuW9CNzUosALfR6mOiC/BIWY7B36QLBIMImIbG9q+4M0VLfGRLbwhzwqK1wptaJzgADnnUtNpPhxtNHVvLiyHgj5ySvGPTmwB39+Y4XO7ejk76CFJKT6cHWa/D1/2bLFVLqmjoVV85iZXeFq4CUxRv91hRcrpylwaVaDFAvhA5TQ16pIPhfdYLzJBFzjNd+U3h02sxoJKPX02Q10Um2KxDBdnNpfvTd8zxZAl56379nz0Lz5JArFrNNPZ98NjrEtxiYzXJwqYebtQ== 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=Q8lhTzo510AWbiecDzLNBhelTS9ihWvXGIrkGkedIis=; b=EFerDIFRCxwFr3vpV5wDaIK5y4lBjry/d57NhfD6E1ofgCLq6visIKSvXjcCTR8aBME7bZvANVQfLz4FbsNhMgJE3CZHWuS9i4nFkL5sMeQ5nINh7GLzM0Qs3z2Mtzb52hmuK5x8NuOe51mwTRUi0NV5u5WrywcTVGSmycMYpXyyAwObwpL4kGRkwnpnIuU6F4854rQhT6pXbAY8tw+hDHrJ7QcoguFEQ5RxHTnjo1sI4zSHyDayo697scrztI2gJKF90gw2xmKiIFvih3mXCXD/PcP/JaYL+09ySpVDmcxclwBEunOwlUisuuRawZRMdlacyn4SXAzVdFX9ldXurw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) by MW4PR12MB7216.namprd12.prod.outlook.com (2603:10b6:303:226::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 15:30:36 +0000 Received: from CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a]) by CY5PR12MB6179.namprd12.prod.outlook.com ([fe80::a600:9252:615:d31a%3]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 15:30:35 +0000 From: Ido Schimmel To: netdev@vger.kernel.org, bridge@lists.linux-foundation.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, roopa@nvidia.com, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 14/14] selftests: forwarding: Add bridge MDB test Date: Thu, 8 Dec 2022 17:28:39 +0200 Message-Id: <20221208152839.1016350-15-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221208152839.1016350-1-idosch@nvidia.com> References: <20221208152839.1016350-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0601CA0009.eurprd06.prod.outlook.com (2603:10a6:800:1e::19) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|MW4PR12MB7216:EE_ X-MS-Office365-Filtering-Correlation-Id: 5906250d-0ef2-4bb8-add5-08dad931266c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMhsxA5wd44ch6O3O2Ec3lqFW8dSIJYo/tKj2kgpC44/dukY/kHr8nItxj9CUetIuOH5+IIsF6spDP3LBh4JIDMVx8ZbWHxNKUCBytOjT5qoRuAm4Kj0x5CzKp4EfKJAdoIB6W+Pz2P5k2WB3Y9R1Gg5U+GnaSNhiLp7SzvApgPp4iFuSHL1WBg3dNSf5SXo/tKAspBIx9dVjH5MU58lxb4KjuCWQzO4nG+uYtRCJ92V3xPjVDXizr7rB694nUO6SICt3HRisxa6gp956uImsn5SpRdXx/x6OHt6VO6RMfkBW+PfBoVGHCezBG5bXBh+eEG2YZJr2GyqAnbss8Rc4AeMpoUVwvn0X4CCTvo1dkiMvlEyhBU4vPloVy7Bb8Si26SoeI8YvSVuNkukh+Jf3d71MZJTFPdmmuMWoq0iu4QIKKoDh4EeMnu1GlgMBvpBdeIc/zY6sbnI8pAA6BvE6Ll/HBa9PSh3lYaFogPpGK2Ps6mVjnBVKKDf076RnFXXonUszlrASdQ+ljb2+jrxkrdRwPUQHT4SJhsAt1v0MW87BNmlfQWd5zapkZaJwK9YiqIRMDF2LO3lSglih53MjdCtJPflryT3w8mWqYqg84CvEI2WCLCAy8A2QSqoMzxJEFMPiciH9a8RevA505elyg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199015)(66946007)(66476007)(66556008)(8676002)(4326008)(38100700002)(107886003)(478600001)(6486002)(86362001)(2906002)(186003)(6512007)(26005)(66574015)(6506007)(83380400001)(36756003)(8936002)(41300700001)(30864003)(5660300002)(2616005)(316002)(1076003)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9vZNUlG4SumA+j+GZxKAwY++Z0S0ViTJ6ahWpRtmTvBNR+YVzhWmCbJTC64tOb/vHk6di9hnq0RHMAWKQir/yIlO83icy5o7f7uEO/DtR7Vmg5nOPUfgd0L8Sz57dZtLzkT2BLSyuReo2dO5s9vWfKulz6/GPDauAUxP6RUOwHcFa2YOKS/EpteBKuM/zxhMAuIyTwKWV8jB2llDMltPPAwUiHZ4kFBOLa8FzmquG5LzVVh96WrFCSYJTBdcrhhDAMwh0szwOGsS8O2c3t2sOB94P80eO3su8oWOZGIfAPjKZ6QYfypH1Iu7kYKYj6VyDpxu7dMGfucbxegdOqVjiVHYJaA5Zo5EIxHW39ZWW1RNsuqJ3Ur7a/sQe5xporZy9PFiHXmqBzmjbIn9W5q2jsX1JnmmzPT2cdI41/U/dQcvmJu6GDA8+ruxM7WbbhmJXrTRPxeW8OmdR7CEQWd9DcOQduTKLAVHCLims4eHt6qqBWbuMTGnqUtkCr6gsdSZhUbA5guWkr35xwxzEJK06KsE+7+RimHAwzd/dJCjuLWGL2ixnMrI7MCyIIf6FCU5gIrh//8tdNJa68c+SNNHJSyz6YuQC6XydbnfI8dPY6p/bz0eP84WDTAYJBikQbren90Rjfc8PBMpJ/unZKIgkV+io37n9YfkAg2M4UcAoTsGQeUkyw3d97mdPWGff07AZPteO4o8TOXGzj2gYB8nfVnRbxkbstNPAqtvOAxxXNmIAnPDuS0yGMHSnKIqmqzIMvzTbwJF1eUCSRMsYybHRcXGb1Hc8JNmTSWlZCLOPpewkDr2gmx0aZSJ0Lq4YJw0ypMt+61n5JgzB0ehJfsStKiJI6XN92JG/1ao8NhZdFi+PwBV5lB5mcq4o63jf63DmTAlUA40ZPFt3TeSAiLYdDTXpahVvYkLUVH4kBkg/1PCcFB/p4GZcezafo/k60aiJ1WpyAPuYSr4L33klwENSbxFLm0EoZC+vtfoexKuYz6fGlTeGc+cCoZryEJJe7chDfy5VzAvuHELTyix/cisO5JMG0H7U/kB9EBF5/2y79KqSCgRBIqJ1j1jo8YvVwwkR+RR+L+LdBvUtvdXIe+PhfTOfA0TDxDofaJvf9q/a8l531Iunh7XfKZCKpI7HT+xaiosoEshdyNDG2dBGvux+nD27B8lXT/UWnt4iZsrpsIiGqszXkJzKVeORfclPLzeBqi3t68AnmGvEZxIzu8hVqFjrC3SqvjBjPV14Zkok66fUFAyD4HG4izYOSJcQDL4IlBu4nAGl3zecQ1RieFsRn7vIR68NrpUfcEwZO1q78eJNvf6OkI/Sg20Q1uYFnmM1rz3jkK7HQj3ZXwc3hVUiuRkPB/9Z4XlUJJxsneiCe+K/ptaDjDiq5DKGfzC2BLtjlOXk0IxYlmmwU5CIBhjMOqPI4/M3ymir+cCBf17D58khm3/rPcU2SQEChGYMEousZ1WTBIwazeyCF0StIZGkHeravpFEvejZrzlUnFRK07UOxlcR2nd83UGx5spEwbTpULLigzAA9FUt0KncRGBIxD2K25c1bLCgvTd2LSN6zSikd5/SddXcm1tYxbkYDxk X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5906250d-0ef2-4bb8-add5-08dad931266c X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 15:30:35.7938 (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: Xwckc+gAbc3mBTPQXUCRsLUQV7aeFTmvV7X3Po48MMCtKPLZN36AVJvtT9LXV+c1p+MGMyD5HHW4imX0eG7kRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7216 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add a selftests that includes the following test cases: 1. Configuration tests. Both valid and invalid configurations are tested across all entry types (e.g., L2, IPv4). 2. Forwarding tests. Both host and port group entries are tested across all entry types. 3. Interaction between user installed MDB entries and IGMP / MLD control packets. Example output: INFO: # Host entries configuration tests TEST: Common host entries configuration tests (IPv4) [ OK ] TEST: Common host entries configuration tests (IPv6) [ OK ] TEST: Common host entries configuration tests (L2) [ OK ] INFO: # Port group entries configuration tests - (*, G) TEST: Common port group entries configuration tests (IPv4 (*, G)) [ OK ] TEST: Common port group entries configuration tests (IPv6 (*, G)) [ OK ] TEST: IPv4 (*, G) port group entries configuration tests [ OK ] TEST: IPv6 (*, G) port group entries configuration tests [ OK ] INFO: # Port group entries configuration tests - (S, G) TEST: Common port group entries configuration tests (IPv4 (S, G)) [ OK ] TEST: Common port group entries configuration tests (IPv6 (S, G)) [ OK ] TEST: IPv4 (S, G) port group entries configuration tests [ OK ] TEST: IPv6 (S, G) port group entries configuration tests [ OK ] INFO: # Port group entries configuration tests - L2 TEST: Common port group entries configuration tests (L2 (*, G)) [ OK ] TEST: L2 (*, G) port group entries configuration tests [ OK ] INFO: # Forwarding tests TEST: IPv4 host entries forwarding tests [ OK ] TEST: IPv6 host entries forwarding tests [ OK ] TEST: L2 host entries forwarding tests [ OK ] TEST: IPv4 port group "exclude" entries forwarding tests [ OK ] TEST: IPv6 port group "exclude" entries forwarding tests [ OK ] TEST: IPv4 port group "include" entries forwarding tests [ OK ] TEST: IPv6 port group "include" entries forwarding tests [ OK ] TEST: L2 port entries forwarding tests [ OK ] INFO: # Control packets tests TEST: IGMPv3 MODE_IS_INCLUE tests [ OK ] TEST: MLDv2 MODE_IS_INCLUDE tests [ OK ] Signed-off-by: Ido Schimmel Acked-by: Nikolay Aleksandrov --- .../testing/selftests/net/forwarding/Makefile | 1 + .../selftests/net/forwarding/bridge_mdb.sh | 1164 +++++++++++++++++ 2 files changed, 1165 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/bridge_mdb.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index f2df81ca3179..453ae006fbcf 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -2,6 +2,7 @@ TEST_PROGS = bridge_igmp.sh \ bridge_locked_port.sh \ + bridge_mdb.sh \ bridge_mdb_host.sh \ bridge_mdb_port_down.sh \ bridge_mld.sh \ diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh new file mode 100755 index 000000000000..2fa5973c0c28 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -0,0 +1,1164 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +-----------------------+ +------------------------+ +# | H1 (vrf) | | H2 (vrf) | +# | + $h1.10 | | + $h2.10 | +# | | 192.0.2.1/28 | | | 192.0.2.2/28 | +# | | 2001:db8:1::1/64 | | | 2001:db8:1::2/64 | +# | | | | | | +# | | + $h1.20 | | | + $h2.20 | +# | \ | 198.51.100.1/24 | | \ | 198.51.100.2/24 | +# | \ | 2001:db8:2::1/64 | | \ | 2001:db8:2::2/64 | +# | \| | | \| | +# | + $h1 | | + $h2 | +# +----|------------------+ +----|-------------------+ +# | | +# +----|--------------------------------------------------|-------------------+ +# | SW | | | +# | +--|--------------------------------------------------|-----------------+ | +# | | + $swp1 BR0 (802.1q) + $swp2 | | +# | | vid 10 vid 10 | | +# | | vid 20 vid 20 | | +# | | | | +# | +-----------------------------------------------------------------------+ | +# +---------------------------------------------------------------------------+ + +ALL_TESTS=" + cfg_test + fwd_test + ctrl_test +" + +NUM_NETIFS=4 +source lib.sh +source tc_common.sh + +h1_create() +{ + simple_if_init $h1 + vlan_create $h1 10 v$h1 192.0.2.1/28 2001:db8:1::1/64 + vlan_create $h1 20 v$h1 198.51.100.1/24 2001:db8:2::1/64 +} + +h1_destroy() +{ + vlan_destroy $h1 20 + vlan_destroy $h1 10 + simple_if_fini $h1 +} + +h2_create() +{ + simple_if_init $h2 + vlan_create $h2 10 v$h2 192.0.2.2/28 + vlan_create $h2 20 v$h2 198.51.100.2/24 +} + +h2_destroy() +{ + vlan_destroy $h2 20 + vlan_destroy $h2 10 + simple_if_fini $h2 +} + +switch_create() +{ + ip link add name br0 type bridge vlan_filtering 1 vlan_default_pvid 0 \ + mcast_snooping 1 mcast_igmp_version 3 mcast_mld_version 2 + bridge vlan add vid 10 dev br0 self + bridge vlan add vid 20 dev br0 self + ip link set dev br0 up + + ip link set dev $swp1 master br0 + ip link set dev $swp1 up + bridge vlan add vid 10 dev $swp1 + bridge vlan add vid 20 dev $swp1 + + ip link set dev $swp2 master br0 + ip link set dev $swp2 up + bridge vlan add vid 10 dev $swp2 + bridge vlan add vid 20 dev $swp2 + + tc qdisc add dev br0 clsact + tc qdisc add dev $h2 clsact +} + +switch_destroy() +{ + tc qdisc del dev $h2 clsact + tc qdisc del dev br0 clsact + + bridge vlan del vid 20 dev $swp2 + bridge vlan del vid 10 dev $swp2 + ip link set dev $swp2 down + ip link set dev $swp2 nomaster + + bridge vlan del vid 20 dev $swp1 + bridge vlan del vid 10 dev $swp1 + ip link set dev $swp1 down + ip link set dev $swp1 nomaster + + ip link set dev br0 down + bridge vlan del vid 20 dev br0 self + bridge vlan del vid 10 dev br0 self + ip link del dev br0 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + vrf_prepare + forwarding_enable + + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + + forwarding_restore + vrf_cleanup +} + +cfg_test_host_common() +{ + local name=$1; shift + local grp=$1; shift + local src=$1; shift + local state=$1; shift + local invalid_state=$1; shift + + RET=0 + + # Check basic add, replace and delete behavior. + bridge mdb add dev br0 port br0 grp $grp $state vid 10 + bridge mdb show dev br0 vid 10 | grep -q "$grp" + check_err $? "Failed to add $name host entry" + + bridge mdb replace dev br0 port br0 grp $grp $state vid 10 &> /dev/null + check_fail $? "Managed to replace $name host entry" + + bridge mdb del dev br0 port br0 grp $grp $state vid 10 + bridge mdb show dev br0 vid 10 | grep -q "$grp" + check_fail $? "Failed to delete $name host entry" + + # Check error cases. + bridge mdb add dev br0 port br0 grp $grp $invalid_state vid 10 \ + &> /dev/null + check_fail $? "Managed to add $name host entry with a $invalid_state state" + + bridge mdb add dev br0 port br0 grp $grp src $src $state vid 10 \ + &> /dev/null + check_fail $? "Managed to add $name host entry with a source" + + bridge mdb add dev br0 port br0 grp $grp $state vid 10 \ + filter_mode exclude &> /dev/null + check_fail $? "Managed to add $name host entry with a filter mode" + + bridge mdb add dev br0 port br0 grp $grp $state vid 10 \ + source_list $src &> /dev/null + check_fail $? "Managed to add $name host entry with a source list" + + bridge mdb add dev br0 port br0 grp $grp $state vid 10 \ + proto 123 &> /dev/null + check_fail $? "Managed to add $name host entry with a protocol" + + log_test "Common host entries configuration tests ($name)" +} + +# Check configuration of host entries from all types. +cfg_test_host() +{ + echo + log_info "# Host entries configuration tests" + + cfg_test_host_common "IPv4" "239.1.1.1" "192.0.2.1" "temp" "permanent" + cfg_test_host_common "IPv6" "ff0e::1" "2001:db8:1::1" "temp" "permanent" + cfg_test_host_common "L2" "01:02:03:04:05:06" "00:00:00:00:00:01" \ + "permanent" "temp" +} + +cfg_test_port_common() +{ + local name=$1;shift + local grp_key=$1; shift + + RET=0 + + # Check basic add, replace and delete behavior. + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 10 + bridge mdb show dev br0 vid 10 | grep -q "$grp_key" + check_err $? "Failed to add $name entry" + + bridge mdb replace dev br0 port $swp1 $grp_key permanent vid 10 \ + &> /dev/null + check_err $? "Failed to replace $name entry" + + bridge mdb del dev br0 port $swp1 $grp_key permanent vid 10 + bridge mdb show dev br0 vid 10 | grep -q "$grp_key" + check_fail $? "Failed to delete $name entry" + + # Check default protocol and replacement. + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | grep -q "static" + check_err $? "$name entry not added with default \"static\" protocol" + + bridge mdb replace dev br0 port $swp1 $grp_key permanent vid 10 \ + proto 123 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | grep -q "123" + check_err $? "Failed to replace protocol of $name entry" + bridge mdb del dev br0 port $swp1 $grp_key permanent vid 10 + + # Check behavior when VLAN is not specified. + bridge mdb add dev br0 port $swp1 $grp_key permanent + bridge mdb show dev br0 vid 10 | grep -q "$grp_key" + check_err $? "$name entry with VLAN 10 not added when VLAN was not specified" + bridge mdb show dev br0 vid 20 | grep -q "$grp_key" + check_err $? "$name entry with VLAN 20 not added when VLAN was not specified" + + bridge mdb del dev br0 port $swp1 $grp_key permanent + bridge mdb show dev br0 vid 10 | grep -q "$grp_key" + check_fail $? "$name entry with VLAN 10 not deleted when VLAN was not specified" + bridge mdb show dev br0 vid 20 | grep -q "$grp_key" + check_fail $? "$name entry with VLAN 20 not deleted when VLAN was not specified" + + # Check behavior when bridge port is down. + ip link set dev $swp1 down + + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 10 + check_err $? "Failed to add $name permanent entry when bridge port is down" + + bridge mdb del dev br0 port $swp1 $grp_key permanent vid 10 + + bridge mdb add dev br0 port $swp1 $grp_key temp vid 10 &> /dev/null + check_fail $? "Managed to add $name temporary entry when bridge port is down" + + ip link set dev $swp1 up + setup_wait_dev $swp1 + + # Check error cases. + ip link set dev br0 down + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 10 \ + &> /dev/null + check_fail $? "Managed to add $name entry when bridge is down" + ip link set dev br0 up + + ip link set dev br0 type bridge mcast_snooping 0 + bridge mdb add dev br0 port $swp1 $grp_key permanent vid \ + 10 &> /dev/null + check_fail $? "Managed to add $name entry when multicast snooping is disabled" + ip link set dev br0 type bridge mcast_snooping 1 + + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 5000 \ + &> /dev/null + check_fail $? "Managed to add $name entry with an invalid VLAN" + + log_test "Common port group entries configuration tests ($name)" +} + +src_list_create() +{ + local src_prefix=$1; shift + local num_srcs=$1; shift + local src_list + local i + + for i in $(seq 1 $num_srcs); do + src_list=${src_list},${src_prefix}${i} + done + + echo $src_list | cut -c 2- +} + +__cfg_test_port_ip_star_g() +{ + local name=$1; shift + local grp=$1; shift + local invalid_grp=$1; shift + local src_prefix=$1; shift + local src1=${src_prefix}1 + local src2=${src_prefix}2 + local src3=${src_prefix}3 + local max_srcs=31 + local num_srcs + + RET=0 + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "exclude" + check_err $? "Default filter mode is not \"exclude\"" + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check basic add and delete behavior. + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode exclude \ + source_list $src1 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q -v "src" + check_err $? "(*, G) entry not created" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src1" + check_err $? "(S, G) entry not created" + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q -v "src" + check_fail $? "(*, G) entry not deleted" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src1" + check_fail $? "(S, G) entry not deleted" + + ## State (permanent / temp) tests. + + # Check that group and source timer are not set for permanent entries. + bridge mdb add dev br0 port $swp1 grp $grp permanent vid 10 \ + filter_mode exclude source_list $src1 + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "permanent" + check_err $? "(*, G) entry not added as \"permanent\" when should" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "permanent" + check_err $? "(S, G) entry not added as \"permanent\" when should" + + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q " 0.00" + check_err $? "(*, G) \"permanent\" entry has a pending group timer" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "\/0.00" + check_err $? "\"permanent\" source entry has a pending source timer" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that group timer is set for temporary (*, G) EXCLUDE, but not + # the source timer. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "temp" + check_err $? "(*, G) EXCLUDE entry not added as \"temp\" when should" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "temp" + check_err $? "(S, G) \"blocked\" entry not added as \"temp\" when should" + + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q " 0.00" + check_fail $? "(*, G) EXCLUDE entry does not have a pending group timer" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "\/0.00" + check_err $? "\"blocked\" source entry has a pending source timer" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that group timer is not set for temporary (*, G) INCLUDE, but + # that the source timer is set. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode include source_list $src1 + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "temp" + check_err $? "(*, G) INCLUDE entry not added as \"temp\" when should" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "temp" + check_err $? "(S, G) entry not added as \"temp\" when should" + + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q " 0.00" + check_err $? "(*, G) INCLUDE entry has a pending group timer" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "\/0.00" + check_fail $? "Source entry does not have a pending source timer" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that group timer is never set for (S, G) entries. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode include source_list $src1 + + bridge -d -s mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q " 0.00" + check_err $? "(S, G) entry has a pending group timer" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + ## Filter mode (include / exclude) tests. + + # Check that (*, G) INCLUDE entries are added with correct filter mode + # and that (S, G) entries are not marked as "blocked". + bridge mdb add dev br0 port $swp1 grp $grp vid 10 \ + filter_mode include source_list $src1 + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "include" + check_err $? "(*, G) INCLUDE not added with \"include\" filter mode" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "blocked" + check_fail $? "(S, G) entry marked as \"blocked\" when should not" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that (*, G) EXCLUDE entries are added with correct filter mode + # and that (S, G) entries are marked as "blocked". + bridge mdb add dev br0 port $swp1 grp $grp vid 10 \ + filter_mode exclude source_list $src1 + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "exclude" + check_err $? "(*, G) EXCLUDE not added with \"exclude\" filter mode" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "blocked" + check_err $? "(S, G) entry not marked as \"blocked\" when should" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + ## Protocol tests. + + # Check that (*, G) and (S, G) entries are added with the specified + # protocol. + bridge mdb add dev br0 port $swp1 grp $grp vid 10 \ + filter_mode exclude source_list $src1 proto zebra + + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "zebra" + check_err $? "(*, G) entry not added with \"zebra\" protocol" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "zebra" + check_err $? "(S, G) entry not marked added with \"zebra\" protocol" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + ## Replace tests. + + # Check that state can be modified. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + + bridge mdb replace dev br0 port $swp1 grp $grp permanent vid 10 \ + filter_mode exclude source_list $src1 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "permanent" + check_err $? "(*, G) entry not marked as \"permanent\" after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "permanent" + check_err $? "(S, G) entry not marked as \"permanent\" after replace" + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "temp" + check_err $? "(*, G) entry not marked as \"temp\" after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "temp" + check_err $? "(S, G) entry not marked as \"temp\" after replace" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that filter mode can be modified. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode include source_list $src1 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "include" + check_err $? "(*, G) not marked with \"include\" filter mode after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "blocked" + check_fail $? "(S, G) marked as \"blocked\" after replace" + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "exclude" + check_err $? "(*, G) not marked with \"exclude\" filter mode after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "blocked" + check_err $? "(S, G) not marked as \"blocked\" after replace" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that sources can be added to and removed from the source list. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1,$src2,$src3 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src1" + check_err $? "(S, G) entry for source $src1 not created after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src2" + check_err $? "(S, G) entry for source $src2 not created after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src3" + check_err $? "(S, G) entry for source $src3 not created after replace" + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1,$src3 + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src1" + check_err $? "(S, G) entry for source $src1 not created after second replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src2" + check_fail $? "(S, G) entry for source $src2 created after second replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -q "src $src3" + check_err $? "(S, G) entry for source $src3 not created after second replace" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + # Check that protocol can be modified. + bridge mdb add dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 proto zebra + + bridge mdb replace dev br0 port $swp1 grp $grp temp vid 10 \ + filter_mode exclude source_list $src1 proto bgp + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep -v "src" | \ + grep -q "bgp" + check_err $? "(*, G) protocol not changed to \"bgp\" after replace" + bridge -d mdb show dev br0 vid 10 | grep "$grp" | grep "src" | \ + grep -q "bgp" + check_err $? "(S, G) protocol not changed to \"bgp\" after replace" + + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + ## Star exclude tests. + + # Check star exclude functionality. When adding a new EXCLUDE (*, G), + # it needs to be also added to all (S, G) entries for proper + # replication. + bridge mdb add dev br0 port $swp2 grp $grp vid 10 \ + filter_mode include source_list $src1 + bridge mdb add dev br0 port $swp1 grp $grp vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$swp1" | grep "$grp" | \ + grep "$src1" | grep -q "added_by_star_ex" + check_err $? "\"added_by_star_ex\" entry not created after adding (*, G) entry" + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + bridge mdb del dev br0 port $swp2 grp $grp src $src1 vid 10 + + ## Error cases tests. + + bridge mdb add dev br0 port $swp1 grp $invalid_grp vid 10 &> /dev/null + check_fail $? "Managed to add an entry with an invalid group" + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode include \ + &> /dev/null + check_fail $? "Managed to add an INCLUDE entry with an empty source list" + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode include \ + source_list $grp &> /dev/null + check_fail $? "Managed to add an entry with an invalid source in source list" + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 \ + source_list $src &> /dev/null + check_fail $? "Managed to add an entry with a source list and no filter mode" + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode include \ + source_list $src1 + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode exclude \ + source_list $src1 &> /dev/null + check_fail $? "Managed to replace an entry without using replace" + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + bridge mdb add dev br0 port $swp1 grp $grp src $src2 vid 10 + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode include \ + source_list $src1,$src2,$src3 &> /dev/null + check_fail $? "Managed to add a source that already has a forwarding entry" + bridge mdb del dev br0 port $swp1 grp $grp src $src2 vid 10 + + # Check maximum number of sources. + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode exclude \ + source_list $(src_list_create $src_prefix $max_srcs) + num_srcs=$(bridge -d mdb show dev br0 vid 10 | grep "$grp" | \ + grep "src" | wc -l) + [[ $num_srcs -eq $max_srcs ]] + check_err $? "Failed to configure maximum number of sources ($max_srcs)" + bridge mdb del dev br0 port $swp1 grp $grp vid 10 + + bridge mdb add dev br0 port $swp1 grp $grp vid 10 filter_mode exclude \ + source_list $(src_list_create $src_prefix $((max_srcs + 1))) \ + &> /dev/null + check_fail $? "Managed to exceed maximum number of sources ($max_srcs)" + + log_test "$name (*, G) port group entries configuration tests" +} + +cfg_test_port_ip_star_g() +{ + echo + log_info "# Port group entries configuration tests - (*, G)" + + cfg_test_port_common "IPv4 (*, G)" "grp 239.1.1.1" + cfg_test_port_common "IPv6 (*, G)" "grp ff0e::1" + __cfg_test_port_ip_star_g "IPv4" "239.1.1.1" "224.0.0.1" "192.0.2." + __cfg_test_port_ip_star_g "IPv6" "ff0e::1" "ff02::1" "2001:db8:1::" +} + +__cfg_test_port_ip_sg() +{ + local name=$1; shift + local grp=$1; shift + local src=$1; shift + local grp_key="grp $grp src $src" + + RET=0 + + bridge mdb add dev br0 port $swp1 $grp_key vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | grep -q "include" + check_err $? "Default filter mode is not \"include\"" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + + # Check that entries can be added as both permanent and temp and that + # group timer is set correctly. + bridge mdb add dev br0 port $swp1 $grp_key permanent vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "permanent" + check_err $? "Entry not added as \"permanent\" when should" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "0.00" + check_err $? "\"permanent\" entry has a pending group timer" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + + bridge mdb add dev br0 port $swp1 $grp_key temp vid 10 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "temp" + check_err $? "Entry not added as \"temp\" when should" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "0.00" + check_fail $? "\"temp\" entry has an unpending group timer" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + + # Check error cases. + bridge mdb add dev br0 port $swp1 $grp_key vid 10 \ + filter_mode include &> /dev/null + check_fail $? "Managed to add an entry with a filter mode" + + bridge mdb add dev br0 port $swp1 $grp_key vid 10 \ + filter_mode include source_list $src &> /dev/null + check_fail $? "Managed to add an entry with a source list" + + bridge mdb add dev br0 port $swp1 grp $grp src $grp vid 10 &> /dev/null + check_fail $? "Managed to add an entry with an invalid source" + + bridge mdb add dev br0 port $swp1 $grp_key vid 10 temp + bridge mdb add dev br0 port $swp1 $grp_key vid 10 permanent &> /dev/null + check_fail $? "Managed to replace an entry without using replace" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + + # Check that we can replace available attributes. + bridge mdb add dev br0 port $swp1 $grp_key vid 10 proto 123 + bridge mdb replace dev br0 port $swp1 $grp_key vid 10 proto 111 + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "111" + check_err $? "Failed to replace protocol" + + bridge mdb replace dev br0 port $swp1 $grp_key vid 10 permanent + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "permanent" + check_err $? "Entry not marked as \"permanent\" after replace" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "0.00" + check_err $? "Entry has a pending group timer after replace" + + bridge mdb replace dev br0 port $swp1 $grp_key vid 10 temp + bridge -d mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "temp" + check_err $? "Entry not marked as \"temp\" after replace" + bridge -d -s mdb show dev br0 vid 10 | grep "$grp_key" | \ + grep -q "0.00" + check_fail $? "Entry has an unpending group timer after replace" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + + # Check star exclude functionality. When adding a (S, G), all matching + # (*, G) ports need to be added to it. + bridge mdb add dev br0 port $swp2 grp $grp vid 10 + bridge mdb add dev br0 port $swp1 $grp_key vid 10 + bridge mdb show dev br0 vid 10 | grep "$grp_key" | grep $swp2 | \ + grep -q "added_by_star_ex" + check_err $? "\"added_by_star_ex\" entry not created after adding (S, G) entry" + bridge mdb del dev br0 port $swp1 $grp_key vid 10 + bridge mdb del dev br0 port $swp2 grp $grp vid 10 + + log_test "$name (S, G) port group entries configuration tests" +} + +cfg_test_port_ip_sg() +{ + echo + log_info "# Port group entries configuration tests - (S, G)" + + cfg_test_port_common "IPv4 (S, G)" "grp 239.1.1.1 src 192.0.2.1" + cfg_test_port_common "IPv6 (S, G)" "grp ff0e::1 src 2001:db8:1::1" + __cfg_test_port_ip_sg "IPv4" "239.1.1.1" "192.0.2.1" + __cfg_test_port_ip_sg "IPv6" "ff0e::1" "2001:db8:1::1" +} + +cfg_test_port_ip() +{ + cfg_test_port_ip_star_g + cfg_test_port_ip_sg +} + +__cfg_test_port_l2() +{ + local grp="01:02:03:04:05:06" + + RET=0 + + bridge meb add dev br0 port $swp grp 00:01:02:03:04:05 \ + permanent vid 10 &> /dev/null + check_fail $? "Managed to add an entry with unicast MAC" + + bridge mdb add dev br0 port $swp grp $grp src 00:01:02:03:04:05 \ + permanent vid 10 &> /dev/null + check_fail $? "Managed to add an entry with a source" + + bridge mdb add dev br0 port $swp1 grp $grp permanent vid 10 \ + filter_mode include &> /dev/null + check_fail $? "Managed to add an entry with a filter mode" + + bridge mdb add dev br0 port $swp1 grp $grp permanent vid 10 \ + source_list 00:01:02:03:04:05 &> /dev/null + check_fail $? "Managed to add an entry with a source list" + + log_test "L2 (*, G) port group entries configuration tests" +} + +cfg_test_port_l2() +{ + echo + log_info "# Port group entries configuration tests - L2" + + cfg_test_port_common "L2 (*, G)" "grp 01:02:03:04:05:06" + __cfg_test_port_l2 +} + +# Check configuration of regular (port) entries of all types. +cfg_test_port() +{ + cfg_test_port_ip + cfg_test_port_l2 +} + +cfg_test() +{ + cfg_test_host + cfg_test_port +} + +__fwd_test_host_ip() +{ + local grp=$1; shift + local src=$1; shift + local mode=$1; shift + local name + local eth_type + + RET=0 + + if [[ $mode == "-4" ]]; then + name="IPv4" + eth_type="ipv4" + else + name="IPv6" + eth_type="ipv6" + fi + + tc filter add dev br0 ingress protocol 802.1q pref 1 handle 1 flower \ + vlan_ethtype $eth_type vlan_id 10 dst_ip $grp src_ip $src \ + action drop + + # Packet should only be flooded to multicast router ports when there is + # no matching MDB entry. The bridge is not configured as a multicast + # router port. + $MZ $mode $h1.10 -c 1 -p 128 -A $src -B $grp -t udp -q + tc_check_packets "dev br0 ingress" 1 0 + check_err $? "Packet locally received after flood" + + # Install a regular port group entry and expect the packet to not be + # locally received. + bridge mdb add dev br0 port $swp2 grp $grp temp vid 10 + $MZ $mode $h1.10 -c 1 -p 128 -A $src -B $grp -t udp -q + tc_check_packets "dev br0 ingress" 1 0 + check_err $? "Packet locally received after installing a regular entry" + + # Add a host entry and expect the packet to be locally received. + bridge mdb add dev br0 port br0 grp $grp temp vid 10 + $MZ $mode $h1.10 -c 1 -p 128 -A $src -B $grp -t udp -q + tc_check_packets "dev br0 ingress" 1 1 + check_err $? "Packet not locally received after adding a host entry" + + # Remove the host entry and expect the packet to not be locally + # received. + bridge mdb del dev br0 port br0 grp $grp vid 10 + $MZ $mode $h1.10 -c 1 -p 128 -A $src -B $grp -t udp -q + tc_check_packets "dev br0 ingress" 1 1 + check_err $? "Packet locally received after removing a host entry" + + bridge mdb del dev br0 port $swp2 grp $grp vid 10 + + tc filter del dev br0 ingress protocol 802.1q pref 1 handle 1 flower + + log_test "$name host entries forwarding tests" +} + +fwd_test_host_ip() +{ + __fwd_test_host_ip "239.1.1.1" "192.0.2.1" "-4" + __fwd_test_host_ip "ff0e::1" "2001:db8:1::1" "-6" +} + +fwd_test_host_l2() +{ + local dmac=01:02:03:04:05:06 + + RET=0 + + tc filter add dev br0 ingress protocol all pref 1 handle 1 flower \ + dst_mac $dmac action drop + + # Packet should be flooded and locally received when there is no + # matching MDB entry. + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev br0 ingress" 1 1 + check_err $? "Packet not locally received after flood" + + # Install a regular port group entry and expect the packet to not be + # locally received. + bridge mdb add dev br0 port $swp2 grp $dmac permanent vid 10 + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev br0 ingress" 1 1 + check_err $? "Packet locally received after installing a regular entry" + + # Add a host entry and expect the packet to be locally received. + bridge mdb add dev br0 port br0 grp $dmac permanent vid 10 + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev br0 ingress" 1 2 + check_err $? "Packet not locally received after adding a host entry" + + # Remove the host entry and expect the packet to not be locally + # received. + bridge mdb del dev br0 port br0 grp $dmac permanent vid 10 + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev br0 ingress" 1 2 + check_err $? "Packet locally received after removing a host entry" + + bridge mdb del dev br0 port $swp2 grp $dmac permanent vid 10 + + tc filter del dev br0 ingress protocol all pref 1 handle 1 flower + + log_test "L2 host entries forwarding tests" +} + +fwd_test_host() +{ + # Disable multicast router on the bridge to ensure that packets are + # only locally received when a matching host entry is present. + ip link set dev br0 type bridge mcast_router 0 + + fwd_test_host_ip + fwd_test_host_l2 + + ip link set dev br0 type bridge mcast_router 1 +} + +__fwd_test_port_ip() +{ + local grp=$1; shift + local valid_src=$1; shift + local invalid_src=$1; shift + local mode=$1; shift + local filter_mode=$1; shift + local name + local eth_type + local src_list + + RET=0 + + if [[ $mode == "-4" ]]; then + name="IPv4" + eth_type="ipv4" + else + name="IPv6" + eth_type="ipv6" + fi + + # The valid source is the one we expect to get packets from after + # adding the entry. + if [[ $filter_mode == "include" ]]; then + src_list=$valid_src + else + src_list=$invalid_src + fi + + tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 1 flower \ + vlan_ethtype $eth_type vlan_id 10 dst_ip $grp \ + src_ip $valid_src action drop + tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 2 flower \ + vlan_ethtype $eth_type vlan_id 10 dst_ip $grp \ + src_ip $invalid_src action drop + + $MZ $mode $h1.10 -c 1 -p 128 -A $valid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 1 0 + check_err $? "Packet from valid source received on H2 before adding entry" + + $MZ $mode $h1.10 -c 1 -p 128 -A $invalid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 2 0 + check_err $? "Packet from invalid source received on H2 before adding entry" + + bridge mdb add dev br0 port $swp2 grp $grp vid 10 \ + filter_mode $filter_mode source_list $src_list + + $MZ $mode $h1.10 -c 1 -p 128 -A $valid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 1 1 + check_err $? "Packet from valid source not received on H2 after adding entry" + + $MZ $mode $h1.10 -c 1 -p 128 -A $invalid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 2 0 + check_err $? "Packet from invalid source received on H2 after adding entry" + + bridge mdb replace dev br0 port $swp2 grp $grp vid 10 \ + filter_mode exclude + + $MZ $mode $h1.10 -c 1 -p 128 -A $valid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 1 2 + check_err $? "Packet from valid source not received on H2 after allowing all sources" + + $MZ $mode $h1.10 -c 1 -p 128 -A $invalid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 2 1 + check_err $? "Packet from invalid source not received on H2 after allowing all sources" + + bridge mdb del dev br0 port $swp2 grp $grp vid 10 + + $MZ $mode $h1.10 -c 1 -p 128 -A $valid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 1 2 + check_err $? "Packet from valid source received on H2 after deleting entry" + + $MZ $mode $h1.10 -c 1 -p 128 -A $invalid_src -B $grp -t udp -q + tc_check_packets "dev $h2 ingress" 2 1 + check_err $? "Packet from invalid source received on H2 after deleting entry" + + tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 2 flower + tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 1 flower + + log_test "$name port group \"$filter_mode\" entries forwarding tests" +} + +fwd_test_port_ip() +{ + __fwd_test_port_ip "239.1.1.1" "192.0.2.1" "192.0.2.2" "-4" "exclude" + __fwd_test_port_ip "ff0e::1" "2001:db8:1::1" "2001:db8:1::2" "-6" \ + "exclude" + __fwd_test_port_ip "239.1.1.1" "192.0.2.1" "192.0.2.2" "-4" "include" + __fwd_test_port_ip "ff0e::1" "2001:db8:1::1" "2001:db8:1::2" "-6" \ + "include" +} + +fwd_test_port_l2() +{ + local dmac=01:02:03:04:05:06 + + RET=0 + + tc filter add dev $h2 ingress protocol all pref 1 handle 1 flower \ + dst_mac $dmac action drop + + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev $h2 ingress" 1 0 + check_err $? "Packet received on H2 before adding entry" + + bridge mdb add dev br0 port $swp2 grp $dmac permanent vid 10 + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev $h2 ingress" 1 1 + check_err $? "Packet not received on H2 after adding entry" + + bridge mdb del dev br0 port $swp2 grp $dmac permanent vid 10 + $MZ $h1.10 -c 1 -p 128 -a own -b $dmac -q + tc_check_packets "dev $h2 ingress" 1 1 + check_err $? "Packet received on H2 after deleting entry" + + tc filter del dev $h2 ingress protocol all pref 1 handle 1 flower + + log_test "L2 port entries forwarding tests" +} + +fwd_test_port() +{ + # Disable multicast flooding to ensure that packets are only forwarded + # out of a port when a matching port group entry is present. + bridge link set dev $swp2 mcast_flood off + + fwd_test_port_ip + fwd_test_port_l2 + + bridge link set dev $swp2 mcast_flood on +} + +fwd_test() +{ + echo + log_info "# Forwarding tests" + + # Forwarding according to MDB entries only takes place when the bridge + # detects that there is a valid querier in the network. Set the bridge + # as the querier and assign it a valid IPv6 link-local address to be + # used as the source address for MLD queries. + ip -6 address add fe80::1/64 nodad dev br0 + ip link set dev br0 type bridge mcast_querier 1 + # Wait the default Query Response Interval (10 seconds) for the bridge + # to determine that there are no other queriers in the network. + sleep 10 + + fwd_test_host + fwd_test_port + + ip link set dev br0 type bridge mcast_querier 0 + ip -6 address del fe80::1/64 dev br0 +} + +igmpv3_is_in_get() +{ + local igmpv3 + + igmpv3=$(: + )"22:"$( : Type - Membership Report + )"00:"$( : Reserved + )"2a:f8:"$( : Checksum + )"00:00:"$( : Reserved + )"00:01:"$( : Number of Group Records + )"01:"$( : Record Type - IS_IN + )"00:"$( : Aux Data Len + )"00:01:"$( : Number of Sources + )"ef:01:01:01:"$( : Multicast Address - 239.1.1.1 + )"c0:00:02:02"$( : Source Address - 192.0.2.2 + ) + + echo $igmpv3 +} + +ctrl_igmpv3_is_in_test() +{ + RET=0 + + # Add a permanent entry and check that it is not affected by the + # received IGMP packet. + bridge mdb add dev br0 port $swp1 grp 239.1.1.1 permanent vid 10 \ + filter_mode include source_list 192.0.2.1 + + # IS_IN ( 192.0.2.2 ) + $MZ $h1.10 -c 1 -A 192.0.2.1 -B 239.1.1.1 \ + -t ip proto=2,p=$(igmpv3_is_in_get) -q + + bridge -d mdb show dev br0 vid 10 | grep 239.1.1.1 | grep -q 192.0.2.2 + check_fail $? "Permanent entry affected by IGMP packet" + + # Replace the permanent entry with a temporary one and check that after + # processing the IGMP packet, a new source is added to the list along + # with a new forwarding entry. + bridge mdb replace dev br0 port $swp1 grp 239.1.1.1 temp vid 10 \ + filter_mode include source_list 192.0.2.1 + + # IS_IN ( 192.0.2.2 ) + $MZ $h1.10 -c 1 -A 192.0.2.1 -B 239.1.1.1 \ + -t ip proto=2,p=$(igmpv3_is_in_get) -q + + bridge -d mdb show dev br0 vid 10 | grep 239.1.1.1 | grep -v "src" | \ + grep -q 192.0.2.2 + check_err $? "Source not add to source list" + + bridge -d mdb show dev br0 vid 10 | grep 239.1.1.1 | \ + grep -q "src 192.0.2.2" + check_err $? "(S, G) entry not created for new source" + + bridge mdb del dev br0 port $swp1 grp 239.1.1.1 vid 10 + + log_test "IGMPv3 MODE_IS_INCLUE tests" +} + +mldv2_is_in_get() +{ + local hbh + local icmpv6 + + hbh=$(: + )"3a:"$( : Next Header - ICMPv6 + )"00:"$( : Hdr Ext Len + )"00:00:00:00:00:00:"$( : Options and Padding + ) + + icmpv6=$(: + )"8f:"$( : Type - MLDv2 Report + )"00:"$( : Code + )"45:39:"$( : Checksum + )"00:00:"$( : Reserved + )"00:01:"$( : Number of Group Records + )"01:"$( : Record Type - IS_IN + )"00:"$( : Aux Data Len + )"00:01:"$( : Number of Sources + )"ff:0e:00:00:00:00:00:00:"$( : Multicast address - ff0e::1 + )"00:00:00:00:00:00:00:01:"$( : + )"20:01:0d:b8:00:01:00:00:"$( : Source Address - 2001:db8:1::2 + )"00:00:00:00:00:00:00:02:"$( : + ) + + echo ${hbh}${icmpv6} +} + +ctrl_mldv2_is_in_test() +{ + RET=0 + + # Add a permanent entry and check that it is not affected by the + # received MLD packet. + bridge mdb add dev br0 port $swp1 grp ff0e::1 permanent vid 10 \ + filter_mode include source_list 2001:db8:1::1 + + # IS_IN ( 2001:db8:1::2 ) + $MZ -6 $h1.10 -c 1 -A fe80::1 -B ff0e::1 \ + -t ip hop=1,next=0,p=$(mldv2_is_in_get) -q + + bridge -d mdb show dev br0 vid 10 | grep ff0e::1 | \ + grep -q 2001:db8:1::2 + check_fail $? "Permanent entry affected by MLD packet" + + # Replace the permanent entry with a temporary one and check that after + # processing the MLD packet, a new source is added to the list along + # with a new forwarding entry. + bridge mdb replace dev br0 port $swp1 grp ff0e::1 temp vid 10 \ + filter_mode include source_list 2001:db8:1::1 + + # IS_IN ( 2001:db8:1::2 ) + $MZ -6 $h1.10 -c 1 -A fe80::1 -B ff0e::1 \ + -t ip hop=1,next=0,p=$(mldv2_is_in_get) -q + + bridge -d mdb show dev br0 vid 10 | grep ff0e::1 | grep -v "src" | \ + grep -q 2001:db8:1::2 + check_err $? "Source not add to source list" + + bridge -d mdb show dev br0 vid 10 | grep ff0e::1 | \ + grep -q "src 2001:db8:1::2" + check_err $? "(S, G) entry not created for new source" + + bridge mdb del dev br0 port $swp1 grp ff0e::1 vid 10 + + log_test "MLDv2 MODE_IS_INCLUDE tests" +} + +ctrl_test() +{ + echo + log_info "# Control packets tests" + + ctrl_igmpv3_is_in_test + ctrl_mldv2_is_in_test +} + +trap cleanup EXIT + +setup_prepare +setup_wait +tests_run + +exit $EXIT_STATUS