Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6105081ybx; Mon, 11 Nov 2019 04:00:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzQYw8GXC6PbsUCpEfnBVTfkXZAMpfPzoQaMrkXsU08YOYI7GTsoFs2t93ZbHkdvQZdaskL X-Received: by 2002:adf:e346:: with SMTP id n6mr19507618wrj.234.1573473659170; Mon, 11 Nov 2019 04:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573473659; cv=none; d=google.com; s=arc-20160816; b=gSjFFB/6U9yJ/hYfp0yeXaANX1KBY3+ZGH7S/vGU+CAb1O4ifxZQKlALaIWyiGCJBE n7joIPnNPI5rsJUP6bcoy7wG8I0d5Zx98DZQ07M93QNM4DjneT/gKFE6XM54J+CAmIj5 j481WfAn0lLGBUKZUinPkC+WFATNEKKMmV+8Gy3txOM088BypntbXCSEApVl7rvRnbDn AOPjVNzzyeZTH6vz/eGIHoyMc4na3WEKqvup/d1YubZyS39v5l1xm17+HtKn0fP6IF+x aLwPXjkr+496efGPr0D61u6ElIqOkB3vTZU+TnzYPz6Lhu0KyWWp9D5Wm4IIdnn39Ii/ gcKw== 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=buVoJYhL+Ij0ZVGEz58GtB2cqr+gBAdPWYqse0+BfmM=; b=LZFTdhixK4ZC/c0HAfToJXUUaTP6BjN2tmAB/yQV5X+pO9dBI/QaI6kfM3nSA6J7y1 zfxdk2KTw/8UKsTuyXy+m6/3oqRdnygWgWKfetN7aJTr4En+3LA84LgOzu0V1jJXZxom JewdSLcVIb47zP7aPxkxnIyK7SV2FtuvzdWyA1J+sqjfDZpkLrfUuuFCD8bChAWPSlzE WCtIxh735RiRi+GVDt1+6+dSoyzwsP9VqydOq3ch/5GmYOD+VUx7Qnh5d5MuhQQwBaWY vKmOEp0TiJTLWTnmsDtNUqWoMwTg/r/tjh038HssD2td3VRGYDhOvBzhCs89pL9AR7dn BAOw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d47si11821436ede.139.2019.11.11.04.00.21; Mon, 11 Nov 2019 04:00:59 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfKKMAM (ORCPT + 99 others); Mon, 11 Nov 2019 07:00:12 -0500 Received: from hall.aurel32.net ([195.154.113.88]:54250 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbfKKMAL (ORCPT ); Mon, 11 Nov 2019 07:00:11 -0500 Received: from [2a01:e35:2fdd:a4e1:fe91:fc89:bc43:b814] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iU8Mc-0006et-By; Mon, 11 Nov 2019 13:00:10 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.92.3) (envelope-from ) id 1iU8Mb-0000vq-D0; Mon, 11 Nov 2019 13:00:09 +0100 From: Aurelien Jarno To: linux-bluetooth@vger.kernel.org Cc: Aurelien Jarno Subject: [PATCH BlueZ] mesh: fix node default TTL Date: Mon, 11 Nov 2019 13:00:07 +0100 Message-Id: <20191111120007.3511-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.24.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 There is a confusion between the node default TTL (section 4.2.7) and the publish TTL (section 4.2.2.5): - The node default TTL can only take values 0x00, and 0x02 to 0x7f. The value 0xff is not prohibited. - The publish TTL can take values 0x00 to 0x7f, as well as 0xff which means use the node default TTL. Currently the default node TTL is set to 0xff (DEFAULT_TTL), and read_default_ttl() also allows such a value. This patch fixes that to use 0x7f (TTL_MASK) as the default value instead. Note that the code handling OP_CONFIG_DEFAULT_TTL_SET correctly use 0x7f (TTL_MASK) for the upper allowed limit. --- mesh/mesh-config-json.c | 2 +- mesh/node.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index b2cff6824..5ca2961b0 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -358,7 +358,7 @@ static bool read_default_ttl(json_object *jobj, uint8_t *ttl) if (!val && errno == EINVAL) return false; - if (val < 0 || val == 1 || val > DEFAULT_TTL) + if (val < 0 || val == 1 || val > TTL_MASK) return false; *ttl = (uint8_t) val; diff --git a/mesh/node.c b/mesh/node.c index e23f32dd1..5dcffe6f7 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -672,7 +672,7 @@ struct l_queue *node_get_element_models(struct mesh_node *node, uint8_t node_default_ttl_get(struct mesh_node *node) { if (!node) - return DEFAULT_TTL; + return TTL_MASK; return node->ttl; } @@ -1352,7 +1352,7 @@ static void set_defaults(struct mesh_node *node) node->friend = MESH_MODE_UNSUPPORTED; node->beacon = MESH_MODE_DISABLED; node->relay.mode = MESH_MODE_DISABLED; - node->ttl = DEFAULT_TTL; + node->ttl = TTL_MASK; node->seq_number = DEFAULT_SEQUENCE_NUMBER; /* Add configuration server model on primary element */ -- 2.24.0