Skip to content

Test branch Please ignore this PR - #133

Open
Khan3033 wants to merge 2 commits into
support/2026q2from
test_branch
Open

Test branch Please ignore this PR#133
Khan3033 wants to merge 2 commits into
support/2026q2from
test_branch

Conversation

@Khan3033

Copy link
Copy Markdown

No description provided.

During MAP‑T to DS Line migration, the X_RDK_Release flag triggers the
release of WAN-related IP configurations. However, the DHCPv4 client was
not being stopped or disabled as part of this flow. As a result, the
device ended up in a state where IPv4 was not reacquired, leaving the
WAN interface without an IPv4 address.
This change introduces the following fixes:

Properly stop/disable the DHCP client when X_RDK_Release is triggered.
Ensure that any active DHCPv4 lease is released and cleaned up.
Prevent leftover DHCP processes from interfering with re‑initialization
after the migration.
Restore consistent IPv4 connectivity after MAP-T to DS Line migration.

This ensures stable IPv4 behavior across MAP‑T transitions and prevents
the IPv4 down condition observed in RDKB‑64560.


UT:https://ccp.sys.comcast.net/browse/RDKB-64560?focusedId=25146721&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-25146721


https://ccp.sys.comcast.net/browse/RDKB-64560?focusedId=25147864&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-25147864
…net/if_inet6 in DhcpMgr_checkLinkLocalAddress (#125)

## JIRA
[SHARMAN-4100]

## Problem
DHCPManager intermittently hangs and becomes completely unresponsive
during IPv6 client startup. The process blocks indefinitely in
`DhcpMgr_checkLinkLocalAddress`, preventing WAN recovery after a WAN
down/up cycle or factory reset.

## Root Cause
`popen("ip address show dev <iface> tentative")` spawns a shell child
process to check DAD (Duplicate Address Detection) status on the
link-local address. The global `sigchld_handler` uses `waitpid(-1,
WNOHANG)` which reaps **all** child processes indiscriminately. When it
reaps the `popen` child before `pclose()` can, `pclose()` blocks
indefinitely on its own `waitpid()` — hanging the DHCPManager thread
permanently.

## Fix
Replace `popen`/`pclose` with a direct read of `/proc/net/if_inet6`:

- **No child process spawned** → zero SIGCHLD interference, no hang risk
- **Link-local only**: filters `scope == 0x20` (`IPV6_ADDR_LINKLOCAL`) —
this function checks the link-local address DAD status required by
DHCPv6
- **Per-address DAD check**: reads `IFA_F_TENTATIVE` flag (`0x40`)
directly from the kernel's IPv6 address table
- **Three states per poll iteration**:
  - No link-local address present yet → keep waiting
  - Link-local found and tentative (DAD in progress) → keep waiting
- Link-local found and non-tentative (DAD complete) → proceed with
DHCPv6
- **fopen failure**: breaks out immediately rather than stalling until
timeout

## Files Changed
- `source/DHCPMgrUtils/dhcpmgr_controller.c`
  - Added `#include <linux/if_addr.h>` for `IFA_F_TENTATIVE`
  - Added `#include <string.h>` for `strerror()`
- Replaced `popen`/`fgets`/`pclose` with `fopen`/`fscanf`/`fclose` on
`/proc/net/if_inet6`
- Updated Doxygen doc comment to accurately describe the new
implementation

## Test Procedure
1. Flash build with this fix on the device (XB8/XB7 or equivalent)
2. Trigger WAN down/up cycle repeatedly (minimum 10 times)
3. Verify DHCPManager does **not** hang after IPv6 client restart
4. Check `DHCPMGRLog.txt`:
- `no link-local address for <iface> in /proc/net/if_inet6 yet` appears
while waiting for LLA assignment
   - `interface still tentative` appears during DAD wait (if applicable)
   - DHCPv6 client starts successfully after DAD completes
5. Perform factory reset and verify WAN recovers correctly
6. Confirm no regression in DHCPv4/DHCPv6 lease acquisition
7. Verify DHCPManager process remains responsive throughout all cycles

## Verification
Fix verified on XB8 device — DHCPManager no longer hangs after multiple
WAN down/up cycles (issue was previously reproducible within 2–3
cycles).
Copilot AI review requested due to automatic review settings July 21, 2026 04:42
@Khan3033
Khan3033 requested a review from a team as a code owner July 21, 2026 04:42
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

📋 PR Format Reminder

  • Title: Test branch Please ignore this PR — expected TICKET-123 : description
    (Multiple tickets OK: RDKCOM-5492 RDKBDEV-3336 : ... | Include US ticket + subtask for user-stories)
  • Description missing:
    • Reason for change
    • Test Procedure
    • Risks (Low / Medium / High)
    • Priority (P0 / P1 / P2)

Expected:

TICKET-123 : brief description

Reason for change: why
Test Procedure: how to verify
Risks: Low / Medium / High
Priority: P0 / P1 / P2

@Khan3033 Khan3033 changed the title Test branch Test branch Please ignore this PR Jul 21, 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.

Pull request overview

This PR updates DHCP manager controller behavior around IPv6 link-local readiness checks (DAD) and DHCP client release handling.

Changes:

  • Replaces ip address show ... tentative + popen() logic with /proc/net/if_inet6 parsing to detect link-local scope and tentative state.
  • Adds Linux/header includes to support the new parsing and error logging.
  • Modifies DHCPv4/DHCPv6 X_RDK_Release handling to also disable the client in-memory after sending release.
Comments suppressed due to low confidence (1)

source/DHCPMgrUtils/dhcpmgr_controller.c:507

  • waitTime is an unsigned int, but the loop decrements it with waitTime -= INTF_V6LL_INTERVAL_IN_MSEC; and then later checks if (waitTime <= 0). With unsigned arithmetic this pattern can underflow if constants change and makes the <= 0 check misleading. Clamp the decrement and check explicitly for waitTime == 0 to avoid wraparound/infinite loops.
        usleep(INTF_V6LL_INTERVAL_IN_MSEC * USECS_IN_MSEC);
        waitTime -= INTF_V6LL_INTERVAL_IN_MSEC;
    }

    if (waitTime <= 0)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 672 to +674
send_dhcpv4_release(pDhcpc->Info.ClientProcessId);
/* X_RDK_Release: disable the client */
pDhcpc->Cfg.bEnabled = FALSE;
Comment on lines 847 to +849
send_dhcpv6_release(pDhcp6c->Info.ClientProcessId);
/* X_RDK_Release: disable the client */
pDhcp6c->Cfg.bEnabled = FALSE;
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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.

4 participants