From patchwork Tue Aug 18 22:22:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Stotland, Inga" X-Patchwork-Id: 11722241 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB4F81575 for ; Tue, 18 Aug 2020 22:22:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91C8620786 for ; Tue, 18 Aug 2020 22:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbgHRWWM (ORCPT ); Tue, 18 Aug 2020 18:22:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:11540 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgHRWWK (ORCPT ); Tue, 18 Aug 2020 18:22:10 -0400 IronPort-SDR: 1MvmYClBNo3BUix5PZO0yBa8VRgvbNKJO9qLrrMVRtoAbc13WjNCMLW5Ho4prmiESQzJ+TA8Q3 Z55nvmUPMDDg== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="152634881" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="152634881" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 15:22:09 -0700 IronPort-SDR: Jdcjc6bvwcySXLaDcnnQPXaLA53jNVFaXNsf95PByCDEI0SNE9AEV8/ysrfUl97LdQ2tCH9G3U a2zIal+yhD+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="336764503" Received: from ypeng18-mobl.ger.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.245]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2020 15:22:09 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 1/2] mesh: Always set net modes based on node feature settings Date: Tue, 18 Aug 2020 15:22:07 -0700 Message-Id: <20200818222208.50938-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The network settings such as relay, beacon, proxy and friend are always set based on local node feature settings. This change makes the net modes intialization unconditional, to include the "No Support" setting on node level which should result in the disabled mode in net.c --- mesh/node.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/mesh/node.c b/mesh/node.c index 1eeffeb8b..ebc111a62 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -399,24 +399,16 @@ static bool init_storage_dir(struct mesh_node *node) static void update_net_settings(struct mesh_node *node) { - uint8_t mode; + struct mesh_net *net = node->net; - mode = node->proxy; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_proxy_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_proxy_mode(net, node->proxy == MESH_MODE_ENABLED); - mode = node->friend; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_friend_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_friend_mode(net, node->friend == MESH_MODE_ENABLED); - mode = node->relay.mode; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_relay_mode(node->net, mode == MESH_MODE_ENABLED, + mesh_net_set_relay_mode(net, node->relay.mode == MESH_MODE_ENABLED, node->relay.cnt, node->relay.interval); - mode = node->beacon; - if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED) - mesh_net_set_beacon_mode(node->net, mode == MESH_MODE_ENABLED); + mesh_net_set_beacon_mode(net, node->beacon == MESH_MODE_ENABLED); } static bool init_from_storage(struct mesh_config_node *db_node, From patchwork Tue Aug 18 22:22:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Stotland, Inga" X-Patchwork-Id: 11722243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FD9B16B1 for ; Tue, 18 Aug 2020 22:22:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 528FD2078D for ; Tue, 18 Aug 2020 22:22:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726826AbgHRWWM (ORCPT ); Tue, 18 Aug 2020 18:22:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:11540 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHRWWL (ORCPT ); Tue, 18 Aug 2020 18:22:11 -0400 IronPort-SDR: aMZj5JUY3UsC/2JfIlu8ibibpx9T+ayS7VtzfdlNiu7zXs7k6arY0bbvP6ey0XzeXUzTc7O8SS SS1QH/IAqt1g== X-IronPort-AV: E=McAfee;i="6000,8403,9717"; a="152634886" X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="152634886" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 15:22:10 -0700 IronPort-SDR: AiLF9XTtW+fawC+lhHeGYU2SJTHh3Ocy8weAUQD4AO9JTxWgmfCJBLul3D9uZRB2DcYn6yTEaD 9Bv9UQC3a8sA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,329,1592895600"; d="scan'208";a="336764509" Received: from ypeng18-mobl.ger.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.255.230.245]) by orsmga007.jf.intel.com with ESMTP; 18 Aug 2020 15:22:10 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 2/2] mesh: Check for enabled modes when dst is fixed address Date: Tue, 18 Aug 2020 15:22:08 -0700 Message-Id: <20200818222208.50938-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818222208.50938-1-inga.stotland@intel.com> References: <20200818222208.50938-1-inga.stotland@intel.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This moves the check for incoming messages addressed to fixed addresses, e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled, the message is not processed. --- mesh/model.c | 21 --------------------- mesh/net.c | 9 +++++++++ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/mesh/model.c b/mesh/model.c index 961391f13..b44e2f669 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -937,27 +937,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, if (!num_ele || IS_UNASSIGNED(addr)) goto done; - /* - * In case of fixed group addresses check if the - * corresponding mode is enabled. - */ - if (dst == PROXIES_ADDRESS && - (node_proxy_mode_get(node) != MESH_MODE_ENABLED)) - goto done; - - if (dst == FRIENDS_ADDRESS && - (node_friend_mode_get(node) != MESH_MODE_ENABLED)) - goto done; - - if (dst == RELAYS_ADDRESS) { - uint8_t cnt; - uint16_t interval; - - if (node_relay_mode_get(node, &cnt, &interval) != - MESH_MODE_ENABLED) - goto done; - } - is_subscription = !(IS_UNICAST(dst)); for (i = 0; i < num_ele; i++) { diff --git a/mesh/net.c b/mesh/net.c index 26440b02d..115a76944 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1658,6 +1658,15 @@ static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index, } not_for_friend: + if (dst == FRIENDS_ADDRESS && !net->friend_enable) + return false; + + if (dst == RELAYS_ADDRESS && !net->relay.enable) + return false; + + if (dst == PROXIES_ADDRESS && !net->proxy_enable) + return false; + return mesh_model_rx(net->node, szmic, seqAuth, seq, iv_index, net_idx, src, dst, key_aid, data, size); }