summaryrefslogtreecommitdiff
path: root/mesh/net.c
diff options
context:
space:
mode:
authorRafaƂ Gajda <rafal.gajda@silvair.com>2020-04-07 11:32:51 +0200
committerBrian Gix <brian.gix@intel.com>2020-04-08 10:08:31 -0700
commit60423fed392a9f454a696622ce6afab61a610bef (patch)
treec953c0fb9c0745c60d1641bc651d784bf27cf033 /mesh/net.c
parent5b294a56664a8c7088d1eea2bc089d812a515794 (diff)
downloadbluez-60423fed392a9f454a696622ce6afab61a610bef.tar.gz
mesh: Ignore beacons with IVU if IV already updated
When daemon receives beacon with IV=n+1, IVU=False it will start sending messages with new IV and set sequence to 0. However if daemon receives another beacon with IV=n+1, IVU=True it will go back to sending messages with old IV=n (IVU set to True). Because sequence number has been reset those messages will be dropped by replay protection and node will lose communication. Once IV is updated daemon should not go back to using the old value. This patch adds beacon rejection if IV has already been updated.
Diffstat (limited to 'mesh/net.c')
-rw-r--r--mesh/net.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/mesh/net.c b/mesh/net.c
index 9a56d2ee8..bfb9c4435 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2696,6 +2696,10 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
/* If first beacon seen, accept without judgement */
if (net->iv_upd_state == IV_UPD_INIT) {
if (ivu) {
+ /* Ignore beacons with IVU if IV already updated */
+ if (iv_index == net->iv_index && !net->iv_update)
+ return;
+
/* Other devices will be accepting old or new iv_index,
* but we don't know how far through update they are.
* Starting permissive state will allow us maximum
@@ -2717,6 +2721,10 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
return;
}
+ /* Ignore beacons with IVU if IV already updated */
+ if (iv_index == net->iv_index)
+ return;
+
if (!net->iv_update) {
l_info("iv_upd_state = IV_UPD_UPDATING");
net->iv_upd_state = IV_UPD_UPDATING;