net/virtio: use new ethernet address parser
Use rte_ether_unformat_addr rather than sscanf. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
parent
b5ddce8959
commit
8eb49a1860
@ -224,17 +224,13 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
|
||||
static inline void
|
||||
parse_mac(struct virtio_user_dev *dev, const char *mac)
|
||||
{
|
||||
int i, r;
|
||||
uint32_t tmp[RTE_ETHER_ADDR_LEN];
|
||||
struct rte_ether_addr tmp;
|
||||
|
||||
if (!mac)
|
||||
return;
|
||||
|
||||
r = sscanf(mac, "%x:%x:%x:%x:%x:%x", &tmp[0],
|
||||
&tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
|
||||
if (r == RTE_ETHER_ADDR_LEN) {
|
||||
for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i)
|
||||
dev->mac_addr[i] = (uint8_t)tmp[i];
|
||||
if (rte_ether_unformat_addr(mac, &tmp) == 0) {
|
||||
memcpy(dev->mac_addr, &tmp, RTE_ETHER_ADDR_LEN);
|
||||
dev->mac_specified = 1;
|
||||
} else {
|
||||
/* ignore the wrong mac, use random mac */
|
||||
|
Loading…
Reference in New Issue
Block a user