Patchwork [net-next,14/14] igbvf: be sane about random MAC addresses

login
register
mail settings
Submitter Jeff Kirsher
Date Jan. 28, 2013, 9:04 a.m.
Message ID <1359363869-32391-15-git-send-email-jeffrey.t.kirsher@intel.com>
Download mbox | patch
Permalink /patch/216136/
State Accepted
Delegated to: David Miller
Headers show

Comments

Jeff Kirsher - Jan. 28, 2013, 9:04 a.m.
From: Mitch A Williams <mitch.a.williams@intel.com>

Tighten up some of the code surrounding MAC addresses. Since the PF is
now giving all zeros instead of a random address, check for this case
and generate a random address. This ensures that we always know when we
have a random address and udev won't get upset about it.

Additionally, tighten up some of the log messages and clean up the
formatting.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Stefan Assmann <sassmann@kpanic.de>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igbvf/netdev.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
Stefan Assmann - Jan. 28, 2013, 11:11 a.m.
On 28.01.2013 10:04, Jeff Kirsher wrote:
> From: Mitch A Williams <mitch.a.williams@intel.com>
> 
> Tighten up some of the code surrounding MAC addresses. Since the PF is
> now giving all zeros instead of a random address, check for this case
> and generate a random address. This ensures that we always know when we
> have a random address and udev won't get upset about it.
> 
> Additionally, tighten up some of the log messages and clean up the
> formatting.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> CC: Stefan Assmann <sassmann@kpanic.de>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Tested-by: Stefan Assmann <sassmann@redhat.com>

Thanks Mitch. This solves the problem of correctly setting
addr_assign_type.

  Stefan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 8f66d45..8224889 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -2735,26 +2735,22 @@  static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	err = hw->mac.ops.reset_hw(hw);
 	if (err) {
 		dev_info(&pdev->dev,
-			 "PF still in reset state, assigning new address."
-			 " Is the PF interface up?\n");
-		eth_hw_addr_random(netdev);
-		memcpy(adapter->hw.mac.addr, netdev->dev_addr,
-			netdev->addr_len);
+			 "PF still in reset state. Is the PF interface up?\n");
 	} else {
 		err = hw->mac.ops.read_mac_addr(hw);
-		if (err) {
-			dev_err(&pdev->dev, "Error reading MAC address\n");
-			goto err_hw_init;
-		}
+		if (err)
+			dev_info(&pdev->dev, "Error reading MAC address.\n");
+		else if (is_zero_ether_addr(adapter->hw.mac.addr))
+			dev_info(&pdev->dev, "MAC address not assigned by administrator.\n");
 		memcpy(netdev->dev_addr, adapter->hw.mac.addr,
-			netdev->addr_len);
+		       netdev->addr_len);
 	}
 
 	if (!is_valid_ether_addr(netdev->dev_addr)) {
-		dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",
-		        netdev->dev_addr);
-		err = -EIO;
-		goto err_hw_init;
+		dev_info(&pdev->dev, "Assigning random MAC address.\n");
+		eth_hw_addr_random(netdev);
+		memcpy(adapter->hw.mac.addr, netdev->dev_addr,
+			netdev->addr_len);
 	}
 
 	setup_timer(&adapter->watchdog_timer, &igbvf_watchdog,