DPDK patches and discussions
 help / color / mirror / Atom feed
From: Igor Ryzhov <iryzhov@nfware.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] kni: don't rewrite ethernet address every time an interface goes up
Date: Thu, 21 Apr 2016 18:12:56 +0300	[thread overview]
Message-ID: <1461251576-46028-1-git-send-email-iryzhov@nfware.com> (raw)

Now every time a KNI interface goes up, its ethernet address is overwritten.
After this patch ethernet address is assigned only once, at initialization
time.

Suggested-by: Sergey Balabanov <balabanovsv@ecotelecom.ru>
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 10 ++++++++++
 lib/librte_eal/linuxapp/kni/kni_net.c  |  9 ---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index ae8133f..45bcf32 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/miscdevice.h>
 #include <linux/netdevice.h>
+#include <linux/etherdevice.h>
 #include <linux/pci.h>
 #include <linux/kthread.h>
 #include <linux/rwsem.h>
@@ -542,6 +543,15 @@ kni_ioctl_create(struct net *net,
 	if (pci)
 		pci_dev_put(pci);
 
+	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);
+
 	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 cfa8339..3d2d246 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));
-- 
2.6.4

             reply	other threads:[~2016-04-21 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 15:12 Igor Ryzhov [this message]
2016-04-21 16:15 ` Igor Ryzhov
2016-04-21 16:27 ` [dpdk-dev] [PATCH v2] kni: don't reassign " Igor Ryzhov
2016-04-22  6:27   ` Zhang, Helin
2016-04-29 13:50     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461251576-46028-1-git-send-email-iryzhov@nfware.com \
    --to=iryzhov@nfware.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).