From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ecotelecom.ru (mail.ecotelecom.ru [193.105.59.24]) by dpdk.org (Postfix) with ESMTP id 77A01591A for ; Fri, 28 Aug 2015 15:08:06 +0200 (CEST) Received: from stand.localnet (unknown [10.210.0.221]) by mail.ecotelecom.ru (Postfix) with ESMTPA id 2891ED407A6 for ; Fri, 28 Aug 2015 16:08:06 +0300 (MSK) From: Sergey Balabanov To: dev@dpdk.org Date: Fri, 28 Aug 2015 16:08:05 +0300 Message-ID: <3010257.KLf28YlHHW@stand> Organization: Ecotelecom User-Agent: KMail/4.14.7 (Linux/3.19.0-25-generic; KDE/4.14.8; x86_64; ; ) In-Reply-To: <1440767187-19120-1-git-send-email-balabanovsv@ecotelecom.ru> References: <1440767187-19120-1-git-send-email-balabanovsv@ecotelecom.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] kni: set kni mac on ioctl_create X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 13:08:06 -0000 Hi, Probably I missed something in understanding why the mac is not set on kni creation. Any comments would be highly appreciated. Thanks, Sergey On Friday 28 August 2015 16:06:27 Sergey Balabanov wrote: > There is a situation when ioctl returns zero mac address (00:00:00:00:00:00) > for just created kni. The situation happens because kni mac is set on > 'ipconfig up' event (kni_net_open callback) not on kni creation > (kni_ioctl_create). > > Signed-off-by: Sergey Balabanov > --- > 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 2e9fa89..61f83a0 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include /* eth_type_trans */ > > #include > #include "kni_dev.h" > @@ -465,6 +466,15 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long > ioctl_param) 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 ab5add4..b50b4cf 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_net.c > +++ b/lib/librte_eal/linuxapp/kni/kni_net.c > @@ -70,15 +70,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));