[dpdk-stable] [PATCH] examples/l2fwd: fix l2fwd long options parse issue

David Marchand david.marchand at redhat.com
Fri Jun 11 09:01:23 CEST 2021


On Thu, Jun 10, 2021 at 3:02 AM SunChengLian <sunchenglian at loongson.cn> wrote:
>
> Readd other long options case in l2fwd_parse_args function
> to ensure all long options will work well.

Please, be more explicit about the thing you want to fix.

I understand --no-mac-updating is broken.
You want to fix this long option.
Is this correct?


The Fixes: should follow the common format.
I recommend setting this alias in your config so that you only need to
call "git fixline $sha1":
$ git config alias.fixline "log -1 --abbrev=12 --format='Fixes: %h
(\"%s\")%nCc: %ae'"

So here, it should be:
Fixes: fa19eb20d212 ("examples/l2fwd: add forwarding port mapping option")


And I recommend aligning this example with others.
Iow do something like:

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 32d405e65a..06cf8e1f14 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -433,13 +433,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}
 };
@@ -492,6 +493,14 @@ l2fwd_parse_args(int argc, char **argv)
                        break;

                /* long options */
+               case CMD_LINE_OPT_MAC_UPDATING_NUM:
+                       mac_updating = 1;
+                       break;
+
+               case CMD_LINE_OPT_NO_MAC_UPDATING_NUM:
+                       mac_updating = 0;
+                       break;
+
                case CMD_LINE_OPT_PORTMAP_NUM:
                        ret = l2fwd_parse_port_pair_config(optarg);
                        if (ret) {


In a followup patch, the "mac-updating" option can be removed since
the associated mac_updating variable is set to 1 by default.


-- 
David Marchand



More information about the stable mailing list