summaryrefslogtreecommitdiff
path: root/lib/librte_eal
diff options
context:
space:
mode:
authorIntel <intel.com>2013-09-18 12:00:00 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-10-09 16:16:15 +0200
commit0b44a857c8b4e3ba4e2f24d5bb4cc52acbafa897 (patch)
treeae0f6c8913cf049929d01908f2a3747f6e4ca67e /lib/librte_eal
parent4583570637e26d22bb7b8c39d165e66c4ce015d9 (diff)
downloaddpdk-0b44a857c8b4e3ba4e2f24d5bb4cc52acbafa897.zip
dpdk-0b44a857c8b4e3ba4e2f24d5bb4cc52acbafa897.tar.gz
dpdk-0b44a857c8b4e3ba4e2f24d5bb4cc52acbafa897.tar.xz
kni: generate random MAC address if needed
Replace the address based on "\0KNIxy" by a random MAC. Signed-off-by: Intel
Diffstat (limited to 'lib/librte_eal')
-rw-r--r--lib/librte_eal/linuxapp/kni/kni_net.c18
1 files 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 dca004f..2e27663 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);