mac802154: fix wpan mac setting while lowpan is there

This change “mac802154: fix wpan mac setting while lowpan is there” in Linux kernel is authored by Alexander Aring <alex.aring [at]> on Mon Aug 10 21:15:54 2015 +0200.

mac802154: fix wpan mac setting while lowpan is there

If we currently change the mac address inside the wpan interface while
we have a lowpan interface on top of the wpan interface, the mac address
setting doesn't reach the lowpan interface. The effect would be that the
IPv6 lowpan interface has the old SLAAC address and isn't working
anymore because the lowpan interface use in internal mechanism sometimes
dev->addr which is the old mac address of the wpan interface.

This patch checks if a wpan interface belongs to lowpan interface, if
yes then we need to check if the lowpan interface is down and change the
mac address also at the lowpan interface. When the lowpan interface will
be set up afterwards, it will use the correct SLAAC address which based
on the updated mac address setting.

Reviewed-by: Stefan Schmidt <>
Tested-by: Stefan Schmidt <>
Signed-off-by: Alexander Aring <>
Signed-off-by: Marcel Holtmann <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 09095fd.

There are 15 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/mac802154/iface.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 416de90..ff99055 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -125,6 +125,14 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
 	if (netif_running(dev))
 		return -EBUSY;
+	/* lowpan need to be down for update
+	 * SLAAC address after ifup
+	 */
+	if (sdata->wpan_dev.lowpan_dev) {
+		if (netif_running(sdata->wpan_dev.lowpan_dev))
+			return -EBUSY;
+	}
 	ieee802154_be64_to_le64(&extended_addr, addr->sa_data);
 	if (!ieee802154_is_valid_extended_unicast_addr(extended_addr))
 		return -EINVAL;
@@ -132,6 +140,13 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
 	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
 	sdata->wpan_dev.extended_addr = extended_addr;
+	/* update lowpan interface mac address when
+	 * wpan mac has been changed
+	 */
+	if (sdata->wpan_dev.lowpan_dev)
+		memcpy(sdata->wpan_dev.lowpan_dev->dev_addr, dev->dev_addr,
+		       dev->addr_len);
 	return mac802154_wpan_update_llsec(dev);

The commit for this change in Linux stable tree is 09095fd (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *