Skip to contentSkip to conversation

mesh: Fix IV_Index recovery logic

PATCH New Brian Gix 1 participant 1 message Oct 7, 2019 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 mesh: Fix IV_Index recovery logic

This fix divorces the state tracking of the IV Index updating stages from the actual realtime setting of IV_Index and IV_Update values.

We are more permissive about what we accept as IV_Index and the IVU boolean from incoming Secure Network Beacons on Startup, in case the daemon has "Been Away" from the mesh network. But we need to more carefully track what IV_Index we use for outgoing messages, and the instant we reset the outgoing Sequence number to Zero. So iv_index, and iv_update are now fully independant of the iv_upd_state.

---
 mesh/mesh-config-json.c |  3 +-
 mesh/net.c              | 83 ++++++++++++++++++++++++++---------------
 2 files changed, 55 insertions(+), 31 deletions(-)
mesh/mesh-config-json.c +2 -1
index 198fef518..df58cbd7d 100644
@@ -2057,7 +2057,8 @@ bool mesh_config_write_seq_number(struct mesh_config *cfg, uint32_t seq,
 		return mesh_config_save(cfg, true, NULL, NULL);
 	}
 
-	if (get_int(cfg->jnode, "sequenceNumber", &value))
+	/* If resetting seq to Zero, make sure cached value reset as well */
+	if (seq && get_int(cfg->jnode, "sequenceNumber", &value))
 		cached = (uint32_t)value;
 
 	/*
mesh/net.c +53 -30

168 lines not on this page · raw message

Signature · 1 line
2.21.0