On 7/21/2019 2:42 PM, Raslan Darawsheh wrote:
> Hi Guys,
> 
> We have a failure in testpmd commands when parsing rte_flow commands as  
> following which were interduce by this patch:
> 
> This rule is a valid rule to be added to testpmd:
> flow validate 0  priority  2 ingress group 0 pattern eth dst is 
> 98:03:9B:5C:D9:00 / end actions queue index  0 / end
> 
> but, currently with latest master it will fail with Bad arguments 
> 
> the check for get_ether_addr6/3 is expecting that you reach the end of string 
> when it parse a MAC address but for rte_flow commands it's not the case,
> since we provide the full string:
> gdb) p s
> $3 = 0x28225fa "98:03:9B:5C:D9:00 / end actions queue index  0 / end\n"

Hi Raslan,

Will it work if only 'cmdline_flow.c' change reverted?

If so I suggest revert only 'cmdline_flow.c' change for rc2, and we can work on
the proper fix later.

> 
> 
> Kindest regards,
> Raslan Darawsheh
> 
>> -----Original Message-----
>> From: dev <dev-boun...@dpdk.org> On Behalf Of Stephen Hemminger
>> Sent: Monday, July 8, 2019 9:26 PM
>> To: dev@dpdk.org
>> Cc: Stephen Hemminger <step...@networkplumber.org>; Bernard
>> Iremonger <bernard.iremon...@intel.com>
>> Subject: [dpdk-dev] [PATCH v9 07/11] app/testpmd: use new ethernet
>> address parser
>>
>> The cmdline_parse_ether_addr does not need to be used everywhere in
>> testpmd. Can use rte_ether_unformat_addr instead.
>> As an added bonus it eliminates some code for copying.
>>
>> Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
>> Acked-by: Bernard Iremonger <bernard.iremon...@intel.com>
>> ---
>>  app/test-pmd/cmdline_flow.c |  5 ++---
>>  app/test-pmd/config.c       | 10 +++-------
>>  app/test-pmd/parameters.c   | 15 +++------------
>>  3 files changed, 8 insertions(+), 22 deletions(-)
>>
>> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
>> index e3e8448c9421..c92c748b18eb 100644
>> --- a/app/test-pmd/cmdline_flow.c
>> +++ b/app/test-pmd/cmdline_flow.c
>> @@ -18,7 +18,6 @@
>>  #include <rte_ethdev.h>
>>  #include <rte_byteorder.h>
>>  #include <cmdline_parse.h>
>> -#include <cmdline_parse_etheraddr.h>
>>  #include <rte_flow.h>
>>
>>  #include "testpmd.h"
>> @@ -4734,8 +4733,8 @@ parse_mac_addr(struct context *ctx, const struct
>> token *token,
>>      /* Only network endian is supported. */
>>      if (!arg->hton)
>>              goto error;
>> -    ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
>> -    if (ret < 0 || (unsigned int)ret != len)
>> +    ret = rte_ether_unformat_addr(str, &tmp);
>> +    if (ret < 0)
>>              goto error;
>>      if (!ctx->object)
>>              return len;
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>> ab458c8d2837..1d804705d96c 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -49,7 +49,6 @@
>>  #include <rte_pmd_bnxt.h>
>>  #endif
>>  #include <rte_gro.h>
>> -#include <cmdline_parse_etheraddr.h>
>>  #include <rte_config.h>
>>
>>  #include "testpmd.h"
>> @@ -2278,19 +2277,16 @@ pkt_fwd_config_display(struct fwd_config *cfg)
>> void  set_fwd_eth_peer(portid_t port_id, char *peer_addr)  {
>> -    uint8_t c, new_peer_addr[6];
>> +    struct rte_ether_addr new_peer_addr;
>>      if (!rte_eth_dev_is_valid_port(port_id)) {
>>              printf("Error: Invalid port number %i\n", port_id);
>>              return;
>>      }
>> -    if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr,
>> -                                    sizeof(new_peer_addr)) < 0) {
>> +    if (rte_ether_unformat_addr(peer_addr, &new_peer_addr) < 0) {
>>              printf("Error: Invalid ethernet address: %s\n", peer_addr);
>>              return;
>>      }
>> -    for (c = 0; c < 6; c++)
>> -            peer_eth_addrs[port_id].addr_bytes[c] =
>> -                    new_peer_addr[c];
>> +    peer_eth_addrs[port_id] = new_peer_addr;
>>  }
>>
>>  int
>> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index
>> 245b610641ee..975a97807009 100644
>> --- a/app/test-pmd/parameters.c
>> +++ b/app/test-pmd/parameters.c
>> @@ -39,10 +39,6 @@
>>  #include <rte_ether.h>
>>  #include <rte_ethdev.h>
>>  #include <rte_string_fns.h>
>> -#ifdef RTE_LIBRTE_CMDLINE
>> -#include <cmdline_parse.h>
>> -#include <cmdline_parse_etheraddr.h>
>> -#endif
>>  #ifdef RTE_LIBRTE_PMD_BOND
>>  #include <rte_eth_bond.h>
>>  #endif
>> @@ -227,8 +223,7 @@ init_peer_eth_addrs(char *config_filename)
>>              if (fgets(buf, sizeof(buf), config_file) == NULL)
>>                      break;
>>
>> -            if (cmdline_parse_etheraddr(NULL, buf,
>> &peer_eth_addrs[i],
>> -                            sizeof(peer_eth_addrs[i])) < 0) {
>> +            if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
>>                      printf("Bad MAC address format on line %d\n", i+1);
>>                      fclose(config_file);
>>                      return -1;
>> @@ -727,7 +722,6 @@ launch_args_parse(int argc, char** argv)
>>                      }
>>                      if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
>>                              char *port_end;
>> -                            uint8_t c, peer_addr[6];
>>
>>                              errno = 0;
>>                              n = strtoul(optarg, &port_end, 10); @@ -
>> 739,14 +733,11 @@ launch_args_parse(int argc, char** argv)
>>                                               "eth-peer: port %d >=
>> RTE_MAX_ETHPORTS(%d)\n",
>>                                               n, RTE_MAX_ETHPORTS);
>>
>> -                            if (cmdline_parse_etheraddr(NULL,
>> port_end,
>> -                                            &peer_addr,
>> sizeof(peer_addr)) < 0)
>> +                            if (rte_ether_unformat_addr(port_end,
>> +
>> &peer_eth_addrs[n]) < 0)
>>                                      rte_exit(EXIT_FAILURE,
>>                                               "Invalid ethernet address:
>> %s\n",
>>                                               port_end);
>> -                            for (c = 0; c < 6; c++)
>> -                                    peer_eth_addrs[n].addr_bytes[c] =
>> -                                            peer_addr[c];
>>                              nb_peer_eth_addrs++;
>>                      }
>>  #endif
>> --
>> 2.20.1
> 

Reply via email to