summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2023-11-28 14:16:55 +0300
committerMiquel Raynal <miquel.raynal@bootlin.com>2023-12-15 13:14:57 +0300
commit2373699560a754079579b7722b50d1d38de1960e (patch)
tree96f7a25ef1181e69e15f135587aa71440f0945f2 /net
parentb720383ab1cfd584c8c0d9fc7b8cc541ed76dba5 (diff)
downloadlinux-2373699560a754079579b7722b50d1d38de1960e.tar.xz
mac802154: Avoid new associations while disassociating
While disassociating from a PAN ourselves, let's set the maximum number of associations temporarily to zero to be sure no new device tries to associate with us. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> Acked-by: Alexander Aring <aahringo@redhat.com> Link: https://lore.kernel.org/linux-wpan/20231128111655.507479-6-miquel.raynal@bootlin.com
Diffstat (limited to 'net')
-rw-r--r--net/ieee802154/pan.c8
-rw-r--r--net/mac802154/cfg.c11
2 files changed, 15 insertions, 4 deletions
diff --git a/net/ieee802154/pan.c b/net/ieee802154/pan.c
index fb5b0af2ef68..249df7364b3e 100644
--- a/net/ieee802154/pan.c
+++ b/net/ieee802154/pan.c
@@ -94,10 +94,16 @@ __le16 cfg802154_get_free_short_addr(struct wpan_dev *wpan_dev)
}
EXPORT_SYMBOL_GPL(cfg802154_get_free_short_addr);
-void cfg802154_set_max_associations(struct wpan_dev *wpan_dev, unsigned int max)
+unsigned int cfg802154_set_max_associations(struct wpan_dev *wpan_dev,
+ unsigned int max)
{
+ unsigned int old_max;
+
lockdep_assert_held(&wpan_dev->association_lock);
+ old_max = wpan_dev->max_associations;
wpan_dev->max_associations = max;
+
+ return old_max;
}
EXPORT_SYMBOL_GPL(cfg802154_set_max_associations);
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 17e2032fac24..ef7f23af043f 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -389,6 +389,7 @@ static int mac802154_disassociate_from_parent(struct wpan_phy *wpan_phy,
struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
struct ieee802154_pan_device *child, *tmp;
struct ieee802154_sub_if_data *sdata;
+ unsigned int max_assoc;
u64 eaddr;
int ret;
@@ -397,6 +398,7 @@ static int mac802154_disassociate_from_parent(struct wpan_phy *wpan_phy,
/* Start by disassociating all the children and preventing new ones to
* attempt associations.
*/
+ max_assoc = cfg802154_set_max_associations(wpan_dev, 0);
list_for_each_entry_safe(child, tmp, &wpan_dev->children, node) {
ret = mac802154_send_disassociation_notif(sdata, child,
IEEE802154_COORD_WISHES_DEVICE_TO_LEAVE);
@@ -429,14 +431,17 @@ static int mac802154_disassociate_from_parent(struct wpan_phy *wpan_phy,
if (local->hw.flags & IEEE802154_HW_AFILT) {
ret = drv_set_pan_id(local, wpan_dev->pan_id);
if (ret < 0)
- return ret;
+ goto reset_mac_assoc;
ret = drv_set_short_addr(local, wpan_dev->short_addr);
if (ret < 0)
- return ret;
+ goto reset_mac_assoc;
}
- return 0;
+reset_mac_assoc:
+ cfg802154_set_max_associations(wpan_dev, max_assoc);
+
+ return ret;
}
static int mac802154_disassociate_child(struct wpan_phy *wpan_phy,