Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05C28C433F5 for ; Sat, 20 Nov 2021 15:54:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC9E482A68; Sat, 20 Nov 2021 16:54:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id A39E582B68; Sat, 20 Nov 2021 16:54:06 +0100 (CET) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 46689812BB for ; Sat, 20 Nov 2021 16:54:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tom.rini@gmail.com Received: by mail-qk1-f173.google.com with SMTP id bk22so13384294qkb.6 for ; Sat, 20 Nov 2021 07:54:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s/TAPtnfOQk+/XGSlHmD+BVJ0C+59Yuge1FIYhuDOQo=; b=g2PH0Kcy+2cczDypgXdAYhklSFwbrce5txyMdaNO5/zt5CYNhXMocL/9c43DLdPjzJ +E8KuXnyaXbpztMVeaH1lIkST5U45lZdwGaiMfery5N78+lT6MvoVPOpOHOpqB7B5r6K ib2T5QCILsQjsOQVN3SdXeNzrocHLff3Ol6toWqu5btEuciwnYGQGeo7HArmuqueQD7R tal+8v1dgN1Ow5deAum5J95QvVoB65kst56VT3T8K5+uFz+mV4DrZd21gncQyYif+1Be Sl+NDGoD42U2iInSlhhzQv53bGpxZzH467EyuHuGchv3wl3C4cjBAHcjRDKLKyvXGTg1 Kpfw== X-Gm-Message-State: AOAM532wuwk+bbop5M3JX+tkdyd+pokbfC2d3TziV9NcDbqPp4B4+Z8w Ec0Jy6pdQH0l0eG/GlWWjfFvIn24Qg== X-Google-Smtp-Source: ABdhPJwdbOUF3GIYN5OtZRu1DyxgyRV70cvljxYH2W3Z0nsBkznIVKMT4gjMwFZ2HtopxczpHJbd9w== X-Received: by 2002:a05:620a:68a:: with SMTP id f10mr37209829qkh.356.1637423642040; Sat, 20 Nov 2021 07:54:02 -0800 (PST) Received: from oliver.lan (2603-6081-7b01-cbda-f112-e5a1-e0eb-5fad.res6.spectrum.com. [2603:6081:7b01:cbda:f112:e5a1:e0eb:5fad]) by smtp.gmail.com with ESMTPSA id k85sm1515698qke.134.2021.11.20.07.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Nov 2021 07:54:01 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Cc: Michal Simek , Ramon Fried Subject: [PATCHv2] net: uclass: Save ethernet MAC address when generated Date: Sat, 20 Nov 2021 10:53:58 -0500 Message-Id: <20211120155358.376540-1-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Michal Simek When MAC address is randomly generated it should be also saved to variables. This step is there when MAC address is passed via pdata but not when it is randomly generated. Signed-off-by: Michal Simek Reviewed-by: Ramon Fried [trini: Update Kconfig, handle legacy networking case as well] Signed-off-by: Tom Rini --- Changes in v2: - Update Kconfig help text to reflect this change. - Update the legacy path to match. --- net/Kconfig | 6 +++--- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/net/Kconfig b/net/Kconfig index 7a2d14501881..20a36156a01f 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -28,9 +28,9 @@ config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + even when the ethaddr variable for that interface is unset by + generating a new MAC address in the locally administered address + space and setting the appropriate environment variable. config NETCONSOLE bool "NetConsole support" diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 0da0e85be031..58c308f33276 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev) net_random_ethaddr(pdata->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", dev->name, dev_seq(dev), pdata->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); #else printf("\nError: %s address not set.\n", dev->name); diff --git a/net/eth_legacy.c b/net/eth_legacy.c index f383ccce0b92..e7f53b958b2e 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, net_random_ethaddr(dev->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", dev->name, eth_number, dev->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); #else printf("\nError: %s address not set.\n", dev->name); -- 2.25.1