Skip to content

Refactor Log_Enable API for improved validation and thread safety#1005

Open
coveyjorjet wants to merge 1 commit intordkcentral:developfrom
coveyjorjet:feat-log-list
Open

Refactor Log_Enable API for improved validation and thread safety#1005
coveyjorjet wants to merge 1 commit intordkcentral:developfrom
coveyjorjet:feat-log-list

Conversation

@coveyjorjet
Copy link
Copy Markdown

Summary

This PR refactors the Log_Enable TR-181 parameter implementation to improve validation, thread safety, and expand the supported debug modules from 12 to 31.

Reason for change

The existing Log_Enable implementation had several areas for improvement:

  • Limited debug modules: Only 12 modules were supported; expanded to 31 to cover all OneWifi, rdk-wifi-hal, and rdk-wifi-libhostap modules
  • Thread safety: Used strtok() which is not thread-safe; replaced with strtok_r()
  • Input validation: Lacked comprehensive validation; added checks for empty tokens, illegal characters, unknown modules, and buffer overflow protection
  • Reconciliation logic: Previously only disabled logs; now properly enables requested modules and disables others

Changes

  • Add shared wifi_dbg_flags[] array with 31 debug modules
  • Add isValidLogModule() helper for module name validation
  • Add validateLogEnable() with comprehensive input validation
  • Implement CosaDmlWiFi_getLogEnable() with buffer overflow protection
  • Implement CosaDmlWiFi_setLogEnable() with enable/disable reconciliation
  • Replace unsafe strtok() with thread-safe strtok_r()
  • Refactor cosa_wifi_dml.c to use new API functions

Test Procedure

  1. Set Log_Enable via dmcli:
    ```
    dmcli eRT setv Device.WiFi.Log_Enable string "wifiCtrlDbg,wifiMgrDbg"
    ```
  2. Verify files are created in /nvram/:
    ```
    ls /nvram/wifiCtrlDbg /nvram/wifiMgrDbg
    ```
  3. Get Log_Enable via dmcli and confirm the enabled modules are returned:
    ```
    dmcli eRT getv Device.WiFi.Log_Enable
    ```

Risks

Low - Changes are isolated to Log_Enable functionality with no impact on core WiFi operations.

Thank you for reviewing! 🙏

@coveyjorjet coveyjorjet requested a review from a team as a code owner March 25, 2026 02:01
@coveyjorjet coveyjorjet force-pushed the feat-log-list branch 2 times, most recently from d1f542d to 2ef5991 Compare March 25, 2026 23:38
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coveyjorjet
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Reason for change:
The existing Log_Enable implementation had several issues:
- Limited to only 12 debug modules (expanded to 31)
- Used unsafe strtok() which is not thread-safe
- Lacked comprehensive input validation
- No enable/disable reconciliation logic

Changes:
- Add shared wifi_dbg_flags[] array with 31 debug modules
- Add isValidLogModule() helper for module name validation
- Add validateLogEnable() with comprehensive input validation
- Implement CosaDmlWiFi_getLogEnable() with buffer overflow protection
- Implement CosaDmlWiFi_setLogEnable() with enable/disable reconciliation
- Replace unsafe strtok() with thread-safe strtok_r()
- Refactor cosa_wifi_dml.c to use new API functions

Test Procedure:
Set and get Log_Enable via dmcli and verify debug modules are
enabled/disabled correctly in /nvram/

Risks: Low

Signed-off-by: Covey Jorjet De Luna <cjdeluna1423@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant