Test branch Please ignore this PR - #133
Open
Khan3033 wants to merge 2 commits into
Open
Conversation
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).
|
📋 PR Format Reminder
Expected: |
Contributor
There was a problem hiding this comment.
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_inet6parsing 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_Releasehandling to also disable the client in-memory after sending release.
Comments suppressed due to low confidence (1)
source/DHCPMgrUtils/dhcpmgr_controller.c:507
waitTimeis an unsigned int, but the loop decrements it withwaitTime -= INTF_V6LL_INTERVAL_IN_MSEC;and then later checksif (waitTime <= 0). With unsigned arithmetic this pattern can underflow if constants change and makes the<= 0check misleading. Clamp the decrement and check explicitly forwaitTime == 0to 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; |
|
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:
For more information about GitHub Code Scanning, check out the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.