Commit b720383a authored by Miquel Raynal's avatar Miquel Raynal

ieee802154: Avoid confusing changes after associating

Once associated with any device, we are part of a PAN (with a specific
PAN ID), and we are expected to be present on a particular
channel. Let's avoid confusing other devices by preventing any PAN
ID/channel change once associated.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Acked-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/linux-wpan/20231128111655.507479-5-miquel.raynal@bootlin.com
parent 95d92505
...@@ -1087,6 +1087,15 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info) ...@@ -1087,6 +1087,15 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]); pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
/* Only allow changing the PAN ID when the device has no more
* associations ongoing to avoid confusing peers.
*/
if (cfg802154_device_is_associated(wpan_dev)) {
NL_SET_ERR_MSG(info->extack,
"Existing associations, changing PAN ID forbidden");
return -EINVAL;
}
return rdev_set_pan_id(rdev, wpan_dev, pan_id); return rdev_set_pan_id(rdev, wpan_dev, pan_id);
} }
...@@ -1113,20 +1122,17 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info) ...@@ -1113,20 +1122,17 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]); short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
/* TODO /* The short address only has a meaning when part of a PAN, after a
* I am not sure about to check here on broadcast short_addr. * proper association procedure. However, we want to still offer the
* Broadcast is a valid setting, comment from 802.15.4: * possibility to create static networks so changing the short address
* A value of 0xfffe indicates that the device has * is only allowed when not already associated to other devices with
* associated but has not been allocated an address. A * the official handshake.
* value of 0xffff indicates that the device does not
* have a short address.
*
* I think we should allow to set these settings but
* don't allow to allow socket communication with it.
*/ */
if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) || if (cfg802154_device_is_associated(wpan_dev)) {
short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST)) NL_SET_ERR_MSG(info->extack,
"Existing associations, changing short address forbidden");
return -EINVAL; return -EINVAL;
}
return rdev_set_short_addr(rdev, wpan_dev, short_addr); return rdev_set_short_addr(rdev, wpan_dev, short_addr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment