From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by dpdk.org (Postfix) with ESMTP id E770428F2 for ; Thu, 21 Apr 2016 18:27:37 +0200 (CEST) Received: by mail-lf0-f51.google.com with SMTP id g184so63994402lfb.3 for ; Thu, 21 Apr 2016 09:27:37 -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:in-reply-to:references; bh=CfmtauLSPYZ0s+1sWmONGI3nJ7xOOTgReVkGYAmVOuA=; b=JjjvoPGIjYkH3O5WmLOsjQ3rHNeObGSdiI0dOxhh0Yee4HMOKmKAuRPCrz3C5BQoqO E9F+2OYC6RynIk1/hRjbb+75ZjRLN6kuA7KuHOGJcPS29QBeNnT3KoG6NitZmPF7ttgX Y1cV+lzf5AiEMhqbMgdDgFJV7JGzm6hq014Cm6tLVIUuzswolzWIXxdLBGa8v6zJ+6Tx iSNV+KTWqU5ixlCJA3pELhC+FoQQDP427TodCyjVsQ/T+ZzVA0rIMUiO+Wa7njsnVXPb ymGknV1IruquctGa45GRj+s6x2480PTraoOi5wOv/daVUHGfj+ccJ8W4REzgYNK0VxkI g2XQ== 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:in-reply-to :references; bh=CfmtauLSPYZ0s+1sWmONGI3nJ7xOOTgReVkGYAmVOuA=; b=Kawd41IFQuZjVe9omel3PTjiaD5k5NAr29jpVB19miuUqsSj0G27ENXa6K2ZG+Nt98 SwsCCmhl/jYmirnqzU3T41mEkZAsb+ixZmOKEN4N/nuI30mClwco3ZBUYMeUF7Izf7qQ 7MclWAzgSd/inrWj9IMbjfqDRZEAorY5S/eorDDZF1Hz+nqnuyc616k5/BQi8eMnxp4G ei9YQ1RuMnybNNjisHFwHMQ7Pd8Flr/aM+Vpg44eEDSc+3dgy9VKJ8LNmXkUprRld902 1wfupyInQQCi/CA1Tb938zZ0RUgKFRfteaVCTKgBklXFkSXCQCupwDohdYegi4cxsMC8 e/nA== X-Gm-Message-State: AOPr4FXtj7565OyuR18d2Z5JG52NeJ/pVqxoKkunCYYsZepVeV+z+pZDh93kpJApKtU5bA== X-Received: by 10.25.125.212 with SMTP id y203mr6974485lfc.91.1461256057595; Thu, 21 Apr 2016 09:27:37 -0700 (PDT) Received: from localhost.localdomain (vpn.arccn.ru. [95.182.74.2]) by smtp.gmail.com with ESMTPSA id l191sm703474lfl.19.2016.04.21.09.27.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Apr 2016 09:27:36 -0700 (PDT) From: Igor Ryzhov To: dev@dpdk.org Date: Thu, 21 Apr 2016 19:27:30 +0300 Message-Id: <1461256050-46372-1-git-send-email-iryzhov@nfware.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1461251576-46028-1-git-send-email-iryzhov@nfware.com> References: <1461251576-46028-1-git-send-email-iryzhov@nfware.com> Subject: [dpdk-dev] [PATCH v2] kni: don't reassign 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 16:27:38 -0000 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 --- v2: - change variable name from dev to net_dev - slightly rewrite commit message header and body 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..871437f 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 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