Skip to content

Commit b79d825

Browse files
drchristensenferruhy
authored andcommitted
net/tap: use MAC address parse API instead of local parser
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: [email protected] Signed-off-by: David Christensen <[email protected]> Signed-off-by: Stephen Hemminger <[email protected]> Acked-by: Ferruh Yigit <[email protected]>
1 parent 719b37d commit b79d825

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

drivers/net/tap/rte_eth_tap.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,29 +2267,6 @@ set_remote_iface(const char *key __rte_unused,
22672267
return 0;
22682268
}
22692269

2270-
static int parse_user_mac(struct rte_ether_addr *user_mac,
2271-
const char *value)
2272-
{
2273-
unsigned int index = 0;
2274-
char mac_temp[strlen(ETH_TAP_USR_MAC_FMT) + 1], *mac_byte = NULL;
2275-
2276-
if (user_mac == NULL || value == NULL)
2277-
return 0;
2278-
2279-
strlcpy(mac_temp, value, sizeof(mac_temp));
2280-
mac_byte = strtok(mac_temp, ":");
2281-
2282-
while ((mac_byte != NULL) &&
2283-
(strlen(mac_byte) <= 2) &&
2284-
(strlen(mac_byte) == strspn(mac_byte,
2285-
ETH_TAP_CMP_MAC_FMT))) {
2286-
user_mac->addr_bytes[index++] = strtoul(mac_byte, NULL, 16);
2287-
mac_byte = strtok(NULL, ":");
2288-
}
2289-
2290-
return index;
2291-
}
2292-
22932270
static int
22942271
set_mac_type(const char *key __rte_unused,
22952272
const char *value,
@@ -2311,7 +2288,7 @@ set_mac_type(const char *key __rte_unused,
23112288
goto success;
23122289
}
23132290

2314-
if (parse_user_mac(user_mac, value) != 6)
2291+
if (rte_ether_unformat_addr(value, user_mac) < 0)
23152292
goto error;
23162293
success:
23172294
TAP_LOG(DEBUG, "TAP user MAC param (%s)", value);

0 commit comments

Comments
 (0)