2012-02-17 15:43:54

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 00/10] Part 4: handle addr_assign_type for random addresses

The fourth part of my patch series to fix the handling of
addr_assign_type for random MAC addresses.

This most of the patches in this series are for slightly
more complex cases to handle addr_assign_type and the
reset to NET_ADDR_PERM as soon as the MAC get changed via
.ndo_set_mac_address where eth_mac_addr wasn't used.

Danny Kukawka (10):
au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()
lantiq_etop: set addr_assign_type if random_ether_addr() used
davinci_emac: use eth_hw_addr_random() instead of random_ether_addr()
xilinx ll_temac: use eth_hw_addr_random() instead of
random_ether_addr()
igbvf: reset netdevice addr_assign_type if changed
batman-adv: use eth_hw_addr_random() instead of random_ether_addr()
cisco/enic: use eth_hw_addr_random() instead of random_ether_addr()
ethoc: set addr_assign_type if random_ether_addr() used
atheros eth: set addr_assign_type if random_ether_addr() used
UML net: set addr_assign_type if random_ether_addr() used

arch/um/drivers/net_kern.c | 11 ++++++++---
drivers/net/ethernet/amd/au1000_eth.c | 9 +++++----
drivers/net/ethernet/atheros/atl1c/atl1c_hw.c | 2 +-
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 9 ++++-----
drivers/net/ethernet/atheros/atlx/atl1.c | 12 +++++++++---
drivers/net/ethernet/atheros/atlx/atlx.c | 1 +
drivers/net/ethernet/cisco/enic/enic_main.c | 14 ++++++++++++--
drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++--
drivers/net/ethernet/intel/igbvf/netdev.c | 1 +
drivers/net/ethernet/lantiq_etop.c | 7 +++++++
drivers/net/ethernet/ti/davinci_emac.c | 5 +++--
drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +++-
net/batman-adv/soft-interface.c | 5 ++---
13 files changed, 74 insertions(+), 26 deletions(-)

--
1.7.8.3


2012-02-17 15:43:55

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 08/10] ethoc: set addr_assign_type if random_ether_addr() used

Set addr_assign_type correctly to NET_ADDR_RANDOM in case
a random MAC address was generated and assigned to the netdevice.

Fixed ethoc_set_mac_address() to check if the given mac
address is valid and set also dev_addr of the net_device.
Check also the return value of ethoc_set_mac_address() in
ethoc_probe().

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: set net_device->dev_addr in ethoc_set_mac_address(),
check if given address is valid

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 60f0e78..cfc0ce0 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -776,10 +776,16 @@ static int ethoc_set_mac_address(struct net_device *dev, void *addr)
struct ethoc *priv = netdev_priv(dev);
u8 *mac = (u8 *)addr;

+ if(!is_valid_ether_addr(mac))
+ return -EADDRNOTAVAIL;
+
ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) |
(mac[4] << 8) | (mac[5] << 0));
ethoc_write(priv, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0));

+ memcpy(dev->dev_addr, mac, ETH_ALEN);
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;
+
return 0;
}

@@ -909,6 +915,7 @@ static int __devinit ethoc_probe(struct platform_device *pdev)
unsigned int phy;
int num_bd;
int ret = 0;
+ bool random_mac = false;

/* allocate networking device */
netdev = alloc_etherdev(sizeof(struct ethoc));
@@ -1050,10 +1057,19 @@ static int __devinit ethoc_probe(struct platform_device *pdev)

/* Check the MAC again for validity, if it still isn't choose and
* program a random one. */
- if (!is_valid_ether_addr(netdev->dev_addr))
+ if (!is_valid_ether_addr(netdev->dev_addr)) {
random_ether_addr(netdev->dev_addr);
+ random_mac = true;
+ }

- ethoc_set_mac_address(netdev, netdev->dev_addr);
+ ret = ethoc_set_mac_address(netdev, netdev->dev_addr);
+ if (ret) {
+ dev_err(&netdev->dev, "failed to set MAC address\n");
+ goto error;
+ }
+
+ if (random_mac)
+ netdev->addr_assign_type |= NET_ADDR_RANDOM;

/* register MII bus */
priv->mdio = mdiobus_alloc();
--
1.7.8.3

2012-02-17 15:43:53

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 04/10] xilinx ll_temac: use eth_hw_addr_random() instead of random_ether_addr()

Use eth_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: reworked to prevent using an extra variable

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index f21addb..c1f72e8 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -327,7 +327,9 @@ static int temac_set_mac_address(struct net_device *ndev, void *address)
memcpy(ndev->dev_addr, address, ETH_ALEN);

if (!is_valid_ether_addr(ndev->dev_addr))
- random_ether_addr(ndev->dev_addr);
+ eth_hw_addr_random(ndev);
+ else
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;

/* set up unicast MAC address filter set its mac address */
mutex_lock(&lp->indirect_mutex);
--
1.7.8.3

2012-02-17 15:43:52

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 07/10] cisco/enic: use eth_hw_addr_random() instead of random_ether_addr()

Use dev_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

Couldn't replace random_ether_addr() in enic_probe() since
enic_set_mac_addr() is used which would reset addr_assign_type.
Instead set addr_assign_type directly to NET_ADDR_RANDOM in
case of random mac after call enic_set_mac_addr().

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: use bitops, adapt to eth_hw_addr_random(), add a comment

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/cisco/enic/enic_main.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index ab3f67f..ed00cb3 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -865,6 +865,7 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)
}

memcpy(netdev->dev_addr, addr, netdev->addr_len);
+ netdev->addr_assign_type &= ~NET_ADDR_RANDOM;

return 0;
}
@@ -1119,7 +1120,7 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,
memcpy(pp->mac_addr, prev_pp.vf_mac, ETH_ALEN);

if (vf == PORT_SELF_VF && is_zero_ether_addr(netdev->dev_addr))
- random_ether_addr(netdev->dev_addr);
+ eth_hw_addr_random(netdev);

err = enic_process_set_pp_request(enic, vf, &prev_pp, &restore_pp);
if (err) {
@@ -2272,6 +2273,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
int err;
#ifdef CONFIG_PCI_IOV
int pos = 0;
+ bool random_mac = false;
#endif
int num_pps = 1;

@@ -2467,8 +2469,10 @@ static int __devinit enic_probe(struct pci_dev *pdev,
(void)enic_change_mtu(netdev, enic->port_mtu);

#ifdef CONFIG_PCI_IOV
- if (enic_is_sriov_vf(enic) && is_zero_ether_addr(enic->mac_addr))
+ if (enic_is_sriov_vf(enic) && is_zero_ether_addr(enic->mac_addr)) {
random_ether_addr(enic->mac_addr);
+ random_mac = true;
+ }
#endif

err = enic_set_mac_addr(netdev, enic->mac_addr);
@@ -2476,6 +2480,12 @@ static int __devinit enic_probe(struct pci_dev *pdev,
dev_err(dev, "Invalid MAC address, aborting\n");
goto err_out_dev_deinit;
}
+#ifdef CONFIG_PCI_IOV
+ if (random_mac) {
+ /*Couldn't use eth_hw_addr_random() due to enic_set_mac_addr()*/
+ netdev->addr_assign_type |= NET_ADDR_RANDOM;
+ }
+#endif

enic->tx_coalesce_usecs = enic->config.intr_timer_usec;
enic->rx_coalesce_usecs = enic->tx_coalesce_usecs;
--
1.7.8.3

2012-02-17 15:43:50

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 02/10] lantiq_etop: set addr_assign_type if random_ether_addr() used

Set addr_assign_type correctly to NET_ADDR_RANDOM in case
a random MAC address was generated and assigned to the netdevice.

v2: added comment, renamed bool variable to random_mac

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/lantiq_etop.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 85e2c6c..aee87fc 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -634,6 +634,7 @@ ltq_etop_init(struct net_device *dev)
struct ltq_etop_priv *priv = netdev_priv(dev);
struct sockaddr mac;
int err;
+ bool random_mac = false;

ether_setup(dev);
dev->watchdog_timeo = 10 * HZ;
@@ -646,11 +647,17 @@ ltq_etop_init(struct net_device *dev)
if (!is_valid_ether_addr(mac.sa_data)) {
pr_warn("etop: invalid MAC, using random\n");
random_ether_addr(mac.sa_data);
+ random_mac = true;
}

err = ltq_etop_set_mac_address(dev, &mac);
if (err)
goto err_netdev;
+
+ /*set addr_assign_type here, ltq_etop_set_mac_address would reset it*/
+ if (random_mac)
+ dev->addr_assign_type |= NET_ADDR_RANDOM;
+
ltq_etop_set_multicast_list(dev);
err = ltq_etop_mdio_init(dev);
if (err)
--
1.7.8.3

2012-02-17 15:44:57

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 03/10] davinci_emac: use eth_hw_addr_random() instead of random_ether_addr()

Use eth_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

Remove one memcpy from emac_dev_setmac_addr() since this is a
duplicate: it's already done some lines above.

v2: use bitops, adapt to eth_hw_addr_random, remove a memcpy

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/ti/davinci_emac.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 794ac30..50adba0 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1260,10 +1260,10 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr)
/* Store mac addr in priv and rx channel and set it in EMAC hw */
memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len);
+ ndev->addr_assign_type &= ~NET_ADDR_RANDOM;

/* MAC address is configured only after the interface is enabled. */
if (netif_running(ndev)) {
- memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
emac_setmac(priv, EMAC_DEF_RX_CH, priv->mac_addr);
}

@@ -1897,7 +1897,8 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)

if (!is_valid_ether_addr(priv->mac_addr)) {
/* Use random MAC if none passed */
- random_ether_addr(priv->mac_addr);
+ eth_hw_addr_random(ndev);
+ memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
priv->mac_addr);
}
--
1.7.8.3

2012-02-17 15:45:55

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH 10/10] UML net: set addr_assign_type if random_ether_addr() used

Set addr_assign_type correctly to NET_ADDR_RANDOM in case
a random MAC address was generated and assigned to the netdevice.

Return state from setup_etheraddr() about returning a random
MAC address or not and check this state in eth_configure().

Signed-off-by: Danny Kukawka <[email protected]>
---
arch/um/drivers/net_kern.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index a492e59..d299618 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -293,7 +293,7 @@ static void uml_net_user_timer_expire(unsigned long _conn)
#endif
}

-static void setup_etheraddr(char *str, unsigned char *addr, char *name)
+static int setup_etheraddr(char *str, unsigned char *addr, char *name)
{
char *end;
int i;
@@ -334,12 +334,13 @@ static void setup_etheraddr(char *str, unsigned char *addr, char *name)
addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4],
addr[5]);
}
- return;
+ return 0;

random:
printk(KERN_INFO
"Choosing a random ethernet address for device %s\n", name);
random_ether_addr(addr);
+ return 1;
}

static DEFINE_SPINLOCK(devices_lock);
@@ -391,6 +392,7 @@ static void eth_configure(int n, void *init, char *mac,
struct net_device *dev;
struct uml_net_private *lp;
int err, size;
+ int random_mac;

size = transport->private_size + sizeof(struct uml_net_private);

@@ -417,7 +419,7 @@ static void eth_configure(int n, void *init, char *mac,
*/
snprintf(dev->name, sizeof(dev->name), "eth%d", n);

- setup_etheraddr(mac, device->mac, dev->name);
+ random_mac = setup_etheraddr(mac, device->mac, dev->name);

printk(KERN_INFO "Netdevice %d (%pM) : ", n, device->mac);

@@ -474,6 +476,9 @@ static void eth_configure(int n, void *init, char *mac,

/* don't use eth_mac_addr, it will not work here */
memcpy(dev->dev_addr, device->mac, ETH_ALEN);
+ if (random_mac)
+ dev->addr_assign_type |= NET_ADDR_RANDOM;
+
dev->mtu = transport->user->mtu;
dev->netdev_ops = &uml_netdev_ops;
dev->ethtool_ops = &uml_net_ethtool_ops;
--
1.7.8.3

2012-02-17 15:46:25

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 05/10] igbvf: reset netdevice addr_assign_type if changed

Reset the state of addr_assign_type to NET_ADDR_PERM as soon as
the MAC get changed via .ndo_set_mac_address.

v2: use bitops to reset addr_assign_type

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/intel/igbvf/netdev.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 9e335f7..d5faf99 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -1695,6 +1695,7 @@ static int igbvf_set_mac(struct net_device *netdev, void *p)
return -EADDRNOTAVAIL;

memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+ netdev->addr_assign_type &= ~NET_ADDR_RANDOM;

return 0;
}
--
1.7.8.3

2012-02-17 15:46:23

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 01/10] au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()

Use eth_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

v2: adapt to eth_hw_addr_random()

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/amd/au1000_eth.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 8b95dd3..8793daa 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1130,9 +1130,6 @@ static int __devinit au1000_probe(struct platform_device *pdev)

au1000_setup_hw_rings(aup, aup->macdma);

- /* set a random MAC now in case platform_data doesn't provide one */
- random_ether_addr(dev->dev_addr);
-
writel(0, aup->enable);
aup->mac_enabled = 0;

@@ -1142,8 +1139,12 @@ static int __devinit au1000_probe(struct platform_device *pdev)
" PHY search on MAC0\n");
aup->phy1_search_mac0 = 1;
} else {
- if (is_valid_ether_addr(pd->mac))
+ if (is_valid_ether_addr(pd->mac)) {
memcpy(dev->dev_addr, pd->mac, 6);
+ } else {
+ /*set a random MAC since no valid provided by platform_data*/
+ eth_hw_addr_random(dev);
+ }

aup->phy_static_config = pd->phy_static_config;
aup->phy_search_highest_addr = pd->phy_search_highest_addr;
--
1.7.8.3

2012-02-17 15:46:57

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 06/10] batman-adv: use eth_hw_addr_random() instead of random_ether_addr()

Use eth_hw_addr_random() instead of calling random_ether_addr()
to set addr_assign_type correctly to NET_ADDR_RANDOM.

Remove dev_addr in interface_setup(), it's not needed anymore.

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: use bitops, adapt to eth_hw_addr_random()

Signed-off-by: Danny Kukawka <[email protected]>
---
net/batman-adv/soft-interface.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 987c75a..fd1d327 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -541,6 +541,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p)
}

memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;
return 0;
}

@@ -783,7 +784,6 @@ static const struct net_device_ops bat_netdev_ops = {
static void interface_setup(struct net_device *dev)
{
struct bat_priv *priv = netdev_priv(dev);
- char dev_addr[ETH_ALEN];

ether_setup(dev);

@@ -800,8 +800,7 @@ static void interface_setup(struct net_device *dev)
dev->hard_header_len = BAT_HEADER_LEN;

/* generate random address */
- random_ether_addr(dev_addr);
- memcpy(dev->dev_addr, dev_addr, ETH_ALEN);
+ eth_hw_addr_random(dev);

SET_ETHTOOL_OPS(dev, &bat_ethtool_ops);

--
1.7.8.3

2012-02-17 15:47:19

by Danny Kukawka

[permalink] [raw]
Subject: [PATCH v2 09/10] atheros eth: set addr_assign_type if random_ether_addr() used

Set addr_assign_type correctly to NET_ADDR_RANDOM in case
a random MAC address was generated and assigned to the netdevice.

Fix error handling in atl1c_probe(). If atl1c_read_mac_addr()
couldn't get the hw mac address, and a random mac address get
set return the error code. Don't go to err_eeprom in
atl1c_probe(), use the generated MAC address in this case.

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: use bitops

Signed-off-by: Danny Kukawka <[email protected]>
---
drivers/net/ethernet/atheros/atl1c/atl1c_hw.c | 2 +-
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 9 ++++-----
drivers/net/ethernet/atheros/atlx/atl1.c | 12 +++++++++---
drivers/net/ethernet/atheros/atlx/atlx.c | 1 +
4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
index 23f2ab0..bd1667c 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_hw.c
@@ -224,7 +224,7 @@ int atl1c_read_mac_addr(struct atl1c_hw *hw)
random_ether_addr(hw->perm_mac_addr);

memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr));
- return 0;
+ return err;
}

/*
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index b859124..1e4e645 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -468,6 +468,7 @@ static int atl1c_set_mac_addr(struct net_device *netdev, void *p)

memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
+ netdev->addr_assign_type &= ~NET_ADDR_RANDOM;

atl1c_hw_set_mac_addr(&adapter->hw);

@@ -2746,10 +2747,9 @@ static int __devinit atl1c_probe(struct pci_dev *pdev,
err = -EIO;
goto err_reset;
}
- if (atl1c_read_mac_addr(&adapter->hw) != 0) {
- err = -EIO;
- dev_err(&pdev->dev, "get mac address failed\n");
- goto err_eeprom;
+ if (atl1c_read_mac_addr(&adapter->hw)) {
+ /* got a random MAC address, set NET_ADDR_RANDOM to netdev */
+ netdev->addr_assign_type |= NET_ADDR_RANDOM;
}
memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len);
@@ -2774,7 +2774,6 @@ static int __devinit atl1c_probe(struct pci_dev *pdev,
err_reset:
err_register:
err_sw_init:
-err_eeprom:
iounmap(adapter->hw.hw_addr);
err_init_netdev:
err_ioremap:
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 9bd2049..40ac414 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -534,14 +534,17 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
*/
static s32 atl1_read_mac_addr(struct atl1_hw *hw)
{
+ s32 ret = 0;
u16 i;

- if (atl1_get_permanent_address(hw))
+ if (atl1_get_permanent_address(hw)) {
random_ether_addr(hw->perm_mac_addr);
+ ret = 1;
+ }

for (i = 0; i < ETH_ALEN; i++)
hw->mac_addr[i] = hw->perm_mac_addr[i];
- return 0;
+ return ret;
}

/*
@@ -3007,7 +3010,10 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
}

/* copy the MAC address out of the EEPROM */
- atl1_read_mac_addr(&adapter->hw);
+ if (atl1_read_mac_addr(&adapter->hw)) {
+ /* mark random mac */
+ netdev->addr_assign_type |= NET_ADDR_RANDOM;
+ }
memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);

if (!is_valid_ether_addr(netdev->dev_addr)) {
diff --git a/drivers/net/ethernet/atheros/atlx/atlx.c b/drivers/net/ethernet/atheros/atlx/atlx.c
index 8ff7411..3cd8837 100644
--- a/drivers/net/ethernet/atheros/atlx/atlx.c
+++ b/drivers/net/ethernet/atheros/atlx/atlx.c
@@ -84,6 +84,7 @@ static int atlx_set_mac(struct net_device *netdev, void *p)

memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
+ netdev->addr_assign_type &= ~NET_ADDR_RANDOM;

atlx_set_mac_addr(&adapter->hw);
return 0;
--
1.7.8.3

2012-02-17 15:55:50

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH 10/10] UML net: set addr_assign_type if random_ether_addr() used

On 17.02.2012 16:43, Danny Kukawka wrote:
> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> a random MAC address was generated and assigned to the netdevice.
>
> Return state from setup_etheraddr() about returning a random
> MAC address or not and check this state in eth_configure().
>
> Signed-off-by: Danny Kukawka<[email protected]>

Acked-by: Richard Weinberger <[email protected]>

Do you want me to pick up this patch or is it supposed to go though the
net tree?

Thanks,
//richard

2012-02-17 20:18:00

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 10/10] UML net: set addr_assign_type if random_ether_addr() used

From: Richard Weinberger <[email protected]>
Date: Fri, 17 Feb 2012 16:55:41 +0100

> On 17.02.2012 16:43, Danny Kukawka wrote:
>> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
>> a random MAC address was generated and assigned to the netdevice.
>>
>> Return state from setup_etheraddr() about returning a random
>> MAC address or not and check this state in eth_configure().
>>
>> Signed-off-by: Danny Kukawka<[email protected]>
>
> Acked-by: Richard Weinberger <[email protected]>
>
> Do you want me to pick up this patch or is it supposed to go though
> the net tree?

I'll take care of it.

2012-02-17 20:59:42

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 01/10] au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:22 +0100

> Use eth_hw_addr_random() instead of calling random_ether_addr()
> to set addr_assign_type correctly to NET_ADDR_RANDOM.
>
> v2: adapt to eth_hw_addr_random()
>
> Signed-off-by: Danny Kukawka <[email protected]>

Please don't shit up the comments:

> - /* set a random MAC now in case platform_data doesn't provide one */
...
> + /*set a random MAC since no valid provided by platform_data*/

You had to work to make that comment look worse than it originally
did in the code, spaces around the sentence and if you can be so
bothered capitalize sentences and put proper punctionation at the
end.

I took care of this, but I will not next time.

2012-02-17 21:00:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 02/10] lantiq_etop: set addr_assign_type if random_ether_addr() used

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:23 +0100

> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> a random MAC address was generated and assigned to the netdevice.
>
> v2: added comment, renamed bool variable to random_mac
>
> Signed-off-by: Danny Kukawka <[email protected]>

More bad comment formatting.

> + /*set addr_assign_type here, ltq_etop_set_mac_address would reset it*/

Again, I fixed it up but I will not next time.

2012-02-17 21:01:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 05/10] igbvf: reset netdevice addr_assign_type if changed

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:26 +0100

> Reset the state of addr_assign_type to NET_ADDR_PERM as soon as
> the MAC get changed via .ndo_set_mac_address.
>
> v2: use bitops to reset addr_assign_type
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-17 21:01:58

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 07/10] cisco/enic: use eth_hw_addr_random() instead of random_ether_addr()

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:28 +0100

> Use dev_hw_addr_random() instead of calling random_ether_addr()
> to set addr_assign_type correctly to NET_ADDR_RANDOM.
>
> Couldn't replace random_ether_addr() in enic_probe() since
> enic_set_mac_addr() is used which would reset addr_assign_type.
> Instead set addr_assign_type directly to NET_ADDR_RANDOM in
> case of random mac after call enic_set_mac_addr().
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> v2: use bitops, adapt to eth_hw_addr_random(), add a comment
>
> Signed-off-by: Danny Kukawka <[email protected]>

This patch doesn't apply at all to the current net-next tree,
please always validate that your patches actually apply to the
tree before submission.

2012-02-17 21:02:28

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] batman-adv: use eth_hw_addr_random() instead of random_ether_addr()

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:27 +0100

> Use eth_hw_addr_random() instead of calling random_ether_addr()
> to set addr_assign_type correctly to NET_ADDR_RANDOM.
>
> Remove dev_addr in interface_setup(), it's not needed anymore.
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> v2: use bitops, adapt to eth_hw_addr_random()
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-17 21:03:04

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 09/10] atheros eth: set addr_assign_type if random_ether_addr() used

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:30 +0100

> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> a random MAC address was generated and assigned to the netdevice.
>
> Fix error handling in atl1c_probe(). If atl1c_read_mac_addr()
> couldn't get the hw mac address, and a random mac address get
> set return the error code. Don't go to err_eeprom in
> atl1c_probe(), use the generated MAC address in this case.
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> v2: use bitops
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-17 21:03:40

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 04/10] xilinx ll_temac: use eth_hw_addr_random() instead of random_ether_addr()

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:25 +0100

> Use eth_hw_addr_random() instead of calling random_ether_addr()
> to set addr_assign_type correctly to NET_ADDR_RANDOM.
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> v2: reworked to prevent using an extra variable
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied, but:

> + else

Trailing whitespace. This isn't something you need to be a rocket
scientist to catch, the tools find it for you, as they did for me.

2012-02-17 21:03:48

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 03/10] davinci_emac: use eth_hw_addr_random() instead of random_ether_addr()

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:24 +0100

> Use eth_hw_addr_random() instead of calling random_ether_addr()
> to set addr_assign_type correctly to NET_ADDR_RANDOM.
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> Remove one memcpy from emac_dev_setmac_addr() since this is a
> duplicate: it's already done some lines above.
>
> v2: use bitops, adapt to eth_hw_addr_random, remove a memcpy
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-17 21:03:53

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2 08/10] ethoc: set addr_assign_type if random_ether_addr() used

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:29 +0100

> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> a random MAC address was generated and assigned to the netdevice.
>
> Fixed ethoc_set_mac_address() to check if the given mac
> address is valid and set also dev_addr of the net_device.
> Check also the return value of ethoc_set_mac_address() in
> ethoc_probe().
>
> Reset the state to NET_ADDR_PERM as soon as the MAC get
> changed via .ndo_set_mac_address.
>
> v2: set net_device->dev_addr in ethoc_set_mac_address(),
> check if given address is valid
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied, but more coding style problems:

> + if(!is_valid_ether_addr(mac))

Come on, "if[SPACE](..." always.

> +

Trailing whitespace.

> + if (ret) {
> + dev_err(&netdev->dev, "failed to set MAC address\n");
> + goto error;
> + }
> +

More tailing whitespace.

2012-02-17 21:05:48

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 10/10] UML net: set addr_assign_type if random_ether_addr() used

From: Danny Kukawka <[email protected]>
Date: Fri, 17 Feb 2012 16:43:31 +0100

> Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> a random MAC address was generated and assigned to the netdevice.
>
> Return state from setup_etheraddr() about returning a random
> MAC address or not and check this state in eth_configure().
>
> Signed-off-by: Danny Kukawka <[email protected]>

Applied.

2012-02-17 21:25:37

by Danny Kukawka

[permalink] [raw]
Subject: Re: [PATCH 02/10] lantiq_etop: set addr_assign_type if random_ether_addr() used

On Freitag, 17. Februar 2012, David Miller wrote:
> From: Danny Kukawka <[email protected]>
> Date: Fri, 17 Feb 2012 16:43:23 +0100
>
> > Set addr_assign_type correctly to NET_ADDR_RANDOM in case
> > a random MAC address was generated and assigned to the netdevice.
> >
> > v2: added comment, renamed bool variable to random_mac
> >
> > Signed-off-by: Danny Kukawka <[email protected]>
>
> More bad comment formatting.
>
> > + /*set addr_assign_type here, ltq_etop_set_mac_address would reset it*/
>
> Again, I fixed it up but I will not next time.

Thanks. I fixed it but accidently send the unfixed version of the patches
without noticing. Sorry.

Danny

2012-02-17 21:36:44

by Danny Kukawka

[permalink] [raw]
Subject: Re: [PATCH v2 07/10] cisco/enic: use eth_hw_addr_random() instead of random_ether_addr()

On Freitag, 17. Februar 2012, David Miller wrote:
> From: Danny Kukawka <[email protected]>
> Date: Fri, 17 Feb 2012 16:43:28 +0100
>
> > Use dev_hw_addr_random() instead of calling random_ether_addr()
> > to set addr_assign_type correctly to NET_ADDR_RANDOM.
> >
> > Couldn't replace random_ether_addr() in enic_probe() since
> > enic_set_mac_addr() is used which would reset addr_assign_type.
> > Instead set addr_assign_type directly to NET_ADDR_RANDOM in
> > case of random mac after call enic_set_mac_addr().
> >
> > Reset the state to NET_ADDR_PERM as soon as the MAC get
> > changed via .ndo_set_mac_address.
> >
> > v2: use bitops, adapt to eth_hw_addr_random(), add a comment
> >
> > Signed-off-by: Danny Kukawka <[email protected]>
>
> This patch doesn't apply at all to the current net-next tree,
> please always validate that your patches actually apply to the
> tree before submission.

Okay ... forgot that ... I'll check and send a new version.

Danny