Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <stefan@osg.samsung.com>
Tested-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Alexander Aring and committed by
Marcel Holtmann
09095fdc 51e0e5d8

+15
+15
net/mac802154/iface.c
··· 125 125 if (netif_running(dev)) 126 126 return -EBUSY; 127 127 128 + /* lowpan need to be down for update 129 + * SLAAC address after ifup 130 + */ 131 + if (sdata->wpan_dev.lowpan_dev) { 132 + if (netif_running(sdata->wpan_dev.lowpan_dev)) 133 + return -EBUSY; 134 + } 135 + 128 136 ieee802154_be64_to_le64(&extended_addr, addr->sa_data); 129 137 if (!ieee802154_is_valid_extended_unicast_addr(extended_addr)) 130 138 return -EINVAL; 131 139 132 140 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 133 141 sdata->wpan_dev.extended_addr = extended_addr; 142 + 143 + /* update lowpan interface mac address when 144 + * wpan mac has been changed 145 + */ 146 + if (sdata->wpan_dev.lowpan_dev) 147 + memcpy(sdata->wpan_dev.lowpan_dev->dev_addr, dev->dev_addr, 148 + dev->addr_len); 134 149 135 150 return mac802154_wpan_update_llsec(dev); 136 151 }