You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/08/05 08:33:16 UTC
[mynewt-nimble] 01/02: nimble/ll: Fix spurious MIC failure
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 65716bde509975501782cbe2c74556cd4e5d7eca
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Aug 4 11:28:14 2022 +0200
nimble/ll: Fix spurious MIC failure
We should only check MIC failures on new PDUs.
If we acked encrypted packet, but peer did not receive that ack, the
encryption counter will be different on both sides for next packet. This
is ok since we should drop retransmission anyway. However, MIC failure
is always set by phy and failure is checked in LL before checking for
retransmissions, so it does not quite work as expected.
---
nimble/controller/src/ble_ll_conn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 4d1bf85e..ec758bff 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -3365,9 +3365,10 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
hdr_byte = rxbuf[0];
acl_len = rxbuf[1];
llid = hdr_byte & BLE_LL_DATA_HDR_LLID_MASK;
+ rxd_sn = hdr_byte & BLE_LL_DATA_HDR_SN_MASK;
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
- if (BLE_MBUF_HDR_MIC_FAILURE(hdr)) {
+ if (BLE_MBUF_HDR_MIC_FAILURE(hdr) && (rxd_sn != connsm->last_rxd_sn)) {
STATS_INC(ble_ll_conn_stats, mic_failures);
ble_ll_conn_timeout(connsm, BLE_ERR_CONN_TERM_MIC);
goto conn_rx_data_pdu_end;
@@ -3431,7 +3432,6 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
* Discard the received PDU if the sequence number is the same
* as the last received sequence number
*/
- rxd_sn = hdr_byte & BLE_LL_DATA_HDR_SN_MASK;
if (rxd_sn == connsm->last_rxd_sn) {
STATS_INC(ble_ll_conn_stats, data_pdu_rx_dup);
goto conn_rx_data_pdu_end;