Repository navigation
fix: clear a soft rfkill block before claiming hciN - #10
DTTerastar wants to merge 1 commit into
Conversation
With the heartbeat bug fixed, the guard now reports the real bench state instead of a stale leftover: the flood binds hci0, then every command goes unanswered and HCI_Reset gives up after 45s, with rfkill state=blocked. A soft block survives on the host between runs and leaves the controller silent while still allowing the bind, so it looks like a dead dongle. The flood is privileged, so it clears the block itself, right after claiming the adapter and before the first command, rather than spending 45s discovering it. Only hciN is touched, and only to unblock. The switch lives under hciN/rfkillM and M is not N, so the adapter is matched on the hciN directory rather than a guessed rfkill number. Selftest covers a blocked adapter (cleared), an unblocked one and a different adapter's block (left alone), and a missing switch (not an error). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 35 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Reducing the open question: the image has no USER directive (runs as root), the flood step is |
There was a problem hiding this comment.
🟡 Changes recommended
The rfkill state values are reversed, causing unblocked adapters to be blocked instead.
1 open finding
What changed in this PR
Adds automatic rfkill unblocking before starting BLE flooding.
Changes:
- Adds reusable rfkill state discovery.
- Attempts to unblock the selected adapter.
- Adds self-test coverage for rfkill handling.
| File | Description |
|---|---|
ble_flood.py |
Adds rfkill detection, unblocking, and tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| with open(path) as fh: | ||
| out.append((path, fh.read().strip() == "1")) |
|
Closing: this is wrong. The kernel rfkill ABI (Documentation/ABI/stable/sysfs-class-rfkill) is 0=SOFT_BLOCKED, 1=UNBLOCKED, 2=HARD_BLOCKED, so validating 'state == 1 means blocked' is inverted. Worse, |

Why
With the heartbeat guard fix in place (
v1.2.1), the guard no longer fails on a stale leftover; it now reports the real bench state. That state is:A soft rfkill block survives on the host between runs. It leaves the controller silent while still allowing the HCI user-channel bind, so the failure looks like a dead dongle and costs 45s (3 × 15s) before it is named.
What changed
The flood clears a soft block on
hciNright after it claims the adapter and before the first command, instead of spending 45s discovering it. It is privileged, so it can write the sysfs state. It only ever unblocks, and only its own adapter; it never writes1back.The switch lives under
hciN/rfkillMandMis notN, so the adapter is matched on thehciNdirectory rather than a guessed rfkill number._silent_hintreuses the same reader.Verification
Selftest (also the CI step) pins:
/sysnot mounted)Open question
An in-container unblock only helps if the container can write
/sys/class/bluetooth/hciN/rfkillM/state. The flood step isprivilegedandnetwork_mode: host, so it should be able to, but that has to be confirmed on the bench; the log now says either "unblocked it" or the errno if it could not. If the host blocks sysfs writes from the container, the alternative is arfkill unblock bluetoothon the runner outside the pipeline.🤖 Generated with Claude Code