XB10-2559: Fix for Client IPv4 Address Display in UI. - #86
XB10-2559: Fix for Client IPv4 Address Display in UI.#86sethumcacit-bot wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets incorrect/stale client IPv4 address display in the UI when LAN DHCP server is disabled, by adjusting host-table IPv4 handling during host state transitions and adding product-specific device-mode handling.
Changes:
- Add logic to remove a host’s stored IPv4 address(es) when a client transitions offline and
dhcp_server_enabled=0(CBR / OneStack business mode). - Add OneStack-specific device-mode integration (header usage and link flag).
- Add multiple new debug traces across IP address discovery, update, and export paths.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| source/lm/network_devices_status.c | Adds debug trace when reading the host’s IPv4 string parameter. |
| source/lm/Makefile.am | Adds a new Automake conditional to link -ldevicemode for OneStack builds. |
| source/lm/lm_wrapper.c | Adds debug traces around ARP parsing and DHCPv4 client/reservation IP updates. |
| source/lm/lm_main.c | Adds OneStack device-mode include, new offline/DHCP-disabled IPv4 cleanup logic, and extensive IP-related debug traces. |
| source/lm/cosa_hosts_dml.c | Adds debug trace when fetching the IPAddress parameter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ONESTACK_PRODUCT_REQ | ||
| libCcspLM_la_LDFLAGS += -ldevicemode | ||
| endif |
8e7b3ba to
47a44a1
Compare
Reason for change: Fix for Client IPv4 address display when LAN DHCP is Disable Test Procedure: Build and Verify Priority: P1 Risks: low Signed-off-by: Sethupathy_Nagarajan@comcast.com
47a44a1 to
ff4e1e2
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (10)
source/lm/lm_main.c:1609
- In Add_Update_IPv6Address(), the new debug log reads temp->pStringParaValue[LM_HOST_IPAddress_IPAddressId] before the field is initialized. If AnscAllocateMemory() doesn’t zero the struct (or if the pointer is NULL), passing it to a %s formatter is undefined behavior and can crash. Initialize the allocated node before any reads, and log only after setting the string.
temp=AnscAllocateMemory(sizeof(LmObjectHostIPAddress));
if(temp == NULL)
{
return NULL;
}
else
else
{
source/lm/lm_main.c:1637
- This debug log uses
tempeven when the IPv6 list was already initialized, which meanstempmay be uninitialized here. It also passes the value to%swithout guarding. LogpCur(the node being updated) and guard against NULL instead.
}
source/lm/lm_main.c:2644
- This debug log dereferences
pHostbefore the subsequent NULL-check (if (pHost && ...)). IfHosts_FindHostByPhysAddress()returns NULL, this will crash.
pHost = Hosts_FindHostByPhysAddress((char *)hosts.phyAddr);
source/lm/lm_main.c:2316
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with a%sformatter before checking whether the pointer is NULL. Passing NULL to%sis undefined behavior and can crash.
Xlm_wrapper_get_info(pHost);
source/lm/lm_main.c:2570
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%simmediately before code that explicitly handles the NULL case. If the IP address is NULL, the log statement itself can crash.
pHost->l1unReachableCnt = 1;
source/lm/lm_main.c:2603
- Same issue as above:
%sformatting a potentially-NULL IP string is undefined behavior and can crash. This should be guarded (or removed).
pHost->l1unReachableCnt = 1;
source/lm/lm_main.c:4536
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%swithout checking for NULL. In this functionpHost->pStringParaValue[LM_HOST_IPAddressId]can legitimately be NULL, so the log statement can crash.
}
source/lm/lm_main.c:4682
- This debug log prints the host IP string using
%swithout guarding against NULL. If the host has no IPv4 yet, this is undefined behavior and can crash.
source/lm/lm_main.c:1739 - This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]using%swithout guarding against NULL. If the host does not yet have an IP address, this is undefined behavior and can crash.
{
source/lm/lm_main.c:720
- This debug log prints the IP string with
%swithout guarding against NULL. In this path the IP may still be NULL (e.g., getIPAddress() fails / returns empty and LanManager_CheckCloneCopy() no-ops), so the log statement can crash.
CcspTraceDebug(("%s:%d, InLease:LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
| AC_ARG_ENABLE([onestacksupport], | ||
| AS_HELP_STRING([--enable-onestacksupport],[enable onestack support (default is no)]), | ||
| [ | ||
| case "${enableval}" in | ||
| yes) ONESTACK_PRODUCT_REQ=true;; | ||
| no) ONESTACK_PRODUCT_REQ=false;; | ||
| *) AC_MSG_ERROR([bad value ${enableval} for --enable-onestacksupport ]);; | ||
| esac | ||
| ], | ||
| [echo "onestack is disabled"]) | ||
| AM_CONDITIONAL(ONESTACK_PRODUCT_REQ, test "x$ONESTACK_PRODUCT_REQ" = xtrue) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (7)
source/lm/lm_main.c:1638
- This debug log uses
temp->...even thoughtempis only initialized inside the*ppHeader == NULLbranch; when the list is non-empty this is an uninitialized pointer dereference.
CcspTraceDebug(("%s:%d, Final:In-ipv6: ipAddress=%s \n", __FUNCTION__, __LINE__, ipAddress ? ipAddress : "(null)"));
source/lm/lm_main.c:1743
- These debug logs pass
pHost->pStringParaValue[LM_HOST_IPAddressId]to%swithout a NULL check; this is undefined behavior if the host doesn't currently have an IPv4 string set (which is a valid state before LanManager_CheckCloneCopy runs).
CcspTraceDebug(("%s:%d, Before:In-ipv4:%s, LM_HOST_IPAddressId: %s \n",__FUNCTION__,__LINE__, ipAddress, pHost->pStringParaValue[LM_HOST_IPAddressId]));
pCur = Add_Update_IPv4Address(pHost,ipAddress);
LanManager_CheckCloneCopy(&(pHost->pStringParaValue[LM_HOST_IPAddressId]) , ipAddress);
CcspTraceDebug(("%s:%d, After:In-ipv4:%s, LM_HOST_IPAddressId: %s \n",__FUNCTION__,__LINE__, ipAddress, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2317
- This debug log uses
%swithpHost->pStringParaValue[LM_HOST_IPAddressId]without a NULL guard;Host_AddIPv4Address()is called even when the pointer is NULL, so this can crash before the function gets a chance to handle the NULL input.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2572
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore the code checks whether that pointer is NULL; if it is NULL (which the followingif (!...)explicitly handles), the log itself can crash the process.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
if ( ! pHost->pStringParaValue[LM_HOST_IPAddressId] )
source/lm/lm_main.c:2605
- Same issue here: the debug log uses
%swith a value that is immediately checked for NULL on the next line; if it's NULL the log call can crash.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
if ( ! pHost->pStringParaValue[LM_HOST_IPAddressId] )
source/lm/lm_main.c:4538
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore the subsequent NULL check; if the pointer is NULL, the log call can crash.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
if ((status.ipv4Active) && (pHost->pStringParaValue[LM_HOST_IPAddressId]))
source/lm/lm_main.c:4684
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore the code checks for NULL; if the pointer is NULL, the log itself can crash.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
if (pHost->pStringParaValue[LM_HOST_IPAddressId]) {
| else | ||
| { | ||
| //temp->pStringParaValue[LM_HOST_IPAddress_IPAddressId] = AnscCloneString("EMPTY"); | ||
| temp->pStringParaValue[LM_HOST_IPAddress_IPAddressId] = AnscCloneString(" "); // fix for RDKB-19836 | ||
| else | ||
| { | ||
| CcspTraceDebug(("%s:%d, Allocating IPv6 placeholder entry\n", __FUNCTION__, __LINE__)); |
| if ONESTACK_PRODUCT_REQ | ||
| libCcspLM_la_LDFLAGS += -ldevicemode | ||
| endif |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
source/lm/Makefile.am:72
ONESTACK_PRODUCT_REQcurrently only adds-ldevicemode, but the code is gated by_ONESTACK_PRODUCT_REQ_(preprocessor) inlm_main.c. If the configure option is enabled without an external-D_ONESTACK_PRODUCT_REQ_, this will link a library without compiling the guarded code; if_ONESTACK_PRODUCT_REQ_is defined externally without--enable-onestacksupport, it will compile but fail to link. Tie the conditional to both compile and link flags in the same place.
if ONESTACK_PRODUCT_REQ
libCcspLM_la_LDFLAGS += -ldevicemode
endif
source/lm/lm_main.c:1516
- This new debug log hard-codes
In-ipv4even whenHost_FreeIPAddress()is called withversion == 6, making logs misleading. Consider logging the version and guarding against NULL string pointers to avoid%sUB.
CcspTraceDebug(("%s:%d, Free:In-ipv4:LM_HOST_IPAddress_IPAddressId: %s \n",__FUNCTION__,__LINE__, pIpAddrList->pStringParaValue[LM_HOST_IPAddress_IPAddressId]));
| { | ||
| hosts[index].status = LM_NEIGHBOR_STATE_STALE; | ||
| } | ||
| CcspTraceDebug(("%s %d: %s %s %s %d\n", __FUNCTION__, __LINE__, hosts[index].phyAddr,hosts[index].ipAddr,hosts[index].ifName,hosts[index].status)); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
source/lm/Makefile.am:72
ONESTACK_PRODUCT_REQis used to add-ldevicemode, but the C code is gated by the_ONESTACK_PRODUCT_REQ_preprocessor macro. As-is, you can end up with (a) code compiled without the macro but still linking devicemode, or (b) code compiled with_ONESTACK_PRODUCT_REQ_but failing to link because the conditional isn’t enabled. Define the macro when the automake conditional is enabled (or align both sides to the same symbol).
if ONESTACK_PRODUCT_REQ
libCcspLM_la_LDFLAGS += -ldevicemode
endif
| for(pCur = pIpAddrList; pCur != NULL; pPre = pCur, pCur = pCur->pNext){ | ||
| CcspTraceDebug(("%s:%d, Before:In-ipv4:%s, LM_HOST_IPAddress_IPAddressId: %s \n",__FUNCTION__,__LINE__, ipAddress, pCur->pStringParaValue[LM_HOST_IPAddress_IPAddressId])); | ||
| if (strcasecmp(pCur->pStringParaValue[LM_HOST_IPAddress_IPAddressId], ipAddress) == 0){ | ||
| break; | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1f4ec84 to
ed93a4c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (6)
source/lm/Makefile.am:72
--enable-onestacksupportenables the Automake conditionalONESTACK_PRODUCT_REQ(and adds-ldevicemode), but the C code gates OneStack paths on_ONESTACK_PRODUCT_REQ_. That macro is not defined anywhere in this Makefile, so the OneStack-only code will still be compiled out even when the configure option is enabled. Define_ONESTACK_PRODUCT_REQ_via CPPFLAGS under the same conditional so the build option actually enables the intended code paths.
if ONESTACK_PRODUCT_REQ
libCcspLM_la_LDFLAGS += -ldevicemode
endif
source/lm/lm_main.c:2314
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%swithout a NULL guard. If the IPv4 address isn't present yet, passing NULL to%sis undefined and can crash inside the logger. Use a ternary to log a safe placeholder.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2568
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore checking it for NULL on the next line. Passing NULL to%sis undefined and can crash; guard the value.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2601
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore checking it for NULL on the next line. Passing NULL to%sis undefined and can crash; guard the value.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:4534
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%swithout a NULL guard, even though the code immediately treats the field as optional. Passing NULL to%sis undefined and can crash; log a safe placeholder instead.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:4680
- This debug log prints
pHost->pStringParaValue[LM_HOST_IPAddressId]with%sbefore checking it for NULL on the next line. Passing NULL to%sis undefined and can crash; guard the value.
CcspTraceDebug(("%s:%d, LM_HOST_IPAddressId:%s \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
Reason for change: Fix for Client IPv4 address display when LAN DHCP is Disable
Test Procedure: Build and Verify
Priority: P1
Risks: low
Signed-off-by: Sethupathy_Nagarajan@comcast.com