2020-01-08 21:01:31

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v2 0/2] Fix IV recovery procedure

v2: Separate actual bugfix from stylistic corrections

Rafał Gajda (2):
mesh: Fix IV recovery
mesh: Remove local_iv_index and local_ivu aliases

mesh/net.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)

--
2.23.0


2020-01-08 21:01:34

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/2] mesh: Fix IV recovery

From: Rafał Gajda <[email protected]>

This patch fixes saving IV received in SNB to storage.

Previously after creating new node with IV 0 (or loading node with
IV > 0 but after long inactivity) first received SNB should update IV
(and reset sequence number to 0 if necessary).

The bug would prevent new IV being saved in storage which resulted in
sequence number being set to 0 on first SNB received after every daemon
reset but IV never being updated.
---
mesh/net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mesh/net.c b/mesh/net.c
index 23565c11d..d7ce5493d 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2657,7 +2657,7 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
if ((iv_index - ivu) > (local_iv_index - local_ivu))
mesh_net_set_seq_num(net, 0);

- if (ivu != net->iv_update || local_iv_index != net->iv_index) {
+ if (ivu != net->iv_update || iv_index != net->iv_index) {
struct mesh_config *cfg = node_config_get(net->node);

mesh_config_write_iv_index(cfg, iv_index, ivu);
--
2.23.0

2020-01-08 21:01:46

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/2] mesh: Remove local_iv_index and local_ivu aliases

From: Rafał Gajda <[email protected]>

---
mesh/net.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/mesh/net.c b/mesh/net.c
index d7ce5493d..0a4d2e72c 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2607,14 +2607,7 @@ static void update_kr_state(struct mesh_subnet *subnet, bool kr, uint32_t id)
static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
bool ivu)
{
- uint32_t local_iv_index;
- bool local_ivu;
-
- /* Save original settings to differentiate what has changed */
- local_iv_index = net->iv_index;
- local_ivu = net->iv_update;
-
- if ((iv_index - ivu) > (local_iv_index - local_ivu)) {
+ if ((iv_index - ivu) > (net->iv_index - net->iv_update)) {
/* Don't accept IV_Index changes when performing SAR Out */
if (l_queue_length(net->sar_out))
return;
@@ -2638,23 +2631,24 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
}
} else if (ivu) {
/* Ignore beacons with IVU if they come too soon */
- if (!local_ivu && net->iv_upd_state == IV_UPD_NORMAL_HOLD) {
+ if (!net->iv_update &&
+ net->iv_upd_state == IV_UPD_NORMAL_HOLD) {
l_error("Update attempted too soon");
return;
}

- if (!local_ivu) {
+ if (!net->iv_update) {
l_info("iv_upd_state = IV_UPD_UPDATING");
net->iv_upd_state = IV_UPD_UPDATING;
net->iv_update_timeout = l_timeout_create(
IV_IDX_UPD_MIN, iv_upd_to, net, NULL);
}
- } else if (local_ivu) {
+ } else if (net->iv_update) {
l_error("IVU clear attempted too soon");
return;
}

- if ((iv_index - ivu) > (local_iv_index - local_ivu))
+ if ((iv_index - ivu) > (net->iv_index - net->iv_update))
mesh_net_set_seq_num(net, 0);

if (ivu != net->iv_update || iv_index != net->iv_index) {
--
2.23.0

2020-01-08 22:06:38

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 0/2] Fix IV recovery procedure

Patchset Applied
On Wed, 2020-01-08 at 22:01 +0100, Michał Lowas-Rzechonek wrote:
> v2: Separate actual bugfix from stylistic corrections
>
> Rafał Gajda (2):
> mesh: Fix IV recovery
> mesh: Remove local_iv_index and local_ivu aliases
>
> mesh/net.c | 20 +++++++-------------
> 1 file changed, 7 insertions(+), 13 deletions(-)
>