Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp541614ybe; Fri, 6 Sep 2019 03:32:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaJ+97ayboRmGv/l6DRUT8h554dEnX89aSNCMqFHfgHUhtqlYjEQCfYFVrVi0kvELHDJ/x X-Received: by 2002:a62:2b51:: with SMTP id r78mr9520316pfr.149.1567765944824; Fri, 06 Sep 2019 03:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567765944; cv=none; d=google.com; s=arc-20160816; b=Wt6JCFavPBK0OAZfJjudslwt9zgEBYBIxl+EMHKo/a3pfKs+JJHrVQziYQ4rnsv8Z9 CF7HQruq5AiSohZ1rDqQ6PEZHLrTQQwXEA+AoGhqAtWTOIcTMx9GhkLqo8zxMiJ/+mOb SmleUVSTuCyxFTSreYMcmEZYVUZAAyebLA2IX8UCVa9fh9qBaDWQzPpuW+vpQu/VgBXo 4k8a7DZV7ED1N/XF4VCUXFQ7fYftYsWnJ9LTKehJlq2PDqtDr0JIiHOnjt5lvdU9xDVC 1oO5SQu9NN5DX6UkEE2ZNdwnfOvaH/HJDrRLEt5UrpQEZAky/G1IHctm2qxk3z59DM0n EPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jnDDD6A1OaMkHUT6a3SEnFyRMEkhUYggcr4SKTqp96s=; b=pIbka/C7FkmD3te1lC2I20/sEl7tS7awe3yUxm8XsiUSrVciEm+opkUHvmQKYOfPso bYYpYb2HilQlGEw/odLSEpziIpRmY/0gv2gZJNRls/uHO1WdrczbVeyki2TV5a3mZZPl EJ6yFvmWdLIDePSNq+rHhnr8PO8VOZ1kHjtkMVS88/pPHABuWf8+NFzq+BJxtUhdWIoZ S7EQ3iMCnmkPOP9UjodQyMVptYwvHAEVxQwDGRM4PIPoa3lECLEtz9bVrU87fObE8YUR 1Xayey9KkdvWpyGCIC//mRp2kQrs6055ya86DOns2L1bt7sPFCwHAXJE4cj4hPIDIbSF GUSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si4626407pld.431.2019.09.06.03.32.09; Fri, 06 Sep 2019 03:32:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390200AbfIFC6P (ORCPT + 99 others); Thu, 5 Sep 2019 22:58:15 -0400 Received: from mga14.intel.com ([192.55.52.115]:50396 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731491AbfIFC6P (ORCPT ); Thu, 5 Sep 2019 22:58:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2019 19:58:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,472,1559545200"; d="scan'208";a="383113379" Received: from ingas-nuc1.sea.intel.com ([10.254.107.68]) by fmsmga005.fm.intel.com with ESMTP; 05 Sep 2019 19:58:14 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Handle messages sent to a fixed group address Date: Thu, 5 Sep 2019 19:58:13 -0700 Message-Id: <20190906025813.5519-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This handles the case when an inbound message is addressed to a fixed group, i.e., all-proxies, all-frineds, all-relays and all-nodes. The message is delivered to a primary element only, and, with the exception of all-nodes case, if the corresponding feature is enabled on the node. --- mesh/model.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index 8f3d67ecf..a78f2bec7 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -311,7 +311,7 @@ static void forward_model(void *a, void *b) return; dst = fwd->dst; - if (dst == fwd->unicast || IS_ALL_NODES(dst)) + if (dst == fwd->unicast || dst >= PROXIES_ADDRESS) fwd->has_dst = true; else if (fwd->virt) { virt = l_queue_find(mod->virtuals, simple_match, fwd->virt); @@ -886,8 +886,30 @@ 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++) { struct l_queue *models; @@ -927,6 +949,14 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, /* If the message was to unicast address, we are done */ if (!is_subscription && ele_idx == i) break; + + /* + * For the fixed group addresses, i.e., all-proxies, + * all-friends, all-relayes, all-nodes, the message is delivered + * to a primary element only. + */ + if (dst >= PROXIES_ADDRESS) + break; } done: -- 2.21.0