Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp937860rwb; Mon, 26 Sep 2022 07:43:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cm1MYQ4RPOtff3tNCu7xwzy9IV7zfbIjnuiH8MOwOdW0jau2J7VkowZLI4C6ZM4f8AAz7 X-Received: by 2002:a63:83c8:0:b0:43c:bc88:ee67 with SMTP id h191-20020a6383c8000000b0043cbc88ee67mr3577627pge.154.1664203386917; Mon, 26 Sep 2022 07:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664203386; cv=none; d=google.com; s=arc-20160816; b=EEBzddWk7r62ViHl2gOe3tBFpqY5N7DfrQo7u9J32sdJqK1i7PteRhr30u9Cj3Zstm M3oigolXAveWIP5dkDvIiG2Ij5rKo5cA0C+UrJCmHWcxxesDfrd/Wimsv9Bnl6j3zrHW j/cz8HRfuAKwq8S5TRDfLezP7Vl0p//TBCiXIbtwWu1swiWr8rLrAiSqTUQoC1Pbd/vS t3lJ+rdBgd2wP76iCJU0uiyO4phqTE5eDk2CEN40tMNaOZb+RE6FGgDZK56OItPjruNw RjYGd6+dVY04fbmXxZDygMQ7b90X3T725mfO3ZunFsJoLBMkdkUn9IeP1oG4ZjJvBao2 30og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VfM3ZzE05GwwXX4l9LeNKTgobgIXih9q+lI5k/19aak=; b=0rcybFpUD6NYDVXEyShE8T46Dhm8X8G2zkCadTLIO/4rX5IRv+/px0plFgIrzVrVnz JSY1z/sDKGdps+ThsVIUisLHQo5rC70fVr5yVXd/s0DBjpVVjsWFnozn72QdYF0AmCT7 /cXcUP1H7BSdb+S8RU1SXzpEA+nPnBa/lonW3hvIe9IaTDReu8rqEP8bpw4Dj2V7Knej drUVAM13N89ZluBPnXrw+GHacgMypcTmWFDxp3Qjs/FApqZVxScfqlodYzKHZD7pBlTW xVZ6tizQ4mBR5cEEdQlYwBXXn/YaBrRqTQh20Vu98u83MdkCZcHk270oKXYwZqCIkV1Q 3PhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu11-20020a056a00410b00b0052e6c99a571si17933064pfb.323.2022.09.26.07.41.54; Mon, 26 Sep 2022 07:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235061AbiIZOlW (ORCPT + 99 others); Mon, 26 Sep 2022 10:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235058AbiIZOk5 (ORCPT ); Mon, 26 Sep 2022 10:40:57 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95011F390E for ; Mon, 26 Sep 2022 06:01:47 -0700 (PDT) Received: from 212-17-98-152.static.upcbusiness.at ([212.17.98.152] helo=lexx.office.loytec.com) by voyager.loytec.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocnk1-00046w-LX for linux-bluetooth@vger.kernel.org; Mon, 26 Sep 2022 15:01:45 +0200 Received: from loytec-dev-vm.delta.corp ([10.101.25.21]) by lexx.office.loytec.com (8.15.2/8.15.2/Some OS 1.2.3-4.5) with ESMTP id 28QD1bCX1107873; Mon, 26 Sep 2022 15:01:43 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 3/4] mesh: Correct HB sub state updates Date: Mon, 26 Sep 2022 15:01:09 +0200 Message-Id: <20220926130110.2146-4-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220926130110.2146-1-isak.westin@loytec.com> References: <20220926130110.2146-1-isak.westin@loytec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 212.17.98.152 X-SA-Exim-Mail-From: isak.westin@loytec.com X-SA-Exim-Scanned: No (on voyager.loytec.com); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If heartbeat subscription is disabled, all fields should be set to zero but collected data should be preserved. If HB subscription is enabled, the collected data should be reset (which includes Min Hops = 0x7f). HB subscription is disabled by setting any of the following fields to zero: Source, destination or period log. HB subscription is enabled by setting all the same fields to valid values. --- mesh/cfgmod-server.c | 2 +- mesh/net.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9c5edf551..55a2d896b 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -496,7 +496,7 @@ static uint16_t hb_subscription_get(struct mesh_node *node, int status) n += 2; msg[n++] = uint32_to_log(time_now.tv_sec); msg[n++] = sub->count != 0xffff ? uint32_to_log(sub->count) : 0xff; - msg[n++] = sub->count ? sub->min_hops : 0; + msg[n++] = sub->min_hops; msg[n++] = sub->max_hops; return n; diff --git a/mesh/net.c b/mesh/net.c index 699469284..7fec98531 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -3608,24 +3608,14 @@ int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, return MESH_STATUS_UNSPECIFIED_ERROR; /* Check if the subscription should be disabled */ - if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst)) { + if (IS_UNASSIGNED(src) || IS_UNASSIGNED(dst) || !period_log) { if (IS_GROUP(sub->dst)) mesh_net_dst_unreg(net, sub->dst); + /* Preserve collected data, but disable */ sub->enabled = false; sub->dst = UNASSIGNED_ADDRESS; sub->src = UNASSIGNED_ADDRESS; - sub->count = 0; - sub->period = 0; - sub->min_hops = 0; - sub->max_hops = 0; - - } else if (!period_log && src == sub->src && dst == sub->dst) { - if (IS_GROUP(sub->dst)) - mesh_net_dst_unreg(net, sub->dst); - - /* Preserve collected data, but disable */ - sub->enabled = false; sub->period = 0; } else { @@ -3637,12 +3627,12 @@ int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, mesh_net_dst_reg(net, dst); } - sub->enabled = !!period_log; + sub->enabled = true; sub->src = src; sub->dst = dst; sub->count = 0; sub->period = log_to_uint32(period_log); - sub->min_hops = 0x00; + sub->min_hops = 0x7f; sub->max_hops = 0x00; gettimeofday(&time_now, NULL); sub->start = time_now.tv_sec; @@ -3656,8 +3646,6 @@ int mesh_net_set_heartbeat_sub(struct mesh_net *net, uint16_t src, uint16_t dst, return MESH_STATUS_SUCCESS; } - sub->min_hops = 0xff; - if (!sub->timer) sub->timer = l_timeout_create(sub->period, hb_sub_timeout_func, net, NULL); -- 2.20.1