Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE Mesh When IV Update Procedure #17977

Closed
LingaoM opened this issue Aug 2, 2019 · 0 comments · Fixed by #18230
Closed

BLE Mesh When IV Update Procedure #17977

LingaoM opened this issue Aug 2, 2019 · 0 comments · Fixed by #18230
Assignees
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@LingaoM
Copy link
Collaborator

LingaoM commented Aug 2, 2019

According to the specification, IV update procedure only be initiated by any node is a member of the primary network, but it is not checked in the code.

int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
bool new_key, const struct bt_mesh_send_cb *cb,
void *cb_data)
{
const u8_t *enc, *priv;
u32_t seq;
int err;
BT_DBG("net_idx 0x%04x new_key %u len %u", sub->net_idx, new_key,
buf->len);
enc = sub->keys[new_key].enc;
priv = sub->keys[new_key].privacy;
err = bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_TX, priv);
if (err) {
BT_ERR("deobfuscate failed (err %d)", err);
return err;
}
err = bt_mesh_net_decrypt(enc, &buf->b, BT_MESH_NET_IVI_TX, false);
if (err) {
BT_ERR("decrypt failed (err %d)", err);
return err;
}
/* Update with a new sequence number */
seq = bt_mesh_next_seq();
buf->data[2] = seq >> 16;
buf->data[3] = seq >> 8;
buf->data[4] = seq;
err = bt_mesh_net_encrypt(enc, &buf->b, BT_MESH_NET_IVI_TX, false);
if (err) {
BT_ERR("encrypt failed (err %d)", err);
return err;
}
err = bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_TX, priv);
if (err) {
BT_ERR("obfuscate failed (err %d)", err);
return err;
}
bt_mesh_adv_send(buf, cb, cb_data);
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) &&
bt_mesh.seq > IV_UPDATE_SEQ_LIMIT) {
bt_mesh_beacon_ivu_initiator(true);
bt_mesh_net_iv_update(bt_mesh.iv_index + 1, true);
bt_mesh_net_sec_update(NULL);
}
return 0;
}

void bt_mesh_beacon_ivu_initiator(bool enable)
{
atomic_set_bit_to(bt_mesh.flags, BT_MESH_IVU_INITIATOR, enable);
if (enable) {
k_work_submit(&beacon_timer.work);
} else if (bt_mesh_beacon_get() == BT_MESH_BEACON_DISABLED) {
k_delayed_work_cancel(&beacon_timer);
}

@LingaoM LingaoM added the bug The issue is a bug, or the PR is fixing a bug label Aug 2, 2019
@jhedberg jhedberg added the priority: medium Medium impact/importance bug label Aug 13, 2019
jhedberg added a commit to jhedberg/zephyr that referenced this issue Aug 14, 2019
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes zephyrproject-rtos#17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
jhedberg added a commit that referenced this issue Aug 14, 2019
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes #17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
jhedberg added a commit to joerchan/zephyr that referenced this issue Aug 15, 2019
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes zephyrproject-rtos#17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
nashif pushed a commit that referenced this issue Aug 15, 2019
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes #17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
LeiW000 pushed a commit to LeiW000/zephyr that referenced this issue Sep 2, 2019
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.

Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().

Fixes zephyrproject-rtos#17977

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants