From patchwork Tue Aug 6 03:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142909 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5CB604571F; Tue, 6 Aug 2024 05:41:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB89040662; Tue, 6 Aug 2024 05:41:41 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012006.outbound.protection.outlook.com [52.101.66.6]) by mails.dpdk.org (Postfix) with ESMTP id AE849402A1 for ; Tue, 6 Aug 2024 05:41:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iYstJBQVQIfBJdDQrM90Zl3cnWXL0RcR2Ybnl9uE92ZetSRrwC0plt5OmGWr4srnrWe6uOx7ow8r0oirlrNMO26MuzgCMnRz3Jsk7guxV2qQ9sPV97iuUkMBtXmzpxXg3Axo5Y9RpTS8WFwTae/0OGoEr5GgDGG3EHor5GIpiJW3Mlw3SbyZUuJtzTH3fAcTjfObdImGgJ7+KTERzCgiI+JpvuPyPXfOXnRwW7kzQfVDsO8IY0HAx3zbBq8ZG1Uku1+yfee0WYs22ELkSZ8s6aztRlH7Vv/0VbnmcBIdRdxnToC/tVtx6hXVjjwrIPm/3kX37H8ADcSYROqajOe1aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l6kixch+intej4LkgXHVzf1X2jxI1uLjIvYCjq0Uq6A=; b=SwAxklEePAMQtuKaVpMa8tyG69cgKjw49x7ccJLlnIKN4b6CLX7Ftrc9DuyRhR0+mkhUxqg/7V4bwk2imhtbOokTT/zti5CLiwNobnvT1CDKmn9D+vAumd/vY5QYlfa1bQlwbFvYPdfy6yRExvV1RPf63n7g80CDdbvxNBUBHuoh+e2E4wFQc0w5jWUnOELhKfYmz1VgdzIGWTGsdlQA0dYFi34QvbagThDCoJyaZDBm7j9E+ZSU5I64xt7HqH4giUJ1fAwswSJJmy819ESEUEnoOWtgIUgTIz7yztuGwxkOl2LbL3RbQZGj3mBgBRJJz+7BRyqQSqyBavLMaEphow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l6kixch+intej4LkgXHVzf1X2jxI1uLjIvYCjq0Uq6A=; b=D8fAtihAg2a79NfDEd/TNak9OgIqgGlpWHyzgZ7TX47HaDFILzfPfCJNT3bSsEsbtM1N6+vffsiT7emFm7kNJ9mjVwhx9IPfvyyNhdEi62XojjPw74Oy8/y6uzj8DJh/Wk9LgOOVAPuLt9ytbbkUhe6bJZc024rlQOvKiVCJfl4ZXhpXh2UzR+1M9P0dymGTxTjU+L11N6BAv1Vo7l3H06jEYo9XcWdjh6Z923qzA3b9zkhRbDZ/0wCssISffPKa8sD7MR05toVqsp4Dm4atjJVMUMjiHtIc0CaUaRZVd92zzUqSAidg8Xk3D1yC7NABkVvbo0IJf05sGH/ABMTd+A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.11; Tue, 6 Aug 2024 03:41:37 +0000 Received: from PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f]) by PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f%7]) with mapi id 15.20.7828.023; Tue, 6 Aug 2024 03:41:37 +0000 From: Gagandeep Singh To: dev@dpdk.org Subject: [v2 1/3] examples/l3fwd: support single route file Date: Tue, 6 Aug 2024 09:11:18 +0530 Message-Id: <20240806034120.3165295-2-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240806034120.3165295-1-g.singh@nxp.com> References: <20240715101458.645014-1-g.singh@nxp.com> <20240806034120.3165295-1-g.singh@nxp.com> X-ClientProxiedBy: SG2PR02CA0112.apcprd02.prod.outlook.com (2603:1096:4:92::28) To PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8205:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b6e50d1-0902-427b-9200-08dcb5c9aceb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: NwhNksteTLF8rVlRTmRcvc0AZ08Bttcq8Oe8Je/WP6IP0RicJGkYUL0w1kkBBHjcm73ZwkrBFJ1u1zSMEEb1T52zyWPjq3JYZh80iBzigsipxBDfMhiIvK6+VHtHC9NNXCXhqcVJaSy6bL/j4olqgvWM+MJsrq0vLzjkyLr52NX4Xg2pq2HwzV+6qhgNSUIwPh7paTbV2RMXJb6WBksvIJ0OAcN+diXBHoI393gs9qyrRI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kysmo8yMl/VTlHQAUa4q7zlZiu694eHPEPJYqDi6c8gix5+9BYiDDfmu82hEqDFHwmSx4PsUAHEQhNS1AGF4ZYo/NYYZOxLiIhoIbbgChsZuSLVaWA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8205.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RrDLY6h5z8AS8tZDk8r/egnCbvtcQaX0nyfAVjpla5IOtiFV1hZqTsR7AjJXnJuWw6tTIFL/UyRFxf6C7crn95//0BYmujCqYuvsfRJ61U+1xu5vfcVUrl2PaClU2fNf2Luf+dtP3z7k0M+XZMURtT24VUGfbjzDS4T1DL//z2cyrAHmXDucLnHnez+EigQ55jWKylnrZvGSzI5E++Pmj893wo15cdRpo/pr7ak4bItoxkaL+N+qnLwCq7obm/IkfMXbTL4GLJV/JY9qIWL9HJpC64aLokcZdmMOuQkWGwD2n/BCOU2BLpSdaIiUhJN1w0aYJStqessxRoWPJj8VdifUKKwksZxTPziTzaZ5avdI2DQJzyOeI3lC2iM7Tq+DjdLHIOwjkkiIDasSsuJ1bGFtFSL3FSuc7W/HdFv9vP8VD1lRyPJmTe775vr/L9D1ON1ZVW9LmoNSkxs8+k+wgSiR4QatpOTrcL3K7o2zwSlWFggcIY0IjpRW+0hQh/Fc2qXPPYn1XicOaUE7MA4lHCAS/QsDd572tbdXc8xFlOqup3EdBz5TOl6s82Dz0UzwJA7xQhxm3Oxhp4yHALnfaKLRzJbr1FzyskQRExXwJq9s1IYPMDRnoXQT/Zy+fj64lGKV5mAOxRorsWXTPDE6WKECXSxZV/UqE2AHjoLMjPwBUKlxYfbmAlTXNfahLntUEtEK0wtk/d/0OeUAcxgguPQzlh4miA6WV1A6xJkgE1q0kFHnpxfRPH6l8xDG4zw2iOx6AlpTqmD1pG+U6Oh8pCnndDdh84Kq5tgxoBCNkWddNKeV6rvLQU0IPwQBQwfMKfQ67ugIzeNHXE4+PwYB4iADeKgH9qPI6AL06olhsHCi3jkWgXKReps7/4ysTsvJXAfST3SNSvUgFBWlAuzpHRNfd3emIurnZbX4bB/v9rXv43ku1UxdOpf07pgzgw2Olpeon0EwFYvGxIYX79cFFauF0uWO5m2TqFY4PjpbYs7oQCR3Zov1Z3LJEG2Ch4jb48I62+zjVttutCNwpdAejofaojQ5Amqzw/0J16DggAcqJy9p/f5fN5Jfp6IQ4VnsoHDgg9kSAMaoo/Vhckh2cxaxrhrbt2hT6UGRaRWkKRklNYq+a9q056TBBt/NnCyEA5YE9HSZjAOJ4nkhFBzpiuij3cIkTlHGkpRY15JjAlo2bgdnsn7a61P82AhDMl3vHk6a48Y6310iIeafsNGx2ncwkRW5GeLdUkbCU1pvxGMPuM54Zeu/3f/uDuR4D9RHT9+qnQYiCklWfCbWWeJLhSlMvDBm9HdE1gXvcc+HLO7ZP25SZmwc7td3h11CO3cktPBHGTwjbKX1FFR+rCQ0LC3vkcOgANO/fcZtm9ib22Akvrtd3Ea70/1Ie89vcYqdIe2xJzqeKfIOfW7UlFONGeQiMKfB6ytLWSgeHRyuesr8FgelUaTky5jm185xK/TLR/ehXHgTm1aJO44xddFht0mZJ09dJ2KhbtBx2FVFn4OzcbDQKeAn9RS2AG3bEmpiPr5xU9qZPB4lkeJE13J2TaQ/XW6WIq/hQZqfeLzleag= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b6e50d1-0902-427b-9200-08dcb5c9aceb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8205.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 03:41:37.5615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i968K7hoVKfV4F/znJOTvjNwx9qskiibtjXPFuj1linSScghRN0LFn+918ZTRh5u X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org IPv6 rules file needs to be specified together with IPv4 rules file to configure user given rules. But if user want to give only IPv4 or only IPv6 rules, application returns error: "Missing 1 or more rule files" With this patch application can accept only IPv4, only IPv6 or both IP rules. Signed-off-by: Gagandeep Singh --- examples/l3fwd/em_route_parse.c | 18 ++++++++++-------- examples/l3fwd/lpm_route_parse.c | 17 ++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/examples/l3fwd/em_route_parse.c b/examples/l3fwd/em_route_parse.c index 6c16832e94..da23356dd6 100644 --- a/examples/l3fwd/em_route_parse.c +++ b/examples/l3fwd/em_route_parse.c @@ -249,8 +249,7 @@ void read_config_files_em(void) { /* ipv4 check */ - if (parm_config.rule_ipv4_name != NULL && - parm_config.rule_ipv6_name != NULL) { + if (parm_config.rule_ipv4_name != NULL) { /* ipv4 check */ route_num_v4 = em_add_rules(parm_config.rule_ipv4_name, &em_route_base_v4, &em_parse_v4_rule); @@ -258,7 +257,14 @@ read_config_files_em(void) em_free_routes(); rte_exit(EXIT_FAILURE, "Failed to add EM IPv4 rules\n"); } - + } else { + RTE_LOG(INFO, L3FWD, "Missing IPv4 rule file, using default instead\n"); + if (em_add_default_v4_rules() < 0) { + em_free_routes(); + rte_exit(EXIT_FAILURE, "Failed to add default IPv4 rules\n"); + } + } + if (parm_config.rule_ipv6_name != NULL) { /* ipv6 check */ route_num_v6 = em_add_rules(parm_config.rule_ipv6_name, &em_route_base_v6, &em_parse_v6_rule); @@ -267,11 +273,7 @@ read_config_files_em(void) rte_exit(EXIT_FAILURE, "Failed to add EM IPv6 rules\n"); } } else { - RTE_LOG(INFO, L3FWD, "Missing 1 or more rule files, using default instead\n"); - if (em_add_default_v4_rules() < 0) { - em_free_routes(); - rte_exit(EXIT_FAILURE, "Failed to add default IPv4 rules\n"); - } + RTE_LOG(INFO, L3FWD, "Missing IPv6 rule file, using default instead\n"); if (em_add_default_v6_rules() < 0) { em_free_routes(); rte_exit(EXIT_FAILURE, "Failed to add default IPv6 rules\n"); diff --git a/examples/l3fwd/lpm_route_parse.c b/examples/l3fwd/lpm_route_parse.c index f2028d79e1..f7d44aa2cd 100644 --- a/examples/l3fwd/lpm_route_parse.c +++ b/examples/l3fwd/lpm_route_parse.c @@ -271,8 +271,7 @@ lpm_free_routes(void) void read_config_files_lpm(void) { - if (parm_config.rule_ipv4_name != NULL && - parm_config.rule_ipv6_name != NULL) { + if (parm_config.rule_ipv4_name != NULL) { /* ipv4 check */ route_num_v4 = lpm_add_rules(parm_config.rule_ipv4_name, &route_base_v4, &lpm_parse_v4_rule); @@ -280,7 +279,15 @@ read_config_files_lpm(void) lpm_free_routes(); rte_exit(EXIT_FAILURE, "Failed to add IPv4 rules\n"); } + } else { + RTE_LOG(INFO, L3FWD, "Missing IPv4 rule file, using default instead\n"); + if (lpm_add_default_v4_rules() < 0) { + lpm_free_routes(); + rte_exit(EXIT_FAILURE, "Failed to add default IPv4 rules\n"); + } + } + if (parm_config.rule_ipv6_name != NULL) { /* ipv6 check */ route_num_v6 = lpm_add_rules(parm_config.rule_ipv6_name, &route_base_v6, &lpm_parse_v6_rule); @@ -289,11 +296,7 @@ read_config_files_lpm(void) rte_exit(EXIT_FAILURE, "Failed to add IPv6 rules\n"); } } else { - RTE_LOG(INFO, L3FWD, "Missing 1 or more rule files, using default instead\n"); - if (lpm_add_default_v4_rules() < 0) { - lpm_free_routes(); - rte_exit(EXIT_FAILURE, "Failed to add default IPv4 rules\n"); - } + RTE_LOG(INFO, L3FWD, "Missing IPv6 rule file, using default instead\n"); if (lpm_add_default_v6_rules() < 0) { lpm_free_routes(); rte_exit(EXIT_FAILURE, "Failed to add default IPv6 rules\n"); From patchwork Tue Aug 6 03:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142910 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 419894571F; Tue, 6 Aug 2024 05:41:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 311504068A; Tue, 6 Aug 2024 05:41:52 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013039.outbound.protection.outlook.com [52.101.67.39]) by mails.dpdk.org (Postfix) with ESMTP id 2B09A4067C; Tue, 6 Aug 2024 05:41:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Er+7zkjWIMSCPXr1sUXpK8VOzJoAoIQqD0cEI6uceaV0H/hK/TpOKTZxGcsE+ntkCaSDMaRrRIAEsa8pb6SbusZznog1tt0BSCo8j3cWd7XZkbuohIL/VmhPzTdwo2uOfxHzl5kxO7FtrFgwv/mL4XcOAntqqyhw1Rs8wPjS45GPzGxeF7P5c7FfzGacspWVvrRQp6NwVOe41kofK5Yo0AeBJlFFWSyuvC23Lm+gJCmcFo6jIdyu1XY4xI+tmAIaBPPO1xy/7WoeqhcPd8WISQ1Iby9N9klBCul/xlZOS03tWJ8oAj2oHL8sMwuolKOe5dvy3UrBc4corJqAFuBwgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/Ctw0pXUC4WbVo/F/HsbyCmjgmGQ45OOMboAysNyuHw=; b=W8JFRHJZspN2aD39DwSmRacONGMFgoi9TOu9k/FTc7Wg1nBiOhxilTNDJLhaQyu0QOjJnMqxxzbxQZ5pOiMqb3Wbde8hXQKk5v1dTwjeJkRWUCoMo7/uVZRA/OOJ7sy9sbGJHTBTfawVZHGmpmOSNiEvNwOmTw1Y9/R4K0FWM7T6DExKrgHA6sbLrFr7kYrGUnUIGWkly4vEiPkJ3lisRWHFcwa7XaAR3lmtiC7piDv5gBkAn9REQcRxl4/+zboVwJWyFSBVAAEMukd9KitFxc4aZo5hc9g+WPm2gmmgAeh/oneQ4YKgr0w3qm1LgidOwYSdf8gykvzws4R9WWqCew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Ctw0pXUC4WbVo/F/HsbyCmjgmGQ45OOMboAysNyuHw=; b=lVcgDG4bVonMjsPwe7Ok/VEcKw4nYtzPI9GV9C3aWxSoIQbrcHwD9Yxu7sjH0k2CB8bKmouA9qHBzy3R6zfxcR6uZ5jUtXmPH7eAgHOfNiCFlxhnbg+lzU0s474b6nLaGAg3bF7uuSMnbfqwpiz1CJo2bhmrwGTtv7DLeWUAc1KJ/FioDr7MBFN6aKdNTnxZjVY8p8ln5dDqfLnZw34NMEv/t4c3WsuHzBC/YmjLD0rt9N4f9L6ep3vQv5F3uZLXb21mE45AhxHHr2BZKcKVuZa0PVZS2i26o/41rNwDIrXMdCc4KyJ8sfdFbaJZLPYPeM54L+a0NGWJLIz5MP3eYg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.11; Tue, 6 Aug 2024 03:41:49 +0000 Received: from PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f]) by PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f%7]) with mapi id 15.20.7828.023; Tue, 6 Aug 2024 03:41:49 +0000 From: Gagandeep Singh To: dev@dpdk.org, Sean Morrissey Cc: stable@dpdk.org Subject: [v2 2/3] examples/l3fwd: fix return value on rules add Date: Tue, 6 Aug 2024 09:11:19 +0530 Message-Id: <20240806034120.3165295-3-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240806034120.3165295-1-g.singh@nxp.com> References: <20240715101458.645014-1-g.singh@nxp.com> <20240806034120.3165295-1-g.singh@nxp.com> X-ClientProxiedBy: SG2PR02CA0112.apcprd02.prod.outlook.com (2603:1096:4:92::28) To PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8205:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d70324c-8e02-458b-1db0-08dcb5c9b42a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: XhQFfzAsDFt2KRhZMfeDicEPdO3fPr/8CPGlJT1r3QgMqzt4ZMIQsVD1p8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R8KCQxdpD2ahg9WJAKgGGKzewnwoiACUokrpmXkHBHGA6PrEsqbZ8y5P+L6WE7h5/gKPy5FElG8xTerFv78pT/v5oWlIz1B9t8jjN2oQFuHSnwBVcFqIElutlgn0rkOSP9ToLe3aHc5o1pN5LM9zqlJHEPIbLcmarbKG88hhFsMr1qi4k5xBjTfde+OGmS00RJGsKFvxvJrJV+r8sRwrshNlEWsOSMG/s92/lXCSKWPb10QiZgzxltJSVj4B7OubIoMNJtHJJaSilgo9fbctq67fS8jKlJgS1Mq2P86HVHGMKBx2qL2ZG9g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8205.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z4dEgRyyNlv5u6HPzurcl1oHvLA3HT6Roeu4x65j5pxalfEdorC+4ANkCdISbptGCSx13U7Gf/d4lgKw65y0q7HAx8vV9UFnu1Z5dwZiXWMO9npdk1Qa3E3zI5RN7RJCC3ic/hhXcSU7OoBVvX0uC0Lxdjd86Ta8PJozf8Tue1dM+SCUD16Bw89T+fAiLfiMe3XWlj97t9/11qr7mzKVa+TD+MHBT6y0TUHp+xCJsRmmJbX7H7MRT07jhe83nCLd7UhUnwpDtD+yz4mP+KsC5Mt0KDejWveuEjhEo/mzse6WyPbMc8a1s+xhK0jn/H9Laa4Rz2vMon0qDFc/t7B8+EPuKSVbL58gsJHwnPfxxgGV2MaxEDdhKY0W/2z4eSXWAFKaMlyiBrvY3F/b5tIqzW1U6Kc17KeIc3D4pqKwP9nwNjaUfpmSvB2fpEa/N/ak87xMODSDAOu76ti2mwDeDzzSTweMsDSyeO0a2VhjhZNdirZCk4uFca/mKuOF+G66izKTI1UoA6+pgmnDSneQR7PunJkug7FyB2MRbgmcG3LtBIqmZWO4Od+KDcmTibFXq9W0p3qYUSwatdedWUMtp7P/bVhdXbce0Zxjo+P3qY9AyfNawU/6eH3ks5f3qHZ/WCfruCSjZcYI4+brTQkaymWxEchxaFTWIprvn9A6F/aLARQTacC9Ks8+JjXU48rWEdivMacCKUwW4aib2d0mDeQA13KKD+ySPdVK5irqLns3NX67SsV1DLJYjtonwiGzN2kQjcMZgv36pOesBm5ocyWArgi2VAuRHASih/+jZqIj+amiyg0EzV8oM6ZmNyKEvOrketRhEeNb3pswgDrbocmxxF25912RQMX9l4J7ViyQsme2WV3fKYi0QKPk2FyzIpO50Q1xFAeyJz7x+Kf2kl664uI+WqP9cX2GrBPRMXU9nezNdtOFeV6NuO1PA6BgQJ1+Ylokc9GESjnYPBOcFwjEJ9nV+qzld8henKx+GcRz8XLhozPysDvdP1ahNF5DzooXEVlq1d8D31ArQU0hnYJekCj+15BjyJ4F8E/vra2uLIPbHjVGlpnVISqVxqKALmn/1P4X4WTnC+9MXZ22BC+XDiiCrJog+UWfpuOpWbdPSzMOvJNTzt772hxI1Va8HbNf/ZReMnY++/qEIPQUKAlmWxB2Bj2AmupDpxjy7DZ06BveuFlrc1RRIlVo9vbCqS0qTuwyd/MRvem/P170GSNMtMdUQZvBhWdowJTvy5AK6W0c0+O8EUp+R1JZ3Mc3n08jzIehQBFUr4YW5ftULyPl11lTMZd1dveZVfjdRvFi84US+5XDW3hz2Bl7eITjw3GosbR6dLBmHVVSvJbZtISc99Y8YmxQp6xrFi3iHa4SvwtiCXu33HubJTl+qz/CnKf7xGFX/CEwCCL6fxxOuTRRFscXXSvjlD0On6IkcRExswln/0oKo1TkQfZEU2MqAY/ALyA/rnGl5K3qQxa5os91jlsf/9/kkuX/bkNF3Vpbwtcs9YSRmydxEVR2sg6B8BRsiMf2fU3LYePqBj9RRQxD45DSpf8MsekW9ZIxJno= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d70324c-8e02-458b-1db0-08dcb5c9b42a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8205.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 03:41:49.7785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZdMuA9lgPr0kCPUm2SQNhC/y/DbWeYNFi/E0FM194/XRZXzyISQdfgWYgL2/SrHn X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org fix return value on adding the EM or LPM rules. Fixes: e7e6dd643092 ("examples/l3fwd: support config file for EM") Fixes: 52def963fc1c ("examples/l3fwd: support config file for LPM/FIB") Cc: sean.morrissey@intel.com Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- examples/l3fwd/em_route_parse.c | 11 ++++++----- examples/l3fwd/lpm_route_parse.c | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/l3fwd/em_route_parse.c b/examples/l3fwd/em_route_parse.c index da23356dd6..8b534de5f1 100644 --- a/examples/l3fwd/em_route_parse.c +++ b/examples/l3fwd/em_route_parse.c @@ -119,7 +119,7 @@ em_add_rules(const char *rule_path, char buff[LINE_MAX]; FILE *fh; unsigned int i = 0, rule_size = sizeof(*next); - int val; + int val, rc; *proute_base = NULL; fh = fopen(rule_path, "rb"); @@ -172,13 +172,14 @@ em_add_rules(const char *rule_path, return -EINVAL; } - if (parser(buff + 1, next) != 0) { + rc = parser(buff + 1, next); + if (rc != 0) { RTE_LOG(ERR, L3FWD, - "%s Line %u: parse rules error\n", - rule_path, i); + "%s Line %u: parse rules error code = %d\n", + rule_path, i, rc); fclose(fh); free(route_rules); - return -EINVAL; + return rc; } route_cnt++; diff --git a/examples/l3fwd/lpm_route_parse.c b/examples/l3fwd/lpm_route_parse.c index f7d44aa2cd..f27b66e838 100644 --- a/examples/l3fwd/lpm_route_parse.c +++ b/examples/l3fwd/lpm_route_parse.c @@ -184,7 +184,7 @@ lpm_add_rules(const char *rule_path, char buff[LINE_MAX]; FILE *fh; unsigned int i = 0, rule_size = sizeof(*next); - int val; + int val, rc; *proute_base = NULL; fh = fopen(rule_path, "rb"); @@ -237,13 +237,14 @@ lpm_add_rules(const char *rule_path, return -EINVAL; } - if (parser(buff + 1, next) != 0) { + rc = parser(buff + 1, next); + if (rc != 0) { RTE_LOG(ERR, L3FWD, - "%s Line %u: parse rules error\n", - rule_path, i); + "%s Line %u: parse rules error code = %d\n", + rule_path, i, rc); fclose(fh); free(route_rules); - return -EINVAL; + return rc; } route_cnt++; From patchwork Tue Aug 6 03:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142911 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A0B84571F; Tue, 6 Aug 2024 05:42:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C0DE406BB; Tue, 6 Aug 2024 05:41:54 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013060.outbound.protection.outlook.com [52.101.67.60]) by mails.dpdk.org (Postfix) with ESMTP id A896A40684 for ; Tue, 6 Aug 2024 05:41:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ltb6wMKfvkh60FwA9UYKODkIjNfVccb1VkOfmd37xVoQuN5skFX/d5uMBji+wSaiiA+u2E/iRY/ckjzdB1UvCYUIsSbdX5VT2DAjWbOREp4WuyVE5RxSeaVdS60XirYq4bHdlzNt/a+U7hox3phqXuYksHWG18r7hENYikEzjuSxQVYbwdwh03ug9QB1807W/z6iInckqYvzRPzV9TqHRBJnPNYLR7k9pEp6rvVp5+W48RSG7DmU2iLbXJAwQibZlASvyvdrYvQ+J5D1AO6AhzOoX1GfLzpG2b+92TIjzxwTR59CQHLX73DxCAP3vRz1bfrT0xsz12Fcq9ppBaZvNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eLnhXVHwUNPYKsUl0kLunP0Mg1f2sUykW51PKqe2zuM=; b=odD8tb2y7bE5M8J3HEzGDcQ93NNl/t3NyUIwmmA+nIPnc1EHn5trRNzd9rueSMvkgzSSC0s+qxe7UiKXNamrNd1B8cwSqfA+2NcsoJOkRonEHwBPJBnFD2JoYc8o2McEryeGGzu0N7zTLf7JhQffxCIvRi1iySmEie1UAZxkJblEP7uS5IfA320lAbguKOFWvxUljrxj6t3sVswxIiB+0QrvUjhi54aG8d87caZM/R8W5bl/YJcl9m559u6PLkSakuZlyq8wazwILXv9wzD0emzYUBGZy5jxacXNRe56Whnlg+oBN5cDokYS5tiKwG7fghlPzNxcc0ECzfPghn4urQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eLnhXVHwUNPYKsUl0kLunP0Mg1f2sUykW51PKqe2zuM=; b=W3BB09SpdyJBD+K+zxtNCxZ2aUTme4gktCM5s4EyUq87vEmPkVSLN5jXGXCVSoYXdH6F7VV1tmnCwIER3yGqRZZvjBowbtTR+hUIxW3sCTeazykRLTisC4Z0UITSIhMqpfubT27GIxl8zS6xbl4xraI9wmNr5/gD4Y73PB+9YQwWVETHI/eu0weXG5f60u9YSBKp6khYGQVX8PXshJdikDfvXqNf4iPfS+wUd53eigMP8G92ts9MsIwEhPXibikoimVL7eVN+Rhyv5Dx2z0ytBgFQUn2TdX+I9CCxyyxuB/cuiLxdw4A09Ybkc+AXwKBh/bKSJwcAOPPbxWNYMp/zw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.11; Tue, 6 Aug 2024 03:41:51 +0000 Received: from PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f]) by PAXPR04MB8205.eurprd04.prod.outlook.com ([fe80::7633:884d:5973:174f%7]) with mapi id 15.20.7828.023; Tue, 6 Aug 2024 03:41:51 +0000 From: Gagandeep Singh To: dev@dpdk.org Subject: [v2 3/3] examples/l3fwd: enhance valid ports checking Date: Tue, 6 Aug 2024 09:11:20 +0530 Message-Id: <20240806034120.3165295-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240806034120.3165295-1-g.singh@nxp.com> References: <20240715101458.645014-1-g.singh@nxp.com> <20240806034120.3165295-1-g.singh@nxp.com> X-ClientProxiedBy: SG2PR02CA0112.apcprd02.prod.outlook.com (2603:1096:4:92::28) To PAXPR04MB8205.eurprd04.prod.outlook.com (2603:10a6:102:1c2::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8205:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: ff8d2a34-6e2b-4004-40b8-08dcb5c9b4ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: T13h8mOcVxF3XwB8AFgYtNrPaA5FEzFEkqHTQqKuSfTuanmfX3ACIp95l2oad2DMNmIfc/KIARyPgQXXQVkd5/Z2zvq/iseX5UB+o8NYt5enaHke/fXEAjgWQlJmvXzfi/8x+Vrz1KJppOyqrtT8Jw5t8aW4wmBRaK4ctE3NeVJ2i1u83RkDgKFVa3Qd86prNMFK1O9TJ4N+j//dXZuSO+TnEz470QKMCY3G1Sjvg6SqbKDQKSTquBF/kRQ6p5rpnmM3+F8BuflZ/0lcwbKrdDXOF/R3ngOIDSGRwyonz51gxnqf7Pb0Aqr1RBHNZUcC/XDr/k7QTGoZ7ERLUOdJYdU7WSvmSlJfcsUa1/mIjdpr4m0pIVcwnNA4h6daq60xRK5PzKtZeRuj7iAdupXKOs60bLGw6FMwhZbNIFaOvSFdgELj5+24GDhPLV5VFBwBebTai6Ee/Ri3y4qlXIQlwv4zSahcpF1L0YBnpa3eMDquG8ytBpsZQyArPI1sonTKtPShiQ401xrk5+0DVp6ZGdv9WyVB3dQvkBYpG8htQhmnIhcUwDZrdw7EjXFkZ6Rfgvy1NSRooXwIXOPwB+t7s16njMiIm/5a87NK2FK7zPvJQhZqyS/7LPIGZwKU2YnlR7iCOA23fwSKvK+CcGy7ttOkgLQChN2kvnUXQV6dJh+0R4oIFA24rj1+saTf+KqcnPPTSuzcVbKO9dChNa8doeUCwHw4U0XqDEiGCqiQEr2YLCVLWGmxKUdnK+d5OWxC6LNBHpaK/C5yzdpDl74+eGkOPFHANwmo5567UbLp42fXBKPdnesptILYkCVPODUko93apC/OtKWOPjh9Bf6shf8xp5QyzE4S7iJys3gqOMvFY8QwAYI1WIIDTPT+r7GhTV7ikxf0itxNb+GOfPhwFfd6G+8nx4cjVc5vWdclGcVpHeB4OjgWI+BJFt3maqkkVH6WVKre3/S6uoMAWmAejqdTcWeRi53Vl8d2gGBhZf0opopBJlRv8XbRBaNmGqaPGt5hYsWj+ouD0j+TZDBnub306DT/PKRrx1PEnI8dR+pikusTwLi4vUUdZ5tbhlSqDIKHRnpR15qjm0quGo75/rI08j8ojpT18WAviNDgLcojkmlcD+FJbLqT9y6VrXF8XEZSQVCa93e+D6lG+MatbR/Hu4k1QrIxfjHE+H/tyqeca4ucTB/BKh8LWBOOB0B+MME3qBMmnPvLxkfAnYbdc1jCmgk3LoS6oBPAmHmnzzEleKKk0dyx5pcuPk13KyweAFdPKSbIGecz0WdIs++lTWy3/oKtowmRNAPNFrIsSKTZK2ImKKUIgEtp6ybnoLyW+ovR6KFIrajMMCWJJJDQZIgtBWpoLUGiwp1ygxmJ3mtMjEb8I3U0JLmnC6hoF4fvBfJvoGZynw1SZA2IcaD2lQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8205.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FhUu4w1hmsKR3l2Y0f1R7g2jv0C3xmo5dmIWBteI41POP5V0Dtm+Nhj/pSRo9V7yIv/uqRvOndBdoY4ED4boWwomKHDIEaT4ol3MbLhSrSuBQJxSH1b8DWvoqdBKpmaRpnRV/r7gg17WgtRm8Zl3dwv4ZMEI3ar7tPVYDj4zeVL39iyMFIUGUsW1xF+zWzthxyqsk6y3Vq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ax45XF8AeBoGXi7Z9GCcf1g5wpxyyDmihZRABQ5aq8YpairIt2RBuqR8IaYUI6MgIBw/AgOGAIRgFQTisLRnY60/KGrmqGAFdqMAw70fEq8FVwyVz0hJGBifY6ixQNA1ycpmVNRYu0aD9VLc547BrWzQX4aXq8bzfijEcvxYv7mbMpBrdryoXNC2tyxUTe08DoPDe6XrxLE8fE3TZOIlF8i+f0zC+z9ANiKTt84ITZS0BLEL769Viuc/lsm5YNiCRjWNqbOeSVWHIpvxHuFwrZ8tOmxlxx9Kn6roUDbTCb1Wmsu1o= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff8d2a34-6e2b-4004-40b8-08dcb5c9b4ff X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8205.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 03:41:51.2715 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7BsAZLENYyJPxNN++OS33qN1vkufLq6IWERH7+9S6BMsYnV6fK2pMs+Dofg1l40O X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The current port ID validation logic in the routes add code has two issues: - It can pass if port ID in route is 31+. - It silently skips rules with disabled or invalid port IDs This patch is: - Improving the enabled port IDs check logic. - Introducing a user option, "exit_on_failure", to control the behavior when attempting to add rules for disabled or invalid port IDs (either exit or skip) - Creating a port ID validation function for use across various setup functions Signed-off-by: Gagandeep Singh --- examples/l3fwd/em_route_parse.c | 4 +-- examples/l3fwd/l3fwd.h | 16 +++++++++ examples/l3fwd/l3fwd_em.c | 22 ++++++++---- examples/l3fwd/l3fwd_fib.c | 26 +++++++++----- examples/l3fwd/l3fwd_lpm.c | 26 +++++++++----- examples/l3fwd/l3fwd_route.h | 2 ++ examples/l3fwd/main.c | 60 +++++++++++++++++++++++++++------ 7 files changed, 122 insertions(+), 34 deletions(-) diff --git a/examples/l3fwd/em_route_parse.c b/examples/l3fwd/em_route_parse.c index 8b534de5f1..b80442d7b8 100644 --- a/examples/l3fwd/em_route_parse.c +++ b/examples/l3fwd/em_route_parse.c @@ -10,8 +10,8 @@ #include "l3fwd.h" #include "l3fwd_route.h" -static struct em_rule *em_route_base_v4; -static struct em_rule *em_route_base_v6; +struct em_rule *em_route_base_v4; +struct em_rule *em_route_base_v6; enum { CB_FLD_DST_ADDR, diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index 93ce652d02..d6510448a5 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -56,6 +56,15 @@ #define L3FWD_HASH_ENTRIES (1024*1024*1) #endif +/* Select Longest-Prefix, Exact match, Forwarding Information Base or Access Control. */ +enum L3FWD_LOOKUP_MODE { + L3FWD_LOOKUP_DEFAULT, + L3FWD_LOOKUP_LPM, + L3FWD_LOOKUP_EM, + L3FWD_LOOKUP_FIB, + L3FWD_LOOKUP_ACL +}; + struct parm_cfg { const char *rule_ipv4_name; const char *rule_ipv6_name; @@ -101,6 +110,9 @@ extern struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; /* mask of enabled ports */ extern uint32_t enabled_port_mask; +/* Skip or exit on invalid route */ +extern bool exit_on_failure; + /* Used only in exact match mode. */ extern int ipv6; /**< ipv6 is false by default. */ extern uint32_t hash_entry_number; @@ -218,6 +230,10 @@ init_mem(uint16_t portid, unsigned int nb_mbuf); int config_port_max_pkt_len(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev_info); +int +l3fwd_validate_routes_port(enum L3FWD_LOOKUP_MODE mode, uint32_t i, + bool is_ipv4); + /* Function pointers for ACL, LPM, EM or FIB functionality. */ void setup_acl(const int socketid); diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index 31a7e05e39..1a1b48635b 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -384,9 +384,14 @@ populate_ipv4_flow_into_table(const struct rte_hash *h) struct in_addr src; struct in_addr dst; - if ((1 << em_route_base_v4[i].if_out & - enabled_port_mask) == 0) - continue; + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_EM, i, true); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX: %d: Port ID %d in IPv4 rule is not" + " enabled\n", i, em_route_base_v4[i].if_out); + else + continue; + } entry = &em_route_base_v4[i]; convert_ipv4_5tuple(&(entry->v4_key), &newkey); @@ -436,9 +441,14 @@ populate_ipv6_flow_into_table(const struct rte_hash *h) struct em_rule *entry; union ipv6_5tuple_host newkey; - if ((1 << em_route_base_v6[i].if_out & - enabled_port_mask) == 0) - continue; + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_EM, i, false); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX %d: Port ID %d given in IPv6 rule is not" + " enabled\n", i, em_route_base_v6[i].if_out); + else + continue; + } entry = &em_route_base_v6[i]; convert_ipv6_5tuple(&(entry->v6_key), &newkey); diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c index f38b19af3f..9e987e2031 100644 --- a/examples/l3fwd/l3fwd_fib.c +++ b/examples/l3fwd/l3fwd_fib.c @@ -670,10 +670,15 @@ setup_fib(const int socketid) for (i = 0; i < route_num_v4; i++) { struct in_addr in; - /* Skip unused ports. */ - if ((1 << route_base_v4[i].if_out & - enabled_port_mask) == 0) - continue; + /* Check for valid ports */ + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_FIB, i, true); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX %d: Port ID %d in IPv4 rule is not" + " enabled\n", i, route_base_v4[i].if_out); + else + continue; + } rte_eth_dev_info_get(route_base_v4[i].if_out, &dev_info); @@ -724,10 +729,15 @@ setup_fib(const int socketid) /* Populate the fib IPv6 table. */ for (i = 0; i < route_num_v6; i++) { - /* Skip unused ports. */ - if ((1 << route_base_v6[i].if_out & - enabled_port_mask) == 0) - continue; + /* Check for valid ports. */ + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_FIB, i, false); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX %d: Port ID %d given in IPv6 rule is not" + " enabled\n", i, route_base_v6[i].if_out); + else + continue; + } rte_eth_dev_info_get(route_base_v6[i].if_out, &dev_info); diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index e8fd95aae9..3193e60dc7 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -583,10 +583,15 @@ setup_lpm(const int socketid) for (i = 0; i < route_num_v4; i++) { struct in_addr in; - /* skip unused ports */ - if ((1 << route_base_v4[i].if_out & - enabled_port_mask) == 0) - continue; + /* Check for valid ports */ + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_LPM, i, true); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX: %d: Port ID %d in IPv4 rule is not" + " enabled\n", i, route_base_v4[i].if_out); + else + continue; + } rte_eth_dev_info_get(route_base_v4[i].if_out, &dev_info); @@ -627,10 +632,15 @@ setup_lpm(const int socketid) /* populate the LPM table */ for (i = 0; i < route_num_v6; i++) { - /* skip unused ports */ - if ((1 << route_base_v6[i].if_out & - enabled_port_mask) == 0) - continue; + /* Check for valid ports */ + ret = l3fwd_validate_routes_port(L3FWD_LOOKUP_LPM, i, false); + if (ret) { + if (exit_on_failure) + rte_exit(EXIT_FAILURE, "IDX %d Port ID %d given in IPv6 rule is not" + " enabled\n", i, route_base_v6[i].if_out); + else + continue; + } rte_eth_dev_info_get(route_base_v6[i].if_out, &dev_info); diff --git a/examples/l3fwd/l3fwd_route.h b/examples/l3fwd/l3fwd_route.h index 467c4d2859..681d10c6d3 100644 --- a/examples/l3fwd/l3fwd_route.h +++ b/examples/l3fwd/l3fwd_route.h @@ -82,6 +82,8 @@ struct em_rule { extern struct lpm_route_rule *route_base_v4; extern struct lpm_route_rule *route_base_v6; +extern struct em_rule *em_route_base_v4; +extern struct em_rule *em_route_base_v6; extern int route_num_v4; extern int route_num_v6; diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 01b763e5ba..3cfe21da90 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -59,14 +59,6 @@ uint16_t nb_txd = TX_DESC_DEFAULT; /**< Ports set in promiscuous mode off by default. */ static int promiscuous_on; -/* Select Longest-Prefix, Exact match, Forwarding Information Base or Access Control. */ -enum L3FWD_LOOKUP_MODE { - L3FWD_LOOKUP_DEFAULT, - L3FWD_LOOKUP_LPM, - L3FWD_LOOKUP_EM, - L3FWD_LOOKUP_FIB, - L3FWD_LOOKUP_ACL -}; static enum L3FWD_LOOKUP_MODE lookup_mode; /* Global variables. */ @@ -88,7 +80,8 @@ xmm_t val_eth[RTE_MAX_ETHPORTS]; /* mask of enabled ports */ uint32_t enabled_port_mask; - +bool exit_on_failure; /**< Skip the route rule with invalid or */ + /**< disabled port ID */ /* Used only in exact match mode. */ int ipv6; /**< ipv6 is false by default. */ @@ -267,6 +260,43 @@ l3fwd_set_alg(const char *optarg) parm_config.alg = parse_acl_alg(optarg); } +/* This function will work only after read_config_files step */ +int +l3fwd_validate_routes_port(enum L3FWD_LOOKUP_MODE mode, uint32_t i, + bool is_ipv4) +{ + uint32_t max_port_count = (sizeof(enabled_port_mask) * CHAR_BIT); + + if (mode == L3FWD_LOOKUP_LPM || + mode == L3FWD_LOOKUP_FIB) { + if (is_ipv4) { + if (route_base_v4[i].if_out >= max_port_count || + ((1 << route_base_v4[i].if_out & + enabled_port_mask) == 0)) + return -1; + } else { + if (route_base_v6[i].if_out >= max_port_count || + ((1 << route_base_v6[i].if_out & + enabled_port_mask) == 0)) + return -1; + } + } else if (mode == L3FWD_LOOKUP_EM) { + if (is_ipv4) { + if (em_route_base_v4[i].if_out >= max_port_count || + ((1 << em_route_base_v4[i].if_out & + enabled_port_mask) == 0)) + return -1; + } else { + if (em_route_base_v6[i].if_out >= max_port_count || + ((1 << em_route_base_v6[i].if_out & + enabled_port_mask) == 0)) + return -1; + } + } + + return 0; +} + /* * Setup lookup methods for forwarding. * Currently exact-match, longest-prefix-match and forwarding information @@ -402,6 +432,7 @@ print_usage(const char *prgname) " [--parse-ptype]" " [--per-port-pool]" " [--mode]" + " [--exit-on-failure]" #ifdef RTE_LIB_EVENTDEV " [--eventq-sched]" " [--event-vector [--event-vector-size SIZE] [--event-vector-tmo NS]]" @@ -428,6 +459,8 @@ print_usage(const char *prgname) " --per-port-pool: Use separate buffer pool per port\n" " --mode: Packet transfer mode for I/O, poll or eventdev\n" " Default mode = poll\n" + " --exit-on-failure: Exit on invalid/disabled port ID given in route rule\n" + " Default action is skip the rule\n" #ifdef RTE_LIB_EVENTDEV " --eventq-sched: Event queue synchronization method\n" " ordered, atomic or parallel.\n" @@ -689,6 +722,7 @@ static const char short_options[] = #define CMD_LINE_OPT_RELAX_RX_OFFLOAD "relax-rx-offload" #define CMD_LINE_OPT_PER_PORT_POOL "per-port-pool" #define CMD_LINE_OPT_MODE "mode" +#define CMD_LINE_OPT_EXIT_ON_FAILURE "exit-on-failure" #define CMD_LINE_OPT_EVENTQ_SYNC "eventq-sched" #define CMD_LINE_OPT_EVENT_ETH_RX_QUEUES "event-eth-rxqs" #define CMD_LINE_OPT_LOOKUP "lookup" @@ -726,7 +760,8 @@ enum { CMD_LINE_OPT_LOOKUP_NUM, CMD_LINE_OPT_ENABLE_VECTOR_NUM, CMD_LINE_OPT_VECTOR_SIZE_NUM, - CMD_LINE_OPT_VECTOR_TMO_NS_NUM + CMD_LINE_OPT_VECTOR_TMO_NS_NUM, + CMD_LINE_OPT_EXIT_ON_FAILURE_NUM }; static const struct option lgopts[] = { @@ -743,6 +778,7 @@ static const struct option lgopts[] = { {CMD_LINE_OPT_DISABLE_RSS, 0, 0, CMD_LINE_OPT_DISABLE_RSS_NUM}, {CMD_LINE_OPT_PER_PORT_POOL, 0, 0, CMD_LINE_OPT_PARSE_PER_PORT_POOL}, {CMD_LINE_OPT_MODE, 1, 0, CMD_LINE_OPT_MODE_NUM}, + {CMD_LINE_OPT_EXIT_ON_FAILURE, 0, 0, CMD_LINE_OPT_EXIT_ON_FAILURE_NUM}, {CMD_LINE_OPT_EVENTQ_SYNC, 1, 0, CMD_LINE_OPT_EVENTQ_SYNC_NUM}, {CMD_LINE_OPT_EVENT_ETH_RX_QUEUES, 1, 0, CMD_LINE_OPT_EVENT_ETH_RX_QUEUES_NUM}, @@ -885,6 +921,10 @@ parse_args(int argc, char **argv) parse_mode(optarg); break; + case CMD_LINE_OPT_EXIT_ON_FAILURE_NUM: + exit_on_failure = true; + break; + #ifdef RTE_LIB_EVENTDEV case CMD_LINE_OPT_EVENTQ_SYNC_NUM: parse_eventq_sched(optarg);