From b5c554b6321f397d3186dfbedc66d2c1984459dd Mon Sep 17 00:00:00 2001 From: wangjialiang Date: Fri, 19 Mar 2021 18:15:23 +0800 Subject: [PATCH] ble_mesh: stack: Add filter old seq_auth packet menuconfig --- components/bt/esp_ble_mesh/Kconfig.in | 7 +++++++ components/bt/esp_ble_mesh/mesh_core/transport.c | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/bt/esp_ble_mesh/Kconfig.in b/components/bt/esp_ble_mesh/Kconfig.in index 22a7bb77cd..9552ef8f90 100644 --- a/components/bt/esp_ble_mesh/Kconfig.in +++ b/components/bt/esp_ble_mesh/Kconfig.in @@ -1070,6 +1070,13 @@ if BLE_MESH lets the state to be changed at any time. If IV Update test mode is going to be used, this option should be enabled. + config BLE_MESH_DISCARD_OLD_SEQ_AUTH + bool + default y + help + This option is used to decide whether discarding the old SeqAuth when + receiving a segmented message. + menu "BLE Mesh specific test option" config BLE_MESH_SELF_TEST diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index faac12dc3b..faabb6224c 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -1396,13 +1396,14 @@ static struct seg_rx *seg_rx_find(struct bt_mesh_net_rx *net_rx, continue; } - /* Return newer RX context in addition to an exact match, so - * the calling function can properly discard an old SeqAuth. - * Note: in Zephyr v1.14.0, ">=" is used here which does not - * seem to be a right operation, hence we still use the original - * "==" here. + /* When ">=" is used, return newer RX context in addition to an exact match, + * so the calling function can properly discard an old SeqAuth. */ +#if CONFIG_BLE_MESH_DISCARD_OLD_SEQ_AUTH + if (rx->seq_auth >= *seq_auth) { +#else if (rx->seq_auth == *seq_auth) { +#endif return rx; }