Skip to content

Commit

Permalink
examples/l2fwd: fix [no-]mac-updating options
Browse files Browse the repository at this point in the history
[ upstream commit bbbe38a ]

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: fa19eb2 ("examples/l2fwd: add forwarding port mapping option")

Signed-off-by: Chenglian Sun <sunchenglian@loongson.cn>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
Chenglian Sun authored and bluca committed Jul 12, 2021
1 parent 60c3dfd commit a3519aa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions examples/l2fwd/main.c
Expand Up @@ -434,13 +434,16 @@ 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}
};
Expand Down Expand Up @@ -502,6 +505,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;
Expand Down

0 comments on commit a3519aa

Please sign in to comment.