[PATCH v2 0/3] rte_ether_unformat_addr changes
Stephen Hemminger
stephen at networkplumber.org
Tue Oct 3 18:34:41 CEST 2023
On Tue, 3 Oct 2023 11:44:16 +0100
Ferruh Yigit <ferruh.yigit at amd.com> wrote:
> On 10/2/2023 7:37 PM, Stephen Hemminger wrote:
> > This patchset makes rte_ether_unformat_addr allow other formats
> > for MAC address. Need to remove some inputs from existing
> > cmdline_etheraddr test, and add a new test in test suite
> > to cover this. There is some overlap between the two tests
> > but that is fine.
> >
> > Stephen Hemminger (3):
> > test: remove some strings from cmdline_etheraddr tests
> > rte_ether_unformat: accept more inputs
> > test: add tests for rte_ether routines
> >
>
> Thanks Stephen,
>
> This enables using the API as replacement to the tap PMD's local parse
> implementation:
> https://patchwork.dpdk.org/project/dpdk/patch/20230323170145.129901-1-drc@linux.vnet.ibm.com/
It can be simplified to just this.
No need to check value == NULL, already checkd.
No need to check for user_mac == NULL, since only called one place and that place
passes pointer to stack variable.
From b478a17f13a1bedadca3b60608c585f31c9ad8f2 Mon Sep 17 00:00:00 2001
From: David Christensen <drc at linux.vnet.ibm.com>
Date: Thu, 23 Mar 2023 13:01:45 -0400
Subject: [PATCH] net/tap: resolve stringop-overflow with gcc 12 on ppc64le
Building DPDK with gcc 12 on a ppc64le system generates a
stringop-overflow warning. Replace the local MAC address
validation function parse_user_mac() with a call to
rte_ether_unformat_addr() instead.
Bugzilla ID: 1197
Cc: stable at dpdk.org
Signed-off-by: David Christensen <drc at linux.vnet.ibm.com>
---
drivers/net/tap/rte_eth_tap.c | 25 +------------------------
1 file changed, 1 insertion(+), 24 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..b25a52655fa2 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -2267,29 +2267,6 @@ set_remote_iface(const char *key __rte_unused,
return 0;
}
-static int parse_user_mac(struct rte_ether_addr *user_mac,
- const char *value)
-{
- unsigned int index = 0;
- char mac_temp[strlen(ETH_TAP_USR_MAC_FMT) + 1], *mac_byte = NULL;
-
- if (user_mac == NULL || value == NULL)
- return 0;
-
- strlcpy(mac_temp, value, sizeof(mac_temp));
- mac_byte = strtok(mac_temp, ":");
-
- while ((mac_byte != NULL) &&
- (strlen(mac_byte) <= 2) &&
- (strlen(mac_byte) == strspn(mac_byte,
- ETH_TAP_CMP_MAC_FMT))) {
- user_mac->addr_bytes[index++] = strtoul(mac_byte, NULL, 16);
- mac_byte = strtok(NULL, ":");
- }
-
- return index;
-}
-
static int
set_mac_type(const char *key __rte_unused,
const char *value,
@@ -2311,7 +2288,7 @@ set_mac_type(const char *key __rte_unused,
goto success;
}
- if (parse_user_mac(user_mac, value) != 6)
+ if (rte_ether_unformat_addr(value, user_mac) < 0)
goto error;
success:
TAP_LOG(DEBUG, "TAP user MAC param (%s)", value);
--
2.39.2
More information about the dev
mailing list