From patchwork Fri Jun 17 19:32:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12885938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8284C433EF for ; Fri, 17 Jun 2022 19:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236566AbiFQTdG (ORCPT ); Fri, 17 Jun 2022 15:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237141AbiFQTdD (ORCPT ); Fri, 17 Jun 2022 15:33:03 -0400 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 0FCC7DE8F; Fri, 17 Jun 2022 12:33:02 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id EDB16C0006; Fri, 17 Jun 2022 19:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1655494381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qfqy93Cw6Hdvjpvbx/L1acyYfNiU9Yv8v7DyB380mro=; b=L8SJVL7l28jQWGj5rz2jlvwPHlK1suSDUdJuwCpcNMZQ5z8yOJDWU0v9T5G1BJhORUztwU /MXVE7KGki5Hq33NO3oBXUoRDwhuDt7dUXXGEdQ2SejHQdtRjLmfPnCi2/9sLW9LpbYQdB omwLxH85iG2lSCLJPP/jAXn0ZH2f+xyqdLjwgyfUcqvpXzNx0iSJk5FN6D4z3/mcC843D8 U2eUQBvGwOg5W5vZ2npb95BJr43GMN/K3FWlCkzdKc558Ocj8FhOC+qp92XeTy7YWbGJaH klaLYH9IZ467qn2XnW6KCqp9VQ85RsxX8yBtuJfHM09IznXJKEyW/t/92WldUg== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next v2 2/6] net: ieee802154: Ensure only FFDs can become PAN coordinators Date: Fri, 17 Jun 2022 21:32:50 +0200 Message-Id: <20220617193254.1275912-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220617193254.1275912-1-miquel.raynal@bootlin.com> References: <20220617193254.1275912-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org This is a limitation clearly listed in the specification. Now that we have device types,let's ensure that only FFDs can become PAN coordinators. Signed-off-by: Miquel Raynal --- net/ieee802154/nl802154.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index 638bf544f102..0c6fc3385320 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -924,6 +924,9 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } + if (type == NL802154_IFTYPE_COORD && !cfg802154_is_ffd(rdev)) + return -EINVAL; + if (info->attrs[NL802154_ATTR_EXTENDED_ADDR]) extended_addr = nla_get_le64(info->attrs[NL802154_ATTR_EXTENDED_ADDR]);