Skip to content

Commit

Permalink
net/tap: use MAC address parse API instead of local parser
Browse files Browse the repository at this point in the history
[ upstream commit b79d825f32cb0012164b26428272b1ea268f839d ]

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

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
drchristensen authored and bluca committed Oct 18, 2023
1 parent 9a7af96 commit 818515a
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions drivers/net/tap/rte_eth_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,29 +2256,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,
Expand All @@ -2300,7 +2277,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);
Expand Down

0 comments on commit 818515a

Please sign in to comment.