diff mbox series

[v2,1/2] examples/l2fwd: fix long option parsing

Message ID 20210611100357.388290-1-sunchenglian@loongson.cn (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers show
Series [v2,1/2] examples/l2fwd: fix long option parsing | expand

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

SunChengLian June 11, 2021, 10:03 a.m. UTC
For l2fwd, --no-mac-updating and --mac-updating are treated as invalid
arguments.Rework long options parsing to let --no-mac-updating and
--mac-updating options work well.

Fixes: fa19eb20d212 ("examples/l2fwd: add forwarding port mapping option")
Cc: stable@dpdk.org

Signed-off-by: SunChengLian <sunchenglian@loongson.cn>
---
 examples/l2fwd/main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

David Marchand June 17, 2021, 9:14 a.m. UTC | #1
On Fri, Jun 11, 2021 at 12:05 PM SunChengLian <sunchenglian@loongson.cn> wrote:
>
> For l2fwd, --no-mac-updating and --mac-updating are treated as invalid
> arguments.Rework long options parsing to let --no-mac-updating and
> --mac-updating options work well.
>
> Fixes: fa19eb20d212 ("examples/l2fwd: add forwarding port mapping option")
> Cc: stable@dpdk.org
>
> Signed-off-by: SunChengLian <sunchenglian@loongson.cn>

Reviewed-by: David Marchand <david.marchand@redhat.com>
diff mbox series

Patch

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index ffb67bb901..a8fa091842 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -434,13 +434,14 @@  enum {
 
 	/* first long only option value must be >= 256, so that we won't
 	 * conflict with short options */
-	CMD_LINE_OPT_MIN_NUM = 256,
+	CMD_LINE_OPT_MAC_UPDATING_NUM = 256,
+	CMD_LINE_OPT_NO_MAC_UPDATING_NUM,
 	CMD_LINE_OPT_PORTMAP_NUM,
 };
 
 static const struct option lgopts[] = {
-	{ CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1},
-	{ CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0},
+	{ CMD_LINE_OPT_MAC_UPDATING, no_argument, 0, CMD_LINE_OPT_MAC_UPDATING_NUM},
+	{ CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, 0, CMD_LINE_OPT_NO_MAC_UPDATING_NUM},
 	{ CMD_LINE_OPT_PORTMAP_CONFIG, 1, 0, CMD_LINE_OPT_PORTMAP_NUM},
 	{NULL, 0, 0, 0}
 };
@@ -502,6 +503,14 @@  l2fwd_parse_args(int argc, char **argv)
 			}
 			break;
 
+		case CMD_LINE_OPT_MAC_UPDATING_NUM:
+			mac_updating = 1;
+			break;
+
+		case CMD_LINE_OPT_NO_MAC_UPDATING_NUM:
+			mac_updating = 0;
+			break;
+
 		default:
 			l2fwd_usage(prgname);
 			return -1;