From 0b44a857c8b4e3ba4e2f24d5bb4cc52acbafa897 Mon Sep 17 00:00:00 2001 From: Intel Date: Wed, 18 Sep 2013 12:00:00 +0200 Subject: [PATCH] kni: generate random MAC address if needed Replace the address based on "\0KNIxy" by a random MAC. Signed-off-by: Intel --- lib/librte_eal/linuxapp/kni/kni_net.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index dca004f588..2e27663cae 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -131,20 +131,14 @@ kni_net_open(struct net_device *dev) struct rte_kni_request req; struct kni_dev *kni = netdev_priv(dev); - KNI_DBG("kni_net_open %d\n", kni->port_id); - - /* - * Assign the hardware address of the board: use "\0KNIx", where - * x is KNI index. The first byte is '\0' to avoid being a multicast - * address (the first byte of multicast addrs is odd). - */ - if (kni->lad_dev) memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); - else { - memcpy(dev->dev_addr, "\0KNI0", ETH_ALEN); - dev->dev_addr[ETH_ALEN-1] += kni->port_id; /* \0KNI1 */ - } + else + /* + * Generate random mac address. eth_random_addr() is the newer + * version of generating mac address in linux kernel. + */ + random_ether_addr(dev->dev_addr); netif_start_queue(dev); -- 2.20.1