Skip to content

RDKB-66812 RDKB-66844 : Pause Network Intelligence while speedtest is running - #103

Open
akumar0702 wants to merge 16 commits into
developfrom
feature/RDKB-66844
Open

akumar0702 wants to merge 16 commits into
developfrom
feature/RDKB-66844

Conversation

@akumar0702

@akumar0702 akumar0702 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Reason for change: To pause Network Intelligence while speed test is running
Test Procedure: Trigger speed test and confirm if NI pauses on ST_TR181_STATUS_STARTING event
and resumes on ST_TR181_STATUS_COMPLETE event
Risks: Low
Priority: P0

Signed-off-by: santhosh_gujulvajagadeesh@comcast.com

Test Procedure:
Risks: Low
Signed-off-by: arunkumar_nagulapally@comcast.com
Copilot AI lite review requested due to automatic review settings September 9, 2026 18:16
@akumar0702
akumar0702 requested review from a team as code owners September 9, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

It introduces a real exit-status handling bug in the new C handler (unsafe WEXITSTATUS usage), plus security/logging/test coverage issues that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds SpeedTest status handling to pause/resume Network Intelligence (cujo-qosd) during SpeedTest runs, wiring an RBUS event into existing AdvSecurity control flows and extending the startup script accordingly.

Changes:

  • Subscribe to Device.IP.Diagnostics.X_RDKCENTRAL-COM_SpeedTest.Status and handle status transitions to trigger NI pause/resume.
  • Add -speedtestNIStart / -speedtestNIComplete actions to start_adv_security.sh, including an auto-unpause timer.
  • Add unit tests validating the new SpeedTest status handler behavior.
File summaries
File Description
source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp Adds unit tests for the SpeedTest status RBUS event handler.
source/AdvSecurityDml/cosa_adv_security_internal.c Subscribes to SpeedTest status RBUS event and triggers NI pause/resume via script calls.
scripts/start_adv_security.sh Implements NI pause/resume actions and a timer mechanism for automatic re-enable.
Review details

Suppressed comments (1)

source/AdvSecurityDml/cosa_adv_security_internal.c:478

  • Same issue as above: WEXITSTATUS(rc) is evaluated even when !WIFEXITED(rc) is true. Guard WEXITSTATUS behind a successful WIFEXITED check.
        rc = v_secure_system(TEMP_DOWNLOAD_LOCATION"/usr/ccsp/advsec/start_adv_security.sh -speedtestNIComplete &");
        if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
        {
            CcspTraceError(("%s: failed to enable cujo-qosd for SpeedTest, rc=%d\n", __FUNCTION__, WEXITSTATUS(rc)));
        }
  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/start_adv_security.sh Outdated
Comment thread scripts/start_adv_security.sh Outdated
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Outdated
Comment thread source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp
Copilot AI review requested due to automatic review settings September 15, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate issues affect event ordering, test behavior, and timer/status handling.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (6)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/start_adv_security.sh:623

  • The timer PID file is never removed when this background timer expires normally. On a later speed-test event, a stale PID can have been reused by an unrelated process, so speedtest_cancel_networkintelligence_timer may send SIGTERM to that process. Clean up the file when the timer exits, but only if it still contains this timer's PID.

scripts/start_adv_security.sh:595

  • The subscribed status object is Device.IP.Diagnostics.X_RDKCENTRAL-COM_SpeedTest (cosa_adv_security_internal.c:69), but this lookup uses X_RDK_SpeedTest. On devices exposing only the subscribed object, dmcli will return an invalid/non-numeric value and the pause path will exit without disabling cujo-qosd.
    unpause_timeout=$(dmcli eRT retv "Device.IP.Diagnostics.X_RDK_SpeedTest.SubscriberUnPauseTimeOut" 2>/dev/null)

source/AdvSecurityDml/cosa_adv_security_internal.c:462

  • This log evaluates WEXITSTATUS(rc) even when the preceding condition is true because WIFEXITED(rc) is false. WEXITSTATUS is only meaningful for a normally exited child, so signal/-1 failures will be logged with a fabricated status; guard the extraction or log the raw return value in that case.
            CcspTraceError(("%s: failed to disable cujo-qosd for SpeedTest, rc=%d\n", __FUNCTION__, WEXITSTATUS(rc)));

source/AdvSecurityDml/cosa_adv_security_internal.c:471

  • This log evaluates WEXITSTATUS(rc) even when the preceding condition is true because WIFEXITED(rc) is false. WEXITSTATUS is only meaningful for a normally exited child, so signal/-1 failures will be logged with a fabricated status; guard the extraction or log the raw return value in that case.
            CcspTraceError(("%s: failed to enable cujo-qosd for SpeedTest, rc=%d\n", __FUNCTION__, WEXITSTATUS(rc)));

source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp:1477

  • This expectation has the same accessor mismatch: the handler invokes rbusValue_GetUInt32, not rbusValue_GetString. The status-5 test therefore fails on an unexpected mock call before verifying the completion command.
    EXPECT_CALL(*g_rbusMock, rbusValue_GetString(value, _))
        .Times(1)
        .WillOnce(Return("5"));

source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp:1509

  • This no-action test also stubs rbusValue_GetString, while the implementation calls rbusValue_GetUInt32; Google Mock will fail on the unexpected accessor instead of exercising the status-2 path.
    EXPECT_CALL(*g_rbusMock, rbusValue_GetString(value, _))
        .Times(1)
        .WillOnce(Return("2"));
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Outdated
Comment thread source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp Outdated
Copilot AI review requested due to automatic review settings September 16, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved moderate findings affect timeout ordering, recovery, clock handling, command failure handling, and test coverage.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

source/AdvSecurityDml/cosa_adv_security_internal.c:496

  • This deadline is based on CLOCK_REALTIME, which is also the default clock for this condition variable. An NTP or manual wall-clock correction can therefore make the timeout fire early or be postponed indefinitely, enabling qosd while the speed test is still running or leaving it disabled. Use a condition variable configured for CLOCK_MONOTONIC and compute the deadline from that clock.
    if (clock_gettime(CLOCK_REALTIME, &deadline) != 0)
    {
        CcspTraceError(("%s: clock_gettime failed, errno=%d\n", __FUNCTION__, errno));
        return FALSE;
    }
    deadline.tv_sec += timeout;

source/AdvSecurityDml/cosa_adv_security_internal.c:587

  • Because this command is backgrounded, v_secure_system only observes the shell that queued start_adv_security.sh, not the cujo-ni-cli operation performed by the script. A failure to disable qosd therefore usually looks like success here, so the timer is left armed and the speed test can run with qosd still enabled. Run this operation synchronously or add an asynchronous result/retry path before treating the start as successful.
        rc = v_secure_system(TEMP_DOWNLOAD_LOCATION"/usr/ccsp/advsec/start_adv_security.sh -speedtestNIStart &");
        if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Outdated
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Outdated
Comment thread source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp
Copilot AI review requested due to automatic review settings September 22, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Outdated
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Copilot AI review requested due to automatic review settings September 22, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate findings affect QoS synchronization, timeout handling, error handling, RBUS initialization, and test coverage.

Review effort: Lite
Findings: 4 Medium severity

Open (4)

Copilot AI review requested due to automatic review settings September 22, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread source/AdvSecurityDml/Makefile.am
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Comment thread source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp
Copilot AI review requested due to automatic review settings September 22, 2026 16:50
Copilot AI review requested due to automatic review settings September 22, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved concurrency issues can cause deadlock or lose SpeedTest triggers, and timeout behavior lacks coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity · 2 Medium severity

Open (6)
Resolved since last review (1)

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Copilot AI review requested due to automatic review settings September 22, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Resolve the SpeedTest restart race, add timeout-expiry coverage, and ensure deterministic worker cleanup.

Review effort: Lite
Findings: 2 High severity · 2 Medium severity

Open (4)
Resolved since last review (2)

Copilot AI review requested due to automatic review settings September 23, 2026 05:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Comment thread source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityInternalTest.cpp
@SanthoshGujulvajagadeesh SanthoshGujulvajagadeesh changed the title Reason for change: RDKB-66812, RDKB-66844 : Pause Network Intelligence while speedtest is running Sep 23, 2026
Copilot AI review requested due to automatic review settings September 23, 2026 05:45
@SanthoshGujulvajagadeesh SanthoshGujulvajagadeesh changed the title RDKB-66812, RDKB-66844 : Pause Network Intelligence while speedtest is running RDKB-66812 RDKB-66844 : Pause Network Intelligence while speedtest is running Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate issues remain in executable path handling, event sequencing, state restoration, and RBUS cleanup.

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)
Resolved since last review (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Resume NI only when this worker paused it

source/​AdvSecurityDml/​cosa_adv_security_internal.c:549

ni_qosd_pause() can return TRUE without issuing a pause when either marker is absent, but this worker always calls ni_qosd_resume() after the wait. If NI is enabled/activated during a speed test that started while it was inactive, this cycle enables QoSD even though it never paused it; conversely, deactivation during a real pause can skip the restore. Capture whether this worker actually paused NI and only resume that state.

Copilot AI review requested due to automatic review settings September 23, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the RBUS value leak and inactive-NI timeout worker issues.

Review effort: Lite
Findings: None

Resolved since last review (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid arming speed-test timeout worker when NI is inactive

source/​AdvSecurityDml/​cosa_adv_security_internal.c:491

When NI is disabled or not activated, this returns TRUE and ni_speedtest_trigger() still leaves a detached worker waiting for the configured timeout (typically 86,400 seconds), even though no pause occurred. If the COMPLETE event is missed and NI is enabled during that interval, later STARTING events are rejected by the running-state check, so NI will not be paused for the new speed test. Skip arming the timer when the feature is inactive, or distinguish a skipped pause from a successful pause so the worker exits immediately.

Copilot AI review requested due to automatic review settings September 23, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address the RBUS value leak and prevent late QoS re-enablement after NI deactivation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
Copilot AI review requested due to automatic review settings September 23, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical completion-event issue can leave qosd paused until timeout when NI is deactivated during a speed test.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c
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.

3 participants