From patchwork Thu Dec 15 17:52: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: 13074422 X-Patchwork-Delegate: dsahern@gmail.com 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 0FB26C4332F for ; Thu, 15 Dec 2022 17:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbiLORyl (ORCPT ); Thu, 15 Dec 2022 12:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiLORyh (ORCPT ); Thu, 15 Dec 2022 12:54:37 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FCF426A88 for ; Thu, 15 Dec 2022 09:54:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OPJa9b1i0p5xmEIRzcmSphaxMxZ3qKv4JnJ6GmNxwLvRZ0r0a/msdfT6/NBKQ2u0UcGhM7T11usVfbmJWsDkxp846ZdndDFszewxO28Jk7puv1WjBABkGq4BFG5+scGBo041M0lHn97u2jKv5zumnkrkAEnmBFWwwAud5dd6Zo824IVmAHrhaVX+qsS2u/99VAuwtdOTg5D75CVHl4FoBfa4D7JqPadZ8rwYsKH8FV1mhTe3ibEhzllntTlPIDNMUuGIxljG4P1YL7YmVIhzAoS8eBFSRVF7hhoHCkpw/2TfhnIHoD90PdHyydHjLhO95WgPJIwFgsKCM7jyfXmocA== 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=aS7wm2Yt7F8CEO/kqg8ryCMHRn7FUdm6EBxiiG8KKPI=; b=VEWchzQnvVk60G9n2O3g3wabPjOJqvqU1cBdfuaxTUXnmrMSo0D4TCgVLrBv8TlrKYvvb02cAXxw87cQPoOhWqb1WW5cFcyGAzYZYd4Tht1ftD9gvTKhB1TWMCXO+YOMr0YQyMhE6Cy0ovuDj39Mu+NA9XvrRrHzGodgO5SrOTW7BgGifMyLvp4eqPtVpctxHK3B+AG3+evhCwoKaie+c1JTrD8f49+CKSmAQWlPFEk79aKxwthdKELaSmZgJmBTKIHoXyD0P9tOXJ+rudQGFQ3yQp9mpSvXHQIMhBG0+FZT+e0CEene0lRfMgBb0f/VTfKj7r9f3DcjjuSHfU/tlQ== 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=aS7wm2Yt7F8CEO/kqg8ryCMHRn7FUdm6EBxiiG8KKPI=; b=HmC7OMisybAZQoSzUNU3/3rNjMbUk6Dzdqr3hh52vIWj32zmaDMl/vVTN/jziRaNUc/QJld0jPB1qT2jnEHdhQ2KF8ELCexKwAOlkeNNYmTzjMBzinvJ4J5WQ37HzUtnxEzFMXSFfW8sVMgK9AN+uGg51trKi/Mof8cbj+mOGf03N7BLrGHKb/g4VR+hyuD19V0qi4Qj+GhmR7f4u/uwQPz11nGPVeGZNiCdVpzkUqL5Cx5uYXDhgDpHIstMjntFagDB1fWxgjYxpnMoMClGVhJtpqisgVcDk3syIxQVOY2+BEtU6uVVt2pby8Z0t3npzoXBzwUIuLBViq0qta24rQ== 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 SJ0PR12MB5673.namprd12.prod.outlook.com (2603:10b6:a03:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:54:33 +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.019; Thu, 15 Dec 2022 17:54:33 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 1/6] bridge: mdb: Use a boolean to indicate nest is required Date: Thu, 15 Dec 2022 19:52:25 +0200 Message-Id: <20221215175230.1907938-2-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-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_|SJ0PR12MB5673:EE_ X-MS-Office365-Filtering-Correlation-Id: be3f4a59-05a1-4972-feb9-08dadec56bfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mG/bgHhcPL7rY5r60yYf1mI8VUWrxZcCxBAIFYqDVyU67vvWnC3ANzZZU8WYy6GimE8ezfxS1MCuP55Is0Hd6j5ppJT2Uw8yZArxsbw4g9VC1y2A+igjQoJXGxdr94Amfr5t0l53UzWCj6KM6ABCQ3uxF0g39fjzaV59so5ByM5d1jDQJne+20MuAtuJYQ4Ol6floo2Tvp8PnlIShQR7Wi5qX4StSI2NPqcaGLnRLSJOLNowWNXET0mJntbIGP3ACC+bGN0fswDqHlIe8ESErD1UCcK6Ywv3Ns9fnIN4ap9iJmeeNxNSk31VWNAUyevVhnZSCDdy8DouR81yYm0xjc9Pwsd5RWy1zlct66hQ/x0kap2lFUYV3eKZ4ONLHGeFHx78/wwadxn+ZJdn81ElmnPRtXyFZ2rc2FSeVYYjoN2zzLW79IXVPVpXwXEC9v3wVAVqzv2/c4575OderOihzf68zYfPTXuQ+7ID7NE7GdiT5lLr0C5c5kiI6DwTTHAaNhOCgfoStS5Vzt8oJoMOe5IY/eSFhIvG1i/4KZGEjgNR9oKlhWenIePwlxdLGCYC2Il+AuJ1zdLvZlON/sCbdwdJ2iq/0sBJdygyZx+pMIvroHGa926bBGWcYCPaW/e5QIqnaG61lO4rF29YStmJDA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199015)(6486002)(316002)(6506007)(26005)(186003)(6512007)(38100700002)(478600001)(6916009)(107886003)(6666004)(41300700001)(1076003)(8936002)(83380400001)(5660300002)(2616005)(8676002)(66556008)(66946007)(2906002)(4326008)(36756003)(66476007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FVYxPe80JknvANiD7x8auPknJ2vjiQwPEtOJRxCEma8b1WMv4gsMTd6O7QAoYEg2dIN61jXcE2PjxE1mwC5RSDhUklpeol3mc1HO7dtIzQw0xy/bhK6kMlY/cAbyrzQdgZLEch/UZ9Q+R8unCQqWCKUiDTXFAG2K75p5meCFB1KF0I8WfxsWPN2Y9ROQv8Np29ikcQd8eTPKy4/kS18uLb+CxBf7wKitLv6CtEmiuAlmFXk9nHBa+Jy3IakyAPMqTnywoWG25RUxnIv1zum/rXPDkbLZUMbmDxeYZk2jdW97wg4fQVkym7q2/C9pRquhuZKUSQUUzjQeCJnrYeMitW/aWabXMeRQavU8k6rgyoTB9HJLaw20OjTdQfK91HXk7pXON6Op5AmbXBRgr1euqYw0kwdKxqDun2+NWjxXgqCwyS94U5z+xeJ1+ooWVG4/LMH/XX1IRWSTINwKrXxX/UHWPLz3AqbrFh7PZxdIfGZlm0qlJyummQxcHfejz3N1COIRFgXIByhviig1F59UeaCWeZ9H1l8oEzUo9s+rPMrK7ocuAh+l+9tWclFGs+Wp1fQP8MVoO/NeU8pWYXDvOtjBanjGDy3oOzMnoSYcndGJ4itZmDKZjn2Tgr7UebHLQCKtAU/lsGJb9vXRGBv/tYX8HMll5ym5FZWpcPWJQOENtTP+TzkRfApZK17PhGA0j1TQf+HM/lkBpmNoTsgLDE780cr6K4AjLM9p0GVWoe3KbcH9WdtMPMFTFq3j+8idAP7LwFs60BjuoNPFddjCBLNjuwYvpQp7F6ZKve90WEcWamCw7gEVhd0nk+i3kd14XSxYEkP+xbrapEfruqg+h7gYb03vDjs4m4Zp8HkTNVNvwOhWM5Nrv/Q4mXPTjDlm9uA6g8uGI2GVZzdvSuLJY2J0dl8PlhbV1xDpReBXYyWXgJh+KkKMDcCE3Q0TNGiS3d7LNQLiwM5HTn9n8BV+M3qFqTkZoHhGJ1cFpwiCpsYHxhlKsuIMflFqW5TfOONMbgA0bhnixUEAp4IazvZ8jJ3UezJBhI7kWCPWhlROz3525bKNcCZjsH/TnGD4evY25x0wYt/Obg4EooEyyhI69TbteDweq1aF5KZxWIAht2GC5XxqnNPQnJv4QkqF4QUaEwfEO4mpjd2ysNN1JwW0SeVphuPCUmrfVBSk6jUO2CgLWwEOetA1YQiGUehK/4vZruR5aE8ttB4n1IPLshkvGMcprrP4XGFLkb8T69fmlo4oS8WvPaIodSUrOT2Ui6ZzrF9TbHE0Rk5s8CD+9pnTRq5TgYKb4doROC3lvmNxStaMNJOYF7lP3j4FbQ9dcL7HstsLM/5zPUWnUDby8xxpbhKm2FB8n/ONijpRpttGsXqGzJzwHIObYs2tx8EopSVM9S3Z9V3BdHL1iSP2K81RY1umMLHjyklJGCysRR/UsC6zu+J+nzpsvCEtxZagVulQfU7FHCa0eXTSl3aiBkks87tKdCvJFMeRz22ue6yQbIqGPWMAe57+h7J4XCJY79L3CHaoNJ37/+T4DA8iYl0lL4QacYSxMGHlNG7vN8251yHfkWBv4VMQYHVCfpQuWWSe X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: be3f4a59-05a1-4972-feb9-08dadec56bfe X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:54:32.9080 (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: +sbbBFYp3oCRXsqd2BsIyCb1PVsMukoiERrAvOwewlXIvLIxT8PPyndze0DpDoDo4o0DQkeOpKbjn/J79nm6aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5673 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Currently, the only attribute inside the 'MDBA_SET_ENTRY_ATTRS' nest is 'MDBE_ATTR_SOURCE', but subsequent patches are going to add more attributes to the nest. Prepare for the addition of these attributes by determining the necessity of the nest from a boolean variable that is set whenever one of these attributes is parsed. This avoids the need to have one long condition that checks for the presence of one of the individual attributes. Signed-off-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index d3afc900e798..4ae91f15dac8 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -488,6 +488,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) }; char *d = NULL, *p = NULL, *grp = NULL, *src = NULL; struct br_mdb_entry entry = {}; + bool set_attrs = false; short vid = 0; while (argc > 0) { @@ -511,6 +512,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) } else if (strcmp(*argv, "src") == 0) { NEXT_ARG(); src = *argv; + set_attrs = true; } else { if (matches(*argv, "help") == 0) usage(); @@ -538,7 +540,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) entry.vid = vid; addattr_l(&req.n, sizeof(req), MDBA_SET_ENTRY, &entry, sizeof(entry)); - if (src) { + if (set_attrs) { struct rtattr *nest = addattr_nest(&req.n, sizeof(req), MDBA_SET_ENTRY_ATTRS); struct in6_addr src_ip6; From patchwork Thu Dec 15 17:52: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: 13074423 X-Patchwork-Delegate: dsahern@gmail.com 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 E79ADC4332F for ; Thu, 15 Dec 2022 17:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbiLORyo (ORCPT ); Thu, 15 Dec 2022 12:54:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbiLORym (ORCPT ); Thu, 15 Dec 2022 12:54:42 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2071.outbound.protection.outlook.com [40.107.212.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7A126546 for ; Thu, 15 Dec 2022 09:54:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c51/WEX0yryaXKviC3TlU42z50z3B4tG4rnxlgyrlAybYwJVCu8IVZB/OTSbzEPBWL//7sWollQlo3/85QOnK2aSGHdgDXI6QpiCCUFtxKjvjkYW3FqvXkmyOqvTpfE5rjMh3r5qr+w4aUM50fP+yowts5zmvoZhZV/g/20+ViDlnWt3tNky1theHJQ9bUdEeUZ+/aCUKFkJUJ5xRlHVZhn72xDtvF0gjUTfJIMuPuP/w0eINliophFUo3OhvvMQJyOxe9jQpiZ/OVWcFuzdLIIzC22OS6MYSFpGGdZYatmlAjm0kq/twCNmjy1gqvBeZZeisX7FDg6c52aeXsXwQQ== 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=4gzFNmb3V1wjawnwGt5yQ8wI+uYXBAmrPQK5AiIPACo=; b=OS5I0+ooeKlPeXrMEzv/uiaQHJGDn0sH0e3kHugIpxqOWL1WwEDSoAPK41HtyZolSUGFqDKDfX9up4uWAFW105sQ6Znzi9gnRatZPaYLlj/bZrNKxwcFthCc8N80Y7WRx611JIFnkmfnmw3KMgVI2cKhKQfPLpncfqBAe4K6NBdfEzwmn6dkkfhCffkC/oR5wl7LKqSb2XRzc6gkxakfrbplMZyZaCmur+/p024aCUa6Wn6F1XhNWiPrPwNX3KVBIosecpbbzCgA+0mikaJ2iZz4UwGpMEZJz93gAjqnkgQSvtqP4Y4Nd2zT2iHmHujpTIlLiaHJO/chO0yohngi8Q== 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=4gzFNmb3V1wjawnwGt5yQ8wI+uYXBAmrPQK5AiIPACo=; b=tFw/0LgsMBWcwCV5WtF2acWnwfDYnjyqm9DU8b0zi9EaUGYQ5PubS3PnpOCLASzsbfPHyyFPJFCZo3Wm7nxoyzrkJeHd5oydwLzER+8Z25CFoQjxqqo5lwkmtzqI+6OTPm+E9dvYq79jQjc6dJNZn2r34VuQbV913ab8YtKZrwXmKv2/iBFckhENVOE3lzXpSLwTrkmM+zoik1AfoA39WwD+p4Ic++pszQEnlzvxDd48gY00Bg/rGcYqGl7tSaUQ0JFo4ecOJZBMqlcglxOYAA5WkOsK78K/JLP4QWtEpc6lN5wVsxbf4Rcg8wC+tiB8WRD5ehv5ljRpQm+Rs6Ujcw== 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 PH8PR12MB6796.namprd12.prod.outlook.com (2603:10b6:510:1c7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:54:39 +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.019; Thu, 15 Dec 2022 17:54:39 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 2/6] bridge: mdb: Split source parsing to a separate function Date: Thu, 15 Dec 2022 19:52:26 +0200 Message-Id: <20221215175230.1907938-3-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR09CA0137.eurprd09.prod.outlook.com (2603:10a6:803:12c::21) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH8PR12MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1ed1ac-0029-49ce-10bf-08dadec56f97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iPSF9n2a0+si18+X/6LTP6xjQgS3q9VkqEmGQrmvgyiF+sLm6V8xotsuHHGbXbOe1UMDKSTFlk4sY5QfP1brOogEiYsW08QA0Pg31anojauw/U9TxxAq491TSs35Rhu6t8ZaY6uYrhUTlPU7KbiNKlKhz8wVIYWa+szVNOX6+73RSJc6i43W3JgRJRQ8plLDbP3GV++boGMxYRIDMk5oRmCMSHm4zOe8XwGw9Unexm4CpRJPv5MEjBLaDkdWxhqelj5Ae38IFqgLX8//7RoGZ7rg6UR2HvZKWUGwWgm1APgJzM2XBHHDLF5K5kfuWpUl5wUay7ZFdEkF7kKHn+WjcQknVQFuAWrV+9a60p79No6WoAWPGEh5BRR61WtlTs6Ec4A/CayXoUVHr31FxKzr5KV15lbZAmwIvXK8P1YXBKchsQIJIwctHX9pg0CcnCCRbOJMaivJGnzJvD4Y+uN/oRbISc9FQV6FUMNQjoKrT20TOUkPiKXMCjmKWDdbB1nHYZNdPhge7SVHLYfpYYhHbYyMDYtv5Cz4ZCywE11QCirG48i05JdYsMCoo0gXSMaP4qOCUEHTMuCkbbI/xGDWs8L7+bf1fEKyI17VDRcJnNKEX0if/33czMUuLs6Fbpt/eMxhoQz4+ibkYCdChikR+g== 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)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(8936002)(86362001)(8676002)(38100700002)(5660300002)(2906002)(66946007)(66476007)(4326008)(66556008)(41300700001)(6512007)(26005)(6506007)(107886003)(6666004)(186003)(2616005)(1076003)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FP4NM69YAI5txog0xIZkvOFIvs1nW4mji7mI8t2MCTA6N5P8AamVRDO5lxLjK2GCQVzb2HUCwuVh4sznGDyl/hc4EhXZy1LIzWKYzvcR1jwbgCh6382xFYprB+2H3NwAs9oB5U+ymWg7k5onGbRShf29bLvSoLvcepFbzWkE4aVoMTwSn0AJf0oYd2bt1wzs0kwfJd3u4c2HEzCGXh8hU6eDs6bnSdO1JVwJzAAMa8OxKeqNlX6YT6kFnppbMmuuZbBFkxYnA9CCB8582QaTvFPj/cHsfeOhgaT3X99Rz5D09NcSxuSf/WPF/RU9yxoIr/du6yayMBKMHPz+D5HtV7BaDepyP9E4S1CUUutUsOmF3rTO6qQOTb9i/CxLQ8OGFPUplWFuSMZhLUiq7U5cA5uQQNVXbXQyiFN9EgIw94NoIN2UOhGkU+VPIUSQQJVtfY2lzFXYfUQBB365oiqkmEIGLfGRbxsTZC44Tzs6H4/hLldOUbtuoktgga/OqdjsigxiHBacM0FMj+sOVgEZ656JVyDj6yzHyJWJfA1dTDn4AgbdeCGxadLK9WqzzdBqIQZcYSBBDQhsVEbfBotKULTuRJFajhjqyUxnseq5sK/NRxhRBUUPZk6Qa5AUNSNlNWPaRwOlBJfyqhyhdh91SRONn58APxDrMR6OnxYZFapQjnzZbIQSKDmLjH9/6Ngkat0Ubw2/cNeYgxBqNgYSej5y31bhZPJ46YLVpco2d4bHQJWxOXkeZCO4O+e0IMFF6ihlc5fW1FHAD+KkMpKADxF41GtFpYKDvDbvPVwH7j0l1q7g+a4UDNkQh0jD6J/Ws0r6Dwg6ZZ1+18OOJQHVEcVSqO8UAzIPuQHm3eJ0PUwjobzFUWV1Z1/4qEWCY+ON87Um4ays3P/eWayuA8F5RBN33IzA0aOC7rfOqdOFl3Yb0RC/M7xvNHc2Tbiwbimv7OkSiUlVJVxWPDOw6bs/6KmcQ6hCtJzpug81tjq88zsyeLRdPcGylEsvNeHDfIA3v9ZDaixUqlkI7ZaMxMb8O8Oty3CSXW/MbihGGR/YnBjdgWHBbXGzLs1BmaeGo6ZuYQYzXHiCJeE95sjmxanaQm/VLlYmINocJObRPsq2B1aeZVBJrtyFXA8SPjdI3vxxxa8KxrmMGh5H9f9NOXj5+7TVnQngblbnEQkSbnbOm3x7CvfwxPWpmPtQGDekgSTHArSiRg1mIPA/KX4hF/0VhcNK4WXsuACzMCz0ZfE1AieqGghfkET2uMx9yb+TTNjt7ZDmk6F1gW5hz1P14fHf/jMFx8TuhjAsOzGs9c0g5DrpoKcENnmoDtARL3c9ahhE9qaFRYqazUHrVb6lR1teFADG4bshTdTwo0S/qBfSVIK09KIvEK4PEYrCSvIpLYCHsjekFuyEFE4xtaO0eVmcpATz6NfvSTEpk82mxbeqmBCTZbbqqv9R/1Ao5uLchgrBzHoT65dxJFfUN46phlpNDF7mf8/1dCkgGjwe3h0UdtNKYdUZ82nSAFZzEyeLiJ2hICw8XWzqW0lrW4frRyfxHvpiKRDcl1wBp6rcOE5sj6j7xnoWeZjLfXIwTnzY18z9 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1ed1ac-0029-49ce-10bf-08dadec56f97 X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:54:38.9222 (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: 4yVR4ch9qCKZZrq7VPCYdjRn8ym97oBm5mcHoBaYMcVvI1nxkGNXbXm70ck13K4nH+VGdW9Oal2SXfCokOX2dQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6796 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Currently, the only attribute inside the 'MDBA_SET_ENTRY_ATTRS' nest is 'MDBE_ATTR_SOURCE', but subsequent patches are going to add more attributes to the nest. Prepare for the addition of these attributes by splitting the parsing of individual attributes inside the nest to separate functions. Signed-off-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index 4ae91f15dac8..64db2ee03c42 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -474,6 +474,25 @@ static int mdb_parse_grp(const char *grp, struct br_mdb_entry *e) return -1; } +static int mdb_parse_src(struct nlmsghdr *n, int maxlen, const char *src) +{ + struct in6_addr src_ip6; + __be32 src_ip4; + + if (inet_pton(AF_INET, src, &src_ip4)) { + addattr32(n, maxlen, MDBE_ATTR_SOURCE, src_ip4); + return 0; + } + + if (inet_pton(AF_INET6, src, &src_ip6)) { + addattr_l(n, maxlen, MDBE_ATTR_SOURCE, &src_ip6, + sizeof(src_ip6)); + return 0; + } + + return -1; +} + static int mdb_modify(int cmd, int flags, int argc, char **argv) { struct { @@ -543,19 +562,14 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) if (set_attrs) { struct rtattr *nest = addattr_nest(&req.n, sizeof(req), MDBA_SET_ENTRY_ATTRS); - struct in6_addr src_ip6; - __be32 src_ip4; nest->rta_type |= NLA_F_NESTED; - if (!inet_pton(AF_INET, src, &src_ip4)) { - if (!inet_pton(AF_INET6, src, &src_ip6)) { - fprintf(stderr, "Invalid source address \"%s\"\n", src); - return -1; - } - addattr_l(&req.n, sizeof(req), MDBE_ATTR_SOURCE, &src_ip6, sizeof(src_ip6)); - } else { - addattr32(&req.n, sizeof(req), MDBE_ATTR_SOURCE, src_ip4); + + if (src && mdb_parse_src(&req.n, sizeof(req), src)) { + fprintf(stderr, "Invalid source address \"%s\"\n", src); + return -1; } + addattr_nest_end(&req.n, nest); } From patchwork Thu Dec 15 17:52: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: 13074428 X-Patchwork-Delegate: dsahern@gmail.com 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 A00EDC25B04 for ; Thu, 15 Dec 2022 17:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiLORyx (ORCPT ); Thu, 15 Dec 2022 12:54:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbiLORys (ORCPT ); Thu, 15 Dec 2022 12:54:48 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2049.outbound.protection.outlook.com [40.107.100.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988113721D for ; Thu, 15 Dec 2022 09:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WotqNlk6ixRSXb0kgtQi/ykG0IuLYsFhfeXzbrpvmuRK7lVHYG8ryGzwwXS+ydT93PApiyWvB6dgFQXPrfMmtTdhoTqMKCRiImy0rhEJoeY24eQ6GvPo8soHPwJWYwKKDMUm7CdPbL83OqA7aVZVuSn4IVPsQqrJPysMVcj1rAVhUFcDdqMKjZq3FxU7Kv5BGysUKiQNbyJ88IThhdZJelFQTW2FY68uouLLltEYNfcfNmpOjeUiy3gbZId0gy7AaAf7CDIk2GbbQgEhp3SXaczlZbVGAfQRHWonBxCXe6UONFEEqXd5azFrJljgFVgij/2g/d345bHwoVrgG8Buaw== 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=ejVH7+b/HEKF8/K8l7x6WM0jAgWho/vPW/cGsc4VCrc=; b=d3cnDM2gSjh4Rr2D16UZACJgswyRAspk0cjtBgDFn6plvdeN1eINECP9ZCWcLL3KnYfIPEW/tGjcIok9kZIJ4aObglt33biHZ3WnkbFc/Jt0u+OY3h4TWUmpIxbxOzjn4NrfDvtiG88HyPtwR4qgdoGIcuzGCPhDztiVi+h47zafhJQOTjaNr1dZ+hGks4f2+0e1NLLH+/caQ873M54m1/poUGu2wtLIcdNY0O0tWzR869uHWaQ8OLaSaEi6H3cNQ9fMlJgG/gAHKeXSgosEU2a7Xgm+RJ0rxFsfXfq+RtVKqWFxk6/+FGAuvcXoNXRE9twaOefhs+w7gsGpO+/d+w== 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=ejVH7+b/HEKF8/K8l7x6WM0jAgWho/vPW/cGsc4VCrc=; b=beJXUpJJqLjfxT+MbfW8qFFTnKJUDN4twojvrp1O7m1GoUiYS7loE/zve2kp8Ge+oawughKSrMC+Y6MlalhuER38mw0PMhPHcm5mC4Nssw49Ji0aM30w6BXGoMQkYmNVMr+wIhn5m22tBM4kCNOaX+jGKWwi/D+A7M6ORTfil5qyoldF3c8blg08om+mFHaCpyDfdnniWVIlFqAEBlBNDQbEfHzakZE9FOHyjiv5CfwNDxR1nCHl+LTtcOxn6179jO4zvcGSqC2O/BnABl1LUEFRczY/6iVl7fHmIKK//5PJFNvfY5r7whQ/G0TKXh6XpkGOk2dbbfj+VRVuRfMgsQ== 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 PH8PR12MB6796.namprd12.prod.outlook.com (2603:10b6:510:1c7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:54: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.019; Thu, 15 Dec 2022 17:54:45 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 3/6] bridge: mdb: Add filter mode support Date: Thu, 15 Dec 2022 19:52:27 +0200 Message-Id: <20221215175230.1907938-4-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR09CA0136.eurprd09.prod.outlook.com (2603:10a6:803:12c::20) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH8PR12MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: df1f86d0-f1fc-4d63-418e-08dadec5739b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FGE8JAHHedVPRFp0XajH0JtAsxYIGav8DTiTf1baFg1eGu64hgmJZcWR4iW6VujI71rQ387wKDnc9DHZYSMvf4IHTO7RxbGF1YSYVP7pum7NbJEZTy+aI5dvR6199iCYaiSJqRoEKZyDnWBB2+qdjbCwygUvBl+9g6qca12HEQFy9eXnNina5FoFzqDchFG72SNi7KhYQiGW6lGLttgJHxxaMMdqakVkHW1k+Gb7dLzDZqnNlJCSO/53l03dpoh6OMm/hDMVrcEOnFhXxneq/tgbFelONCNV0cKM0xc7DLNAk9fnOLAyrStvHnSbNKLARPbQDWI1Jr1e9ygYAK2IMl92lMaDGoEmqXuT2TDLTDw/Z6w1WTXELngoXDqi+KUo5wqk0ZJEs/RQJWYM3l6frTwr53rYaW88mynJXL19yTQNo10gf5l2a8gU+voET4hbB8UU/Ixv06nZ3ZIME5lrjD+edVoHbP2vcjSdLR3/9t2yr5gTKjQwVlmHWyqDfBLqnAsnMcd0ig192eXJx4GSnEMSWwiyQVgjF79gEIoxJvCx8Z3yacpsqAJINB0gc8n6UAMiYj3LxmlQ2QlTUhlmqS27Li8Y2CKT6S2joMqo4jZeFk41NQwu4DbfLfiuCvyB95GEGOEvs1LR1sAsJFVvSw== 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)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(8936002)(86362001)(8676002)(38100700002)(5660300002)(2906002)(66946007)(66476007)(4326008)(66556008)(41300700001)(6512007)(26005)(6506007)(107886003)(6666004)(186003)(2616005)(1076003)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OpFn9AG0Cq0YzI3HCDDsdh15q4bTfRwpZS/GeZ/SBkx8zGxjbaS94186ho4T1GkZ1p2BK7hnuU3TVpITyFXL6QE/a+RnIShK43Hw9NF7N2fPghy7/uA7NY/fkOcNFAgOGdkUG/4RSnz+49OOAY5WxCxGWdkgev1HU1KtnRrxZB2VPHR+7QJE7xaMUlGcnIa0yVa52SlGiG1Wj5TP6WwQ1EbqRzhYMNhYE/eAlpMJIllQRWDTQp0YB4aXXX8X19CRZbWZ62La+fZPna7/wMGDfeVZJXCJHVXdkmX1TCwWXs4XK4GLOFozKYOgCgCbPkrIMmRKmt17ob2kgRkCJzpTamqrKhLvsHjCdSecS1pdNOinD2xLZFtDVPeLFvcWR0xVgk+1FEgxiq+9SX73Dws4oiNbDOyZ5lwzqlUB+yRxRrkbnAgPRdhjp6jGyctlx/5w3SAGho1s9BPGQFWliuoKQZU4NSxLxJGfeHjp96TLcakEB7tNsTny+Eq6wSBsapvuHGmcEwIv1ZPQwzG8S2CHsEq8GHWVRd+gkWiYYMcACly2hNNMXPxwxLmjlHPGl5/smYHq7A6cRX4Y00D73VmcvjTzO5dRrqDKDqq8xEbEj32jxydyqOwUFU11KcZPgEANJbrlL9ArWEqYw4vO88b+NrDdP8QA/LNJh1b5yKzB7l2XEYlxXlPTETZA9kMkirgLm5SnIISjxocFU4RxVWLpfc7B6vVF8dunP0Vtbs/Iynrt7PXOFERQ4LummGCoW6cO+rrB3qrg1JJHdNbKVixlVjbGVUCFGRcHGM8FFq8mFA3tHMjJl/OKZuMqbz4Uu4AjRwxLBs2wLQxhJrV8xeWXfVWds/z0jbCmiA2fC428FVsKSnxTXImg2JMhUOnV3WtvRXTvOuJ7XR47K5AlMH8wmt5gsGJwwjPRAEbnbnXGx3U+aE4yIoPYDdp5VcIGAf064ghWGe8Eys146wUYiXOWlLBftDt8VWBkp6VtGHAHrSjt2XMuQoAZLRNVK3g9Wm69eVbXsGmhp8OfGaBxWEqZru7NyOsH99ZzAPykmHAAHu+rFOY/HY9MgG/wJK7yQljqzmJdsK1lwYTmPAlsbBG00P08XVlhvabkH3u67DzmFxQZPSMbtGrpES4RsBmkfnKNq+XwVflYdv2nRJkXL5cbUFg2MpxOAlJBdvnv5F+kzd+s2VR8Ir5nFpAL6BrjnT/7FKgCyxsxx8jcSK4XDk9+Ay+8oDd7ocJHB4etESe3zK9oHC4vwvB9ZEmHZTap/K8P8zIfWuFsVEGH36Yi3w34YX7ro3wNIVecpH6H851MQi2DdWdK9UCTtDKD/fbv0kVli4SM8nDDYa3yZXJzhqTX+QMwedtFy8boSnJrlrEgKjRwr6AvJZyghzSkUkyElSTVvQ1fr2GzA7NbDY2mfCPvFcDWj84jC1s1F92jaRgZy/onT8KmTz1otiq4GBP0MXNbUHHN5aes4JO1uLAmwz0VuB0thcwHQU/vzc52V1mZRd6XmB4Av5RPnsEgy5Al7B9TgIgGxXDpPBjCyFDQf1wzLCVmAV9N2xKefkfUMp3mDql/IgcSRO8IAxly6sW6Rqyg X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: df1f86d0-f1fc-4d63-418e-08dadec5739b X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:54:45.6762 (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: 2Mxdjc8Oqm7EgB7xnTYfjr7t+3TjD1TsW9dbiH1rZ8NtvzKvaqCAyWBzM1TX0/si5WgRRh37B8oQjAGCdBCarw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6796 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Allow user space to specify the filter mode of (*, G) entries by adding the 'MDBE_ATTR_GROUP_MODE' attribute to the 'MDBA_SET_ENTRY_ATTRS' nest. Signed-off-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 27 ++++++++++++++++++++++++++- man/man8/bridge.8 | 8 +++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index 64db2ee03c42..ceb8b25b37a5 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -32,6 +32,7 @@ static void usage(void) { fprintf(stderr, "Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n" + " [ filter_mode { include | exclude } ]\n" " bridge mdb {show} [ dev DEV ] [ vid VID ]\n"); exit(-1); } @@ -493,6 +494,21 @@ static int mdb_parse_src(struct nlmsghdr *n, int maxlen, const char *src) return -1; } +static int mdb_parse_mode(struct nlmsghdr *n, int maxlen, const char *mode) +{ + if (strcmp(mode, "include") == 0) { + addattr8(n, maxlen, MDBE_ATTR_GROUP_MODE, MCAST_INCLUDE); + return 0; + } + + if (strcmp(mode, "exclude") == 0) { + addattr8(n, maxlen, MDBE_ATTR_GROUP_MODE, MCAST_EXCLUDE); + return 0; + } + + return -1; +} + static int mdb_modify(int cmd, int flags, int argc, char **argv) { struct { @@ -505,7 +521,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) .n.nlmsg_type = cmd, .bpm.family = PF_BRIDGE, }; - char *d = NULL, *p = NULL, *grp = NULL, *src = NULL; + char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL; struct br_mdb_entry entry = {}; bool set_attrs = false; short vid = 0; @@ -532,6 +548,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) NEXT_ARG(); src = *argv; set_attrs = true; + } else if (strcmp(*argv, "filter_mode") == 0) { + NEXT_ARG(); + mode = *argv; + set_attrs = true; } else { if (matches(*argv, "help") == 0) usage(); @@ -570,6 +590,11 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) return -1; } + if (mode && mdb_parse_mode(&req.n, sizeof(req), mode)) { + fprintf(stderr, "Invalid filter mode \"%s\"\n", mode); + return -1; + } + addattr_nest_end(&req.n, nest); } diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index e72826d750ca..e829b9cb592a 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -138,7 +138,8 @@ bridge \- show / manipulate bridge addresses and devices .IR SOURCE " ] [ " .BR permanent " | " temp " ] [ " .B vid -.IR VID " ] " +.IR VID " ] [ " +.BR filter_mode " { " include " | " exclude " } ] " .ti -8 .BR "bridge mdb show" " [ " @@ -931,6 +932,11 @@ forwarding multicast traffic. .BI vid " VID" the VLAN ID which is known to have members of this multicast group. +.TP +.BR "filter_mode include " or " filter_mode exclude " +controls whether the sources in the entry's source list are in INCLUDE or +EXCLUDE mode. Can only be set for (*, G) entries. + .in -8 .SS bridge mdb delete - delete a multicast group database entry This command removes an existing mdb entry. From patchwork Thu Dec 15 17:52: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: 13074429 X-Patchwork-Delegate: dsahern@gmail.com 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 E5D63C4332F for ; Thu, 15 Dec 2022 17:55:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbiLORzE (ORCPT ); Thu, 15 Dec 2022 12:55:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbiLORy7 (ORCPT ); Thu, 15 Dec 2022 12:54:59 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2051.outbound.protection.outlook.com [40.107.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B458C46678 for ; Thu, 15 Dec 2022 09:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U2pZyWjf3oukY8YTSKkrmJe48zyG0xUImKr/1MqVPldXQHP3DJNmzi3hZqJ3+NShmfmN6OWkT7EoY+kLDDGkUzeQeGg3D44TTfmPchhiDy5t3vDoj93SAYorTRwvZg3SsBscDmTT12dKSpxR4OOdxJi/RECuhGaCGwlpASreGvn7gCQz9BfTyjrEaDa5UynzHQ1V9gbdtzd3qW5q4oAQwVwgSXmye5HGRu1jdbVihd8qsvy9b3ikmQrSCY4/+LmVP5uQWHUy2uKcyf+aFyMqhDxJNldiBVaEr5+Pz166oqJxMjVOzC6BXvdE5vYfr5sJAuMISPe3RXvpUDKSJy7UXQ== 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=qK2wDTU9Aod3KVHf5NzZKVWw/CptEfI5qc0V12dn3sQ=; b=DFHD9Dzp2J9V1KlJsYi1lMPm1rbUC+oP/1QbkJyFBIQwoJGiAjepXWO98yXUeTS7i24752Be7Esh6N+P9aCpiXBvPBAGO/tKqSKNMvW4zOdsRrD2cSmJguildVbgiwhtr2yKVUqbvsNvLfK3Wix6PhED5lGjdUgEMoKWBOToOWMAnqhml3yy3LhOddj3xgl2tA1NRgbJ77o81FRg4IPc8qycQp1rLIwWmvk3u9agBa8hi54NAWUtKEgJ/lBQpnwwvBs3Eol4tMMD91EjhRdWzRSZu+qB+HM1dzwQHQIDoj+WOzar3jDkGxfEq5ZpLEo7H6ldUimlpGTS8a+gzvoO5w== 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=qK2wDTU9Aod3KVHf5NzZKVWw/CptEfI5qc0V12dn3sQ=; b=bdMR2X82kaVPxuGvB4l2B4oYyfqw5lb4u69uQRIUIl5eds1LZP3DkaIsH4lteI5GiDDuJEZLC0T2pM0gW0xVOGGPCtJj9nJpi+BTyvTDGteRBe6NsFILTyJOvA6ZZx7oEHM8yxFppJaoz0VwS1urHXc8GSb1sX1VnybHNkULKjnz8Bgjg3q4vTloOnOtudhSQPlNqb4QDsk7eZWMMNM3CW/3wNzqcdOQVAuECb6ZnGRrpt5hWjipqavayjavYktRN2cpTGCVSwwe3keA+5oUp2eKH3EJI2pFraWCm8f7vPXLwi40Ey0SHQuznWr3hOdpTCsNwfd0xeMcEetMsv5wkQ== 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 PH8PR12MB6796.namprd12.prod.outlook.com (2603:10b6:510:1c7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:54:52 +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.019; Thu, 15 Dec 2022 17:54:52 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 4/6] bridge: mdb: Add source list support Date: Thu, 15 Dec 2022 19:52:28 +0200 Message-Id: <20221215175230.1907938-5-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-1-idosch@nvidia.com> X-ClientProxiedBy: VI1P190CA0039.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1bb::20) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|PH8PR12MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: d72ec710-c50a-4f3c-de02-08dadec577af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bCONjFx5hPlaxiC+ztjiRZ3zJFFW8TbPyoRAFO8SUUEnuHavaw4JBL+12F9CYyXNBT0CIo/JuvfGgXHAbNjI4nBA7ShJ2pUuGDkLYM5IhzyNyFKZYYYLi4FCU29xlrqoHa5ZID6FvYXJd4Ik6nP9253mmZV9iBTzkVSC7s7+qwmHFi8WGqQNgysgnI2ec92gEN9l+xsX29ecYtSLLpfpdu5Gy94c+cPkPKoaQS4j/C6x7o9m+N34d3Snu4b8UdPVNAFcXk6AJIMdqvssAb1ieB17l/vi8tdlfqLjkorF/K/YF2+6ScfAgV19izOslFp1ScOkNLwfcQWZSVZGCj1g+MaI2aZetE/izCpuC1o/osi8sfkKF9xj4j4brZDJcYv1DpGI5aV3pW0tJxHTBFxWJtHJCTihozl45pTwSjvxU3OzHPYfrYXWaYPLkiYJ3NH7X8+IbvUydyPhRx1dj2gf4lcyK9sJgQy+hxBvz76qhyUwABiDzTrJ/+Jcvag7pfNc6aJFcTQ6emKWD/yc7AD7Gxw/xnoRt5Nk3drS48xfddUO1wbgvQbimBqWHrnGM+2yiE/khU99HRZoxHV0qdEiwJsB/iwrqitQY/iVYRkoPkzgNSEIUmkntZq+OT3b/1miytQmgiTMNcPdtGlJGT+Z9A== 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)(136003)(366004)(376002)(396003)(346002)(451199015)(83380400001)(8936002)(86362001)(8676002)(38100700002)(5660300002)(2906002)(66946007)(66476007)(4326008)(66556008)(41300700001)(6512007)(26005)(6506007)(107886003)(6666004)(186003)(2616005)(66574015)(1076003)(6916009)(316002)(478600001)(6486002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DmGLTfQSIW+o+oez5wAYAsRtgma30Xcd+e0q0qNOEvEAumUVsE5muELJxbPFgi/R2daUi44IVlQD5mdMKuyZfPCYHAyeTtnco0ZG9xlcju64rrGo+yy9CDQGx6Ebo8bwtRD3ERLzu1ZymHKQB4jNh10W98B+33wb17UeiA17a8pBMOsf/Nbc86aopjn1o04UG5KAS8+/W2YRMUmljLHlmfxp6CprU0MUQxXrbyyuuPtX7/0HMv8SU67H14EXnYEX2XYP2uPJaJ87GPUiaGhJ6z1F1Fj7G/8pD5XX0d6Ukts/CjjIDXtzQorsWw6MLuaI5noBq+EPO79UYO+pAYuvyPvLNbnU7aTA3/6W9TuHZUf4PepY2mAnDXSJnn8WUA/fuGB/ILUStWUsgGDxqrogPAN+TAw22aekeOipQtfkSeZhBF53pZ7zRwNjKGVP53GUg3m4XBnL0gD1NJjg1UBzzEhD+jB4tU6SE4vZPFM6gbGWR218aRW2BepdCDqZSeeMVAOx/tuOm1GHOMvXxMjGIc5I4b11ZdQGo7fx0dBK+6MM2cK/nmtll1gnyKqNlnc5MpEtCp3cJrfbMLo8pQ0+7KT2Jloe0To176gc6KaKrv3gJ7g0knJhRUVhSB3h/XGw+eIj+HGZxiQglo1RalPfZeSSH9EOljuuT/Ozmqq7zFAa+wV4kVc7eE4TzXRrOoRsGKVsZ1F2mVHtA3gnQ4FwrS3sX5NmlSa6zbmn74meA6jQVFLzAwAhTH/3R3cPu5Z/qHKPORb9dBQ94gHhNI1G6Gkh6lVy610ymzLaQT5ftxb/mScYCICmqzYK46xBfEytO32K1+Unak2CFOk4qN6BKRecIFx9jgrvhOin2bSKj+Wc4CjPe/jWW2mv3brHXDN5xHDGrZHyTYoryyo0YzmHaL2CZmt01XDIeFTN/qwvsIEVhY+5+kSS8c0or3gQZ9I4dC60TEEGvgJcnPq81YnoRhNPkXT0NIS5YCuZgUtVz8wzUlQ8O8+Sm5uQ2huaYWWnBfg6eQMcAAK+7ZDTb/z7Z1B5J75+D3IVAAjsG3w2X3QRJzyxZgR2AE/+xIj9hx/J5vHwAXLsmC07bVP611OkSj/RzUjxpkCCBWxLnw4yU8H8pVIh7MMB1+4giFuYS8Kg9OFFm8Rvb/dfFMpOkQ61sPPiOMOwkGnU41BfPW3xHNUhH/pe3/gp4FqQOiqUnM3p89Jdm9PV18Tqe1pyMKAyoclhMWqhTiZa/btQOFASglz/w99y3qDDPfUHB90BLd0ZZdCpNsq/KGt4sHOP4khLik4W5vUJPmvSA6ei9d2wQudm1cDH/SV8I8ctdcJ55x7lrFcWebDWfksnIN1FZ12JR2FkWYqSuQp1UbfbwkZEWBlHmZ3xu27LzS/RtVRmPsqkHKedp95neowH7Ll8zmyMB824wbvdKqZJ2h6aIrOIx5qjvGhI3DCmXNPWEh3u6AErSp4wg/AyBQfEHkkxoyd6jMjgT40SPY4wPepKXw+u2D/H8dOEjrhsN1mrERbVYWVCpBuSI1avhFYwFRS51U0bO/WohsEdedaM5H3Z66bktl1nX39psgCPZ1Z0WO4ORN+x X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d72ec710-c50a-4f3c-de02-08dadec577af X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:54:52.5064 (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: vMicw8iHk3HOMoJgmEVbnra+IFLjJHe4J0R7eJkDf8uIxU77Xt+Xg/D1ibJcGC4E2wsFsfQtsCwYvpbvDUZkXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6796 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Allow user space to specify the source list of (*, G) entries by adding the 'MDBE_ATTR_SRC_LIST' attribute to the 'MDBA_SET_ENTRY_ATTRS' nest. Example: # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 temp source_list 198.51.100.1,198.51.100.2 filter_mode exclude # bridge -d -s mdb show dev br0 port dummy10 grp 239.1.1.1 src 198.51.100.2 temp filter_mode include proto static blocked 0.00 dev br0 port dummy10 grp 239.1.1.1 src 198.51.100.1 temp filter_mode include proto static blocked 0.00 dev br0 port dummy10 grp 239.1.1.1 temp filter_mode exclude source_list 198.51.100.2/0.00,198.51.100.1/0.00 proto static 256.42 # bridge -j -p -d -s mdb show [ { "mdb": [ { "index": 10, "dev": "br0", "port": "dummy10", "grp": "239.1.1.1", "src": "198.51.100.2", "state": "temp", "filter_mode": "include", "protocol": "static", "flags": [ "blocked" ], "timer": " 0.00" },{ "index": 10, "dev": "br0", "port": "dummy10", "grp": "239.1.1.1", "src": "198.51.100.1", "state": "temp", "filter_mode": "include", "protocol": "static", "flags": [ "blocked" ], "timer": " 0.00" },{ },{ "index": 10, "dev": "br0", "port": "dummy10", "grp": "239.1.1.1", "state": "temp", "filter_mode": "exclude", "source_list": [ { "address": "198.51.100.2", "timer": "0.00" },{ "address": "198.51.100.1", "timer": "0.00" } ], "protocol": "static", "flags": [ ], "timer": " 251.19" } ], "router": {} } ] Signed-off-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- man/man8/bridge.8 | 11 ++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index ceb8b25b37a5..58adf424bdcd 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -32,7 +32,7 @@ static void usage(void) { fprintf(stderr, "Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n" - " [ filter_mode { include | exclude } ]\n" + " [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ]\n" " bridge mdb {show} [ dev DEV ] [ vid VID ]\n"); exit(-1); } @@ -509,6 +509,53 @@ static int mdb_parse_mode(struct nlmsghdr *n, int maxlen, const char *mode) return -1; } +static int mdb_parse_src_entry(struct nlmsghdr *n, int maxlen, char *src_entry) +{ + struct in6_addr src_ip6; + struct rtattr *nest; + __be32 src_ip4; + + nest = addattr_nest(n, maxlen, MDBE_SRC_LIST_ENTRY | NLA_F_NESTED); + + if (inet_pton(AF_INET, src_entry, &src_ip4)) + addattr32(n, maxlen, MDBE_SRCATTR_ADDRESS, src_ip4); + else if (inet_pton(AF_INET6, src_entry, &src_ip6)) + addattr_l(n, maxlen, MDBE_SRCATTR_ADDRESS, &src_ip6, + sizeof(src_ip6)); + else + return -1; + + addattr_nest_end(n, nest); + + return 0; +} + +static int mdb_parse_src_list(struct nlmsghdr *n, int maxlen, char *src_list) +{ + struct rtattr *nest; + char *sep; + + nest = addattr_nest(n, maxlen, MDBE_ATTR_SRC_LIST | NLA_F_NESTED); + + do { + sep = strchr(src_list, ','); + if (sep) + *sep = '\0'; + + if (mdb_parse_src_entry(n, maxlen, src_list)) { + fprintf(stderr, "Invalid source entry \"%s\" in source list\n", + src_list); + return -1; + } + + src_list = sep + 1; + } while (sep); + + addattr_nest_end(n, nest); + + return 0; +} + static int mdb_modify(int cmd, int flags, int argc, char **argv) { struct { @@ -524,6 +571,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL; struct br_mdb_entry entry = {}; bool set_attrs = false; + char *src_list = NULL; short vid = 0; while (argc > 0) { @@ -552,6 +600,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) NEXT_ARG(); mode = *argv; set_attrs = true; + } else if (strcmp(*argv, "source_list") == 0) { + NEXT_ARG(); + src_list = *argv; + set_attrs = true; } else { if (matches(*argv, "help") == 0) usage(); @@ -595,6 +647,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) return -1; } + if (src_list && mdb_parse_src_list(&req.n, sizeof(req), + src_list)) + return -1; + addattr_nest_end(&req.n, nest); } diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index e829b9cb592a..801bf70c0e43 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -139,7 +139,9 @@ bridge \- show / manipulate bridge addresses and devices .BR permanent " | " temp " ] [ " .B vid .IR VID " ] [ " -.BR filter_mode " { " include " | " exclude " } ] " +.BR filter_mode " { " include " | " exclude " } ] [ " +.B source_list +.IR SOURCE_LIST " ] .ti -8 .BR "bridge mdb show" " [ " @@ -937,6 +939,13 @@ the VLAN ID which is known to have members of this multicast group. controls whether the sources in the entry's source list are in INCLUDE or EXCLUDE mode. Can only be set for (*, G) entries. +.TP +.BI source_list " SOURCE_LIST" +optional list of source IP addresses of senders for this multicast group, +separated by a ','. Whether the entry forwards packets from these senders or +not is determined by the entry's filter mode, which becomes a mandatory +argument. Can only be set for (*, G) entries. + .in -8 .SS bridge mdb delete - delete a multicast group database entry This command removes an existing mdb entry. From patchwork Thu Dec 15 17:52: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: 13074430 X-Patchwork-Delegate: dsahern@gmail.com 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 C12D3C4332F for ; Thu, 15 Dec 2022 17:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbiLORzW (ORCPT ); Thu, 15 Dec 2022 12:55:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbiLORzI (ORCPT ); Thu, 15 Dec 2022 12:55:08 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2A346660 for ; Thu, 15 Dec 2022 09:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SgBbLaJy4fPQh5xQTsqoM1bwq/ZljNcZ2yKkuU8J4kXUcy48aIXvrdX44xmWaFyCRRQR1Aro0TXifPZ2RPOYSbewW+01ik5AEZ4zmw9ZRRD7JveATgmSCvgD3pLYDYE+VFZ+FUbt5u3y3jrx81RU3PQF/UkPRKSpv0p2tRM74aPefQCgul4/n0OuEvIoLdegUeJ8KTM+P3imh3a9OT4cfB2mPZBBiJ1qsjpnoc2VTJAfGfO8wdxexoCIv+ql57c+3TRBwLd6HNhDf0h1SjSjFd9D8m03CBcb/f75RN89wJFp+bbJy38lXnspkEWssVM777iuspipLlhrLgerdWuxpw== 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=uln7dUWS6Yb09CL4g+IOlxPHjcZBkVOJL2PhnG79xk0=; b=gGXYlhJ2G4BL6qxY6k1LFgd8ydh6LfEiHh1Xie1WVks5g0/u0u/oJDFiZTH9BMD2QPubCm06OzTttg6fMgo+Mrs4PytpNm7Jj8bY54zX0vf4ZEN0KRM6txRV8j8S3UnaY7ZwTp+7F3EdIzA5IIVukpoJJi4enAmQPxGTOdG8h4HpZvX5sxborP4ll6A6mKYZZt5sxdklwPaA98auifViQ+LwBKWlauWdfUOFciFgTZVqAT/F9KWZHoOuX03Ct7dFYfh/I9tIxf1jVXbwGzRRlx9TXBdoqD0jQ+GfCpcEZP4FC5jHpyWn2DcFr1oSCOH0BuYPfWbG/Vfj14O1HzoNmw== 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=uln7dUWS6Yb09CL4g+IOlxPHjcZBkVOJL2PhnG79xk0=; b=gQ/mwg2PlpXqpuJd/eqcIwKKKOvZ0pJmL4hDJGZ2LFsL0LB8lwR2o1QizlM8o6cnH91LHvGWVEWNTzEDHU48Ilh9znut/wEAiCn8GW1ReqMEuj/yIviiG9qpDCsaML4bqrtgi4LRnQekHPeDKQEoSyPBEmE8QedTiHMTNxnHvZ6LSYIpMrj/zW7dpys8VxOt3+aTqMoEzFCBXTfw91RvJBHsna5q31pSxLH3SmW/QRxODK+Mkb5BBHip8HUz9HDw99QQSTDF2EgwQlaS5UjOyNGcSGDYSPfmA7AZHKVn0RQMhihGG/Hk1Ryeewa8Ms0CK2Pb7F0FlNBWBHFaOK5q6w== 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 SJ0PR12MB5673.namprd12.prod.outlook.com (2603:10b6:a03:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:55:00 +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.019; Thu, 15 Dec 2022 17:55:00 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 5/6] bridge: mdb: Add routing protocol support Date: Thu, 15 Dec 2022 19:52:29 +0200 Message-Id: <20221215175230.1907938-6-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0802CA0019.eurprd08.prod.outlook.com (2603:10a6:800:aa::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_|SJ0PR12MB5673:EE_ X-MS-Office365-Filtering-Correlation-Id: f748ca11-9571-4d28-78ba-08dadec57c2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4i99vVeIj460tPoQ9tHMZvM1A+difDzvmFNn8VJCoF1Qf8wKonPYUk/rhuRAkiUEfS3MAgi5KmMpY1NRQkqSZnuXeK8+IC1mhmPwe+syP7hXxOxFbGM4cF/unDTx7Lx5qJaAWWj3AWGac2C+peN55Mi4dPfhknnvYftw9Oi1NVnZv7FmqemBy1S62yFofUrX1QGMymCtWGm665Ad8mla8OzDgJvId3hpNF+Fcw6eVoMtQhIUxysfZJaib6fGKS0YLjREtH3mm15GkzPZ6WUIu8JknK+IbpMctF0+Lv0Je75vnUL0DkmHsbTrYWJJTmPQvwb3+t8Nwh+5c1t9fCZcgUlt9We9+N2kD7xWudGw2iQzYsFFW3ZdNSoK3Gsv6wY/KtddAsDfUMwiT4HPsVx/CxAz3+eFk31wSae07wsKPhyQZ8WiIT1QqlQry6Aig5DTS77QILKe/4tY6GAsBritFXbrCDrJXF1YX8iz8XcGjI0rZKXUdsvua3esfh2RYHE5sWiMueNFaUwwyk5iAJZL6L0IfrYZJV1otZH3num0FQeCNN6rvrkWorGbiMQBtETjcjrq52Z2qKCNyBiViyapAX9NhV+IHEpSEiOkcWwYtC3qAbrWRmzHjZZdJWqM9t945q8gRHD7GLR3GBoG1rRj9g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199015)(6486002)(316002)(6506007)(26005)(186003)(6512007)(38100700002)(478600001)(6916009)(107886003)(6666004)(41300700001)(1076003)(8936002)(83380400001)(5660300002)(2616005)(8676002)(66556008)(66946007)(2906002)(4326008)(36756003)(66476007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5wKdRSFeYvDXlbfW8B4P/bnmHQziFU+yrgxJSagSdOH0j9vpmWRV6iVu+MGSlZ6wrbRV3C2YzXr/U/mfzrVtnlAdwcC5Ys90o/0PoFx0i2vi1pAZ4ft8oxpDI/H8vQKVi1xYVXW20sc1IL+WpzUOjXMl7nfCqAaDxU3HxKp5sF/MISjLVpC7NMC6mmKO0gEMxFKVEzC0yotx4OQlZmvlrPxUY0RWlMPcvPPh5YAAJ2DVqBEouGQC+0FQVVm3GJlna+Dyq1rpWnCert8ScxVw1Ph+EZ0nBVJ0xZtKPFbqhLekHot4rB2jnpLvyzmmnfJ6FKUokw3NmV1gRNNnMppAGA0Rw7fk+g0dku1gj/v4xed0ZofyKHKyvd+1z5lDO97xYNDgMlsIllcOKbuCb67sDnPMWzmFfmYK6Ed9A39lO34EzrP75pFA5yz3j1o3KC+MsS/MtsKagijrSJX9laSRRhxbOub4BJKnJZWR0oP7F23AYn2bxNA59fGkEG0TwipK/3GxOX9lhrLNNjle6SIhUOd/zhgsdT1312L1JejZmUfwHiYu+oCVAG1FSEELnWJJZ1r4lOrMEoC55mm9hnFHFwkmKuVTbWpUF30UulGvbq6BB/m9uL3npIssmjqdJdPwewbLWF/d8NLlP0WK8flVBsedEfLSg9QqKUHDxFWRR6p5H1n50iJ9SEONKEs4k6SyfWR2u1QSBvcwk2EpcvOGNrfwVwuVs7ExcNFZCvB7dMm0T48rljW+oipJMwawQVP3xpFY2aAPM9hcjVxopM1kc7TbMTtpD0yEi7ulBfd07H6qELf73AxtrKl8v5pl0Ld48RSsGStZY3BR4TnZN/hvx77fqsC+TONdzD8+jr1A7wW8RknnpJxryfHy0mJT7giX25KNaSuOeGtpHYmRgfgcYrSVVLDcIMNwfuLMxc75z8ioPXBGv3SVH7xzdC9/0ALuggG1/II+sI65KstPA4TcsGFKEhuFA9fDWRoDyn0XJEincP/FAkw+iKJ0vLrGXy1tsxLx+bJTCDtLWFE82gHZdnOjNZ5TxDThHd9oZDj5kA8Qu3VPxCOLLt5KpQG3+qBxcj2tN7LL/5/q0ntAmOUnFO2GpMuZzyEyTn4bU4+Uzc3aV00A8EBMXXfZ4S1uuumeJWxwd+2IWUxKOQvRZj6TeQuD/5X7WtYfLAhaj3kzB7cuR1bc8oUoKBxcD9upybdaS+TlJEJO4uHU2R/NlDSVOfD7BGpYh3nXvnuVkwNmX24tiiNEn0kdBYZjuBZuwB+uUovr/rECtU7LlAeiYlrUtEoL5O8sRXHaJWMI5faD3Wkv/7HWDgmwPS3P5txg18mBbAN9DiXn7ajmUMQCuW4nQjGMz06sNWhSs8s//QYlBJL7Hjia4JowWUSvhdQWpewDAuZj5OkxBaIu6RltMEqbu5XUSdBryLpe4Q3eS1HTTrWaM/I/x8QqqVmbFct/32op6wQNApSFK3niTUh3TlpkKfAT5XjE4jF7d2Ulon8NI1mvDAE2TXMbwDrmEN8cvIeYE7IADV1zvT7tOQM3dkpELF7srRy7CvzAzxXTH9/6+koLMZqkfcvJUUBBKuM6+wBF X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f748ca11-9571-4d28-78ba-08dadec57c2f X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:55:00.1005 (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: KWMWwoM52lDpii31XzHxCQLgC0bptpLQCa5q41wtfQSWszuzlUPLz1yKeugt3c6FLxizThlbjrjHKu0OMEpTsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5673 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Allow user space to specify the routing protocol of the MDB port group entry by adding the 'MDBE_ATTR_RTPROT' attribute to the 'MDBA_SET_ENTRY_ATTRS' nest. Examples: # bridge mdb add dev br0 port dummy10 grp 239.1.1.1 permanent proto zebra # bridge mdb add dev br0 port dummy10 grp 239.1.1.2 permanent # bridge -d mdb show dev br0 port dummy10 grp 239.1.1.2 permanent filter_mode exclude proto static dev br0 port dummy10 grp 239.1.1.1 permanent filter_mode exclude proto zebra Signed-off-by: Ido Schimmel Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 28 ++++++++++++++++++++++++++-- man/man8/bridge.8 | 12 +++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index 58adf424bdcd..195a032c211b 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -32,7 +32,7 @@ static void usage(void) { fprintf(stderr, "Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n" - " [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ]\n" + " [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ]\n" " bridge mdb {show} [ dev DEV ] [ vid VID ]\n"); exit(-1); } @@ -556,6 +556,20 @@ static int mdb_parse_src_list(struct nlmsghdr *n, int maxlen, char *src_list) return 0; } +static int mdb_parse_proto(struct nlmsghdr *n, int maxlen, const char *proto) +{ + __u32 proto_id; + int err; + + err = rtnl_rtprot_a2n(&proto_id, proto); + if (err) + return err; + + addattr8(n, maxlen, MDBE_ATTR_RTPROT, proto_id); + + return 0; +} + static int mdb_modify(int cmd, int flags, int argc, char **argv) { struct { @@ -569,9 +583,9 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) .bpm.family = PF_BRIDGE, }; char *d = NULL, *p = NULL, *grp = NULL, *src = NULL, *mode = NULL; + char *src_list = NULL, *proto = NULL; struct br_mdb_entry entry = {}; bool set_attrs = false; - char *src_list = NULL; short vid = 0; while (argc > 0) { @@ -604,6 +618,10 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) NEXT_ARG(); src_list = *argv; set_attrs = true; + } else if (strcmp(*argv, "proto") == 0) { + NEXT_ARG(); + proto = *argv; + set_attrs = true; } else { if (matches(*argv, "help") == 0) usage(); @@ -651,6 +669,12 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) src_list)) return -1; + if (proto && mdb_parse_proto(&req.n, sizeof(req), proto)) { + fprintf(stderr, "Invalid protocol value \"%s\"\n", + proto); + return -1; + } + addattr_nest_end(&req.n, nest); } diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 801bf70c0e43..3e6e928c895f 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -141,7 +141,9 @@ bridge \- show / manipulate bridge addresses and devices .IR VID " ] [ " .BR filter_mode " { " include " | " exclude " } ] [ " .B source_list -.IR SOURCE_LIST " ] +.IR SOURCE_LIST " ] [ " +.B proto +.IR PROTO " ] .ti -8 .BR "bridge mdb show" " [ " @@ -946,6 +948,14 @@ separated by a ','. Whether the entry forwards packets from these senders or not is determined by the entry's filter mode, which becomes a mandatory argument. Can only be set for (*, G) entries. +.TP +.BI proto " PROTO" +the routing protocol identifier of this mdb entry. Can be a number or a string +from the file /etc/iproute2/rt_protos. If the routing protocol is not given, +then +.B static +is assumed. + .in -8 .SS bridge mdb delete - delete a multicast group database entry This command removes an existing mdb entry. From patchwork Thu Dec 15 17:52: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: 13074431 X-Patchwork-Delegate: dsahern@gmail.com 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 5D6C3C4332F for ; Thu, 15 Dec 2022 17:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbiLORz2 (ORCPT ); Thu, 15 Dec 2022 12:55:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbiLORzQ (ORCPT ); Thu, 15 Dec 2022 12:55:16 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 024B446678 for ; Thu, 15 Dec 2022 09:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QZJ47OIMfvDlmTpYkLtsLpMJPougeQPfo2z3iEXQqmCFQQL2jFxHj+CPOlheUUTYjJ1pRGy+pw8M+0j5OV27WH65RNEDm/a8P0m275J0JoWKu22fVlf8+YnXd1My3X974Wb/xS/4wULOEjdV5Ri5lixw706ABnMyoN38FbztEDGODWFQ+IV1LcuzJiOAM+bdjRhqRzdESU2zQOJVJa3Wxprjq4VRxqJVo/pJAevNsTi86pbk1+W5MqTMJha7X6UyzqyREYdOyNWdIs4jtP7d4kLuIo/brmW5SyDuHUSdQAlc+ulDJhJCkOU1lRrmO/vcS6RLcm00toCXnpH57kNblg== 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=ZPXMHPAIew2zmB0QuSopnSNB+C1jOYeYPtaVPQWQ0/8=; b=fJokZSYhbSoQyN0G4E6fuWHxyy9MV8MTVQneGXTgFgMe5AL7+UWkFkPmYreQSFexEuaAVhLmMf1VAq9qpNQMWTaJDP7xOZMklORZDX1bghp8Z+15W4ER8T6lvZpSi7q4enY1izmj/8DwV5wvCj8KNkxVGrf0QSDEifuqOBTnu7xvRpjncQFR8fGWHugsK1cQ1NzHvc1KU16TrU7PF540stMnbSkBWIPrQU9GthCY0bRHJ7HQ1n4BZzcNNtPU+P8I+LEhThrcUzsmLjeFvzQJ2zVZInjxgvWBhvvDbRvK7V6N2EOgOeokMMwZYpKGxswrLdr0dK2NOCxjKyOwYzAvig== 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=ZPXMHPAIew2zmB0QuSopnSNB+C1jOYeYPtaVPQWQ0/8=; b=VMSqOTbBglq/cQmWzGpIQrLtucB99jl3XzY+Y0m3Cu8dmfJaZ/lyujgIO/d96FGGdXlHcl0Je6qk/qXaJOdIx5R8iPj3ER/DaMrSt/bBSQTVxhVmwhI9HLUcJiI73rdn6d+//YUmAU8H8FEomOrcC8LKksOYsK+/SEOXeg5zP+A1kxJAV6EHp4GFPOIk/appa3Ix53rPUIkAZSyL4NH97ngJlEjWnWskfoxogxR1g7BAILZdWksOqBzH5+uuHikaT4csM5kYwFb9qlHjZg5d7KMAE7J9PQTWjXEw2HjUn/mUHVekyhmGOrzwsyhZRXkVqtLu94x6RgG4abBs3Q685Q== 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 SJ0PR12MB5673.namprd12.prod.outlook.com (2603:10b6:a03:42b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.12; Thu, 15 Dec 2022 17:55:08 +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.019; Thu, 15 Dec 2022 17:55:07 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: dsahern@gmail.com, stephen@networkplumber.org, razor@blackwall.org, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH iproute2-next 6/6] bridge: mdb: Add replace support Date: Thu, 15 Dec 2022 19:52:30 +0200 Message-Id: <20221215175230.1907938-7-idosch@nvidia.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215175230.1907938-1-idosch@nvidia.com> References: <20221215175230.1907938-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR06CA0112.eurprd06.prod.outlook.com (2603:10a6:803:8c::41) To CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6179:EE_|SJ0PR12MB5673:EE_ X-MS-Office365-Filtering-Correlation-Id: cb09e16b-de98-433a-924e-08dadec580da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ZndbRyWQN66UzYnoZVl4lHgjr5+ARhVfnUaAOW3JacR/sMzCTOlC5HXApV68D8lR1l/sa2rLamIbVElEsR78zgz3oczIeiIvcOzdgb5NElnM7/oaQQ868LNa0UuhoF5u89RWe+1+nOJe6okLNrNiQnns9Ll6FXWwvr2+qxiapo84h0XzdF65K/zKWTX983kj0G+Od6P7TQOguraQafarXNcG7nGu8sdWPQFHAujuqCsJiS9aeKKDIq7OG1kixVlREzPBeYeAtFG3iRka0lM1iF0IthHJjbzmxh/WZKPir9e0dwfs4Q1BmxSekJ5Ck4GWT5hQVzHHQc6G8Y1aL8WjP7FuWvuOHSO7XWcB5GDXQUHO7xBO09VQLX7gCBnnNHffTsW7n+8TeIlNeQSoE6/uIYIiVs9zqqWvCVzEk+5aRz93KncQcanPl7DI1XLbWCQN+ot9b5fGCyMxHGvRTmuug/So9bi2tHz8xNCfO4AyfPCccxwa+KNJ9enUNnCgAHvuxkpmOBP9Py7JpWaECnEdp9llP1G1LBoKPXU3eG6lUJR5YK2ObRmH+Aha7MfK5+IBO/3oB8RYFxG88ipQuBscwTuyZNVX4j6LxRnjVX9tLRSmqzcc5gfaWefRQ32WKOcTwCtpdAB9xck5Pvw3P3IcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6179.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199015)(6486002)(316002)(6506007)(26005)(186003)(6512007)(38100700002)(478600001)(6916009)(107886003)(6666004)(41300700001)(1076003)(8936002)(83380400001)(5660300002)(2616005)(8676002)(66556008)(66946007)(2906002)(4326008)(36756003)(66476007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +ArxUYYbT6fnQ0X/csUA4HeUAj+cI+X51X/xtYBlUCOHq5AJyOfezjETSJi+iSqMQQ6hExrDc03Zcbp7V45lldrpSVo6Zpn+9U0VR3weJMYNpdIV05BM20kuKuyNdH/c/Tah1A1Bg7HuRV+1+aD5owYZgRMkc2YWknYIetanQFD+nOO3EcmoS7ZsUMBoQ52ubUbcfOwgaYShcomwFgFgGGD7IzIJ3W7WywODgLvPVer+mehKf8ZDaKDNGNNU2FCybGRSS+FWwt0AxYi3EKGVZkudcejYCM7RVp9EHlSR5QMffgRLi80BI7CK+v3Q+O53vHGC7gBl0w/HCdHFvtwr9bw3BysrBsXY8ZpvsNWA5dknJkdAAsM81dK/7IHZtHrQFg3m721ZL18xBsJPwjlGCctVkPozYA2vwANpKLW/zBfDr/UNVxQ4By5Y37kst8JLhnucAq109AIwYz62WLGvRyC2duS95Blwc3MNy/W172rtApPIJUU87Znzj0rx+moIQ9MiJdsMRyHSH/vbL7Mt6jhECSYI4o/XbtS5J3f4ekneVaHl2NrofXcsopOLRjvMSXZKMyZ3dqdb6JVOdTcBNtbQlLeZBfgyVA9yadD+mMFDoPiRdxWR3jTHhWdgkHqYIW5S5SJr9ImUoGRtzbCqxhanEOywyem3UMOtYfRhpp79OrA6YDV2DdrDgpo5Fsv+gSSGuPsNQZxjcxGfOCVAkOkzz8Vva9nJxsrTQcWwqbF2y8GFszyPtbL38sYmZC0roryGPvVjVg/BuZG+BnyyhsRlBKbgeDixzp5RPXGCTdk71JQwGmgz/ci9pi39H0S2j4hX/H+dvOl1VJSh20oW99XM0/xPLuZM2cwNCSrnzT362d2PM6lfNxag6Xn2mzlZ608sf++MKZMFRN7GFBIbQx1Ruun2m1CNg1DhBLS9IcS+GB8DM+uw9P3+hUQQifhnsb5O1Y7MOkZk+dlI/ET5WEQRxPfDzSFl8cpp4iZst7F3MUNy43lPesYajV2N2HrtUdS7w5i0+cSFOplZloz8KR/s5r9Ysc/EsXYGx9JUTY1z82Utowfb6ekTHzrcQmmrnFPxOy165s9S4oW+0DkQEB2SjfL4YvRt12au//1tSAuPb+GVDKx/4eyPdLCxf/8XJbhXK153JIcdhEmyz/JHX3AtbRmlijSa0RWAsb41ZgQDygfoku9LgrV3GyymMukzCOHpgWLB8HYZ3pFqKlmezHNVHeNnEZtigvrh19ggOkZ6pQhzepB2904ckuKj4PHlx87Xws41LyukJxIBoZoaHs8Bb8JHkGaRE2/QyJ37nMCRmmBrH72ONNwq3XXkm+99SsVu2iaEuUZINNjmLuDcx8JIb/dlLiQl1dESgk/hyPYdH6INw8wNGsaRo9nIYB6zApmXMzW1ZNFstuTtR6kktnbm/yAW2hhenvpEhsjMziIdkbFVlySxtQBnQT04ET6vLlwk7N5QPnB3zPdHjbFm1CQkvmOeQnbbKNtGvusMJJhOVadrEHHbFGSxKGvKxNv+9CH0ukGnxcqzNzYsUTnRr+obVEII01U1NKqBpr/MYypWHV9SxhiFN8HcDcUqcO0T X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb09e16b-de98-433a-924e-08dadec580da X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6179.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 17:55:07.9015 (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: bcp2v4YG9ZdDfT0+QmyupcfYFx/PH0XUyGE3hv9+HKsRu4bm2eZc1xk4Rfh2J3pAdtRYG1o34wKfPsPQ5aNI4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5673 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Allow user space to replace MDB port group entries by specifying the 'NLM_F_REPLACE' flag in the netlink message header. 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 Reviewed-by: Nikolay Aleksandrov --- bridge/mdb.c | 4 +++- man/man8/bridge.8 | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bridge/mdb.c b/bridge/mdb.c index 195a032c211b..f323cd091fcc 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -31,7 +31,7 @@ static unsigned int filter_index, filter_vlan; static void usage(void) { fprintf(stderr, - "Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n" + "Usage: bridge mdb { add | del | replace } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n" " [ filter_mode { include | exclude } ] [ source_list SOURCE_LIST ] [ proto PROTO ]\n" " bridge mdb {show} [ dev DEV ] [ vid VID ]\n"); exit(-1); @@ -692,6 +692,8 @@ int do_mdb(int argc, char **argv) if (argc > 0) { if (matches(*argv, "add") == 0) return mdb_modify(RTM_NEWMDB, NLM_F_CREATE|NLM_F_EXCL, argc-1, argv+1); + if (strcmp(*argv, "replace") == 0) + return mdb_modify(RTM_NEWMDB, NLM_F_CREATE|NLM_F_REPLACE, argc-1, argv+1); if (matches(*argv, "delete") == 0) return mdb_modify(RTM_DELMDB, 0, argc-1, argv+1); diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 3e6e928c895f..f73e538a3536 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -127,7 +127,7 @@ bridge \- show / manipulate bridge addresses and devices .BR [no]sticky " ] [ " [no]offloaded " ]" .ti -8 -.BR "bridge mdb" " { " add " | " del " } " +.BR "bridge mdb" " { " add " | " del " | " replace " } " .B dev .I DEV .B port @@ -898,8 +898,8 @@ if "no" is prepended then only entries without offloaded flag will be deleted. objects contain known IP or L2 multicast group addresses on a link. .P -The corresponding commands display mdb entries, add new entries, -and delete old ones. +The corresponding commands display mdb entries, add new entries, replace +entries and delete old ones. .SS bridge mdb add - add a new multicast group database entry @@ -964,6 +964,13 @@ This command removes an existing mdb entry. The arguments are the same as with .BR "bridge mdb add" . +.SS bridge mdb replace - replace a multicast group database entry +If no matching entry is found, a new one will be created instead. + +.PP +The arguments are the same as with +.BR "bridge mdb add" . + .SS bridge mdb show - list multicast group database entries This command displays the current multicast group membership table. The table