Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp12859668pxu; Sat, 2 Jan 2021 14:31:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJybbHjDEfh8dwiI+08mSeeN2S3+HXvyUt097sCjUgmaGO0GBe+2TIqwUmMKTp9a78HdoC1Q X-Received: by 2002:a17:906:3881:: with SMTP id q1mr62844081ejd.490.1609626677306; Sat, 02 Jan 2021 14:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609626677; cv=none; d=google.com; s=arc-20160816; b=TNCtxymtxGdv0cKNLlFRgkt1pBaGttqKe4il8ZsvFCV8KhDgPNmpMNzIDX14Ga1iC2 vmcFgv08e4DIHzkeUf7kXswxhS5LjCCWbufNGHG1dADEiF98Nw+hmibX5l1huEd2EoBx nu1yTs6XaUlJ2A8rfv6f6F1Q+QCsMBCHYQgbF1QNPLZKsp2RZVIg4XwB2WiOdzE3Gj5m 50799cj+0f44fgIgHxKbs6g0qe1IfZo/0J3j0hR55JWw2rbLVb1OkJtGspoayAstwSdn DQs6cho74y98il1a7o8bkbMrnaGdriKbnatv6RhqXflBs91i+o410Vl8buXhYc9EQnkI /l3g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dAydG9/MsjU2TJrufkEb0tkJKZeFuS2f9kNKs58jbcY=; b=kJPTrKtLmBQqhPXG3twlTa24iexopDO/tjTL/UA/fsZNujT3sfIM8ZhJMpflc3OdvF FlF9VUdzAOiTRAZzn/vipxde42iJZsnZEaOty2Jhs5wrCNtkqGiGMdqMluCsm0uAOOzF P3+SbpnemEUkXuGMTPM4jVmxBnLymQSPFead+DWiNrm8sGo7VEvq0RM9KGdkLYvR+bql wvBrBg/dXzPzQ+5YNo6Y7ve2upA30JfNTcjOI9/TFVBLIlwmPcIKBrd9lU+Iw9xfI3Pv bamn6vyPqSlg3VZUUh/2j6LJvcUvKx8zjFiPQqnXhma1pne0caxJCe5quDZtYnoo0g5h mUHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mnmoran.org header.s=dkim header.b=dUpZOjv1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm17si27188763ejb.131.2021.01.02.14.30.40; Sat, 02 Jan 2021 14:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mnmoran.org header.s=dkim header.b=dUpZOjv1; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbhABW24 (ORCPT + 99 others); Sat, 2 Jan 2021 17:28:56 -0500 Received: from hoster906.com ([192.252.156.27]:49006 "EHLO hoster906.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbhABW2z (ORCPT ); Sat, 2 Jan 2021 17:28:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=mnmoran.org; h=from:to :cc:subject:date:message-id:mime-version :content-transfer-encoding; s=dkim; bh=3a3ozUQKZL7l4Gq/fhNfenKeS ZMe3rXq3sm3ISX9+7c=; b=dUpZOjv1yUK1BjvfOD3BDG7xYCP6YT65ZXU7LpEDr QJbZgvI9VymZQf0uHgbkYVoSJ0w9zbdI08faBL/wiVcWGpD5irTbKNfCEbK44yD/ YdIQ4N+RA5ky3IlwTO8V91WOcALj8kM+W4cIcoF5D74kUhrxPbi98o1W0ToRkpQu Jg= Received: (qmail 37574 invoked by uid 503); 2 Jan 2021 22:28:14 -0000 Received: from unknown (HELO knuckle.Home) (mike@mnmoran.org@40.134.89.129) by hoster906.com with ESMTPA; 2 Jan 2021 22:28:14 -0000 From: "Michael N. Moran" To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com, "Michael N. Moran" Subject: [PATCH BlueZ] mesh: Update AppKeys on transition to Phase 0 Date: Sat, 2 Jan 2021 17:27:55 -0500 Message-Id: <20210102222755.71019-1-mike@mnmoran.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org At the end of the mesh Key Refresh procedure when a subnet transitions to Phase 0, local AppKeys that were updated were not updating until the bluetooth-meshd daemon was restarted. This patch iterates the AppKeys at the end of mesh Key Refresh when the subnet transitions to Phase 0, setting the new state of each updated AppKey. --- mesh/appkey.c | 18 ++++++++++++++++++ mesh/appkey.h | 1 + mesh/net.c | 2 ++ 3 files changed, 21 insertions(+) diff --git a/mesh/appkey.c b/mesh/appkey.c index 549f5a80d..504f67aab 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -50,6 +50,24 @@ static bool match_bound_key(const void *a, const void *b) return key->net_idx == idx; } +void finish_app_key(void *a, void *b) +{ + struct mesh_app_key *key = a; + uint16_t net_idx = L_PTR_TO_UINT(b); + + if (key->net_idx != net_idx) + return; + + if (key->new_key_aid == NET_NID_INVALID) + return; + + key->key_aid = key->new_key_aid; + + key->new_key_aid = NET_NID_INVALID; + + memcpy(key->key, key->new_key, 16); +} + static struct mesh_app_key *app_key_new(void) { struct mesh_app_key *key = l_new(struct mesh_app_key, 1); diff --git a/mesh/appkey.h b/mesh/appkey.h index 3bb70445b..c83dd03f6 100644 --- a/mesh/appkey.h +++ b/mesh/appkey.h @@ -16,6 +16,7 @@ struct mesh_app_key; bool appkey_key_init(struct mesh_net *net, uint16_t net_idx, uint16_t app_idx, uint8_t *key_value, uint8_t *new_key_value); void appkey_key_free(void *data); +void finish_app_key(void *a, void *b); const uint8_t *appkey_get_key(struct mesh_net *net, uint16_t app_idx, uint8_t *key_id); int appkey_get_key_idx(struct mesh_app_key *app_key, diff --git a/mesh/net.c b/mesh/net.c index b24cdba77..22ec03d7a 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -2600,6 +2600,8 @@ static int key_refresh_finish(struct mesh_net *net, uint16_t idx) l_queue_foreach(net->friends, frnd_kr_phase3, net); + l_queue_foreach(net->app_keys, finish_app_key, L_UINT_TO_PTR(idx)); + if (!mesh_config_net_key_set_phase(node_config_get(net->node), idx, KEY_REFRESH_PHASE_NONE)) return MESH_STATUS_STORAGE_FAIL; -- 2.26.2