From: Igor Ryzhov Date: Thu, 21 Apr 2016 16:27:30 +0000 (+0300) Subject: kni: keep ethernet MAC address when interface goes up X-Git-Tag: spdx-start~6986 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=166605b1bf8d34d76466299c8d3198d87a53866d;p=dpdk.git kni: keep ethernet MAC address when interface goes up Currently every time a KNI interface goes up, its ethernet address is reassigned. After this patch ethernet address is assigned only once, at initialization time. Suggested-by: Sergey Balabanov Signed-off-by: Igor Ryzhov Acked-by: Helin Zhang --- diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index ae8133f33e..871437f8d5 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -542,6 +543,15 @@ kni_ioctl_create(struct net *net, if (pci) pci_dev_put(pci); + if (kni->lad_dev) + memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); + else + /* + * Generate random mac address. eth_random_addr() is the newer + * version of generating mac address in linux kernel. + */ + random_ether_addr(net_dev->dev_addr); + ret = register_netdev(net_dev); if (ret) { KNI_ERR("error %i registering device \"%s\"\n", diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index cfa8339865..3d2d246e25 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -69,15 +69,6 @@ kni_net_open(struct net_device *dev) struct rte_kni_request req; struct kni_dev *kni = netdev_priv(dev); - if (kni->lad_dev) - memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); - 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); memset(&req, 0, sizeof(req));