Merge branch 'bugfix/ble_mesh_proxy_cfg_replay_v3.3' into 'release/v3.3'
Bugfix/ble mesh proxy cfg replay (v3.3) See merge request espressif/esp-idf!10821
This commit is contained in:
commit
7d8d841659
|
@ -2912,17 +2912,25 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||||
phase == BLE_MESH_KR_PHASE_2) {
|
phase == BLE_MESH_KR_PHASE_2) {
|
||||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||||
sub->kr_flag = 1;
|
sub->kr_flag = 1;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
BT_DBG("Storing kr phase persistently");
|
||||||
|
bt_mesh_store_subnet(sub);
|
||||||
|
}
|
||||||
|
|
||||||
bt_mesh_net_beacon_update(sub);
|
bt_mesh_net_beacon_update(sub);
|
||||||
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
||||||
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
||||||
phase == BLE_MESH_KR_PHASE_3) {
|
phase == BLE_MESH_KR_PHASE_3) {
|
||||||
|
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||||
|
sub->kr_flag = 0;
|
||||||
bt_mesh_net_revoke_keys(sub);
|
bt_mesh_net_revoke_keys(sub);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||||
friend_cred_refresh(ctx->net_idx);
|
friend_cred_refresh(ctx->net_idx);
|
||||||
}
|
}
|
||||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
|
||||||
sub->kr_flag = 0;
|
|
||||||
bt_mesh_net_beacon_update(sub);
|
bt_mesh_net_beacon_update(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -501,6 +501,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub)
|
||||||
BT_DBG("idx 0x%04x", sub->net_idx);
|
BT_DBG("idx 0x%04x", sub->net_idx);
|
||||||
|
|
||||||
memcpy(&sub->keys[0], &sub->keys[1], sizeof(sub->keys[0]));
|
memcpy(&sub->keys[0], &sub->keys[1], sizeof(sub->keys[0]));
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
BT_DBG("Store updated NetKey persistently");
|
BT_DBG("Store updated NetKey persistently");
|
||||||
bt_mesh_store_subnet(sub);
|
bt_mesh_store_subnet(sub);
|
||||||
|
@ -515,6 +516,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub)
|
||||||
|
|
||||||
memcpy(&key->keys[0], &key->keys[1], sizeof(key->keys[0]));
|
memcpy(&key->keys[0], &key->keys[1], sizeof(key->keys[0]));
|
||||||
key->updated = false;
|
key->updated = false;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
BT_DBG("Store updated AppKey persistently");
|
BT_DBG("Store updated AppKey persistently");
|
||||||
bt_mesh_store_app_key(key);
|
bt_mesh_store_app_key(key);
|
||||||
|
@ -535,6 +537,12 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
|
||||||
if (sub->kr_phase == BLE_MESH_KR_PHASE_1) {
|
if (sub->kr_phase == BLE_MESH_KR_PHASE_1) {
|
||||||
BT_INFO("Phase 1 -> Phase 2");
|
BT_INFO("Phase 1 -> Phase 2");
|
||||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
BT_DBG("Storing kr phase persistently");
|
||||||
|
bt_mesh_store_subnet(sub);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -553,12 +561,15 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
|
||||||
*/
|
*/
|
||||||
case BLE_MESH_KR_PHASE_2:
|
case BLE_MESH_KR_PHASE_2:
|
||||||
BT_INFO("KR Phase 0x%02x -> Normal", sub->kr_phase);
|
BT_INFO("KR Phase 0x%02x -> Normal", sub->kr_phase);
|
||||||
|
|
||||||
|
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||||
bt_mesh_net_revoke_keys(sub);
|
bt_mesh_net_revoke_keys(sub);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||||
friend_cred_refresh(sub->net_idx);
|
friend_cred_refresh(sub->net_idx);
|
||||||
}
|
}
|
||||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,6 +593,10 @@ void bt_mesh_rpl_reset(void)
|
||||||
} else {
|
} else {
|
||||||
rpl->old_iv = true;
|
rpl->old_iv = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||||
|
bt_mesh_store_rpl(rpl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
#include "beacon.h"
|
#include "beacon.h"
|
||||||
|
#include "transport.h"
|
||||||
#include "mesh_common.h"
|
#include "mesh_common.h"
|
||||||
#include "foundation.h"
|
#include "foundation.h"
|
||||||
#include "proxy_client.h"
|
#include "proxy_client.h"
|
||||||
|
@ -171,6 +172,14 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rx.local_match = 1U;
|
||||||
|
|
||||||
|
if (bt_mesh_rpl_check(&rx, NULL)) {
|
||||||
|
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
||||||
|
rx.ctx.addr, rx.ctx.recv_dst, rx.seq);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove network headers */
|
/* Remove network headers */
|
||||||
net_buf_simple_pull(&buf, BLE_MESH_NET_HDR_LEN);
|
net_buf_simple_pull(&buf, BLE_MESH_NET_HDR_LEN);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "prov.h"
|
#include "prov.h"
|
||||||
#include "beacon.h"
|
#include "beacon.h"
|
||||||
#include "access.h"
|
#include "access.h"
|
||||||
|
#include "transport.h"
|
||||||
#include "foundation.h"
|
#include "foundation.h"
|
||||||
#include "proxy_server.h"
|
#include "proxy_server.h"
|
||||||
|
|
||||||
|
@ -308,6 +309,14 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rx.local_match = 1U;
|
||||||
|
|
||||||
|
if (bt_mesh_rpl_check(&rx, NULL)) {
|
||||||
|
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
||||||
|
rx.ctx.addr, rx.ctx.recv_dst, rx.seq);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove network headers */
|
/* Remove network headers */
|
||||||
net_buf_simple_pull(&buf, BLE_MESH_NET_HDR_LEN);
|
net_buf_simple_pull(&buf, BLE_MESH_NET_HDR_LEN);
|
||||||
|
|
||||||
|
|
|
@ -665,7 +665,7 @@ static void update_rpl(struct bt_mesh_rpl *rpl, struct bt_mesh_net_rx *rx)
|
||||||
* updated (needed for segmented messages), whereas if a NULL match is given
|
* updated (needed for segmented messages), whereas if a NULL match is given
|
||||||
* the RPL is immediately updated (used for unsegmented messages).
|
* the RPL is immediately updated (used for unsegmented messages).
|
||||||
*/
|
*/
|
||||||
static bool is_replay(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match)
|
bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1058,7 +1058,7 @@ static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_replay(rx, NULL)) {
|
if (bt_mesh_rpl_check(rx, NULL)) {
|
||||||
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
||||||
rx->ctx.addr, rx->ctx.recv_dst, rx->seq);
|
rx->ctx.addr, rx->ctx.recv_dst, rx->seq);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1486,7 +1486,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_replay(net_rx, &rpl)) {
|
if (bt_mesh_rpl_check(net_rx, &rpl)) {
|
||||||
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x",
|
||||||
net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq);
|
net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -114,6 +114,8 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx);
|
||||||
void bt_mesh_trans_init(void);
|
void bt_mesh_trans_init(void);
|
||||||
void bt_mesh_trans_deinit(bool erase);
|
void bt_mesh_trans_deinit(bool erase);
|
||||||
|
|
||||||
|
bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match);
|
||||||
|
|
||||||
void bt_mesh_heartbeat_send(void);
|
void bt_mesh_heartbeat_send(void);
|
||||||
|
|
||||||
int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,
|
int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx,
|
||||||
|
|
Loading…
Reference in a new issue