DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org
Subject: [v2 1/3] examples/l3fwd: support single route file
Date: Tue,  6 Aug 2024 09:11:18 +0530	[thread overview]
Message-ID: <20240806034120.3165295-2-g.singh@nxp.com> (raw)
In-Reply-To: <20240806034120.3165295-1-g.singh@nxp.com>

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 <g.singh@nxp.com>
---
 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");
-- 
2.25.1


  reply	other threads:[~2024-08-06  3:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 10:14 [PATCH " Gagandeep Singh
2024-07-15 10:14 ` [PATCH 2/3] examples/l3fwd: fix return value on rules add Gagandeep Singh
2024-07-16  6:55   ` Hemant Agrawal
2024-07-15 10:14 ` [PATCH 3/3] examples/l3fwd: fix maximum acceptable port ID in routes Gagandeep Singh
2024-07-17 10:17   ` Konstantin Ananyev
2024-07-18  6:30     ` Gagandeep Singh
2024-07-18 10:01       ` Konstantin Ananyev
2024-07-22  3:28         ` Gagandeep Singh
2024-07-22  4:27           ` Gagandeep Singh
2024-07-23 16:22             ` Konstantin Ananyev
2024-07-24  8:02               ` Konstantin Ananyev
2024-08-02 10:13                 ` Gagandeep Singh
2024-08-06  3:41 ` [v2 0/3] L3fwd changes Gagandeep Singh
2024-08-06  3:41   ` Gagandeep Singh [this message]
2024-08-06  3:41   ` [v2 2/3] examples/l3fwd: fix return value on rules add Gagandeep Singh
2024-08-06  3:41   ` [v2 3/3] examples/l3fwd: enhance valid ports checking Gagandeep Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806034120.3165295-2-g.singh@nxp.com \
    --to=g.singh@nxp.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).