From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id EB8422C18 for ; Thu, 21 Apr 2016 17:13:03 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id j11so62625726lfb.1 for ; Thu, 21 Apr 2016 08:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=FSKRB/1Ug5x3l8sN3Y7sbeTVsLzbeYW+YY3Seq1Ttbw=; b=QKjDRTDTQ2wUFqj396jRsvStnon+FXRz7zRHs19UVb5To74ExNdUbOJvLcAkkN/ZXO b/HL2z/UJ+jpnoDZyQq5j2cnJ64BtpoJMD3FAM0/aYzWcbICiI4lHXSa+ohhIlLdPWiH fctBRQGCNBjbPkEhoFu9IPAzVPpEisutra+trLDC5PxHjNUEl8E7chR0Vn/9a1xcJGTZ NLdDSrg7NdmJGtEZrlbJGX8cLmCr8weaxBt/peuZ8vfEbs64gnSiMQq9zKAfTRPSIbQY y6mGJeRLdg7L8/hGSgXdJvFJUnJqMAx0icR0kQdDmhags9jKxScsGOAKU/OzvUCbrKxQ r0LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=FSKRB/1Ug5x3l8sN3Y7sbeTVsLzbeYW+YY3Seq1Ttbw=; b=DR1JJnTpvJ2ChrZvibk3vLgBGh0BGGUj+7F2gHw6RzmLrkp+gd3R4UX1WKNuYvQlSu OO1uQY/4114BZCBehWpeYNGN2V6NtQOEWlGBNx7O0fGmu6i1QHFP1/tW4GZc4vfqE7aa h1Qt4F2Lrmh44ehINGqYVkeRbCFJCv+h/cWZQDlpkbgdJsb42KaoNf7orqB7KYyiQXIh aAULeCx86VZIKIwrwrVfj/l0j9Pcb/8NFgqKycmOX47Sbn6P8EWfCx04jKVR814SqhE3 ySN2kEKG50gzrqzB9UdC3LuYyoyYfDbWEbsdLTwSgOHGitVf6bo1oOa34wo6r+wVmiC2 6Muw== X-Gm-Message-State: AOPr4FUJEMmkW7Nvbs8+eLGDLnd7RThDQE70nCZK7KkND4VsfgkMH3j3oEGFCrtHZ8A3JQ== X-Received: by 10.25.15.36 with SMTP id e36mr3457730lfi.148.1461251583601; Thu, 21 Apr 2016 08:13:03 -0700 (PDT) Received: from localhost.localdomain (vpn.arccn.ru. [95.182.74.2]) by smtp.gmail.com with ESMTPSA id bd5sm626293lbc.12.2016.04.21.08.13.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Apr 2016 08:13:03 -0700 (PDT) From: Igor Ryzhov To: dev@dpdk.org Date: Thu, 21 Apr 2016 18:12:56 +0300 Message-Id: <1461251576-46028-1-git-send-email-iryzhov@nfware.com> X-Mailer: git-send-email 2.6.4 Subject: [dpdk-dev] [PATCH] kni: don't rewrite ethernet address every time an interface goes up 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: Thu, 21 Apr 2016 15:13:04 -0000 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 Signed-off-by: Igor Ryzhov --- 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 #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(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