This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new a35cb28e nimble/ll: Drop received PDU if it is handled after scan was 
stopped
a35cb28e is described below

commit a35cb28ef066ee32ef0b24991f5b2f9e8ea4bc25
Author: Szymon Janc <[email protected]>
AuthorDate: Fri Sep 15 16:41:18 2023 +0200

    nimble/ll: Drop received PDU if it is handled after scan was stopped
    
    When doing continuous scan and channel is changed close to scan stop
    it is possible that PDU is received before interval timer is cancelled
    and RX is disabled. This may lead to processing received PDU only after
    scanner is already stopped. While this case was already handled in LL
    task it was not correctly handled in ISR. If this happen simply mark
    PDU to be ignored by LL and don't process it in ISR.
    
    This is more likely to happen when small scan window is used.
    
    Mostly affects initiator state as this may lead to assert when happen
    after CONNECTION_IND was already sent.
---
 nimble/controller/include/controller/ble_ll.h | 1 +
 nimble/controller/src/ble_ll.c                | 1 +
 nimble/controller/src/ble_ll_scan.c           | 5 +++++
 3 files changed, 7 insertions(+)

diff --git a/nimble/controller/include/controller/ble_ll.h 
b/nimble/controller/include/controller/ble_ll.h
index 408f03b6..7247f31d 100644
--- a/nimble/controller/include/controller/ble_ll.h
+++ b/nimble/controller/include/controller/ble_ll.h
@@ -179,6 +179,7 @@ STATS_SECT_START(ble_ll_stats)
     STATS_SECT_ENTRY(rx_connect_reqs)
     STATS_SECT_ENTRY(rx_scan_ind)
     STATS_SECT_ENTRY(rx_aux_connect_rsp)
+    STATS_SECT_ENTRY(rx_pdu_on_scan_disabled)
     STATS_SECT_ENTRY(adv_txg)
     STATS_SECT_ENTRY(adv_late_starts)
     STATS_SECT_ENTRY(adv_resched_pdu_fail)
diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c
index 84475c32..fd96f7d6 100644
--- a/nimble/controller/src/ble_ll.c
+++ b/nimble/controller/src/ble_ll.c
@@ -320,6 +320,7 @@ STATS_NAME_START(ble_ll_stats)
     STATS_NAME(ble_ll_stats, rx_connect_reqs)
     STATS_NAME(ble_ll_stats, rx_scan_ind)
     STATS_NAME(ble_ll_stats, rx_aux_connect_rsp)
+    STATS_NAME(ble_ll_stats, rx_pdu_on_scan_disabled)
     STATS_NAME(ble_ll_stats, adv_txg)
     STATS_NAME(ble_ll_stats, adv_late_starts)
     STATS_NAME(ble_ll_stats, adv_resched_pdu_fail)
diff --git a/nimble/controller/src/ble_ll_scan.c 
b/nimble/controller/src/ble_ll_scan.c
index d1c3c8ad..445cbb58 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1610,6 +1610,11 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t 
crcok)
         goto scan_rx_isr_ignore;
     }
 
+    if (!scansm->scan_enabled) {
+        STATS_INC(ble_ll_stats, rx_pdu_on_scan_disabled);
+        goto scan_rx_isr_ignore;
+    }
+
     rxbuf = rxpdu->om_data;
     pdu_type = rxbuf[0] & BLE_ADV_PDU_HDR_TYPE_MASK;
 

Reply via email to