From nobody Thu Sep 18 01:16:19 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FE57C4167B for ; Tue, 13 Dec 2022 08:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234657AbiLMIVR (ORCPT ); Tue, 13 Dec 2022 03:21:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233635AbiLMIVP (ORCPT ); Tue, 13 Dec 2022 03:21:15 -0500 X-Greylist: delayed 1923 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 13 Dec 2022 00:21:12 PST Received: from m126.mail.126.com (m126.mail.126.com [220.181.12.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A50910070; Tue, 13 Dec 2022 00:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=5ip81 +wNz5xtBTBVts1Fb1RLCzaC6pg2EyPJm4Juic8=; b=Vfd8zv4SXPKww+w/McsNX 5Xe8D4dghgGyhdEz0O8lP9FbjAdufk42luNx6/r3tJ5l4H6Sw+lewSFHZthIbMPe Q/FAmvPEXAHfoLF+knQ9+Yz9Qqs5yuvI2a8WCU/USvbjg+NCHeho25XqiE6iUAxf j9QRdg0UlHj3yBaixrAFwk= Received: from localhost.localdomain (unknown [223.104.64.131]) by zwqz-smtp-mta-g0-1 (Coremail) with SMTP id _____wDXNYROLphj12MGAA--.16034S2; Tue, 13 Dec 2022 15:48:31 +0800 (CST) From: Lixue Liang To: anthony.l.nguyen@intel.com, kuba@kernel.org, linux-kernel@vger.kernel.org Cc: jesse.brandeburg@intel.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, lianglixue@greatwall.com.cn, kernel test robot Subject: [PATCH v7] igb: Assign random MAC address instead of fail in case of invalid one Date: Tue, 13 Dec 2022 07:47:26 +0000 Message-Id: <20221213074726.51756-1-lianglixuehao@126.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDXNYROLphj12MGAA--.16034S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw1ruFWxAr17Ar43tF4xJFb_yoW5uF4Upa y0gF43Wryktr47Zw4kWw4xZF95W3WDJ3yfGa9xZw1F9FnIv34DArW8K343Jry0qrZYkayx Jr17ZFZ7ua1qva7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UmZXwUUUUU= X-Originating-IP: [223.104.64.131] X-CM-SenderInfo: xold0w5ol03vxkdrqiyswou0bp/xtbBGgnWFl-HaR-tlAAAsE Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Lixue Liang Add the module parameter "allow_invalid_mac_address" to control the behavior. When set to true, a random MAC address is assigned, and the driver can be loaded, allowing the user to correct the invalid MAC address. Signed-off-by: Lixue Liang Reported-by: kernel test robot Suggested-by Suggested-by Paul Suggested-by Tony Suggested-by Tony Nguyen --- Changelog: * v7: - To group each parameter together Suggested-by Tony Nguyen * v6: - Modify commit messages and naming of module parameters - [PATCH v6] link: https://lore.kernel.org/netdev/20220610023922.74892-1-lianglixuehao@126= .com/ Suggested-by Paul * v5: - Through the setting of module parameters, it is allowed to complete the loading of the igb network card driver with an invalid MAC address. - [PATCH v5] link: https://lore.kernel.org/netdev/20220609083904.91778-1-lianglixuehao@126= .com/ Suggested-by * v4: - Change the igb_mian in the title to igb - Fix dev_err message: replace "already assigned random MAC address" with "Invalid MAC address. Assigned random MAC address" - [PATCH v4] link: https://lore.kernel.org/netdev/20220601150428.33945-1-lianglixuehao@126= .com/ Suggested-by Tony * v3: - Add space after comma in commit message - Correct spelling of MAC address - [PATCH v3] link: https://lore.kernel.org/netdev/20220530105834.97175-1-lianglixuehao@126= .com/ Suggested-by Paul * v2: - Change memcpy to ether_addr_copy - Change dev_info to dev_err - Fix the description of the commit message - Change eth_random_addr to eth_hw_addr_random - [PATCH v2] link: https://lore.kernel.org/netdev/20220512093918.86084-1-lianglixue@greatw= all.com.cn/ Reported-by: kernel test robot drivers/net/ethernet/intel/igb/igb_main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethern= et/intel/igb/igb_main.c index f8e32833226c..8ff0c698383c 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -241,6 +241,10 @@ static int debug =3D -1; module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=3Dnone,...,16=3Dall)"); =20 +static bool allow_invalid_mac_address; +module_param(allow_invalid_mac_address, bool, 0); +MODULE_PARM_DESC(allow_invalid_mac_address, "Allow NIC driver to be loaded= with invalid MAC address"); + struct igb_reg_info { u32 ofs; char *name; @@ -3358,9 +3362,16 @@ static int igb_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) eth_hw_addr_set(netdev, hw->mac.addr); =20 if (!is_valid_ether_addr(netdev->dev_addr)) { - dev_err(&pdev->dev, "Invalid MAC Address\n"); - err =3D -EIO; - goto err_eeprom; + if (!allow_invalid_mac_address) { + dev_err(&pdev->dev, "Invalid MAC address\n"); + err =3D -EIO; + goto err_eeprom; + } else { + eth_hw_addr_random(netdev); + ether_addr_copy(hw->mac.addr, netdev->dev_addr); + dev_err(&pdev->dev, + "Invalid MAC address. Assigned random MAC address\n"); + } } =20 igb_set_default_mac_filter(adapter); --=20 2.27.0