rayhunter icon indicating copy to clipboard operation
rayhunter copied to clipboard

Misleading log entry / Rayhunter possibly not proper initialising on TP-Link device?

Open ogermer opened this issue 2 months ago • 2 comments

Bug Report Details

I am running Rayhunter 0.7.1 on a TP-Link 7350 v9 with stock firmware (9.0.3 Build 241219 Rel. 1089n) I patched the Rayhunter installer with the installer from https://github.com/EFForg/rayhunter/actions/runs/18575608127 to make the install persist / work around the race condition.

The problem is that - at least by interpreting the messages in the log file - the logging daemon is not initialized properly.

After a manual restart of the Rayhunter daemon using the "Apply and restart" button in the UI, additional lines are added to the log that suggest a successful initialisation. (see below)

However, the device is creating a recording (as seen in the UI) after cold boot. I have not had a look into the contents / quality of the data in that recording but could provide the data if requested.

This issue can be replicated.

Expected behaviour: I can see a successful initialisation of the device in the log file.

Log after cold boot:

R A Y H U N T E R 🐳
[2025-10-22T09:55:47Z INFO  rayhunter_daemon] Using configuration for device: Tplink
[2025-10-22T09:55:47Z INFO  rayhunter::diag_device] Diag device initialization failed 1 times, retrying in 100ms: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:47Z INFO  rayhunter::diag_device] Diag device initialization failed 2 times, retrying in 200ms: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:48Z INFO  rayhunter::diag_device] Diag device initialization failed 3 times, retrying in 400ms: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:49Z INFO  rayhunter::diag_device] Diag device initialization failed 4 times, retrying in 800ms: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:49Z INFO  rayhunter::diag_device] Diag device initialization failed 5 times, retrying in 1.6s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:51Z INFO  rayhunter::diag_device] Diag device initialization failed 6 times, retrying in 3.2s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:54Z INFO  rayhunter::diag_device] Diag device initialization failed 7 times, retrying in 5s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:55:59Z INFO  rayhunter::diag_device] Diag device initialization failed 8 times, retrying in 5s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:56:04Z INFO  rayhunter::diag_device] Diag device initialization failed 9 times, retrying in 5s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:56:09Z INFO  rayhunter::diag_device] Diag device initialization failed 10 times, retrying in 5s: Failed to initialize /dev/diag: DIAG_IOCTL_SWITCH_LOGGING ioctl failed with error code -1
[2025-10-22T09:56:14Z INFO  rayhunter::diag_device] Diag device initialization failed 11 times, retrying in 5s: Failed to initialize [2025-10-22T09:56:40Z INFO  rayhunter_daemon] Closing current QMDL entry...
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] Done!
[2025-10-22T09:56:40Z INFO  rayhunter_daemon::key_input] received key input shutdown
[2025-10-22T09:56:40Z INFO  rayhunter_daemon::diag] Diag reader thread exiting...
[2025-10-22T09:56:40Z INFO  rayhunter_daemon::display::generic_framebuffer] received UI shutdown
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] see you space cowboy...

Additional lines in log after manual restart of the Rayhunter daemon using the "Apply and restart" button in the UI.

R A Y H U N T E R 🐳
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] Using configuration for device: Tplink
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] Diag device initialization succeeded after 0 retries
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] retrieving diag logging capabilities...
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 329 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 1
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 298 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 4
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 140 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 5
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 168 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 7
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 122 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 10
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 73 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 11
[2025-10-22T09:56:40Z WARN  rayhunter::diag] warning: 72 leftover bytes when parsing Message
[2025-10-22T09:56:40Z INFO  rayhunter::diag_device] enabled logging for log type 13
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] Starting Diag Thread
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] Starting UI
[2025-10-22T09:56:40Z INFO  rayhunter_daemon::display::tplink] fallback to framebuffer
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] Starting Key Input service
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] create shutdown thread
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] spinning up server
[2025-10-22T09:56:40Z INFO  rayhunter_daemon] The orca is hunting for stingrays...

ogermer avatar Oct 23 '25 14:10 ogermer

I think there's a few bugs:

  1. rayhunter does not shut down when initialization of the diag device on the main thread fails. I think this is because we do not cancel our shutdown_token on drop. we should use CancellationToken::guard() to create a drop guard, so that when the main thread fails, we cancel all other threads too. @simonft
  2. why those tasks block shutdown of the entire process though, i have no idea. maybe that should be fixed somehow?
  3. finally, the device-specific issue of not being able to initialize the diag device. might be that v9 is special.

untitaker avatar Oct 28 '25 14:10 untitaker

pcap of uninitialized diag device (no sim card in device)

836554.zip

untitaker avatar Oct 28 '25 14:10 untitaker