mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-11-12 07:20:33 +00:00
host/mesh: Remove outated RPL entry from persistent storage
This commit fixes a bug where outdated RPL entries might not be removed properly from the persistent storage making those entries dead. This is port of 1b129c50c2fdb4d7e8a270356dd5fba623deb1cc
This commit is contained in:
committed by
Krzysztof Kopyściński
parent
03076b3eb9
commit
275ea539a8
+33
-26
@@ -32,6 +32,27 @@ static inline int rpl_idx(const struct bt_mesh_rpl *rpl)
|
||||
return rpl - &replay_list[0];
|
||||
}
|
||||
|
||||
static void clear_rpl(struct bt_mesh_rpl *rpl)
|
||||
{
|
||||
int err;
|
||||
char path[18];
|
||||
|
||||
if (!rpl->src) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintk(path, sizeof(path), "bt_mesh/RPL/%x", rpl->src);
|
||||
err = settings_save_one(path, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear RPL");
|
||||
} else {
|
||||
BT_DBG("Cleared RPL");
|
||||
}
|
||||
|
||||
(void)memset(rpl, 0, sizeof(*rpl));
|
||||
atomic_clear_bit(store, rpl_idx(rpl));
|
||||
}
|
||||
|
||||
static void schedule_rpl_store(struct bt_mesh_rpl *entry)
|
||||
{
|
||||
atomic_set_bit(store, rpl_idx(entry));
|
||||
@@ -171,13 +192,16 @@ void bt_mesh_rpl_reset(void)
|
||||
|
||||
if (rpl->src) {
|
||||
if (rpl->old_iv) {
|
||||
(void)memset(rpl, 0, sizeof(*rpl));
|
||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||
clear_rpl(rpl);
|
||||
} else {
|
||||
(void)memset(rpl, 0, sizeof(*rpl));
|
||||
}
|
||||
} else {
|
||||
rpl->old_iv = true;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||
schedule_rpl_store(rpl);
|
||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||
schedule_rpl_store(rpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,6 +270,10 @@ static void store_rpl(struct bt_mesh_rpl *entry)
|
||||
char *str;
|
||||
int err;
|
||||
|
||||
if (!entry->src) {
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("src 0x%04x seq 0x%06x old_iv %u", entry->src,
|
||||
(unsigned) entry->seq, entry->old_iv);
|
||||
|
||||
@@ -269,27 +297,6 @@ static void store_rpl(struct bt_mesh_rpl *entry)
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_rpl(struct bt_mesh_rpl *rpl)
|
||||
{
|
||||
int err;
|
||||
char path[18];
|
||||
|
||||
if (!rpl->src) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintk(path, sizeof(path), "bt_mesh/RPL/%x", rpl->src);
|
||||
err = settings_save_one(path, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear RPL");
|
||||
} else {
|
||||
BT_DBG("Cleared RPL");
|
||||
}
|
||||
|
||||
(void)memset(rpl, 0, sizeof(*rpl));
|
||||
atomic_clear_bit(store, rpl_idx(rpl));
|
||||
}
|
||||
|
||||
static void store_pending_rpl(struct bt_mesh_rpl *rpl)
|
||||
{
|
||||
BT_DBG("");
|
||||
|
||||
Reference in New Issue
Block a user