You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2020/09/15 06:41:48 UTC

[mynewt-nimble] 07/09: mesh/beacon.c: Fix key refresh procedure Key refresh procedure was ignored on non-primary subnet.

This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2c7186445fa51331f28618dab1ae535134784ce0
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Thu Sep 3 11:27:17 2020 +0200

    mesh/beacon.c: Fix key refresh procedure
    Key refresh procedure was ignored on non-primary subnet.
---
 nimble/host/mesh/src/beacon.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c
index cd540aa..4f848c6 100644
--- a/nimble/host/mesh/src/beacon.c
+++ b/nimble/host/mesh/src/beacon.c
@@ -329,6 +329,13 @@ static void secure_beacon_recv(struct os_mbuf *buf)
 
 	cache_add(data, sub);
 
+	kr_change = bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(flags), new_key);
+	if (kr_change) {
+		bt_mesh_net_beacon_update(sub);
+		/* Key Refresh without IV Update only impacts one subnet */
+		bt_mesh_net_sec_update(sub);
+	}
+
 	/* If we have NetKey0 accept initiation only from it */
 	if (bt_mesh_subnet_get(BT_MESH_KEY_PRIMARY) &&
 	    sub->net_idx != BT_MESH_KEY_PRIMARY) {
@@ -347,17 +354,9 @@ static void secure_beacon_recv(struct os_mbuf *buf)
 
 	iv_change = bt_mesh_net_iv_update(iv_index, BT_MESH_IV_UPDATE(flags));
 
-	kr_change = bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(flags), new_key);
-	if (kr_change) {
-		bt_mesh_net_beacon_update(sub);
-	}
-
 	if (iv_change) {
 		/* Update all subnets */
 		bt_mesh_net_sec_update(NULL);
-	} else if (kr_change) {
-		/* Key Refresh without IV Update only impacts one subnet */
-		bt_mesh_net_sec_update(sub);
 	}
 
 update_stats: