Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2909087ybe; Sun, 8 Sep 2019 03:18:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxm2sFGOfs2YeKbSTh9qx0hhtdS+J9k17iUp19rR8NlwYMXD+NBKelJFmDi2isYc+lRCBVl X-Received: by 2002:a63:e907:: with SMTP id i7mr16180299pgh.84.1567937932656; Sun, 08 Sep 2019 03:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567937932; cv=none; d=google.com; s=arc-20160816; b=KqQPIOZg7rs73sM3HZbF+ytn3y0S5Aqn+Lh4NQaicVhsDBsnAn4SRiCZG1egQP7fIz 8wk0N/8EewYoA2LrsY/K9ri66Qcw1PIdTYYZvmjJ/Oc0teOy0jFUfMp1NFzpi1dCyh8d hj5Hr0vKDAQMYeiGh5QoYIDFusJ+L4fgEI+WbtTicwSKhKdX3mUqRxoaN6EQelHc+d8L ZfFlfcy9JA2GZ0FMn1H7mTuOqIJ0EMHRNzM9nfnEq7CqzRlDRa7R1pA+KyEgrqPfmcpx 6/QO02doPL1sfxISGYor5R07/rCFtYxZANUqtU3ldAkqOuXDR7mPyWjX5D1ZBHFJ2tFy d/mg== 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=BL9PmtP6YWCSkSxuXUBI68jx9Uw+/+kIGR6Na0R+AtA=; b=lu0CreQRrV/dRd2iZbtMbBJ1p4iHxTwoQI2NlmFCTT6XXWglO1ui7qmbKoezMdNTef 3cv15FyENFpHjx7cPQzdOLq4ieOdkjaHCCB4GkGqi7Mry/xxkX+kPrayLclsM/5EfRbL lz+8AYBlr2jJnsNoftjfjBJUNoHyQTVoPZyPb/wOSXpsMQjWt+gGKm++fLQZK0b9ooLw NSYgESGhBlvB45YgbdAVplmdoiJbMuhdVAdnp7BVACbdjLgcDHM5G0hrAax+b1oqnZF0 dQHR1VmSJRY1qaXM5Zn0Yw7Yl4hm8LNRtoRtxOrSJDS3qGZtEFCStf4VsJCs/7jnzvH6 /R1w== 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 w19si10899986pfi.200.2019.09.08.03.18.22; Sun, 08 Sep 2019 03:18:52 -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 S1726186AbfIGARc (ORCPT + 99 others); Fri, 6 Sep 2019 20:17:32 -0400 Received: from mga09.intel.com ([134.134.136.24]:32989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfIGARb (ORCPT ); Fri, 6 Sep 2019 20:17:31 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2019 17:17:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,474,1559545200"; d="scan'208";a="188476220" Received: from ppan-mobl1.gar.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.251.132.218]) by orsmga006.jf.intel.com with ESMTP; 06 Sep 2019 17:17:30 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v2] mesh: Handle messages sent to a fixed group address Date: Fri, 6 Sep 2019 17:17:29 -0700 Message-Id: <20190907001729.15839-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/mesh-defs.h | 2 ++ mesh/model.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mesh/mesh-defs.h b/mesh/mesh-defs.h index 1219e4939..885c30d3e 100644 --- a/mesh/mesh-defs.h +++ b/mesh/mesh-defs.h @@ -118,4 +118,6 @@ #define IS_GROUP(x) ((((x) >= GROUP_ADDRESS_LOW) && \ ((x) < FIXED_GROUP_HIGH)) || \ ((x) == ALL_NODES_ADDRESS)) + +#define IS_FIXED_GROUP_ADDRESS(x) ((x) == PROXIES_ADDRESS) #define IS_ALL_NODES(x) ((x) == ALL_NODES_ADDRESS) diff --git a/mesh/model.c b/mesh/model.c index 8f3d67ecf..8fe6378b3 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 || IS_FIXED_GROUP_ADDRESS(dst)) 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 (IS_FIXED_GROUP_ADDRESS(dst)) + break; } done: -- 2.21.0