From patchwork Tue Nov 28 11:16:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13471025 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hDD7HRH6" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 105E9109; Tue, 28 Nov 2023 03:17:00 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 91213C000F; Tue, 28 Nov 2023 11:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701170219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aTh1FtK8KxFr4g7tE0WFtAC6xt11QyMpr4cp9khROnQ=; b=hDD7HRH6glOLkZIQfmkpTAt/Iffn8WSug+GMZs5ApFRw3mrpxb1xMxszo6vE84WHZfDVt+ 8WlCSH05ZRNOMzOe8xU0/6VNxEJZ3cD4ks4YAtY/MWfzJqnpg2va4H3sSiQ+bhIcVsyhLv D2vE7ahDThBcYirvX+gO8uMqdB8gHSNMZv+xDOHNMK4aVuow0nUHldoJidDaOJgcm6RhoG xh6m4fXUiVF38/9S6t/HbxkfrEMP5MlkXbYvdFT4ufA3t+lAACM+WtIQ5cXyP0rt5boq7C SsRua32772EI5coKjl9NjM5bWhF/G/Y4chaxQ+ZeF3m6C+qMCdzCjCXMlmisfQ== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Miquel Raynal Subject: [PATCH wpan-next 1/5] mac80254: Provide real PAN coordinator info in beacons Date: Tue, 28 Nov 2023 12:16:51 +0100 Message-Id: <20231128111655.507479-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128111655.507479-1-miquel.raynal@bootlin.com> References: <20231128111655.507479-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Spam-Score: 300 X-GND-Status: SPAM X-GND-Sasl: miquel.raynal@bootlin.com Sending a beacon is a way to advertise a PAN, but also ourselves as coordinator in the PAN. There is only one PAN coordinator in a PAN, this is the device without parent (not associated itself to an "upper" coordinator). Instead of blindly saying that we are the PAN coordinator, let's actually use our internal information to fill this field. Signed-off-by: Miquel Raynal Acked-by: Stefan Schmidt Acked-by: Alexander Aring --- net/mac802154/scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mac802154/scan.c b/net/mac802154/scan.c index 7597072aed57..5873da634fb4 100644 --- a/net/mac802154/scan.c +++ b/net/mac802154/scan.c @@ -466,6 +466,7 @@ int mac802154_send_beacons_locked(struct ieee802154_sub_if_data *sdata, struct cfg802154_beacon_request *request) { struct ieee802154_local *local = sdata->local; + struct wpan_dev *wpan_dev = &sdata->wpan_dev; ASSERT_RTNL(); @@ -495,8 +496,7 @@ int mac802154_send_beacons_locked(struct ieee802154_sub_if_data *sdata, local->beacon.mac_pl.superframe_order = request->interval; local->beacon.mac_pl.final_cap_slot = 0xf; local->beacon.mac_pl.battery_life_ext = 0; - /* TODO: Fill this field with the coordinator situation in the network */ - local->beacon.mac_pl.pan_coordinator = 1; + local->beacon.mac_pl.pan_coordinator = !wpan_dev->parent; local->beacon.mac_pl.assoc_permit = 1; if (request->interval == IEEE802154_ACTIVE_SCAN_DURATION) From patchwork Tue Nov 28 11:16:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13471026 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lM3SiAEB" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8971A5; Tue, 28 Nov 2023 03:17:02 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id F405EC000C; Tue, 28 Nov 2023 11:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701170221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DHdGd2zzkKYvEZysTBsYqr5HfSWPcxyAVoJcqSobQ9g=; b=lM3SiAEBiKoKC6fToOH5g7dgKhjwcrv06zEayNvk79IaZX4Bi8BB+ki/1WRj0XnGLcD9L+ qUeM4dTlD7G/4qjUbXX3WFV3k8MIq9jShzOSo/Rs/eMi3znBu8yd4HNr3OZH6n2mF16uzW YCwTfxkF+GlVzNPkPEW3EZexA+XbqcZw43XohyB3hCzrHlGGAxhBHd1xoM3dKwcQAIM4h2 dN8zXEtrJRcR3C7jLjb0ZDp6TpgswiJmWXFID8HYWIdpUpgbe72ndLFO77362Th2cxFCAb 4Av4YJ8mQB8WaDeQHCKR+3IlThCFddnHkUwkI+uO4VYGO4W2pH4GefyEzKPFYQ== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Miquel Raynal Subject: [PATCH wpan-next 2/5] mac802154: Use the PAN coordinator parameter when stamping packets Date: Tue, 28 Nov 2023 12:16:52 +0100 Message-Id: <20231128111655.507479-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128111655.507479-1-miquel.raynal@bootlin.com> References: <20231128111655.507479-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com ACKs come with the source and destination address empty, this has been clarified already. But there is something else: if the destination address is empty but the source address is valid, it may be a way to reach the PAN coordinator. Either the device receiving this frame is the PAN coordinator itself and should process what it just received (PACKET_HOST) or it is not and may, if supported, relay the packet as it is targeted to another device in the network. Right now we do not support relaying so the packet should be dropped in the first place, but the stamping looks more accurate this way. Signed-off-by: Miquel Raynal Acked-by: Stefan Schmidt Acked-by: Alexander Aring --- net/mac802154/rx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c index 0024341ef9c5..e40a988d6c80 100644 --- a/net/mac802154/rx.c +++ b/net/mac802154/rx.c @@ -156,12 +156,15 @@ ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata, switch (mac_cb(skb)->dest.mode) { case IEEE802154_ADDR_NONE: - if (hdr->source.mode != IEEE802154_ADDR_NONE) - /* FIXME: check if we are PAN coordinator */ - skb->pkt_type = PACKET_OTHERHOST; - else + if (hdr->source.mode == IEEE802154_ADDR_NONE) /* ACK comes with both addresses empty */ skb->pkt_type = PACKET_HOST; + else if (!wpan_dev->parent) + /* No dest means PAN coordinator is the recipient */ + skb->pkt_type = PACKET_HOST; + else + /* We are not the PAN coordinator, just relaying */ + skb->pkt_type = PACKET_OTHERHOST; break; case IEEE802154_ADDR_LONG: if (mac_cb(skb)->dest.pan_id != span && From patchwork Tue Nov 28 11:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13471027 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RVRvW61c" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9200DD6; Tue, 28 Nov 2023 03:17:03 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4C018C0006; Tue, 28 Nov 2023 11:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701170222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9iBZtX0anCTLAf+AwYFYTLyMCZwBIcSzyfNNx7MAlns=; b=RVRvW61cnZWSwOBY42XNQW84SmWKFinNae68YCtEy2gHgFJNW0gX/NM0sfwAcmQFfXqhZJ exwHNWHChGQG5cqQHgrMxDd+CdtY6eJ+98aA8ndr4iDKcjSXHbaw6kARoVC6t9/gZW725j iIjr8vRJ1qa2s+drj2ZO9TWMLlM1SS/YdaOfWRRQycZLRZ2uIitBj7kyF47rfpIa6Xk2qy HSlkszwtD/vWGQ1/LXenZA07GOMGM3/S6l9JcAJo9rl4/6WGF9qZy9CtDXKwVe0bAj/FWd ZD/B2MJFTeFhYjQ2o6EaHUbyBtqdqc7CBndFsObAsO0E1RFRGcF0hLm85aQRLA== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Miquel Raynal Subject: [PATCH wpan-next 3/5] mac802154: Only allow PAN controllers to process association requests Date: Tue, 28 Nov 2023 12:16:53 +0100 Message-Id: <20231128111655.507479-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128111655.507479-1-miquel.raynal@bootlin.com> References: <20231128111655.507479-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com It is not very clear in the specification whether simple coordinators are allowed or not to answer to association requests themselves. As there is no synchronization mechanism, it is probably best to rely on the relay feature of these coordinators and avoid processing them in this case. Signed-off-by: Miquel Raynal Acked-by: Stefan Schmidt Acked-by: Alexander Aring --- net/mac802154/scan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mac802154/scan.c b/net/mac802154/scan.c index 5873da634fb4..1c0eeaa76560 100644 --- a/net/mac802154/scan.c +++ b/net/mac802154/scan.c @@ -781,6 +781,12 @@ int mac802154_process_association_req(struct ieee802154_sub_if_data *sdata, unlikely(dest->short_addr != wpan_dev->short_addr)) return -ENODEV; + if (wpan_dev->parent) { + dev_dbg(&sdata->dev->dev, + "Ignoring ASSOC REQ, not the PAN coordinator\n"); + return -ENODEV; + } + mutex_lock(&wpan_dev->association_lock); memcpy(&assoc_req_pl, skb->data, sizeof(assoc_req_pl)); From patchwork Tue Nov 28 11:16:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13471028 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="G2Dxk8Qu" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4656109; Tue, 28 Nov 2023 03:17:04 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 819CCC0007; Tue, 28 Nov 2023 11:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701170223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F+Ca0i6LS9EErxIJcnfDTMGUbmzhckltyA1nENhzjEE=; b=G2Dxk8Qur2PT0FS20ThRlbIYV8LVyg55LGKiLObgI6cZgEtEwHnNBMfrHkPS7YOq58W+UL zdWABnrVsoAuDYFlXZOi17fH+5iVeA/+NH9SEYu0ddDEVFhCYv8TaGnj2+lqDwXP3waPWH uEw1Qfe3uDTnmAewTRVr/wKGgTxFpoCqNTeC3cdP735QblUrilJPvuSp/mF1N7BJDmoUwH 03TbgzXLs4z2d9qaRhHsrAzHL/ia8qBYSkVE1JLPLD5+42on8HRx7AOTqnnjop3XZep8s0 C2HF8SlbXI6mj0bmpZSFPlPsHyN/0kTc6b0KN7IRU+Ji2QRmsoJ3TVJTaM9Rzg== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Miquel Raynal Subject: [PATCH wpan-next 4/5] ieee802154: Avoid confusing changes after associating Date: Tue, 28 Nov 2023 12:16:54 +0100 Message-Id: <20231128111655.507479-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128111655.507479-1-miquel.raynal@bootlin.com> References: <20231128111655.507479-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com 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: Miquel Raynal Acked-by: Stefan Schmidt Acked-by: Alexander Aring --- net/ieee802154/nl802154.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index e4d290d0e0a0..5c73b5fcadc0 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -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]); + /* 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); } @@ -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]); - /* TODO - * I am not sure about to check here on broadcast short_addr. - * Broadcast is a valid setting, comment from 802.15.4: - * A value of 0xfffe indicates that the device has - * associated but has not been allocated an address. A - * 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. + /* The short address only has a meaning when part of a PAN, after a + * proper association procedure. However, we want to still offer the + * possibility to create static networks so changing the short address + * is only allowed when not already associated to other devices with + * the official handshake. */ - if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) || - short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST)) + if (cfg802154_device_is_associated(wpan_dev)) { + NL_SET_ERR_MSG(info->extack, + "Existing associations, changing short address forbidden"); return -EINVAL; + } return rdev_set_short_addr(rdev, wpan_dev, short_addr); } From patchwork Tue Nov 28 11:16:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13471029 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ho7KjvDe" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B519194; Tue, 28 Nov 2023 03:17:06 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id B27ACC0002; Tue, 28 Nov 2023 11:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701170224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ys3ca1B1UbKD/hiXV7EsopdZfBXR8sughDSJmOeFnyk=; b=Ho7KjvDexQzSqAv63wwaQOpUvXBMFGvCJV0GOxTcyAtlOqVm3wiRSLCr4CM078PfqZzoD7 Gb7gOOTH95wib/m5+LV2lEeakJ0TMqcoHV6u+C5ytFsHz3+T1uiEDuLmMr7UQXYsJUSx6r UVmSvwbMpb7sohIG0WUWE12nxLQU7WvMUA1JVY4Zb/MJxAytiuixUDLMgjyNsidzVwak7i fk+D9S2JjQeW9LHEs0N/DMs5bEC6NS97rbpM4eF33QwuHlp9k0HboLmEvz2vv1MrvorfHp w9l9DqrWceTH37ZsHmILT5nadyFHbkqF78Tb1DycptAsYsOwfebOeUBUu1nQag== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Miquel Raynal Subject: [PATCH wpan-next 5/5] mac802154: Avoid new associations while disassociating Date: Tue, 28 Nov 2023 12:16:55 +0100 Message-Id: <20231128111655.507479-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128111655.507479-1-miquel.raynal@bootlin.com> References: <20231128111655.507479-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com 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 Acked-by: Stefan Schmidt Acked-by: Alexander Aring --- include/net/cfg802154.h | 4 +++- net/ieee802154/pan.c | 8 +++++++- net/mac802154/cfg.c | 11 ++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index a64bbcd71f10..cd95711b12b8 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h @@ -589,8 +589,10 @@ cfg802154_device_is_child(struct wpan_dev *wpan_dev, * cfg802154_set_max_associations - Limit the number of future associations * @wpan_dev: the wpan device * @max: the maximum number of devices we accept to associate + * @return: the old maximum value */ -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); /** * cfg802154_get_free_short_addr - Get a free address among the known devices 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,