From patchwork Sat Dec 10 14:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070337 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 02239C4332F for ; Sat, 10 Dec 2022 14:57:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbiLJO5a (ORCPT ); Sat, 10 Dec 2022 09:57:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiLJO53 (ORCPT ); Sat, 10 Dec 2022 09:57:29 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2059.outbound.protection.outlook.com [40.107.96.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668851A20A for ; Sat, 10 Dec 2022 06:57:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DZm4XWLSANY+J/ziVjATPpIShl+VUdHCpj+qsWuVnCpn9vunZ944cM1HUM5td1tKWlNIyP+bk/oO0G8pR5vHdtp1MFKG1XDpL+JlIJW2GNqkRCDM9+IMGrUCDOTD7s5+x6N9OdiWYJxMNzlP9iIYHNpeFbuyLuA9ZUuVfBr//uUTYlsBoJhJQZVp74klLiG4bpevqz8yJHBd6O9SmKgidJHz6Vm+h32eOLtYu2blljwaSXXyPFrNIjzOCnlJmC7ei6PRuQlVLn1UvlZPFFRkoLYNkjECq77LJl5DJl/vmhJn13bEOwtZHiUXTHhYjDrwUtNjzwH7hz8GNVPEQlVU8g== 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=yM03GIg1YwgxJFGyTUnV8Za9M+lBuhgfqRMZea9IeS0=; b=HmG5V7Bl2C5yxSD7lGXGzHJ75b2AuttSHBVHLwDP9WVj0GjJJ5w0fme2MQQDjdyd0Yc39NCR3gqebJfHASxV1ITojbsinqbe4MOWK7OC8LT1V/6X05MuXPbIiEoeUtr+LXo5LyYnnsHygEJmpch4zVHT2m07PdDtenc+OtdS9VWIDGv6hlSW1QRhrTG1fcq5vClO6Zhg//LryEGulr0BWjFGF3dXrP4B4IXGfBL7Yjx/kX0WETHMEcNXh2GTRsG85EU9nZByEYgY0xG7JEflT5xjnaO89drbDfiRZSaSCwy6hF/dMsLsAdp/iHPwz4BcyFOwraypHDonFYcP0zqbng== 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=yM03GIg1YwgxJFGyTUnV8Za9M+lBuhgfqRMZea9IeS0=; b=bO3IVvPo1tzhUt/FeXK5cJ0gLp/9gfZbLH1u2sU3gC39X2BAUbGkiS1dRiWRReQ0Kqg+Y/7lRcaPjAuxPJFPyz3sm7jWTnKvMSg33M9n2aK9bs0UB8H3xyu73mWH1S5e+vrw8wvtIVXtXGAUFJz3fZOBm5My6NPaOWwcST8u48QiOTf9u5tQoLqAMA6MyuWxK41+9VpxVR5gc1QsnIlZgYciROV+0FBov89dFin7WD8zJe2b9+YUQlOj1VnMszVX0QgmG8AC2IWm8CkmMJ6K5dg8xGPNWcG0UOYMNawWTPoDiAP6nLE2hz/bA35vfu8J5pDbUfwB+8Gih8M7nwNFzg== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57:24 +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; Sat, 10 Dec 2022 14:57:24 +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 v2 01/14] bridge: mcast: Do not derive entry type from its filter mode Date: Sat, 10 Dec 2022 16:56:20 +0200 Message-Id: <20221210145633.1328511-2-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR03CA0066.eurprd03.prod.outlook.com (2603:10a6:803:50::37) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 96cf8d56-a0ce-4b15-f474-08dadabed910 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j4VwQjf7jCQODP/VcFk4SBd8RId8/h0Flid4sVfZqxzI9PJap9GzwqXAcn+/2mHYl9jVjw3JIU1Q/j0uAouUXkPuOOmYcACJ+SoBMweD1vtlRL+eyOYnei4h/G0CA6JxfFx8DC+L5IpqY5I3lwpYpVm8BqFhig0tl1laknB9M/YeSTjfNKngVSiG6Lxky8xlmFws88UwPSDwaaZf+Sqw++MABV7DY6C+9V/bOBkbZKaUN7rVoD25uQTlpo/v33SOOP9x3JwZmhYjYr/ekIE4XAvxNxCybHBNKL+74I9VNPze/zbMuUlls1CBTUPN0tMHpfX0gpxA882UCIcJIixmDKDvG8lm/CCv2zc0D7FeBpCNarue4V4Noa5n8EjST1K4W+GF5V0fFEyTaqhgbc2eL+I4SSkgDoa+XVbxFEumyuKYX7I03y1Eynuii3u40ob0yugnI9vTkZmTBBs49kpuB8qhPolzRnJ0m29o89fljWv+yVVABhggo7SRvsIK6LufNs2FU99NzeJVvDQjheaC9YD4o744cQhTsDNgC1ansN6U/UEwiBRltUzJZlkZKpy+lITxxSqGCiZOme9VGlx+8/H/YHrSydHqxpI02C+OOqTnWLS8kSPYdlt530tD4Rsi+sn2pw6e7n24W2uxUeFmVg== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GfYl8pWT1CVn9xRK923ewHAUBERFwEVFaIZ80BiSchA6JP1FChsOwbRbf+XdhRmwIrtZa6yoGmYIR6wJ+1cLNinM1W7N+FmpNgrYSUQ0re3I6cYuztR4QRmU/q+TsItbiHtrkHgs2Az/LNwJJfBWINIcgzAYgghQQPsrwHhOwLZWn0UXnljR/ec8gOTtRMJK0sz97Mi26E2ybbGOsAd6dpx0Z0p22ctDpkqSk9UCc6zFEU26WhlYT47QIK9br8oFpBZ2aPxk37O0rfxUiPh4QLHD6roVjsmpO0OTZRtRWgcKT0XJUo5Cb0RBKVJKzjaUW6kOAQ4ssxTPkjSJHCDut7wbGmDQWbgWRZWwqiIuH+2d6n78LN+FXUyka/k6DzayI5MuwMXGVfgAos7uM1kimXRqKsEfB1SM+YxMqmCeo7+bSbZzyGxi3G2Mk/BIGnpyOxOKpDZ9gfXRDlzrkHFNwRSBp5UxLFnfDUaHPXdNhgveUij1qNkQ6mg1CsY1oOgY8fMbf7FQHghd+scNGzGEEOHnPVZPsQARa1rUidyTVpWWIKgPZFi5cIjWPCUViaAzJZr/S+b7SuiLNWIaBfqnAyb3rY8BMUWNevr6c24WjZRZYoBv+yRR3uY/MrgdAS3xSwr5y68Ml8ltDBQxJGzUXwezNsDUV8m7gaEol9w+HrtAjOstn26PNro3VCo+NtKkOXcQAStb5zT5XV2NmNyk7e7N0D+atmg+O+G6Jk/VVUsTN2YqGgI07RDQMtnAIW+RdM/q3copfoDuB+228pHoH+Zz0NTR0GJFwaXv/eR8KaAKkk5aHiCmlHhS4julDL2FHnEmcloEnFLPPSdz0v5dGKSulhPOBC+kU726zg6vvGFmP0Jj/++2Up036FOp1aWaMg3h3KgzB/yOXbsNKnpHbq7dhKkiAEna0nVHt3hl0tBV05uTHB9wcxNKdKheyDNLQFTUaAdxUKP+xC+jkm/uAWcPYWX70c1+7QqFk0HjcQAcad5AFrozpU+JcELpOrF2c24e+rc/S5OHpjkeEz4e6c3nC70fG/Tx0XzP15T8H6o1oHyfzm2RHBbSV9g0qZ3xGOp8+zG0kc0eY9HlgeKIOIgxb/nHYIm4ioeG/sVqIbZ/zLGZrFTe8Yjk5fEIzOGrzG21t9kY5PA59pDPXx4//EJOmUCHkYQ44OjcZYdotx/eDPuWBg9lIEZhfmWiPiSaQpZ+nkIbjBPc/7CC5Kb9LzsYl3Tkl5zHJhYNZ8Iz3buXFATBHYC99xQlHxXw/95fWfQlUp24M8Ddex8kpeEAWxIeYB6ylb3tLXS5pUQ8ZAr5YMe0lxPjGdEHGw7I4u6VDA6hG84kG3qo+zpfjjwpBxe3G7WSn/mhtzwBy8CG7iOdW0E/XXglwAvL+njsgR4xphkQz/M0jiYXTBtMLzVMpc/X/pboKM2kX6EyJDqXICgPmZh4kYjfuW49y/W3cNYGi1vFi3WBBB0kiaLR8MfnijCbymjrz0UtlxUHMCPo4sWj7etBwWUGvFRydZU9vTaufgQrKCrULhZ/yz/aAID++T3hBFVkNbtdYmFpUsp7LVChE+bKZnvHHl1lG6ttLq/G X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96cf8d56-a0ce-4b15-f474-08dadabed910 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:24.7691 (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: tEkSzelLXgWfp7IwtlEZ3wXOGQZfV353p7pD2gWHl07fIcOgV2pmmOWbeNZGv7GxKmyo+am6u9dUpWd5K0UBdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070338 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 7FD9DC4332F for ; Sat, 10 Dec 2022 14:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbiLJO5h (ORCPT ); Sat, 10 Dec 2022 09:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiLJO5e (ORCPT ); Sat, 10 Dec 2022 09:57:34 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2084.outbound.protection.outlook.com [40.107.96.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08C21A225 for ; Sat, 10 Dec 2022 06:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ES/9kEY4efVCetKv6VHe6LQj0HXbCx+7TL9+xb4+9ZKvIC0CXzEuVw0fkSo+m1uecHEXvY22k7LuwgP+k7ze8ogLEdvm6JFUiA6v4Fw20m/2uJxfah8/wQNp2YZev7TuFApqyFu42VEpEFdogIiDyv2Xyj5bkxHlsV2WZOM0lxPpXk/HV9U4WHy4V70fwp1eoUgILe8+CPOy44mrcRc+MZWqpm/YA3ALtnqVcvT/cTlIW3tIE8uxXiwdQ4dy0I0eTbhAhNlR0qXN3RS2mrB+jB8I3BuP1l1akA+8bWL5Rdvi2I26jYWvK5M1FAM/CztIMsxT2Bn//m7AH+aBIQsPCA== 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=KTat1adZC/sbh7f8N77P/a0y0eW+413i0rOMlVSpHLY=; b=KxasTwTzZ18boXuIi1R4m0wS9l3DvioJCm0xNn+ecFZa8yNIClgOtFFXFgWa+zrVCfi1+74VOADd4p5utSxqO30Ay7CLWvKW79U+zTu9neG23lOL9yKVPMRynZk8YssY83ewpd4KbumkbSB/+zSyh4wwOzaBtBZPD3Eqh/2ATWeRWVAkrloXMD4RHrxilVVZQ35jtF/U9y06LH/wx/IdB3K7Dil+/cG2vgj2IJzHtoW3cR/1Ii4R81CoWNgH5VA2aNuaZRZcDYfFSHif2+trMoXMTg4plauW978E5Zu4s98awNBS+e93SItGMjB4AwvrIGBAVmBu0AJQ/4itXoDGxw== 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=KTat1adZC/sbh7f8N77P/a0y0eW+413i0rOMlVSpHLY=; b=VH95BIlflj5Wzd2bON+zxto+Tj7jJP3SdQiRBE1tkboMUfxxaE0Mxc+ag9rQmBOrEoesTPeunIP1dT4ftI7fZGhuX02u5rsW0xJC0vp+onRqbwF4HZ1qOevmpC+kkuAId/L+qy7ZgNUpf5jbYZxffbtYfdQ0MR31qrVyBqiqpgoqC1krauBMf8L0fHQdcdmCGE7XslZdwtXA1RenbDChyxL5L6juItV3KV6KPlnKvoc3Tw12i9XeK2s10F1WNOOk21e96VP+aIW2IzolOAVOvNyZU4qv+qC6KTyuBJ9GSEr2mIrzesnRHvIDe7otDqCzf4i90uapKGE4HWY/ZA73nQ== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57:31 +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; Sat, 10 Dec 2022 14:57:31 +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 v2 02/14] bridge: mcast: Split (*, G) and (S, G) addition into different functions Date: Sat, 10 Dec 2022 16:56:21 +0200 Message-Id: <20221210145633.1328511-3-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:800:60::30) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: c0e170d4-98da-4ac3-465f-08dadabedcd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kfJ5PE4m4yVsN2iGrTv5ubJq2iUnLHdiWYiWgY8VDD8KnUR1p+q6e8k6crj7iO3w0T7A+FfXwhT+xGUJr84xvsx5pCITIS8EbaYSAEzgRAWlMwnOoIABcaZNZfz83ZmnkxiWukEMBDR8zz8EgCON3xdHryHlfWayoHeYYvzZvkUzrmrMtWc6IhzAsz+lbS+sySWweHMv5fAmUhwuIEETZjfS/NoZs1ft5N4Jly5tT/96o9TJzfBHN98oJBRKozAX/35mmr4kOs6feb8/kxTQYuN6Ns5jLfQqWujA56jn6L7aMZFBSVgc3yhON+R5tdWQjgg4fZGFOpNmj6R3AE/DjpFv1t93qnmpyIvnjyTiIRx7VbFxMgJ4iopIXU9yszcZXZ7gDHskyQe+pdJpZ2JhGphusDoPwL8aVIh8nQd0f530/ZiWSYRHahIBaA/r6v6Wn4hSlNsgQ7arSeQD0ksFEZX+xBPRX7ouGdEBLiP2W+M3NZaYvDqgbmzfFmkLeqL1M3wirkopKJxkObqUztz3DvTOSzpJBd6Gq/D2UK6ZkOIp4P7sh6BH1I6o5Qy/DePLGTtW+kMoq87ER/nGaFZ+RZ+ugAyzuMBe8k7R8++hNv3IJUraD3pnlpzZkm63ooHz4JG/Mb/v2a/0LocXOZSCgA== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: degoF/hfpW8/icNy9AcPdCAKjbqGQ+jZD0DlX63YSx2GbKBpBf5BhA3Ai+DDG7mypaisFNeO8nnZveIJXH6Si8VuyzMxlJiXCo5bQT7vSt7Wm8ZwiFoyBdEwu3OE1Tq6Zt8vZkf3xgxOm7IvclHpkR8GtGrdmDxzfhzM0EtU2gcIKDfLvVolVnWw9Zn4DJ7fsiRyZlH+LOJAYEf0yK5vaPnwnbRVwESA7hvzH3/Xjyk3SLa8vUnO/D+I6/KbeKr2WhonxYBP+liZpdfE+A+HAuVdB7eSPf1lRMykLce1Gx65TIwK07byHeCFON2NNKcHSJ11+K/GxngMgXnPH49NvY3I5qS6xJam7Lwr+agaoOLNmiPGpXaF0JoXTj+2NnJScobWWidcir0J1+cDCvSKPdw98vBfadrYtVLFyL2h8jqIquaTDC541b0TVqtkMB1Lc5fWUJ/D82/LIqTIlfUycNWZWQIk5C0220XKnQrsVlayU+A3hB4m10BgG2asSgj5h7dydetfl9UesB9g+IjT5woNwkHK+6gclYw4855PuMk/5Qj/+Kfc0fRRrHmE8+nRQXjmxdZh0hTVSfQ18gAW1lFTXoARKTDoXcIOz3RvrdJsS10F9zlnZiGBKAFaoGoYQKsoPm1j0+i81rJFcZzU3C8Ggu6zqnIYt6mw2BS8qcZrs2G0a92aiwJI33M/nXlB4fJvN5f88+2K2rqATE70uwiWeAPrLsNb/z/xytEWfcHyJ1iTeH//+FW81JfImD23nGWK2VcfK1VtA7otPO7A6C0UsEZauEZggqB6/XCj2sDhBn5h04by0fmNHzbNoWoOoM1Q+RDfz4vQ9l+BJfNNmoqQzVuDAJ9CJz+i6/d/Yi+3WftRPIC5bw0DJ8hqYAmw/OQkbw3b0uQo69xhIxIHTV6mV0JVgXe6l3E81hvi8IWybcXX151our37WytNBIIxVNbXGbgnzNtQYLLHesP5HYYnKVE6RszvWyRRO4xd8FtqurN/CwRMo05mhePIIzhFsQpe9GNeo0+f6olFDIVagcfLBDXZdEoWggSkaA6YPpnLO9kMgAhU2qU6SydT4ygDwDkIREMkhvhHAr5K8KzGHoKIqZbbP5FrmJBbVVbKBMRi+P2CkqZSRhvqyNHWPY5PyUwMQ3usHugobumpWt6USVjW46rdrG1owXfqVbFl3fVjVsa9w5f4+tjAyN3SfWLX718rr5kxnKzrFPquhP6E31+5eErQLanYFMAz5k65v6EDDaATg+TlsksRmHW9rPiUmBLbFjIkXy7l+M60X0qHHD3/oNM5S0rPKKnn53phM3avnFpZ0FPaDt+oSDjYiYPI4PB6eLYv0salIAzVoyf/Z+zgl7IcJVh/mRBm8oPc4pd/tGZ+cR3QbZhIXWSVS29Yvok6ApAR5s8eRsaUvlQnIVvtRVZbIpakaqdWI4zR7UEo5075m4p1aoXDguAqsLD4h+VPmf5g3kvyogHPo0vnwqJLXBOmfepQ+LpH8bR9n86NAI6AAwl0JVaBJ1szU03XRuxmXmhBhudLeCK0BJSkDvpryvU3npzMKL+XG60ZcFK8MKvXykcUHXlrZyWXKw/r X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0e170d4-98da-4ac3-465f-08dadabedcd9 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:31.1152 (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: CRGAwL/fiNKheFrKGZPLMonfQj85jRE9R3GH1ZfKG7qFsEJIu2t8gqgsWSQyFCBDBDBmfxi+l9cMKung9FkkiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070339 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 B64BAC4332F for ; Sat, 10 Dec 2022 14:57:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbiLJO5s (ORCPT ); Sat, 10 Dec 2022 09:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbiLJO5l (ORCPT ); Sat, 10 Dec 2022 09:57:41 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2078.outbound.protection.outlook.com [40.107.212.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E2C63A3 for ; Sat, 10 Dec 2022 06:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dK7y02O43OufkCUEKn/spO4QaJ54OchlwvG2E3DHRM6GblRGO0gdS3aZvDFku3RIPXH/GOaCzRTGuhPZlelYQ6uizEQNCB3Nh1uoDOK+Is50LVjJ8dvXO+AP7JSEtoA5kp0ABX7gmX/t4JkPBc4sBqqRt0+WafRkVe6JeiFkFSKfyTx6VlcldvykWx6LO6H9JBjUbj/pd0ktVQTA8Z8XicJR6yMp5MsdWiw+LL6RynArVmTLf7GsixUUKaQLkSMgFfFA9UXCrF9IQ4vrj9CWLAw7lV1TadHjVhEEMd3EQc2+5t1UYjOnq029lDM5nOq3POlCua4ARmLiOrnuuvc/TQ== 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=guuAiKTMq1cHWylnX+TBumTs3dPvMOVIRHAI4ZB3SJE=; b=LEpvQfwg7QOK14v2qGMYxvSV4gjgykTr2zZRqiPVA5USdpY1IqWrgf11ty0h0pBnqkuiOSPIXBYhaseNG/Xm9I8QrRpJTppvt2Ajqtu5S/LoKIW9A5bmsErNZD6tbaum2NQflS79SKl9lcGgFmD2Pv21JULmaTTwJ0emQ1SNipmGCBHi6i4wntrIJgVRSwWooWKlqgdIQZJt/sR2b5Zu1si+5ahhRuK31YgXV0eo2IzRN2sevt9kbADG95pu73V4pDbKJX4KBY3awwnYAB8Azg6wuMjr/bmXX4VR4JZGv1zNs0Md/10y/9aIG87tcZfo+ShxEcBpUug5zNn+oYJZXw== 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=guuAiKTMq1cHWylnX+TBumTs3dPvMOVIRHAI4ZB3SJE=; b=PQC1QCUoVqroTSCHF/lOvuWW6cLfcjVkC/rvoqW+x3mbnp8xbbq9vJ1xiYza0JSYR0wXX3pL1UZNrZ+mXLTyyFRZNEL1jtukkZaMXu1kc6eNHBSu+RFh4Vd4EgdO0QngsOttt07G2GIa4YvLkMb5cKeQwktNGLePIMVw4SplypGwOjSXoTtaK7DJgaORju310BFsG1Vmw/ygBSdg3cSDv9/ilqTiROm7uDh4ti0FQI36eubTa2pzWWvn/Z9gSppqaomyuBYL/jIjCm8AEbUeW0e/KLDqYHfqIeLOdBD2BAtDdslu7aTXiuyWtElNypwjnMHbWqYcH9WKLShaeGwOog== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57: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; Sat, 10 Dec 2022 14:57: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 v2 03/14] bridge: mcast: Place netlink policy before validation functions Date: Sat, 10 Dec 2022 16:56:22 +0200 Message-Id: <20221210145633.1328511-4-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0501CA0037.eurprd05.prod.outlook.com (2603:10a6:800:60::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_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 00dced73-d650-4e11-21d8-08dadabee0cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: as1NIEoD/yAtFa9tggEunRWky+l9FsvZM7c0fylPpWGCZ/fhvj6qd1LcaFIF/hftUW2fvDpfkucJruHe/wqgu6iEnX15MvTfZ5nInVMiuFXy7Kp2tzOH/PWGgKDHIdTQi2/quSBPzOlW6qL93sGjaIeq2v1z9vDXCzJKMSSb3cB6a+lpCq4tvrB1d13b9GN5qb+z4zkr69FXoqe9Td6FbUKY1KvnEENny01lVQ08twhzh9MW4uxTnwu8lETi9Ff4/EUDx0tc6rsTVF9iVe2q04YLqw15PVt4NU0oDjJK/RqVdh3wgRioTONEyZv+Zw2afJdFpArP1NWjVOwMZWzqBh7Yg5OFZu9wv7hn0AN4Hp5dH0peJNnTW2Kthkvo8r8fqA2Xl0Bu+OgZ8vFdaD+Bdt0RrNBnykgs9ioEwz2MkS6wieIWq1RvUgwK51Yq5DfW/OYR2w04Bye5aKlxSUXijDp9neTF7bhO4+Sj7I0sEHtugclwS86bCULAAsh33C0nLko6adfaXsLX6ZECpcLug8DqEYsUKht4PaPmckxEPVuvLBK5twSnF/yLIX/Wm4al2vcsIMppZV0/s3y8h9T7Xdwa4jWG1kZrQEzyZwFDofkQB9BkJHkI63hxaCmNaRR99TrCbIZD/K4z8CzrbSpsJA== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oDb+v5daQkPQU105+oNiXZia6oTNBhaJT6L7eQERY4rnboau4EAhku+gD5r20YHLV7+dhM9C14cl39EEyd79qKQnMRnpPx5/H4ISI7zGLwFwSkFzP6XcwQ0nMGvZSXsTmeKwJy01Ot2FOJnDeTsQBoliM4EJSrFjRucpBH7ubSiFOqWb/lTcgTgTGgWllGJedEALg0pUvcq3/qjk2/1rAfMC/QHoIwpkuQK8rZnxtCS4D2IK/ucM2mZGxm2JAmASCHft7bwGC98mYumK7wutNJbz+pOgPn9bsaQt8WvQPD+a3WLeFJB0toz4McHd7eJRYXlFtu8Ote37OjzLR1hpB6BOGvDWYDiW0TlJ5WZKCp4W+gvLCtnGESQSLVRHjS9Go8TtnriQzAWb7mjk9nf5ppV8eYvF5ZuFlquPEih1qts3pYWgDWvR+Z6wzhrZPr32nPlPAGd0v3wuVuUUoyvwdHP3UTsOyCsUI4usIKqgiqRP95TE6r7wV//q21fyS5pG0i7al16Lm6l4WhAbTGVRIXeRkxKFJ7U1Gmjm+LxL3XCHJoAsnVvRskjQjsQy+JnAcJs56MYeVQ47IIukEgOTWXLYumXnqrmXG+BvBjWB2OQRjXkgoHUZZCxdK6bM5lWtqCz8OjdQBBhSFFBnZ+RTXMuElsEZ5vz0Jcoje6IymTndpZRdoKKaPuyNHm7KpoR3DjgI9V13dRw2H5x6j4YqfDIKkcnC2SmcBlqKTf1DIEuS8vTvSg6nPiBdma/Kn2T9oB4XtP0veR+JIG+ycgv2Y/k9J17SOp9mvTHaYNnTha9kiTrAolF9Y3OAAg5zijCOI87gHicq6953qR1+zDx1LEdLuOaG356JBysvMFCKQt7UeZMnEaG7YPyOOrPaGTCheaMEypcgmFp3+9+5oMnAZQsZUMQSIlLReh9DMd/Wl3KOKwQxOxpdKdur6p3E7kHrFgO5LApUgZDxeRcqP7fxO2wRLS/q65E2m5Wj+Ie5c91SA5OrsDfyfJzitFg/bpHWDtzaS+o0scTFsqHUq8DEyt7cbR5hj5m4P9Dm5A464MdtBtibsPNmzogekP/h6nUzY7FyJsrf+Uqa3BmlocbrhqJQNTjOWYOSogO2dXMun9nZbpvP7bM0h2Nr4THDfbUovOG1P8tpFWqApoSgyOkuxm7UvGKmOk0qqQNG398BasPwFCVxS/aiSsFZBI66rKwZuIuGZp8zQ+wAXyoqSbCSQTWlYZT3fmBU/LnyfOFfApPj5oSgIQpvl78+Fu7M9rDu4l/fD2c09iRmlgVmgTyoDAwjse1bxpUfL0cQKEqQLI11OxwmDHqlCyZuFubE0nrYwIHnztphLOmKWm0vDkRKSB4E9l/BPu88rDAys0+Yg+tSGnKoJWC7ctMBlxERupm8J0E2Py79nR1iIbFkK7wknVTjiTxwMiEu363MU6ZuqiHgT/Sf5uyJLgXqAxJcEGmv1kAWb4kWNEeqd/OpHmdAeOav0GQs+f+L2MbMmm2YqvpK2dZYybFakRdrKRx+YwVO/LGAvr8PYs4qJtVGywz/XmyYtAqhh7L8wNYmp2t8WWlBvCxZ/E9qHpX1g4E9Q/Hc X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00dced73-d650-4e11-21d8-08dadabee0cf X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:37.7752 (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: ReVCGvGeINe0TffPLfahIVXK0da1FyXq62/beROcAp1drpZuwUUAyyBAH4lUjlbi6hW1gfzImlGAphtWD/FaNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070340 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 63E18C4332F for ; Sat, 10 Dec 2022 14:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbiLJO5v (ORCPT ); Sat, 10 Dec 2022 09:57:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiLJO5s (ORCPT ); Sat, 10 Dec 2022 09:57:48 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12CCA6178 for ; Sat, 10 Dec 2022 06:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gCSBRt3MyRng0ooEvRlloWVNtJ7i+FvT2/Gsy1vESia1JGNHbr/Amba+4dwz+fOKUFpIsZeIbfYXUUjcz9W2EVq3ale/lDwZ9hLTGfD+v4alahp+sduBkneEuyu4Ax2OtOdDfYNBI5nTzkvyUXVa6rJ/jtIRcrgc7O+yKXooNYExHW4lNAaWjF+TlvQK5XNeHqgD7bUhTZXiquf83MlX0JxzAL7AU2xZSkMqHGQxIQBuZ1JAQMMTZUQFJGfcBItyKNXqNjlVk82UkvDq0IKtf0G5C4aU5LcZX1RnAOTXAsrN3sapx6p+arY4oj8ycA9P7T9VLBs6wzEQ6oyf//4cuA== 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=xY24savDE2tVnazL+AV43iwdxH6QPiA3//wQh4CZfWQ=; b=N9KocA2ZxBloDcUuV/iP+2WpRt/e9okAIlYGPmtgs4saWGlGJ3PVjeisak2VKWHtxkAW5kTXsS0W/O720AeLs9lH10xVBi0XtMbhVxwY1GblwPL7rsmMm8+M+A8GU+SPp+CPkkDsDU8xIHjwrrRo7A2O6mLlP+4veo5phr0wtpdcIiRRFXmBtxrgZEU1eecYJ91nhJqvGGQ7m4ZS9M16UKdRsWRfVbYI4kfWnCiacXQoHxINlw9ov8Z11KwEC/A9cJEOxoBgFWPp+i7knGaaCQYKPZY2hfK5DbNrcABIh5SgPxtPT3+MpDQA0Cy9aa9PggDNvH+CzPxlxiTrYCb8SA== 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=xY24savDE2tVnazL+AV43iwdxH6QPiA3//wQh4CZfWQ=; b=mAmG0zlj0y06MbOwfs5sOWAi071Rk6pBLnQnGXVtVx+oRrxS3qmyTQ7H/i8BxZ0bbe+azlS6cUB90z6an+UfjCDSZuWlCZD4MRPudMdHGwzebZsv78E6tCJNvHwgO0vcZAjmrxZgmntlcX8li58EeEnr/r6QIfjGDwXPuchdaXTU8dBONvgRpwXe79lThJIhGHIYyorHeGocAqbhBQ7hcGTEASVSEsJetjVC0opF3OntcI9UQQraBPCh1r0kBwLcryLKOVlgkwTlwMrwnTOkaOqBjtca7JIxrjKQ8KF7D0Mjoqq30MXcId5aaXcG1ivKB302lhl24sdP7c3LckgPkA== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57: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; Sat, 10 Dec 2022 14:57: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 v2 04/14] bridge: mcast: Add a centralized error path Date: Sat, 10 Dec 2022 16:56:23 +0200 Message-Id: <20221210145633.1328511-5-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0258.eurprd08.prod.outlook.com (2603:10a6:803:dc::31) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: dbc92cd5-0dee-4124-e2b3-08dadabee4a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lz2olgnjkLacH++av71Ql8baXPYgANEnwxXoQsiOOASnkjNeQEKTiGY8X3xGZe4UCCJ0DcAudSmTMJ0QcmLm5LkE6eUF+LexIyF1hbXp1CTU3NhK70WyQA8X+Augh0rSixX/DoE/JF4I36UjirOL7X58yxsIeX6wZpGzl9LIjHa6pIcvwlE9peO/frNpEqShjNx4eiPemr7LiyrNdYZV5zgLnDBAM12E3njxWfw54hwARIQqVuaYwx6l+9O4SfWWb6y9m9WJRKAmtBHEMRDHJfzFPc4ORPaX3KlgyL1oyn/nB8HYc3dSPX25GDTGm/a6EFsoEBqnaSREGqbPtdTt70uglCm0f9dnZtuf6dKR5SKTaQiO2g0b2RbO1NmijV+xwajDJsscqOZYv1eoZ5k7szu5diIsSt56fo0BNDwwKxem7EfTbBaLGc3/spQyYfB3+zZEVy1Ch2StpdxaWOZdAFs/YDlJUdb2ZP6d9SNKxetb9X6vU8J7d0lku+6BmMAk14wp0JTpoWBahg67qJK5CXeOI2kTxji+0H8I/PW+SucA2dCjqVVlAMxmHdfdogiACiDLsH1+2+z3qrwsF6rN+/tzxvnCeOxU5NTkmP14FJ2Bo8BFFY6Y8Ih4sYWLMdeaIq5NPSH8tivX2xPT44HO7w== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IUBtov83EzEI3OF9Jq7KcjzE/g1cJ/1HOMKkHsSmTADzrShMLek6IAMlxpUUvHTNeVrHwl84buDktiMRPvg+x185SDNIjrmRESAYuIezmX0/AjvW8lJByGXEZ5FHqpzMuiINcPG717LSRMwQcdVGmW6XzwFwC99b1fDk4Y10oX6MKXji0UE9tJe3d9tX1BcGyy1wmDEyZb5OZ+FOO6ZO6yeQP0F+sqaLcgJfZ0qrf/JpHNnWtVGk97o5almcUP9fiT+RaI0Mtdoqe9WcKwL7lXZaqbCKAgpfh2XACJTsc0WisbTaxTQ1UFLZHuGbi8Jukjo68ceXX3sxL8fl1DQbYLzQyK38PUx3ZUTmYVGYNAOeC1vPdhuT0BQnaA38CMx8qJKaru3EEwxZE2SfokTyl5etekJHu4CDTVz2RobqrzW1+Z/1kxh4NpecpLXve5bII10loDJ31pJdvIXhPFApNsaiXH3SkHjH8UEOGpru0QWz5lxibpq/YjIoqBvtQpIw1kP2T73X81TTfec2DzukrBxRUA6tO/Y52uoGLdW+j5Jfcn53RUEIw9E+rcggVBEudDvuC/K0v6tf8eZpfS6AvIqIaf2ZRniNoMD5zmcNrpkE3nGqQ61z8oJqxCqX+IHnul5J4+xz6F94/JNztUpYu957AdE3OqNahVdLExSXV3ZrQrEE/9XLxOeZqJJAJxdRm2BGztwsJQR684GXLpBfa48Z/+lCZY1vIKhDq51f517VzhrrIs0AubjHnTGgNCL+U1YjqdKHQTeF2Et3kSX3ET9nQmIIKGT/4jBCYFxsyRvsnQ4J3u3Pw9iGN8QgR02/WQdwVS9Xlq/7P0Tg0StBIxPi5OST04ZBv4lAk325gqfPwxUKR26bG21G5z6DQzUu5eavVVsCq8mN9fztAdO/eZUrAUtmvhcnAQnB/t4A8adLATj0Zep+nVH67OWrLeBF6hJ1qy6+BN4o6BgTNYJMjCSUDqyGqepXfIpraf7t4c+QE+oFqGxji91BDPWWCPryqlPtl3tUIcV98MYpMKbgM4tSc5dUg/lm9urPUFd9NyzaiOr1U7H0P34MrkwlS55v+56CbYZq4IfmNiapRal+aZFafBrVZXe02dG0MX6pVFePBVAMogCZgLB0Bfy7K7IMZYCHTwl7TllO0jOOYIWvR/pFm/t2UNCUHKtbSe/4+BXZPMIwCc7yOasFfuKpOE3FQYIUm9ZDOP9GiYWdHq7TXA5NYv7uiRbaBy4Nvgn1RNvKtv6FZOTwZkTxJuRCtpJ13s/MBaaDLuj2QIRDNANmMUyh2uQbk4AIV9ivppIXZ4i2485iaQoHnNWBgIuo/EPjR+cDqXYRgwGQUwenGH4o4IsH4oFzz6uOn4BKPuZ7u0mOolB1K70S21qL8g+vRK85GWK+VRN5FzqrFQECa77/91+7ayi9Rm1UXEF3asbpbf6bhv2S8EnJHGWo3j4Sa0sF9Spjfy96tU3powCSLRCtcl4xJLaAu1WwHJ9qDKU4unJTIACoCi3cacGAX7vQbyg8YGbM3+si2ee7AIXeXqYcfu30TY8j0jHO71SkqHU9Sqkd3hK8D3CcvvUIX6pZbu/d X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbc92cd5-0dee-4124-e2b3-08dadabee4a7 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:44.2133 (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: 5AmBpA+nI33hrQpi309a0vYUEIlxj/R/Ew65Jrg+2JBLRDKTd6ZFiBVutmiozznXhAL8iQNyjXnkZGZnRdMZag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070341 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 1CE19C4332F for ; Sat, 10 Dec 2022 14:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiLJO6C (ORCPT ); Sat, 10 Dec 2022 09:58:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiLJO5x (ORCPT ); Sat, 10 Dec 2022 09:57:53 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2058.outbound.protection.outlook.com [40.107.96.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD49913DC0 for ; Sat, 10 Dec 2022 06:57:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XiMxYHCKqCe0oaN9pf7L/YZaYeeeE4H4jFa46+30ZcjGzCMmmqgjAmVFMdPm7cYzb9yLp4jul3t2fIDqkcixm/sKVF2wxvxwH8l+UToQMfKEd8IRMZh1uQffEibdSp7J0eGgICjSsUHPWvjMHtVEuIT9tnGMYeU/9A94Lz87JxvG9ZfnsOcucPghhGi60tT0tB/9HN2KKxk8++2RsgBHgVGo1TY4ZeJD8dpV62DyxxFzrMR9NO1qTrMNKJdU82MzXsfIWxjW5lWTgIx5Kz4StgYvSI30IFMXRXmsBEZmvisYCLCTyCIizIbK+eD3i6adKPA+gdxHuthgK7C283p54A== 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=vhjkLzUUqq7AZtBVlw352mbVcqWLv7WZ5npg347BeyU=; b=Ncn2w5iopMsxszKFOfFRZprgJhhESWnUuTg5auEyKzE3/tDunBMqU0OPWpdaXA98c4Z5IciszwJVZq1uy1p4J5PligPajwRN0sdiBgMwmJ7X8cxPyLns1FCUXaHT8ZJj3aqU0lA6uJsLag14RNP/jOkja4ULImJs/k7MunVpyUtee8kfnlTgg2fWd9c1jmMVMhQyJ8PV975tpe497/oIYrQIczYZTqt2yWFHWatA4rEke4TkqSzV7CDHPvGuCmigpUEOi7nWZtOyVkzrX58RB5j6AGREqcQplBx37hoYxz6IZWCB9ku0DrSheSr4nr/1MjvQ8QbBiLKGtBEuGqLtsw== 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=vhjkLzUUqq7AZtBVlw352mbVcqWLv7WZ5npg347BeyU=; b=tjUfxB200Ontcj3QDY0DCZCigN8up8n1DkmnO5BC3ij6Sv4rYIhYtNq5fg1XCluVMhdc9OLn1C1o1cqnHifWmxTOndwsjn7ROGSuKk6us1TQNOQkqgSR5muBMfsqpoGH/uQkGJzyABoD7lLSuXkVVcn7eOd2zeXPXPgtU932ivaL0lEzHLqaouhaqIsC2I3RLx1eUpD+wpGeBR0+y/LQVZLe3GcgkcdA0hsgUmaXdtwyXgy6IgfrduL1HrMc4CJDA4deC+ohY2IwOqECWwzPbBhWXm11FAWigqCvN1VB0gZgoXN3widJjglF6zx+nQd3K959IAlkFWIm6uP0k3gHgw== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57:50 +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; Sat, 10 Dec 2022 14:57:50 +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 v2 05/14] bridge: mcast: Expose br_multicast_new_group_src() Date: Sat, 10 Dec 2022 16:56:24 +0200 Message-Id: <20221210145633.1328511-6-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0401CA0016.eurprd04.prod.outlook.com (2603:10a6:800:4a::26) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ba5812a-4e7c-4634-a48e-08dadabee828 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: olvzw1yMgQQcMPJqbV7HMZx2g/JW+Hgevq7ZHmiLexXEXcQau2+Q2yBKWkKqBDH9PW1CCsu+KYMjjIBppGLhdLo4rXV4BAq2MpwRKH3i3dhTV1RZ74DchJHJtoc41yGb/stb6v577hykW9zXVhR4VUgjfvBeNcG0hErxXROBdMO6EvS03VnSgfz3QOFmF8SM9QZ9Yw39NuYE43MTG4NqLWBLHL+T61DhwoEvaoviqI4KOYeha5m7jPjer9GPuAK3qmPY4UugyhGUlBUHfFAv5yRjfni0xelATBIxoW9eNP9irLQ+NCyV0Tlf8PmdMggp+2qHQA+DFndXxTUYdBAQWEucknsA2rmN10MeXesOYI5FPKYnR5en8V1Weoh5YGS9ZO6G8KBSkBtU7jAmOH3LafSfypzPPWSzxaVrF59C82nGCJAD2g0+TzCX/aU9pJyOPC3BHliEZ8vAQk5eZf7l+soGZ7LlEuYHJGrtgd93iXdoQee/4mwZGO63d04fP2gCUQpg4DBfpsQRE2uqNkD7pDXlZekzUzdg4CeY2SttH2+bw4OW+RoczNEMWD68arQ4H+ardyJ/oGWlLPpIc2zOcf0YCyefAduMcKUIHoYrpcyCyGEJUy3BRnL9QDN+7rC/Jm+N/50A3fh1SMWjAG8ruQ== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SM9deNMS48OSlvWyYwX/sCOD2FEjBDj228CmQFhMR/DLO1HS/PO0fZr4tWDIDAInN6QfmNzvfFI+hQrhSQWbip/0l2BMtbvIj9Pxe+05PGM0ZzOuoPKC9RMqhpbkkSU1k8UuBUC+0HGzxeASkZn81jSl7ggdP33f3xTIYG5gdbFcTRiNT3wIq4Gvkz3Jo0w/ETpfek2CgU8ifcg2g0qSns/dES41+AgKYg2v4SJ4xy0h4H6b5E5zEYgTlPyflRxgXvD0In1JfObHUbJVWxFVPTS8cw+9QR89E/KliRga/lniGxjlUJP2fvDDiR2oi+ky2c7BQSYTJ05X0vxVooy227kCITq2FsBwnbNbTkgZb7oWIs2S8LHFk1lvl78VLS/ewQ77o/MHMX452bt8dU8WcJVkUxKDizkzm6kN++A35On8CMqJTEsBjkBVOkOzkTQyod5CNe+XxUJeT7rpOTFZkpxlrhP5q5CZBGVr4RqHCLVphQfu7ITzVAM6M2tGgK1xXYT1k2gWZW14nDBToYUNjo5aN0bbUDU31gqhs/MHAq/a4CDpiEl+wBs//XEQE53ALCb/QaaFJcJf8LcsX9ZDZOUad38cdwOg9pO1CAKT2MdMzfFRPKUM6FQvIo3zvS0VnoTRKBs38nEjDpwbXaFz74c2VlLRzRCLFSelY3AISMEZaFN71pUB/V8bJbJ7Ank9OsKgXldPippugJyt89+4Jx1V/y410k6k5P1btLSyCNLJWQ8+U+dYSW1MBd9uq2kSir5OQ9PXNqBofDtlOfjcW1gmtU9B8yvZYaaWQkXD3PNkzS43Ll7SmbwdtGV018usXVFUf0m4BDMtCc9JxEAbjM3uxge5hSbv91pFAnZqITI/PfgDP5Fmv1AVMrUYIgLdUd9Y/Ae31sqeDv9HHsZeT8Pmf7OuR0Yac8OKlnK6r5Jl3M4L3dEF6mBtqTmR+gRE6453lpVsi3pEMnku5ttQvH3TCgVrHWbrDVsc/ykMUNq/L+C/iDRZ2ZcTP+ZAGmFW4unAuW0DPLjHJuOkS426rOPXzX4WNA2wPd99aVZdWXqagjprDKGoMMpr2Yz2jalQadTToR+TIuXYWtIUUhxUdx9u4T8u7QBLckIryeJ+7DcLokbhSUSrtkRbkEf8JzIeW4Bs95k34OlbHEsXbuT5w9ciTY8RrrAXJfdtGQix6pIDbVt+7eP4Xt83jyfYVxs34UAkxTRAbgnyauBd2jQPTltE6PISF4+MRoGr049ncJRST22e4bOuQh9MX/bQiCJpJ++TVfrCIQ6DAXO1qFS4NAD4YMGY9Ss12YZzrxviJ2stIf/wU3lKIJQjGZoECZP+QSHvYAjKOwQ9qksXAilCoq+DjkJz1FYs/nkIaA4I5ktzmI0BZF3Mf1apVU/FEHuI6xkxHbAJU8R5Q50yTAhFJCbUxIDykILv+J9SF1ewYxvESIQyPxNmWLsMmUlDjvUXLtJW0VZyu6v9TCxTz5/UH9jqtY1/f2mPR/Tv2RlKvaB4McBKVVrCXfrcbonU6lyd6G58vd4zc2cH7hOmsPPehv/z6p4RmDFp3zCFLciN5R/f0YzTBF0ciMX9y3gmkDmA X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ba5812a-4e7c-4634-a48e-08dadabee828 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:50.0901 (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: BTgjkF8CwObfx8I2UlOUJjZPzOniyV0ifr2fFM7zRpotPbMdZAdER/2lgYRD6W02bvisVghSC1vxxLq5+n041Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 13070342 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 8CAFAC4332F for ; Sat, 10 Dec 2022 14:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiLJO6L (ORCPT ); Sat, 10 Dec 2022 09:58:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbiLJO6C (ORCPT ); Sat, 10 Dec 2022 09:58:02 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 669B91706F for ; Sat, 10 Dec 2022 06:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6XmCEt7mwApgoKRFYLnxJYHy9q+W+Vwu1Ikk5Ak6bCpdJVkRd4GOH/+6X0UhTNFeEeVRoCpScLINxfC/1LeTU50xk+WybhAh831KJtO95ONblN3rOw8NN2WtLLAl1do9bEfIw9fZN011HjW3TA8GQmdRO7FkHqX7g8orCw282RGS+WSQejD1bJ8WsGrEafurrEJ3nFvzchwtapmGrunEBTWzyy8QH1HZ88sxaGqu1pA7CMCFrOQ1od5m5qwA0lanczg8kG1H0mr+SJDM2ZuGw0GE+HahFzOB0wc/N+ALqnHAKghYfQo+xewXmAQXCUYhNwDePBjslbERANkuspTIw== 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=dvCiINSgInnpIymRGCEhRqVBUTuaGlTHULAaBfYIF2M=; b=QxuxWPPL4QdJRy10jj/uNKfSD25vAMlO1zsP7dEBaNE0IUBuTBHStIXYNj+X1C80K7iZixbr+QNwCyTMiA0Vz9BDJRltZXrDTb4IE/EgSUriPg2dyTu+ZRs76p8aWX+E9d3hSA9SMmd2EueWGQv0N524byS9jS14pznDHx0R1wvr3GeszsmpWspcP0DQFFg7rw/sp+9R1BWCv67xa541M6gr3S1LEdoC66RwDPf3cCRKegM+V68rUv1styPKfA+EpRUC3gzQODMGTAbOJ7O+NzxqODvywpOrgq2bwxB0RBauIsYG/6Wp+WCIsMIDTCy1GFHzEA8Qv9Gk+h1rtR+L/Q== 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=dvCiINSgInnpIymRGCEhRqVBUTuaGlTHULAaBfYIF2M=; b=e5/1XUw27ciuZ4Ef3a2cZfUd9B2XtpgMdJSYDsxPteWQDn28AcSYZX6wlKCRbBEjl+WXVgjhgI0xoETOWOZZPBcyrjWf864VCojN00VUmshR/NUbJswfa6muhi8vpVFzHJTkwef0p4xDnf5uIy/P6FktCCy22pCtl1GyPBCsCH4sp51vnV9GpkEZk+tGgK0LSXI2VVrcx4mHI8bTZgu6epUYBaAU0ulYHdLI0CYX7fE7TAlQe6uiBkQj7caUUe2bVrgubI8qsnQYn52+rmqGa4RTsvGpKPO82o0Daj4CNsx9H57t4ktoEMuaQfoLciHjMrCd4xdQVj5/U5WyTkZIxg== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:57:56 +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; Sat, 10 Dec 2022 14:57:56 +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 v2 06/14] bridge: mcast: Expose __br_multicast_del_group_src() Date: Sat, 10 Dec 2022 16:56:25 +0200 Message-Id: <20221210145633.1328511-7-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0210.eurprd06.prod.outlook.com (2603:10a6:802:2c::31) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: c977ed35-c83c-4389-8b9a-08dadabeebe2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EftOba9gGrGvlJ1SrA1OzlTebGAr5o3psJ4DwKL3rKIqShDvnFbS9d372SeSXFoZtLw0DVk4Na+boQ8BsPhYfppmigntXZnIe7TqW8h33c7+WssjBbHTL26vWOyGmnUzAdAR90YsK7228NHP+Z7jp7Czeyn7CtAssed2KcvMuMhS3DCFsFHEa/bTXzdQ7xIJQdfYotaSJnpql8iDksNABHfonW+nP6v+6+7doZ/BDX0ww3zdWi/fBFXCO+Q+yBbHCtlJp8bpFm2FXSXztqzSxQQp8xyq+iKV4mTZ8jJ8fIdzNHT8xg8YutxQoaYV/mx6b5QPZLDjF3aJUN+LEikOKTo9YG86v3+ePG5dRuCpFj6HfyAENYy+On4deaZtgec9Lrte5MEE+/xFTa4yCWxu+4v6hGO6riknwUg0w1c2wm1dJtVO9R9rmmKCXlVAD6XWV6pdPX1SY4yLHOhAhopeamzRTuuOKU8Dg/6oYdmuQ9PgPN5ItRXalfcTAID6n0iM4xi6A74lAk0IOzt2b5wZ0tmyPbumBOXLlWK8khAnbIzxLzecSMtmbVo5IHEPfhrf4IClqHCPSYQBUvPjFQX0q+/laZQyrSv0cdoVEWtsPvZJHqkTRE1JoK7pK1RFyR0+79eR/UkDsQcR6XFoij/n3A== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TL+ULLHfVMfAXaOTzVpKefn7ih9wLz2x17OnKEEzZ9wzXqiGYL+OUkSXjzWn/ts1bi6wyxsRRqsM4nOe9znFfPwd7pT/uNUptBQnBQS14wTUKhHwvFGut8yDbb+FfN1upo9GFoz4U1Eq71oq0AVc5PBaQ3udhsPWWjAGkNIZsqrzCFTYt4ifLC3biZyjxNi68Z/GM/pLlk8yiQM5CHtaq4TzNwyPWNLo5LClzlCBN1PdqWtQ2U6wkltHjlfmYbrLg7ODDbSUqrMI3HhPcH4HxxUPU5NNX9rRgtOAuFoGpFbWpS+PfnSJIF49Akx83ZymZyFUOGxSvz0zz3LrCSre2o70GEQiqE4yWZkuvfVNVASSYfk9Es7XwI4UorYOH+JR+ri4GRtbMri4c8lKSbbsPhXZ9B9Tn3Zb5mi5BDRM71BV/eiDLNky1Vw6LY3+E2NnOtV7Z2ySeZvwYLmaaOLgYDJQ4zxYIlLtIweJjCpa95KZaVLFxcYljYTSwLjUYph8I7swehMx6Yf95TPdvzZGrbH04cBFx2e7DJMeL/8f+0g33lFzrin2btcv82S9J95kGFz7KvQhzHBmVRQA55gwJVdm7nw6/u4wW1ZYxqtmofldVt4j1f312X9EDfDKtiRW37bgqS4rLCQS0LvX3GtIuVQe9rFELvvgjdW8IFEGGmL7M9Sux6tkmZAvqb9j/Sw6zGo6g+smWo4rW/exRshO1sPk4tgeMD6NsOC3LCSpWVWP4fpaeFCYFfH4bEac5h1TaUBO1gV/02kiIYkLZJUID6K/+SF+emF3+kVJfBVWa3KPxEZ8PcTkpjsx07+jpewC7q1/cvArjBbJZpZYcXI/6sOONw0flF2DL77m4eB9h63Z0B2niwNoQ9RLRtPqYRXKQNA86gHCc8Ha/BYXEfzg/gkskiiHUi5Jp8n9lRln0CDgqEZB1pJHNTUslbQOqeRy77EE8z+2v9s3gXIjh9xSopzdXZVC7AuUYUarcO8Judx0rtiEhlQF8ffqcFD1VywWru1BmgF60c0DI2JY7Du7CW6pzDzwYW4pMelHwwWVr5bMrSv2vE/0789M/+Rhipppl0luS9BPxXWAWoCKOrK9ADnP3xC2CnSalu/VbRGZhnO3FHn/oJWI6X4BUxOFb8sf9Wj6zTRH2BMMWTCDj9WmAO2/0ie/emVryS1EzssXilJxlN6S52EjaIl8vyilzh+YqBUd1r5cQLr/ypZoG0VzrdoF4EsanSGYOqJg0tuV3cVQvT6aogoaGg249ZxgdoZt5yEAhQDPUpjiV6FmgDsGMy3D0JRF/5xavQvQlBOLxL9duloD2Zch/bC5ImYDa/kV0bwkWOHkyH6gV5drqA0ByKdlOsP7ABzssCpY6o4Zec3nDteQrKX0EepgphkEFCKZXNDiCy5UBkMC9aYPz/9PT2feu3JFRdbUxZ2fFsqVRLCeomK4o1jScin1k64KoHlPSynGb3XLtieK5frWDJLvIfR+pUaOlrBgEFk+Uc3cVmSBH6oT7COwP08lxb1XTQr8ftfxQTEGBIQTaeGW2BHJcRAQz31oZneNtu/9yQwg+ERBSgc/5i7nZAhHFeDSfxSO X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c977ed35-c83c-4389-8b9a-08dadabeebe2 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:57:56.4667 (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: sJrmCEKUtN3VFKlw4w0g/UAHP/XDijKi2KnomHkkAKOX+7Xsn8EpCS+5D23cJxj4xUWTMyYNhHlLbtgMs5BijA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070343 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 D1AD7C4332F for ; Sat, 10 Dec 2022 14:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiLJO6S (ORCPT ); Sat, 10 Dec 2022 09:58:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiLJO6H (ORCPT ); Sat, 10 Dec 2022 09:58:07 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 351D71A224 for ; Sat, 10 Dec 2022 06:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k6elELlbleUrlL6xGjV5onMJUp7RnvdIVc7SN2fyyxYtUXO95AC5OPFQLfmxZZNmGqAMtS6i3w+8pbg9cFQo/GoTtxv70qk4m8678IEyqkm/iJF6LoiFC66AOIeB9fGnC1uIoq3Y3SvkOODba/eMOZO7rGSA9i1gR0LKkXjhK3ggOMhNbAga8qriBTDwRy2Q4GBFul2dSpZ8E4e8u96l7JfSq6sahfyNLmV2HaWeQhyiKhbWdVnILsQqKWN5xYHaPIbIuz1WPXio8Z3bVktLqJrDfEy1TP3MZoG6fu9vmWkMtrzio8xP/Sn4QSVK9xXVPzxR5cv+x3DAI9sG4PHlLg== 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=2UdVK9p1VBhRyQALpImydJ0b7WZxGQ2JlhU7sflf2JM=; b=HXwi9iPsxvFo7uS9TxnXsSihzR+7CHoI6q9TMjZZ2cRfPz3WOZPqPW8QazAsy4W7k59S4MV1izNj9MFtusbrCBR6ly5KgC4ZNRK6RdHpdKvpMcrDL7Y4+bFvtvcW3X+7IVfdv130gW9HM+Ck/1vsqLMfXyHIL33jKFjdagMg7zVTPpkxcvDajootEzabzVBP1lb+yM38wvK235jxoS6Fq6HO/V8oi8Jmy86NIexg6sh5AsH/GPLyw0sNWOs3GhkX2CkAsVEUxhoaFUI9s0bob/niluhd8LjncX1+34oEuVVP76xQPkL7YTgJgjCa+lSgPCFeR2S9BI0QGnH8hngC3w== 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=2UdVK9p1VBhRyQALpImydJ0b7WZxGQ2JlhU7sflf2JM=; b=R9z9LgoFNXMGncD8RZVT7vQjE5bYSUmMyeMYwhM+wwnW3o6IllTbMxcBmf+sXPW4oJmfzprzg6mYN4xXCrObhCt8GXqVJJLKQc30QnjYlYHYzqvasiV9vXIiFXTQXa2mQ/eoPKQhz1B+Si3lZ+IcOsy9GOKC8oUA9mY+/Jr/c5Y7EdPEBgJdrn0XaunaeEfwfFPM1nxwbUCZjbS+8EJ4+wXm45zKs6qji5S7pe1wP5sKZwDmCnOs6GKutqWR4KGIY228DQrlH6ICDtWLM72ddk4Eu02w/LD1n3JwUrsy69BBlwjd5TIwcp3B43Usg0oYrkNFZq9rDgPzIoJPVQwt7A== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58: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; Sat, 10 Dec 2022 14:58: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 v2 07/14] bridge: mcast: Add a flag for user installed source entries Date: Sat, 10 Dec 2022 16:56:26 +0200 Message-Id: <20221210145633.1328511-8-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P195CA0094.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:59::47) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: dedff852-bd14-417b-b6c9-08dadabef112 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GME/YjC8PbPEbqDpIDhPkgaY1Sy9BFHkFGZzhSWbpNLeyrajFLzxpSTLQKbxLsToZ9XPgqvZcMjEmPpo96vK0+nUYjy1qqU5zGkpYkkT1Ntwpk7/qEwnn6SFsR5FONWUq0CypnG2i+W/MfXZcocEHr2hlBcl8c54axC5OCoAstEO/0DSzAC1KmgF4NFah/fbxGY2J32V3x80Sk5SrZ0eBs+KC7Nl7p9mD1KevOsQiUMd66EOMXf248nVuwSohxFzTi/tJ415ejBO2Biezovox+kYfZbsq405TOLJWH4kjhrcaVmfqaRST/WPLbT56n01L3DE6mp8N4et7wodkjzEoDUd2lL7owEnBLzNwRnwYbE2NwwlXDx4IxE15dX5iMK6EaigZOUoouc+W2P2KiIR5y62657RsFpdvzIJmkhnbMdll3vK3yaDfPvtDyfpYX4mXMhFp0vQu2ty+rRIb6htppODSlxZjD2dCvtZkhyLtPLEEKnJJjGOofGIfOFW3wCHn7M1QQVmUsmoI3l2A093+bIbvw+wYmheWjaN7KhAiDZVbAO5k5ltvz0KdRYhnKscSMHrTOrkq/59V9H4HdEwtf6nTEbj3FJ90URK0hbEY4RaJMBI9BSCSHuvMP6vWqtVcps36QuyEZr1nqWYOA+Nrw== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IAWLdszd14rEoMnwy9T5G/tH2Itt4z3UUJSImKoIrzLCrVfzGHS3kupKvy21Kaizi0tVcbt/cvmljWis8E6fpn1HqsYrpHt50n0lLBVT+9a2nci58Y/MzYEwCAInTR2dKyWqtlTgQvMdD14BplN+YQSbwRWOXXEe2rPxuyX0wlgTA3OZa/BKMcHp9ViPA5dJEeoY/QzXIgqdvsracgipu1Yp7KutAwyounmdau4hXo8cNEMPmzflUEneqaUBbhNB3kz9igVK8uBGwR9SON7zgAPLIX2hifa5/GfzslLf2IadR9sMDAhEABaHgvtfVuQhoWBx7bgI6clWKg9Xq2SiV681szEQFRLhQfPN3X/XZUkiLu6IZ7m3usGEYAVL1UK+rGupIrF2KLSNyDkOtfnYBEaSVHJkLxmeaq8sTMU+VzAGhycGh8Zbv+30l17W5WWZRmGgDiz/6j7ln9q42RLgI/cT+h5FHmlkNyTPR0SVIQ2SwzGGAMfNlXXZ7Pyg26Iz3FZ6boLN48f/DJ1Gv6lBahDPYP73yI5prs1tbu6fny/1W0XFLxbnlH+4xdvtDlKkt0rY8UFZv1EMNMEsCFDwQsGPI/k1UcPeuPFSd9mVrZkrjSKeUAl3EIP8jQkNyGnhY14iVgIDpJfxmGF7VvLehYiXyQjAKWOFcs4SkyrsfujnTwzwITEZyUmU2AfQ2IucWBhxjRDiYqLHmME4HushfAMbmK1ee/6onFK311FGR6eC0KQvcSLB22uOJKK4x8vV+BBV8vMCc/mBzIQbs1c42wfKv7IyRSfX6e9k/UcOiP7YpFoaq21+VYXd+Pdd3LX9kLylIJTtu9Y41evc3FpUE/ctBQRadxPq52GsaUFdp7nGLcK/stXKrZll8CjtpVJPY4YoSH7c/a3bKdLM4XupvDiAAxL2i7bSSZ2YgLINOCcsSH7x9TinYc6IZ8QG2wZ/QXDRR59UaKmhKDQZqcYVh6ATxNOlKzhgxx/zrfm9BSjAkl9HmtAKh60czudv3s/fguBIzfBF41Js+jBYDph4yUJ2wh5bOqCNY6W4CsiZnlNOh3xRWtQuDFzn7KJh6vOi4OVhdObaBATNfDSDQJFIeBcv2etzlGhLzo/t5Q0Ur4DPnkyEczUEUbArXDbIpXr9QH94Xh+vVpsCt2LwUBhe5Jofg5mmSlwbvBg79zyUnkSONrWdegJzwx2jmblanaf7EqIM9ss+//AEin2aqCxSiMOiXafrFB7zVzmYNCHEtzh8Sxyxua8/rlvBeGnJPNoWw6uuEIGMINMXU7W9+KCPTWU+MmZ34Kbl4iH2o8EfVsZszuaJPuVSjIKAG6kr6YdaD2phpQu2mMI1azcS/XAk4igJSqxlRZoNwGU9xGaDC5SPRbaE72Bz5u6fyWeF3uRb73nArMoPaHmV3uvvTW5PqQ4sUuLQEd1499O/gnl+B36Kx9/bQf+VaRE3z6VrhcAM3BCN6R9v2ig68FNBipa4f9rc1sePc8wZq4wr7fZPxHr+uYS+EQ7huS/v4NanJjDMJulF2Y4+rMTQGv0tIv3yDvGb3nVantiXoipJEUYyipRg3kaAPGaA/BWaQiI/lnai X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dedff852-bd14-417b-b6c9-08dadabef112 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:05.1085 (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: eL8FtrSLcIlqTIygDAZLAJTUgy3R0YR7f69UoiwqqP85QMv5vhrRoQAysPx0wbq1zr8MK5i1/IGbFeWvcm7L3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070344 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 66F53C10F1B for ; Sat, 10 Dec 2022 14:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiLJO6V (ORCPT ); Sat, 10 Dec 2022 09:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbiLJO6O (ORCPT ); Sat, 10 Dec 2022 09:58:14 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A3C7183AE for ; Sat, 10 Dec 2022 06:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PzvPbWWYcUcCp83N/tRRro+BKoDxK5MFIpZlkS9pv2KZ8nU9MdGTp3VkAlPYfBeNmZYb+PZ18VtVy7kgj8zLgOKBdzCjr8RkK19+wtQcATqKO2blf+TF8lnxmcGZEeJBxTCPjj5oJ5TBYVmGq1GCXPagNpkb7esxkaAZB4wbiGhswdbb8AE/I/AGenhiu+uvb3wcg04dik8mucMBDuK1rJeop7BhxAKxUjZr7MQ6WdDjUk5O/hZweSng6/vaz90B/br5t/W6Gq/vFLP/9opU4l/3kxCG3HGK1FVVYsk1NLowh0K/YGqhwFiAkQMhVgQ84TCF4CQQ0FZVcU3RCYDPsQ== 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=tYgRQjJod9sxq0dZSHBMevA+JFjKhO4R5dJtsuTAAB0=; b=e24fOPWaRN8xM43dKWRlYbkvLszDa7Iz/6E3pMD1ibcLAoslfB26Gin9qBHNoywyipDCKVTNc+hWyCyiKV76zxbx+juO9bNnzTkxoRbaOTA6rS+rG5s7L6xBcAZZWUrqc9Nqhtg491qzSRb91A6jyUvs+RQAY7Fb0arfe6ZcOYlIFMgiwTHb8QmszLuIXGSAj8EugVn5QWwUoptjwL61+W2+YtnjwUj/p9Bz3ieJCk8xVqbhLsh8oojWvX8Fm6ty235CoTiBH8Ap/1KeCC0Te6ZOdeh1hRUD9gxOlKrM5HuYY1cu0L7eLCLpU7GlYqda2WuRq6ZWJY0IhgT/y3A6gg== 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=tYgRQjJod9sxq0dZSHBMevA+JFjKhO4R5dJtsuTAAB0=; b=dbSJD9N0aNmUxeclCQi2MDCDc0Leq9ZvtsCQHe0wUYAYHqe4hUADbHVPezHFm6qGcHrJ3ZHoE05fCOqMfF/a15sOTzqk4+GIBsE5ZUzb2sf7EJglEcTQzjV4KhVxxkw6ga2I8ErlHdb6+lKI/bLMPvsrW7ACbiZpjKCSbYuK1b6q1q2sMURqF2RrPxHWb2Vosa/V1Qt/mdymhyCTKdtA/EFFGHLncMMVMCzdawXHtBvrHdMh86S3A7/AAs/tw7JwOe6XgQdPX+Shi9UETtE/IziLwd3pggCiSGLwkM1IKQc6s2swgeopw5Nm0FEEb+yuxKo+byyFjrfC0Yc8CxzdPA== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:12 +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; Sat, 10 Dec 2022 14:58:12 +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 v2 08/14] bridge: mcast: Avoid arming group timer when (S, G) corresponds to a source Date: Sat, 10 Dec 2022 16:56:27 +0200 Message-Id: <20221210145633.1328511-9-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0257.eurprd08.prod.outlook.com (2603:10a6:803:dc::30) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 7729b3f6-e161-441a-70df-08dadabef581 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fFP/x5XFNwYJpLDYWUmO9rJ+8Kktzd9DhYYf432RRHalKt3I8+zeAJjPJd0tZ6Axto78J21ChRQDuf9wRw42YqJz9tBRjGE9eV7vC8OW5QH0/+3FA9yiEKXRI8FzQapO3480Qm+jl94s/+e0gkX9KedYyEPWFqatJPFCKYONm7b6rJMSzju4a+skgYTfflSr611wpidJ6CXII06E/7nRyGGixxcJsGUqFj29TUGL5KVRKyLga4tlFno4H6LL8yuaLWJRCbZTMqZYsp8Bgf+ZjTrQ+gBNk+ZBmnn2mISLI4D0/nVyGP6XkjF7Hn+vSNXZtSuRUoWsBE7LkROsGNYSDh7OblDepOFXlAwCaVaZTZbwRLxlsBn7YneF5GGsBP9Y734nV4QxmxaBOJujxAfjVrzh/gWypRd19SsLGOC9E1lDt5pBnYAxhT0cNlLILfafucZ3C3XTpjA4hnD4GkKfaIlijFO1OPIsJ7uuN18mKGQGTZMwrKK/CsA7aDLrEfDvNe8w2TLES7nJVuZ9R9Obci0nL+5RMA4SG/PQzd3F/tanPNvMHapllVE18fQECaX+/T9CnwWM66YDmObsG2WTdAo162m8CjKDRVp10VA4YUoe+mhnH6WEzwbgGpxvx4J5DL07PqCtg1TBZhbSfiiGkw== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cHJVBo8royIJKyvJm1e4+0VuAYHfuO62dR7wBaCyCOYx9WjscJCNsdrDJVV3JJcCqexEEDXXb+VC2adYAvqkhIRgQoSWntTlMoxyzkVWT3Yjwih2xWzvF8OCSsuBq8DNHTm/jzDz1w89HcgIgEI0JrzHLQ0Vn8wlxlhvDG8/D/7b4RP/RWz2jw5AxI7Zvb+OSeG37vcGwaq+0w9sgA23YxIWLlu3Ol7rYZXPj9jfBY7Pk7tR7Xw/3TT/CvaG09x+Ub/CIeyi6AG6nnLYC+qmM/ogpnO0JMdan25N7X8VIoaWRQK3Kom8Z8UkrCOcqgsvNbIEuYJpiwwny+nbB+VAzD8jAh/Bt9PeS10zdCYmIgJcEY9UYDHm+LaQezcdMs4z3s6w+Xkd6JMPlopBH9+wc2++3v3UC5nhGU2Zd+78gI2oCoWeFzgsbYXFZBJ2WAFCw5tTG4PuAi3BJNI0NMN+QHj678nV7E88Pn3ZuteNlq3rsxHZ/mExCQO6Cwrr/NUzR5hbkMaXkB5esZXW2Wj1o72jvvY6teAHw5j0P66J2xLpeJEwLIlw7kRGetZ4f09HYDRYUTzJ15Jq2taCeV0jFgJuXtvZ6PtFjeWt0nTKEEgxAemmu7mxxnrMCmdOmypgBaOL7eNV7b8Tk7G9d8SgdvDXkYQxglOYo11ahb96SwR37LqJkcWZ4v/L5hIShEMsaDcY6wW9xfqFIMbl3o9r5gDaoGht10k0tMkWrupU+L2jTOvPlJvKjSRSH+Hb8hHdqt326l4JEsYkFzxy1RvdPUuqmni0DE4iRFiB9Oi6LKZyhHWGnQxU7loy0af7KWZzQVT2rEu9i0Kf/5ON9n9uTawjvGzui3Fkv5gItwK9dZ0b47iIpxzB5v0I6Tl3at7+jET09ejW4MpJ5TD1JEoD2y8nyUc5/7EIGwuYd0kg6tuBVgV5YaRqVktVV9FhFW6I5rhb3LI3WesDQ5y6oEGYLiMNqLBzDqYeT7M3XY4cpb87uqkROmIa5tyDxLBIfdBrqXmIiTfVZuhGXB/FdgYVIKsBt7YGFVqghxAxzWEaO+hGK6nllu+QDodkAA2/pzl2sx9qw3esk1esmaoDDqIEoTLT4qE3YC2TyUqrGnt9I36Dqj4idhuOMZJn5AgenRcDKbNNRQAZagL5pvDEkxE5tHAcPgh2QoNraeKYf22/4EkSe9qYVHJm7TaurUsb1u1vS3SvtzpGUGvEYzLjDNFsMI1rccIstCcxi3MfuHvRrCXby5BuEylFbv8k55o6FyYWXxgYsAhlnsLXrJbtkq353MaLluHfT8Z/tZJJENfjTX7d/BUZjFu40UdWkzX9sU9Y70/vl7dZo3QqMvvVeUXGzrbptA5XGv/LuKe2Mh32JQnoZvSgvidmXsPg+KlqOew0MHV/oIlPMS+kwhR0DsfcPBDhhsIGB6x3EShtEAGBkTLOv+e/94xlQFs+kgEcN4zEyXvqBoxDbRLulQF4U7DjXiczBmLl0BtXuch3qVP0L6BBurVmyt5Zge2cQ/gUQHEsJR5w060DLchPV4SHnjpcbg6mLCUvX3vU/9RE0Z3dF7hmCvpQlYYF20zcNHz9Iy2c X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7729b3f6-e161-441a-70df-08dadabef581 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:12.5138 (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: Rql8DWedhYr3393R3TNXwuc2jTKgtHBA/Hne7mSKvCCe1iISD9yhtQ+aX44dwJKfplFnAl5Qg2cljKex/ilOFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070345 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 7B72FC4332F for ; Sat, 10 Dec 2022 14:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbiLJO6e (ORCPT ); Sat, 10 Dec 2022 09:58:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiLJO6W (ORCPT ); Sat, 10 Dec 2022 09:58:22 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2060.outbound.protection.outlook.com [40.107.212.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562ED165AD for ; Sat, 10 Dec 2022 06:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JgmHm+vj8eDlCfEh1bL9MZXleVo8oyyJZEtiM7QudS4iPtGGrnUjbEs1dFJKYOSA9coNghkx4d1CnCxWoMhHVhKA4i7Sob/X8O+dOeK3cy7iD4xXYNmuI62IYlIApYp5ORL5yghbb3Yh5cNwD49FhmkiPztD8ouVCtABvDZ1ZtKMs00x6qMnNzH12Jp/yvMCyM6AATNTkdSuX+Xmbp0efUuJY4Sxowf1h1ec7bSMDcBfceJgRP+Tele+zirBssTWOBeV903C1qgnfEEXGshlp4ZwdURm1pJNTUMQtWHzYJhjLWj+9KRiFkvf7KQbAX86A7qBJxaiDSozoxL7hfmnyA== 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=pZJ8CCbsl/gjhK+QFImDzWN5UiqPInCf2cah5MNbM7E=; b=mjkrF7sqGZpWUdNXV0YVru7BgjiRzK7C3IZ9EG+VAmSb/qqegaz+iCMRmH2phpyVWqj65OeguhLY+dFUjdBg0msdvle+zYM7KYeOP0D801vyt5OgAyl/cs0jI/vZK8Jv7XOBzxZ0GG/0VczAcHLOlBCmIwZSIxh8C+5/hZRjGgrshPJeNTwXgOki69dDIX+wfYEPaOti340PembBROzkSrpErsFZbhCjeWa7wFEnYguxIwq4Oo3DOwac8/lkEhR5aQg+5UQo9A7F1MnAdFYL7cCOye1RRo1AjiuFMgabJGupMGaaSVGhaVBmYkxUDs/K8MHbpn4Do1O4QWMAgm0Olw== 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=pZJ8CCbsl/gjhK+QFImDzWN5UiqPInCf2cah5MNbM7E=; b=NpH6z57z3ZgOW0KdU9dEBpgJMxgIHQSvx5+/wye6IF8YaW/l5YCWu3doUmc+f4GooHwWblM+Z0AS5a9j+YevNHN9lkoP4ZdbJ5nlM91SkeJvI7jc68v6yk28TkWziaxR40tlGr2JNjxK/AEcZx2En+MZNmYrr52XjKA9FEDAYUEOScINA0h+QOSl0KcGcDoo9dWvEFnsXFDEGLglsRQ9d/h97P/6LqdesA00GaJ5dLIzp6CJQiShyAsYDiq6ADNII1DcDZ9GDdDHG1/hNqukKojm5nqlYba6D4VFgu3V1gc1hPsXyrSEUTCYtndt4rlOsQusDGM5MQ7yHArgnjVFrg== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:18 +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; Sat, 10 Dec 2022 14:58:18 +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 v2 09/14] bridge: mcast: Add support for (*, G) with a source list and filter mode Date: Sat, 10 Dec 2022 16:56:28 +0200 Message-Id: <20221210145633.1328511-10-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-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_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 45456392-095d-4f29-5af6-08dadabef8df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hdnKtezTGHbILGYYU7pe2VZF1/cb9MfM6y2ftffYpmXzRJ2IkWY7V5s/FmfStP58lHP6zJdjpHdCGOfjzDsiR3gSYlXTiIozr11uqGeC5YyHyV1FlErdg4ReT++FXFakK2H/to4LG7d9Bauz7vLYOD3ulr2TOBWxRcPpIHCCzB9YanRGWLwKRB3FVu7eKBUdJst75LVXa+NGlEQ34VeBPIKYDDJNARqSFlnVUcgkxYOtvt8WAHVIXsu8rirWkVD2yahlothM+mjD437zykS4OqZ85wP7HJEZK5IlsNQ4r9B7xaYBFSlDOoxKyEWzUyv+ilTkxtaBlUYMHQwMSRI37Y71pdK6+SCAScS7L6wyNkISjmxQb7TwEY5xhV4q/689wnKGyRJPURHsGoA85e6eG9nJR6Pp/rsiEcTwwnTuQqUbqr7gUouBQ68dzGf6yYZXcRWgDHzNfI+ckhpRnDvMiJViIqucT+X+bQZtcBXrkHxeo3tQXf/yzmYLGdtAhtA38s2FddKEutVNcSZqZm9mH9YivvonAZX9H52ZujQ0I9GTldD8mJd4zPWRGO5x1KSeDG63cGoNk7025hFiu7OXYd9gCe9FK5Uvvfun100P1FTOUqOGfsmwdIcm5iAXCOsQTyGCY7I3oF2GHRsbHlO9yA== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(6666004)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: luu61DTeQ2frBLym5WwtIGb+pGnE2Wjvndsifslzgc3UyJQ55RiL+6wZZzFGovpFguTim22YGtElAIUyWCQJNxTN+9Dm/I3tj8k1GGr5BChJOQD02be/2Bn9m1/Tbv5mkFUsXoPCWG+bOzKoZnuVGRC8fWREKA1Ji0nVhsK7A1DHagNqd0PX1TxH1ltY4mRnT4tbyb/f8r+Zv6a/peOI/UslXMxPnoHN4gL8TzdwjW1a5JUX2CEgFfRsSnV1VCrpmrhiiGBJITaC+wEVSxu1cVgmXAO37tyM7IwvCkuCViNobTOWfH8J0Ao/hS1kIX/8uNG3xMICplNBsZkOyA6w6Mom2t0DgQhzbuyTvHxhRUK2MrWGYMcf1Q0wI030NS6unl4JPc8aH24OzZsXJ1bxt7KCqrPGSMwD43W5osFdKW7oKfVpNUmqjgsBaKnL+PUuvZw4r82ubJs39b2u/nH8cNa0LjuopKEaBUC2Qzrb35kL4D19xvoVQ6Rw3pDKSZecaVEx7Lc9nPzUZqmwOaI3OHciyj8D/m9q0Eney2m+vOHyVyU8Zgd0/3t1krfXfQlMhvddZUFLwT1qMpYpALphkaT72UxVWbaTS2SRN6Sy/ZppE6Si1sUIPaIqB0Ol7Trir8TdGOf4ED+NzqTHJALXNJuVMep/1Epkg47RQvILJ7czhD8GaTBLAPAwKL8z/VN9P23zO4TVEUXlSFZcIMavRhJ8oJmu6lMomT06tMbc3NVdkZO6QElvwd0lsbQ835RSbi7yvi9Q6Db7uhiq+aTqrcUWTpcWm72YajeYppyiFBq3DMFUydiyIcx0MPU3YgUkmIbprrERs+Kb0mn4HTkJ704A8iVKxGpv0ZZc2KrYMZaQHvqYDZVBMn7baYB3zYz62Nd+CzSp7T5S4/sZ/9/LhSTIzJwAsZBserc58h35aX/7kGPeyxHo4ARFbt8I9+SY8VYZMpa0vNgcCHkVR90qyXIVv4hx8Hyd9gy51w/rywtTVPaWJV6zgzgIZBvM5a3zESUus4LzvLmS/OJ0eA+FtQwVQbom5fP14aB6zPmgN3nH8Ov+A9pDDjIN5fLEFnIEvv+tG11d0L0cQJ9RYzMLcnDCnDD9suuacCtMZLEtIHIssQRpVAZE5KwTOJS/ShbvaCl9wVmybTaR9iYGkmRLfqlTTwQCXs2utYIXNpPjpDauediY8K3b4DzxW4gwMRYnEssGCgm7aBsJWdKTzZS6Nk9NazdEce414h4YM0YbeNtq4UGsPZI/dvN/SYDSVT4rq5lFykEmHyJxm2ke8rl1crgX9C6pbSfsC+t1Ywts+Ld8qSf7VvpoBSBqZGVRVl3zvembD7KR8LG3je2Ie5KtPSs2I9t9L9lREd19EIGtcGrMx4l/JEunx1YeAIVKrP5oLOPk11HdAfFF3MLPWJSfS0lnhdECnpGby5H/fShMZHECGIizZsVr8WfJjQcd2KUukQvtpubLRWOVKEPpQbEohWCQmKKvsVJpmXkP+ZMwKnavIuI+iezw5qTLbZTbIGaJh+eRQQO7U+eHYCKS49NEzhn/Pp3ZopDxzV7FXRWYvy75c+pXIwtRd0vZrm3k5Tei X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45456392-095d-4f29-5af6-08dadabef8df X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:18.2405 (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: V1i98StnHwLy41bWgvNWIHg9nykVt9ey79GnpSdJJJiIbU6az4AlqIH10PEMotD51pG0xV7vF5ZvpdW3yITgMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070346 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 6AF16C4332F for ; Sat, 10 Dec 2022 14:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiLJO6n (ORCPT ); Sat, 10 Dec 2022 09:58:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbiLJO62 (ORCPT ); Sat, 10 Dec 2022 09:58:28 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 102AA1A398 for ; Sat, 10 Dec 2022 06:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZX26KGMaGC02GNsqrVRFifmaim9YoM+bfBlA/URCA0D55vZ7qC+AzBke6KqoinDu4L+3FfMS1+G5SEbQRD1eVZe+ZvQOJV6/fwC0oRtRg1jj0HgIDGHba6vPjzSKyBlepHC/TXVvwUofS+gjtTLbozYHUDJspuUk79IbdJ4T6p5GdetLVf4QphKjtSBz9z6bthO/I8oFp0z8+LJRxH2nBwln2VfRiyawkJbt/foPW0U4msEwQmg8hBcOhYzZQKD64jpJkO8rMeHkiUJ/RVvKEkff2n6DMMZ87pP5pP2DrV3JuVkmfGXOYRFRRYKijMS9JMAkmgT60xB3q7C6SL9rA== 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=Prt3U8OQ1/aCcOV92KzZD0IF4LtS8oQDmLJTpiae5qI=; b=hYFCmXxvDO3bXkc9NsFgM8pyA05l0+05eqaOrHmv0nDx4E1upSamTS+7XiyaK2KbsUDnARj1j9AGSnpuchSsZBrC3hXFDYHGLdWOdGhWhTjxfCHhb9GVH2CNLzF99bu+Q3XNbzbARIOP0rxSZcfwIswRetOcVL18rdIgkOSVkD5aIkc5IBEbSFWOpC+6Sl1iBbgNCp5pjEj6xKUBzP8xIOSJRUBbxv5MahjtlBVzAKB+Sparqxg4adnLqIvAutqxiQpR/enm8ENxhJwAQwqhLtLqDoz3hKViMHHkQ5TY/fLfy9Ff5luUUiNTBkYx983CQHghMNYYtziqSqHrbNgu8w== 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=Prt3U8OQ1/aCcOV92KzZD0IF4LtS8oQDmLJTpiae5qI=; b=DsJ3Z9tx4jEen5KtN8+aqtaLQ712+DSRZIhDCPJLzKJG8FTKUitnfiqrShIF2ivNMjR8EXt62WjLzTIWZt1rdDRHjV0Pmf2oTyYnd+fmCRnUugGoBdc0zJtcqr1ZdBfCqLT59qFwXS6cS504tWAEmnzUTo931Vme7VqTeL1ZEp43w5OxeGvbLREcewXLiCQuzN24Fd5BA5w8gAW+eKqZ9vKVXcIdOl7LNzUnSEyi+DZQ3ezedxXERP8ASQ8ZVyAatPu1dOz0mzoxZct/EzUDFgqaBapZDAM1H5vvckeIXGJZtsVQ0oQUeVQFzjBouxVfvKifLPBhxOTOY8/dx4OjGw== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:25 +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; Sat, 10 Dec 2022 14:58:25 +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 v2 10/14] bridge: mcast: Allow user space to add (*, G) with a source list and filter mode Date: Sat, 10 Dec 2022 16:56:29 +0200 Message-Id: <20221210145633.1328511-11-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P191CA0005.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:1ba::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_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: af3825a2-5ef8-413e-d8c8-08dadabefd12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MrY3fGNyyDGmg4r1JOVyNvHaIHGZ1gqJSuy0kmHI+UzujpnOZQeaFjpSdXsD0z5JZxVG1SiloD5vuM97Fe4XR0Z7qZ/WIToSKfZtdtRavbxC0UPBwfddEe9RpAUpzyqWoMnUNz+bocMxNwQ2pGRIl/yGrpvPIexeIy9B0jEfeN+YEVZrc/Yk8O0gig7kvHCbFGjOJGEPCx3+tsZ1yh9+59DV1FOIZrix1keT/SfNdLHW87MEdJH7V0UQsuddpuI3jC86GrUARGVMfbzlAFD5hcimctfKt/8ZI7kxp4HIcef8q0VriPEGPKrdn9xkdOe4KK73vy3cjOs5jh3yyGJYRFymfNWuzdjnd5wgfKO6dDrLHbWpdEk0uBdC4uS4aEQx4nhNq6z3IlP3OljB8ODI4kmiHTxUGV4FCRcQv+QAtpyeYwqPq/jEnJBa3x+VENN3f4TJyGMa4lAs5SmiJL1Nzv/dD9xi+SIP2lJ19r3v+79fjaJJBi9pPJujloJUHEGNVw4gVcOH08hFa+Fhb4bfJC190Xq9++FT1jWRf8d+dQq8UPfFIU1X+ZsHi9sDdRl9pE70MWHicSaoBV9Ag+1AdxnVXAdWy7MvBum4qUHwo0exxYvqXU9an6YvlUPHkLKDhpGP/FcFkGrK0hm40dNRUw== 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)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(6512007)(186003)(26005)(478600001)(2616005)(1076003)(6486002)(6506007)(107886003)(38100700002)(83380400001)(66946007)(66556008)(66476007)(8676002)(4326008)(41300700001)(316002)(2906002)(5660300002)(8936002)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1jAHCJ1xh3OQ26ixjbU3J8cS8CkchZ3gTvR/uYtge1W7X4OoMYcX02E+9g7vccW3r4pfAhkE5oIQXGsBCDlaaOVm0WNmVsvL+cGTk3yHjtqT1E0ETheVWg795tfktdFx82BHpBteQIYEjxJOiFybXaEMhcH6xp5hjP85ti2CcIIivcx/St/bpGKrlyatGWgzutXPRQXDIDmH9kuNSqXKkoxiXu0YK4hmhkuDuAxclvQ64pgzKy+Jm4yBf7t0/5WnDFfD0RiJcawqAvI4z7Le6DoUc2gQ54IJ59HzzmPm3AOVQV0dkgDClI5XMPYrJ+Hv9g+B47zx/ch0LkeO3tYVs3frcmzwjg3BY1GugofpLL6u7u1fSUlkwSRSPz2q6j9Gxsrzwcv2KtR/UhdWryneyuA5SlSA9dQGsRf2oDeZdyxBomyvYg54WdPr4YiBipNQfq2HeX2qrTDZWbvsLBSpN4YdxT7yx55CHNQuTY4IIZRW1b4aCjqeS7t3KAJtl/UsPdYLi9SUnc4HCJVxkfDR662ZMsGEkG1NMPBJhdOoBt0kU4JlkEuQtuAmUCAOjGKwspx/W+w43jViseoWj3GIQ2stnZRJ4W4iDuvC3lABchMAy44cen2m5HGoW10rgLtKvVyknTYGIWtJDgB4zM91LW+lzB6OE1rPZTuDQ9tXZ3mV4VnrRlQf6SY26x16KRuxARYdfw2fKEp/+l1DlwzYLGjf2vJ6Nel4CEvNy8BWA8qDYGS8bIpfVmrTjO6OiIZNvkypMRi7cDvmlFlaeYWYJiE1CCD1T/Frn0qTorkEYTIHiZTZwR2H2AS/pcDH8aDIZWRSe7B/5A8FhggnDezPp4gYpSu4G1oU0CY54yd+eCLKeECuyImzQHwQ4jIXG8QWXkBoWBrhW47t6hxY6gUnoy6hq6Ri63zZXoJ1gYYQMbeLLzXd+lfUwuVLUkkGt+/UJAIw74hvTJ5MBgPPNjSkvSxfKl1BSCPkcbtse6nXhnQ0QwYGoyG0OOUP/sHXgJiUpdoRhKxL7VfHzPMDHr5qXk3V6W5wv+RajvXBWkdMZdTl6nUBH7x1KTMNOXU7NCgoxX/m3YV2ZIAvTCmuiK01GCm658vmgabA6IutMeZc+S0wtgnK8WMlgu6w70v6k2vY0Kmx7zSFAIL1cu0bUr3wNacSbQ/Dx1wPW5f32tpWosKAx/iKe5eAhW9/Tsyvn++SG+8d8ewCDi5s9YxcQHBkpTTF8Tr/l7CBkAid1/ze8GgjgiZOAe5tfsieLqglMnQlSZVTObTeYotPVEGByYEJ8N94SfbJWWRmJbTycLxupO230po/wcEB9+7ovP0dLk1jJ4ErzsLk+UfMnjUuph2NoCUu8li7QKlaUYgaT+tRsSW4G4X3JImNxnRgCsBWoJhZpe8bgHL1wXb2idpdOAXlrlqklD4Nz00H5TWqHsD/dOKclqWRUDBHS/WplbE3JIHL8UU5I0dxDDhXQ2c3UGVh7+WtVmajAAcnOyUQRpFfbNt7kTFVHUmQEKwfwAUhcro5txF3mhAjuHzpGWgQ8z3lU84VRlkllXq0hprExgAoxdEOT6oVzs1vREKjyD77C+NZ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: af3825a2-5ef8-413e-d8c8-08dadabefd12 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:25.3358 (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: 1xPnmjAdtePKN/1b7aFAXdt71fORgL1kues0ZRHZbIEuY2ubUCDi6FybdQ4ymidloCT6ufEo8TAXAi2NedEcvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070347 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 589DAC4332F for ; Sat, 10 Dec 2022 14:58:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbiLJO64 (ORCPT ); Sat, 10 Dec 2022 09:58:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiLJO6e (ORCPT ); Sat, 10 Dec 2022 09:58:34 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2086.outbound.protection.outlook.com [40.107.96.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DA06141 for ; Sat, 10 Dec 2022 06:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rxz9hwA9mlx6CerGaEd6NcodAJAdKSepSqQaXPf8uJP4H9fWyoc3AtEtJViTG2BJ0hXRCjm4wloNMMEGXrnuWn4x0A92OjyskZcEPNZVfYbs8qHMl3AWtLObuKd4OAhkf1XTGFjb/QGTIGkaSYa1vDsIZmBf2JUaJgwFa3Gr2KZxxFqKhJwojDCbUlwK0cmIe8LW3KL4+I3HIXuZH/inOLF9oR+sItw3yQvPY7jJMkLhonUgWY4of/B61wHOpNixqyUYoBbzhqVaWHINnUUu1DdxQsL5CprV2ClvdNSWIa3gDX2uB69vbkdiCXM4nj/vZrobnsjWJDB+NSBdxlPOaA== 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=CmPkmYqU6S/w4DNuMfccOzmIVcRK9UkjmIMlqvpPd4g=; b=dqRoO0voxFu9F9hyCWCIvyaQdBXYTjN+ZCpAY/rrgmEb7XMyp4LUnKn773Wl1i7jRmrfq9cKrmk6Fvk2Czc+Un1yRlBf6/gAByGh/Bhh65RZW6QNsa942XCG65MwGv88GZ3Q6WA3qr2Mtdux5l2hPtiFJpAbf4KeNEh1KA1c79oackbV8wyx/SsiB72UWTluaKKhKOwQHqGCkxNan4/v3AAytIiPDHPXc32ANfwDD2aXY9wxLM+eWibDwnCP4FDyAWxOhFwenTcQr+vEl92Dxw5FRn/0ly0LLj7v89u7Sd61BHCjyxRDA96rZxpHW27qDz18G+uo7Stfchvtba5bnA== 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=CmPkmYqU6S/w4DNuMfccOzmIVcRK9UkjmIMlqvpPd4g=; b=tr2/k4gFpqqkLH70il1XYLhBqYENgQzbH9RAPgfdehgXCVq3sORC4lp7lJzKHUQJWyADyqaSoe9BHWTWTsSDOMKh9BqbyvLpK9byA4AydO85pwyj46QEhJNLs5MXg0Tz/cWQE7VvA+SwsHBSg8snBvhI8mLm6M3AjK0heossSGIOL+2u8KzAcHCjB+s+Xio95fN1zcDOcbxYmV3UOSsaPs4v9W8IP+QQeHCQ6hEvk3bNrCSAiTLEgOXXj9QsU3iB6xZ6p7ZQk+gbBLPq6IVwIezzXzKD8OzAwCPXb5uTnP0bReNwougSr3rvtEew0hfnJlsZhzJGxa24nlsO8UEenQ== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:31 +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; Sat, 10 Dec 2022 14:58:31 +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 v2 11/14] bridge: mcast: Allow user space to specify MDB entry routing protocol Date: Sat, 10 Dec 2022 16:56:30 +0200 Message-Id: <20221210145633.1328511-12-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0802CA0012.eurprd08.prod.outlook.com (2603:10a6:800:aa::22) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e524bc3-76d9-489c-ba44-08dadabf010a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lGm6vo81hoTMqZa50NUj7dcPuo8oSxpo3Hz9ApCLoEFtA0RsCk71Jy6kJZDFDdla0WceM/uI2/RNKs/zaCvwte8Hr3yRxaqmcopBOiUbcrm+gc7hpmIMrQ8e55J12m8drhEvRDc/wAc/Y/DuksDNFrNcnIeg4YmEYE6ufopgckMemRfFfhyBeHljXUtY6v5Tbr7M1jXRaeyLaicVILMY47DEkUEjrZdb8zMnyITGLpFMBRrpwsMlyGh38NEZ6KtIKQWgevbPP9b3kDtVgRhH3S7FfDkbK+s7ioX4z2VI1gEn1IIEY9gamrdDUBdInQ4T2F76W8d5E0v/XWt+QV3kl4mKaoFAFbuIb+tYCAAxsrTr//uDJc7YKFXR7C0uOEBK77jg6gxhGZ3cUcfNYPr3eZD9LxlELfjA+Z29SCW0GGWJkedViK9lnpoEZng00AZS1vkBoo7nomfFNP4b+niWvJB//F1+cc6vSjIYyadSgXng932+A2BmdUY5u9NyqBryflFlDq5RDNAZNYyjdCCbMQ0VhV87Z678U8SJuj0pxSRxW+Nj2PXCGKTHVlw/J8LF3SU9koGVWNtwpnQ4V8B4zkiTP0l7q1xkwhhm2ltbu1+/H0Vp827zW0M/zhClKyqgQEawSpDOsnKhZ0MUaGGTuQ== 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)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(1076003)(2616005)(6486002)(26005)(6512007)(186003)(478600001)(107886003)(6506007)(316002)(41300700001)(4326008)(8676002)(8936002)(5660300002)(2906002)(66946007)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uZAFknEZRxYZjrD1hqt7bGRwgJVNG8vYv7OpkRMNxJZn33d65JAkMoBhSvP5aW9DVmBi5vs5oOzPDGO5qK6hVdKZIjt5XSZVeNROI1x8iwOStp0y6VCE/LYujAszD1AVrbubWpDPO4aToEMbBa2niiHhJuSbk21xNifKjqv520BVe57MjrhXA0AJ7XSSQbnopVVi7VEtVYOg2Fjew6p+jmIIv9FwN29JR59H+MnwbiPC5af3Tlow00OpNE0eCJ3/eu8pTcqv3Kw2/z/wZf6G9F4dw8CLnlBNE6azlBu8qnf/Mqx3y6Xh2wulQlhAtj719+HkCw3RDAxG9peWnkeT+wvIXEgtqVHHHpBXqUFPxSoFerFFAHTSiF6iLH5vQIqhdjW6ssDZTCeUAFEsPfVQxHF+j06srQkyQuUNYnHr3/XlYok6815p75tzLIK3n5DTK6dRGc/TwrEc826uJeYU+52bFBlJKuS2q8xdRE9kLYtFHNt5dUl0fHYAwwuv2byc0kRi7oCejx+GSNJiQtKikdVBZARVPxShl5SDzYcgGvHSi4R5diAQdN9qiYYemhPAwNgfZbOomiPhmJQU4oQp9iqVzU+3h8bdQbsOhZ1opjD1IzNNYv7KExFBpFXKbsHRieSXWd3gIlIDCiif3v3JycN/boI+7gazuPcXbwduHrTEotDh3LpCzKBCyzH2PMXvcyGZiH22PPXMa4MSBcenKQ59ccx1n76G/8CKjboeovkC1ynREozRzt/uOwcc9Co0UY8sSP8D365cWjsrsrHZxJsyzfqAagdNimTW3bMYo3klJ3Xiwi2eB+eKLGq2L1hUlWPA705wN12FqmEG9ZCdEG8HwMO5kYwnGiMA34OW0kKRvFdJUebcKl0GfgfW7j+gFQm3nwBNGx99Y3dkLOmjGQasBR9lxeb+rGgkjVuLS9V3znBuwkQIGFUWbBcxOavMH4XBO5Lx7sMbADB/ron29wmYjaUoths8KVDhdIo7lGGVB8o0oX30dIxy4Kj+JLQ1abVf6i1NmWuS4INq2EWaebhkSw8aWoxAy1FW7Z3g+xYaUvDB2rpp1fyEyV8jHu0TvMusmv6Sp/lpSUV+irkgfKCG/61OlLJaiTQ1XvLpg35iJp062jvQGAQbGG1JBeQi4yWLRXDzaityfk5ujdM4XUfEnfiKEuFdnrxvpGdtIiBdH/YSnpKKDHmEqYsd7CewkLomq70mgV4kN1meJXAuYBAAXLOaLc5gQwzNSqj+RN1GsOGMPeRPLIplKwInfEw7uQVSvY263wy9t5tzq2GecaykEPS/7w5B6bf5Zqg0TFJhB5mE9Mco5bF+sdm6VDlqN5tFn6fdPWZJPTpODuOGqNhO/ra2uz24CZibcvBmNPiE2O8b65ct1/UzOeFZ95+DlvDg/ozVkuxKr7j41Traw5zkqX7rF78YUkzizipTKpi1F1ow56q8fa4YfS5BQxQzd31q+QsUS/xbzfNAnL5RVAMIF/s4tcrPU/Mxmtv0S1aoT/ZA+YwOGde5x54tJQI9KzObiYw+ryKWBPF/Dnz1oupRpsZSNB0C9H/VLUQkJdWaP6En0g58iccuDnRxEARw X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e524bc3-76d9-489c-ba44-08dadabf010a X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:31.8216 (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: 37gprxUd5m4T9zhmRVAaoqKx5aSnUPDROjIbdpMoQE8Us0pNz10+pnb1JOZ+j8VhoFbKxfYYq25s21wejHt1cA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070348 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 640A8C4332F for ; Sat, 10 Dec 2022 14:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbiLJO7J (ORCPT ); Sat, 10 Dec 2022 09:59:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbiLJO6l (ORCPT ); Sat, 10 Dec 2022 09:58:41 -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 162B01A831 for ; Sat, 10 Dec 2022 06:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WEGv8iWHje+a7c1SbwtfFhUy9ML7cGayYDdk1u8h1M24s24Bs060Y5Z1KSr+obzUMQxXxNl65Ltulroq3ZZmtdGBGLzUdZRiBXxbu/ejZmkwlJbk6ov7h++DoAkrKA1leTRxU/9mBgV2G0xLh3492syVxvUfKyi6yYOWvfWep9+GT+1vGZG4crWRum56rvU5Cp6MFlRgqqENfbSISyP/6DaEua7GIijxyv9d8DVPRP3BC8YARuqALOHW0tTEyg+r/X4CINnHT+NU4h7zsA4WkMxmhSNTZX5P6HuHYsU+lGAryobIli9p1zXh94o633wZsWmdA3SJLAhsEbdIDHI8tQ== 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=9MKmMm0AJpZBp3RQtjob1AbqKhdrwCzF1aqPGmhskSc=; b=FjQp3c3b0oTN7KiaIWChl6B+hch962Bjtrgj3t91BV8f9G9FU9CSGPJis2McAwL9EirzOkTegj4gibtBbDdKYZhEb0+qhP4otHLW3uYN6rbMDuh4+8fzx5AAgCmXYy9XHOSHL1n4OKE+s7L4XoT7DPNuiukfXalj47fYJOqD65lZxYuH8RSU5X7rwXLPra5Qz5th6jX4byxol4ZaQFPdgBw54F/IZihXTMDQ2bIQmN97tg1DmiX56Bgl9JPnnyOkFG/FhJr/nKz627Q+yZaODYOPWaDQcU2Cl8Qo148yYpPgVFQhCTMLIgRL7CiWdIqA+znULKAV4ZAnECzLf7yLaA== 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=9MKmMm0AJpZBp3RQtjob1AbqKhdrwCzF1aqPGmhskSc=; b=T8g0Kc5UIKfBVFo6WL6lcRqJUKPPXjGG3IMUskXMBGdLW5LzixSVqZ37JTTZJaK1sTU9pQMIkpbTxsb8olPqM4c4V9USWvX4dYy8ombRdk7v4oDm9EilGAynUwJova78arMM8yAFYhVxZt02GJcPFhiUYyP1xM9dinC+6omTeiofDWdqdGL0Q5wRUbO/IMMKcBTSeG6rt/mdUEl03gOEWE9g+bixFo4H3o3oi9S+0GxHwaGpYOXF0paEc53ToOjNfuKTLs+2jDP+FbySOf2DNO0bffBpQexaEo2Uap/aFuqvfquLhvYayHmnXWrlm7DsMrwvdWaw7bjGsxzOxe7Sog== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:38 +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; Sat, 10 Dec 2022 14:58:38 +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 v2 12/14] bridge: mcast: Support replacement of MDB port group entries Date: Sat, 10 Dec 2022 16:56:31 +0200 Message-Id: <20221210145633.1328511-13-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P195CA0008.EURP195.PROD.OUTLOOK.COM (2603:10a6:800:d0::18) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: 19ecb761-7ffb-43f9-f037-08dadabf04c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oiKNBy9mXd1p/JdxCUgqHsj0BmFoBKhAjqYje5UEfvRa2CLJOWi8skED8lvEF26a1ngkhA5LT2r22+bg44Rq13SHvF+a01COrNytdwz3hMFXxuyGw60soStiw4vIqOmCEhcf6pnAJ42N5Bl5aRklcDQDGKUHH38u1PItUwBhnbPQ6lT09P8NKj+PqS5KFQL5eHjvXYh7FhT3mtZ2qNnSfaywoRbXXdpHt0hqeXYbQBA31kfhnM249k2mDjekIumrorRQWTJIMuTYCksYEkmFNFKQOhwA0uJqdRiWv7bjgHsbqddrsF6a1WJWpZkgo/qRnhjXf7xR+ZaRe1cIlEv759sVc6fh/elW15xRWFeDcEu4w3dnhNFVqPdqMPR6jB5/8ERyaI98r5JXRcpOZ+WpvMhiPpPF09NcNvdRqHejzTRk2zuxGJKiNSX1MCo4qs34tw/yt5n6QnF49wOanKAI3sjWAFWKiP2mVurFe73wGhvDraLlG3q85buxVPc/Cn82FGL4OsAiysF2USsJpMI76rZDQzO03aWTTjaukUNzhNG7wm8rQECPddQNoXIaS02W1DZIgNi5Qm/AG0CY0iw0VB+1tVOgjXDDRO8K0fNqb1955lB+j52r8iqqtVjEp7Ep44+bcUjy8fPJDWvf6TDqmA== 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)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(1076003)(2616005)(6486002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6506007)(316002)(41300700001)(4326008)(8676002)(8936002)(5660300002)(2906002)(66946007)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S8FE103Mu7L+99VG5KL6V2cOq2/D+bPAb82ayrxZ0szgcMZN7+88GZhqn2RQhOc92ybdZ3Vh/QVPMFwWLTFUJByVN7crH++eFCLBHNeQ+hM8fvrcuyqOyUzsxWSz1MN06V4Omzs4B6rtYIVCfca/0vsYbYMFgFIdX533FUly0nEOztmwLRhljnOqxN+7Pbs+l4daQGxGH0t8dCkSnhXvWEjzCuDAgYAZpj2lBnpAVN7Cqs95Wf7s/q1109emVavh1s7VhSXFE+eZIRRg2d4XOk52CdMwKHzy4f+j0WxuAEg398VKi81toLuEMenD/FNS8vi9fL7cLk25j1K4OTsr1t3IljuPxIjCOWK6Gw7w1X8TBq9Xp1VLSuhBgeu1EHzvbLfJHKtHGpAYXi9wQmrsHQDaDe0piZkq9YMuPUs5BjNBa650X/Gn2foryXt3ddizfRaSe1VW4B83ekcLrOCJcQkf03zQeEi67Eqqp8G46g0av+fJ10jpKMrI7/Ufwa4SNr4ZbrZJIf9vLGRjVYCA2XbSqBDPcb1hfeyJuiHOc0oX29CIp+bRux8nbNjiwXBiDchn2muncwFyKbLma6aiBkp2ooSfiYg0AweCwSOZLE5Y21OZqM/PIKybEE2b937BQE3E51luJKGYPCHdHJDysoI13Wosujbi8VGpJmmtfv7YoBL6OElFo5A+8Cl+gaCjYLUQhiKE0kvxI2TrsbLUfkEyKtSjmpxKhVcdrvXX0DGXEpjMCQLQW6ej22rnF8v6hIrMPj8Ykpw3+MvNOtlZ2teu368arno0N53Yuejgde7Jkjuw5P1BQpGfG4sr72Zqh7cKmI7/yM0Uq1pyvzXn+QoeCm04lZzkc8aZPktGocvEzVvho3TYWhjKFyonJZp8VPTlD+/EcK4IrxznWBw1OK/ROghTxkffi6tK0aSwEqUoKipyZ0t00uLvLPiZCuTuX+nydwCS8mjub5QIXXLxBCOd9iXX+btYtmSILwkmiA79XAZgH2fiNnQ77tnbB90ou1buIEtKpI2jfN+jpyg8urAgRRYUIf3QnreDtx7e7l0b49peN4AJXK8jJyXSqgZkRa1t3NLC7t0aXd+9FVxB8G/EsYcKn8xWuQkTOAy10uv8GB560ZuMzmt5qjfO1QAwoI4JvSiKdekW1EXyEma4o2IW7Eq1I55RJS6HPBtVeSIFX2XyQCoYg/xG811SxfXlDbYyPwZu2WA7wwMuHq0EQBaRlI4P91eWSk1/fhKax0iI1Eao4/Zwrw0V/dCmm1NvKhqGHA9SezqyODqoqhhqICzvq70KVYWwHC1/IsNkGwfLw34Ned38+b/Z+sSiLIcHm0UQol94du8ERxQAGhfGGdf7i4LzFh5WrNKEdBX9ixHrNqPnKF+D2noZOM69qFg/c/+hkk7960Flv7N7dINIu3oVgiQJRCdB2oWecOJJzReM3cfrfm8MlyAWvsnfcVPPu5e3d20pCxRskdE/Z5E9USudJYAFmVT7/eN9WxFxcwwOvG0vRd50la5zZh9gCDOSqaz8vnFL0vU6QAtPBFatywqNw1Qes6BCfcb+fJWDajIOIuVqfTjwRmz5My3i0+No X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19ecb761-7ffb-43f9-f037-08dadabf04c6 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:38.2288 (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: XWmmggqUVhIzOiAW/Ggy2ddoF47ai8Sv9JxGe8Yp1Lrevus89vr5P6+MUy1Cxy/VhcQsifebODiOJWXeAi3GVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Acked-by: Nikolay Aleksandrov --- Notes: v2: * Remove extack from br_mdb_replace_group_sg(). * Change 'nlflags' to u16 and move it after 'filter_mode' to pack the structure. net/bridge/br_mdb.c | 102 ++++++++++++++++++++++++++++++++++++++-- net/bridge/br_private.h | 1 + 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 72d4e53193e5..00e5743647b0 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -802,6 +802,27 @@ __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) +{ + 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 +837,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); } if ((unsigned long)p->key.port < (unsigned long)cfg->p) break; @@ -883,6 +908,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 +929,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 +987,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 +1063,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 +1314,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..15ef7fd508ee 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -104,6 +104,7 @@ struct br_mdb_config { struct br_ip group; bool src_entry; u8 filter_mode; + u16 nlflags; struct br_mdb_src_entry *src_entries; int num_src_entries; u8 rt_protocol; From patchwork Sat Dec 10 14:56: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: 13070349 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 DC447C10F1B for ; Sat, 10 Dec 2022 14:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbiLJO7L (ORCPT ); Sat, 10 Dec 2022 09:59:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiLJO6v (ORCPT ); Sat, 10 Dec 2022 09:58:51 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E7D1AF01 for ; Sat, 10 Dec 2022 06:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XjEMEDEcMktwOmyD/MJboyRU0Ph1w8xH5zQZyd4TsKKjo9mVpdR/vqa4Mo0OfMyhypmLxtr11DJ0Pp+Ulil6paRkczGAbedtwHrroLkGfS3oU4hYfuhnSlQiT/JubTY6vp5Kko7wAIhv9qGZqf5VBRAFXRQgvmlSUjMoLiq0CLXv/0+yjRLyP38zWdlWLf4ZQm0ceObPVgikkLqiXaXJ0aqjqylwQhqQ4FK+fgVPXAp0d1/UTc2+eQlU53z0mg3atmX2YyQCxjN7zvkAgMiJ+PyIgp74s3XimhSlFQnDMnjTHLhIL+Ow4PBJ+ni3ohGE6GnxPLSJq401hnQc2gcHFA== 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=/mwLfxSWuHXHhKMuieNDUM3tBBmhZ01RMiC5XcCnZss=; b=TQUnDgTCw51qDsKqmt5z9GrhaB0sXzu57qUPHYF1y5la1wZIAm7Iz4mjYmT9orVhP1LFeyTWPuDOC5LNNbecfQonf9fvUAzOc2D2/L/n1VFUV7H7Q61UscX3PZYi0t9b1H+G80lB65LxhpTNatJlEA2QF3324p91D/NpZ+sTnMltuCDRom26qwrP0kigczBiHqunlctFGtrgkuoA4ciwE4CAjmbtS1VB0R3Po0ASXACpXd/UV917FdWiPRe6/LZRO0aUcrrHJdEdMXQ0HbtPqoGqjVTzHpAFTnh3pDwWOxDElkEbbuwk79FzqoWyZu8cR4zrGvEdAt49tlYUMVGs2Q== 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=/mwLfxSWuHXHhKMuieNDUM3tBBmhZ01RMiC5XcCnZss=; b=tU0RshxEGC2gRj3vxZS2hsR8UeVpsM6cyZD5Q9bxWZZQ0Pk/WqRPn+hRYHQQAXqH3PHDP1MkJJA83TR+FnJuG78qpBWeV1+jz0Tp/pQbhRtF6RkNassKZ4vhPbJ6IU8q9tK66kdDF9Q32hfKpRzaMqq9qs2ZHBRUqIAUvhnigrN1XhL6UUAPdLx9nrNHb2DrtPoLZw1j5/G4Gn0ZB+HiWhu8cJ4pgyArJy8tPLunJoMvyOam+HLUQpJcBiojMZXM/ZjpiNcFgmifu42pKbFbC3eDXmiuxIN0Evze1ftNmVaPtdjHLp/6IqJUWtl7vwxpnbYny+6YxnlTRFppxpnoRw== 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 PH0PR12MB8128.namprd12.prod.outlook.com (2603:10b6:510:294::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 14:58:45 +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; Sat, 10 Dec 2022 14:58:45 +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 v2 13/14] selftests: forwarding: Rename bridge_mdb test Date: Sat, 10 Dec 2022 16:56:32 +0200 Message-Id: <20221210145633.1328511-14-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P194CA0038.EURP194.PROD.OUTLOOK.COM (2603:10a6:803:3c::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_|PH0PR12MB8128:EE_ X-MS-Office365-Filtering-Correlation-Id: ab70e1fa-628c-4f35-f884-08dadabf08f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VyVKuP0aFZRr0wvyacN93B0dlysJ0sdPne9U+zUJDslPe7r0vGoCOogr9VM1Iw938ItO3YTOEQHk9wWbPwfSBnoDCSP2R7hFSRIrP/si4M/euewOIIQ0qQZHat/6o3G/i1+igfT1IneoLfq75sNjuNVin0fZxBRxuCsEHAYfmYGsqdhy1iWoiN5yAFODI4jLzeo9gFqk5EWSSvj5YFncAEPuLo/mElH2Vo10+bxAssu9DrRrlJ9vBYo1GOiOVqap7bT9JcmvFMQw2RHFrMdHvQDHmWDiseciPHqf7PplRYAHXZ1lIKCEC4UBD/T1iJBG3AfeKQAc57qYXpVMvQDRP5CwFnnQg3nxJBZUcSnZ2clj/ItcJW/t1KN45Blwi/DqhnXFFPTDLTpDVAc5NvYJGnwfICE/6T19s7flaY3FfwHdAFdej7kliTV6wTBjIcNMD/umd1bSmzRdu+S+cIzIEWL3ovWlLvzwDhpv1n2dd9LHSjmyXyqAAcmLOUSbSJkpFUnl6IcbfxMZd9UrHFVF5Ia+B27+12Tg/omrRoBTe6u4lHak/hycOtDosJnXTVb6r+g/iivMwN4JaGuMhify1mJ0pyCPhyaDX2LTFYBhn8A8vyf6Ffq35hS2qY5pOkVbC02KgfvKnmMO7jsBy3FvVg== 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)(346002)(376002)(366004)(136003)(396003)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(1076003)(2616005)(6486002)(26005)(6512007)(186003)(478600001)(6666004)(107886003)(6506007)(316002)(41300700001)(4326008)(8676002)(8936002)(5660300002)(2906002)(66946007)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y4xTPBY9YXQ+JTuBeP3ITPfHhmhOwJ7b+LlpGZs0sZepdEDi26cT4JOUIE9lz5Hl+Eu9k+kxqm7BnnXG9+/C3VfC6CFxqgjxZvNd0lfMUmNfjr8heINyQGoj1j5yhMJStTRGZ3uVmOovXQaoC6oI2Il3c+ZCSggb9Q5lm8weZSED2KDgK2Eqv7Vet0hTazqveK2O77+HU1MBGs3QMcdF1KD6+kHOL5Ng00m2j8sZsbXna/clgz6XPVHcgjFk1CpYiov9UA+lgo//4IDFUkyU/MVhYGOM8sGxbtmEfAXnqzCrYhmc9HqGRY9e6gErw92wUhSOgje2LJ0c0JpXGm1BzPnxiDEjEHKBce6jv/u8uQrRk4EZsNWzdmyw9D9l9O0BD2lp/Mk0KMuilghVZpNNx+WwksvDU6nPgHZca+kWBwIvxKd63cDGX9zCpMSHHhXP3TJDWETv3nUULwjO1Ps1wNUKx8edwWBhrpgo83+nw/SC0DphC4J4qVfL/eL/IlZRvjB22tRzTLbCTJQLn/8t5PFCrccjSvzeUXlWa6c0vobXFc7yzy3eeMU0qUlQD//j0coRNjsIbl167dUP+2SYBSwAT/wzWslX+GwSa7oXthtvSz48LTQsebRfppcZ2KHarhvNLFfUNwRY7WMp8rn8zvgjPISteh3RsxXZ8FMN5OS1XyO4W5YgcmaV2gdWyjlGYqi/cc3KmyfSq9EmjR8p+nmCT/4Q1dEWWzB/8Z2m89khRAoPVuyVDKesD0EVx5Vacpe17zk55TEOV5AUgO+BjzkLetW2mkJvM6NVXrCrvy4dbGTuK2+EprDwM7h6AHhm2yKyoe6xVmkyKgEWQxKt9c73secx8TepXYesxM75RNhznq12qI2zdAi3t7V98YpPOM+p/RLOz0OoKlIl/yPkrJv9f3d4uhsG3A0IJsHpOeoJvTQlkfempArnV1/s0XrNCYoUrsg9BV/nHI2XapT7JmMIlMlGXo/FmQxrnTy1ldKR8BxEhengugwFP0pqHwt0WRSD+cCwpVvabOW5nFLuPkS4rVLZgWENMCYvrC0K3OqWTqd3KeOYxD37aR8mXeHhQrQSb5jOy5O0Q/ndPwKg4Kqlg9ePfXnrH9maB5i9f0DBh6HLykaHe4hZ1XgMeiFkVzuFWwi9oS8x3y2w/IJusRwCadtOYUOQxyN1hLzXtg6qbfgA9c2BNTi7E9KzEvZ762tWf2kqubChEyZdkWwxD1Fxq4TpcWoMlUzfkl/q8hdSdfSUK0EKF0tuprLOS83lwdjbpR0eT/MP4pAjEVeowM4P+YeeQZXD4FCNzRAB9ebKCbbMfcApP5s2Fu/FpM3pbaJzWj522P/PXv09HAVVg/wo5jesWORNpXm3zmEEMJPjuGrSlZolNeCMmcTheq9cyB3h2xWFc2dn7w9ND9IkMwraXHSYvHxG6Cu2dvODLv/7Y3TzoyH4KPP1Re9pv2aCPpNDJBsxGeVJO5YEwfiE997RDLujWrvqjaHtjvGwrTTxsoiOCs2Z4sXstQfRNUC7r3RfvsTL7EhWJNh+nR3iJ4dQML/a7i7QAF8mh6hmBbUUNPhoBkH1oCODLTZNqMM6 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab70e1fa-628c-4f35-f884-08dadabf08f0 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:45.0902 (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: raBkfK1dhW0aAMOdz6Y5qdwajDUmxOnGMZfrPfCsHwUDZgfFfmakmBr5b5KT8CLk8zwAa/DB0i93NNwIuSjsmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8128 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 Sat Dec 10 14:56: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: 13070350 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 6D065C4332F for ; Sat, 10 Dec 2022 14:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbiLJO7V (ORCPT ); Sat, 10 Dec 2022 09:59:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbiLJO67 (ORCPT ); Sat, 10 Dec 2022 09:58:59 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA53BF0 for ; Sat, 10 Dec 2022 06:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BUnEdZNDgQiMiA38Cp2xTvNgbZH/ox9j082uyXJjxHPU6iDcEnSzpdjQIRbaxHoiDr6rjCi5ox3stFpdLgdstEsJFbnaYwP8r/CJov+FO6PpT+m5+NQxZgMskzV5LM0US7+nHWhLRoNubALfsgyavqa3rDJV5aTbSzzthmc2h95qV7PZiBqku13ueji53A5xcUfOxBVWNDrU1Ci0Qf5gMfZYiL32N2PeJEULbNXBsmyujG5HPD3eJk3cYc/0G6PeMspW7AHiY5HlYF0ym9uMgWwwUp+n8/6c6uO1XouKQZJyuSNzR94JvXC5P0O6bGTnG3HAzoL570NRFLlb7mChSA== 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=rW/cmcU6++1a1uAqiREeR++jrkBzHj648EW5iUMXNys=; b=HMdSapcF1S/ds6z85GAv6jckjfJkETW/V6pe0rhJVIwF7J65nk1LnjaJkZxMfNs0lAPqhyc04sygI2Spy4WfzhhYuG6SLckGMEvQGzax1Tk1T3hrGW+R8DQ2jiJlTssn0G+M6LPb02Xq4Rt8fgBIh8mpbh3NIP8gXlSahHQgogAwYmGE5k8QOF6lq/BHOGWKeme+yUze3dSE5tQOPcsh54CWaCY0cacmmykzY2YgcCceCbVdfQTlJELSzKUtBORBM/fEOAOrJv8bzaF6SWIqzqYmctzQ8CCcV60hqHak7isPyXNljM7A/vrA6JyiBcwu1O1Pt7mfaFPHhX4EDigj0Q== 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=rW/cmcU6++1a1uAqiREeR++jrkBzHj648EW5iUMXNys=; b=I7Hu9lhPH4Jk5beGmDDRYpzRnWtozOfP/bjLbPPFV4+/G4aVu6s51OAOHuUirwQf/n6eSzqxnCAOf9TVXIV1uBtnG7L3OPFBwrd9gaOxeSx2XFFqd0ThFGFTFtVyR1diM80Rjm+yJ+vKo1dSXLVeij2RRs3Xt2Zwicrs4azmlMX8J6mWN9tP/rwu0iBiZnBHWeFo2/d9G2o/E6cJRNgnxIhVOdmDMhLWNE671Fw9tKirdYcgdPZjCmOPl65KLtKW9bVx3FK1bXmsyr0vU4nBZSYPHDP4RJXjfXuDQcPFAUdWGy0743SRen1xY26yyi3mcY3mhS58Q+T9RYFBqaOlfQ== 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 IA1PR12MB7496.namprd12.prod.outlook.com (2603:10b6:208:418::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Sat, 10 Dec 2022 14:58:53 +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; Sat, 10 Dec 2022 14:58:52 +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 v2 14/14] selftests: forwarding: Add bridge MDB test Date: Sat, 10 Dec 2022 16:56:33 +0200 Message-Id: <20221210145633.1328511-15-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221210145633.1328511-1-idosch@nvidia.com> References: <20221210145633.1328511-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0156.eurprd06.prod.outlook.com (2603:10a6:803:a0::49) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|IA1PR12MB7496:EE_ X-MS-Office365-Filtering-Correlation-Id: 045f5fac-3a00-4272-5d23-08dadabf0cf7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mZ7bjAxEOxrqZG/ss6wmLuMbgQ1yF6Peb1tcKyN+vZzv0MpdC/AgGO31Xqkryhx/HSLnMuQFiQ59sCbuLxz5AwBJCge5iGTkebHoEhM7zdFD3NoB5a5wx9tamY/gWxruRYF8nhVhJQWAo7RspHKruofhgHrVmh9WZCA/DYghkRXsQIDayMsKxqmvnoQjviqvi8EG2efnTvvauB1zqCWcY1CEoBlwAZQhUeBQI+27B2/mLxcIeryJlm7bHZsO6d0TIHIcRVf8x5lY7ZvZpZfmIqOrFpn4yZwdJc3C7wnmFXhLtOGPnlX6WlQaMDcIFTEoJaeoajHrciAm60sv2CIMoILRjlwweqXLvwaUjEA4IyHa9/SOlaAK9nrp0HKaORv/tPWt+huILfYkn/FdDulyejOG2O8/oeKxDealeZMwiprSX7wKsdceTYq1AnPtWupbGDOM4/9rKYegoIfhkSUgDVTwA8Jwpz5W9TcpUaTH6ZZBDzlAx0W7uizxNPoYpuWF6qI1fecerk3d30pngclWNYTZ5Ij0iQccgSOvR+HZBgozYTcLu5ziZ3GFK1invuqgIW0oL7WrrUCI+eppnrHRuDeQQlXFJVIF7QwHziljIPWnHgZ7h7C7uXJao4TYKbl97QHQTYNLsUZs0BXMnys3mw== 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)(346002)(39860400002)(366004)(396003)(376002)(451199015)(30864003)(66556008)(316002)(41300700001)(86362001)(36756003)(4326008)(83380400001)(66574015)(66476007)(8936002)(66946007)(8676002)(5660300002)(6512007)(186003)(2616005)(38100700002)(1076003)(107886003)(6486002)(26005)(478600001)(6506007)(6666004)(2906002)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oVZQO8v9inyXszpkR62KCIPR2+cX03V+Z8ehyVxhx+GkL7ux0mRGLZulvX5BHJRtUg1+FBa1OA9nZthvx6rq2QWRrfzhdz8PJA/LJ1vbDoiaNzQYPrIKsjmj2YWTn6jXaS+tW+KbZijjPLwQNDs1jBDd2/Eaz0G4rt+p19t3gWWmlTbSWUmCrjXHdOIO++CswYwkS2aKtmuze59sWGv2N8qtT/UO+VCpsJjHvlbt2plZrs+w7bdrAMrrcf8zQNft8phpUKvoWnhML9k7JGTlufe1AfDRFHq9cjwyfusTGSBOGepUx18eJulB92menUZXVWumezOZDmN2GJAhTo7a1sjiVhR/14YOQSscBFWK1yI6+ZQq4aIzJKS5WDHkIP0bbetiq0l6xXrjqb1WfS6XBI42JNQJBKKpWU/5cgAc8Tct3itkAVbLmDpn+6bKDfyg/pe9HL1AQo1hJSvyfMinMDojoCqvGpBoVvDXPr/8Vzaci60u8rQfT5qwNqtnfp7nh/JWQfhkX9gMcN1Y27YAhqcFGERcmr7XHBaa+eS0D7Zzoh6VfG0/f+g6xSj7i7aacDoH315u8YajWHqM8zzI582Q4fTYSxQUGYBCG8w9z7gCdOzLtbxyfNnJzjW7YE820+iw2lBaXbJuaym+beQGauqool6v+Ec24kI+oJAtBpp3g0OnHwSRbeFmYR4pu0uh+94b3hbgIVpQzBP7zd5TPi2DgmJxKvlxdWu8ArxJEduYycoKGcf4aO/YtG7ZZEgUkNZ1SQ6SoQIsBWHdDagbq0mBIDHdBR/hE0YzTn/ISJBlFSaVWX65uk0aohYgQtYVPQcbwbcurL2rPOj+FGEerO5BZwBbwjUK8XVbw22vZ2BeUXD2vqkO7Yk+gufyFIrgmazYfVwbQdaw4sG+GTDBPuYnpZe3/J/WmELCmezi4sDc1Mi/uu8LOQfH5tjTdedaGUsf9Y3NyOiRCBxAwxiqbMsSFZMI3yAd1b/9izeqrp4/H3S2BvWOhW4U3sP5aXGGLBmd+UtrZnJf4VDH7dgeoam7HS+e225HBfIFshNpQD89fy+a8lRRUDue6jKbgfi+Imj5ODqGd4RaLIwd9he/Zx2OIWIRydObHcBuMESlo3WQMO3IRcNSkY74zYwXevt0rJspVfm08aGqCE+UHqwAjn3OJ6LXGlSYn2s1ZWw0jle8Xc6GaEaVZYxUfk+V3YKwlQB2LlnloeP+ZppwW36WGjf9d7GXvWJlwMB75/y56zYgXLac35ifQpUpzk3nShlr8Wyqmjy1EVFtvt1dkMjkcZ4LgWtGBSBDSFxbUOaT4UrnwkX2Ler9zACZn9o1oybnve6AziED70SV8J56FE4khLdntsJaxFnlFtJZ2WlHBIY3agcuOLjsONMLaN9PAomrnJ2y+Wsc7nFHeXmFwTGZgPi7zyzoZIOGMXT/PfYv6m7kHT1brOqa3+Yl4i9ki0Tk8xoa9JRMOUxyTSHcJGHofBI+Y6B+mzPTWFKiP9iblrc+uaZuUVzfrHXFN8lJRmNRcjz/2ATPCPg7RopXRQIN6y6yBKQC5zUEgn+iCCIcX7dXemxlvdT+NN5LcsUMJsjZ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 045f5fac-3a00-4272-5d23-08dadabf0cf7 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 14:58:51.9836 (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: eXFOmtKZtCpD8v7iW4yvBv1lx9mBfncC2ifqHG0kHWCE4yXRlGeQNkj2NB31soO+M9CvoumJRCYo6C6sofGHbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7496 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