XB10-2559: Fix for Client IPv4 Address Display in UI when LAN DHCP is…#67
XB10-2559: Fix for Client IPv4 Address Display in UI when LAN DHCP is…#67jayantrais wants to merge 1 commit into
Conversation
… Disabled. Reason for change: Fix for Client IPv4 address display when LAN DHCP is Disabled. Test Procedure: Build and Verify Priority: P1 Risks: low Signed-off-by: jrai722 <jayant_rai2@comcast.com>
|
I have read the CLA Document and I hereby sign the CLA Rai seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
There was a problem hiding this comment.
Pull request overview
This PR aims to fix incorrect/stale client IPv4 address display in the UI when the LAN DHCP server is disabled by clearing the host’s stored IPv4 data when the address is not found in the DHCP lease file and dhcp_server_enabled=0.
Changes:
- Add syscfg-based gating (
dhcp_server_enabled, anddevicemodeon OneStack) in the “IP not found in lease file” path. - Clear stored IPv4 address fields for the host when DHCP server is disabled (to prevent UI display of stale IPv4 info).
- Add additional warning logs around the above path.
Comments suppressed due to low confidence (3)
source/lm/lm_main.c:750
pHost->ipv4AddrArrayis a linked list allocated viaAnscAllocateMemory(seeAdd_Update_IPv4Address), sofree(pHost->ipv4AddrArray)only frees the head node and leaks the rest (and may mismatch the allocator). UseHost_FreeIPAddress(pHost, 4)(or the same per-node free logic) to clear IPv4 addresses safely before settingipv4AddrArray/numIPv4Addrto 0/NULL.
free(pHost->pStringParaValue[LM_HOST_IPAddressId]);
pHost->pStringParaValue[LM_HOST_IPAddressId] = NULL;
free(pHost->ipv4AddrArray);
pHost->ipv4AddrArray = NULL;
pHost->numIPv4Addr = 0;
source/lm/lm_main.c:751
- When clearing the host's IPv4 address due to DHCP server being disabled,
pHost->ipv4Activeis left asTRUE. Downstream code (e.g., presence detection) usesipv4Activeto decide whether to treat IPv4 as active, so this can lead to an “IPv4 active but no address” state. Consider settingpHost->ipv4Active = FALSEwhen you null out the IPv4 address fields.
pHost->pStringParaValue[LM_HOST_IPAddressId] = NULL;
free(pHost->ipv4AddrArray);
pHost->ipv4AddrArray = NULL;
pHost->numIPv4Addr = 0;
}
source/lm/lm_main.c:736
- Under
_CBR_PRODUCT_REQ_(without_ONESTACK_PRODUCT_REQ_),device_modeis never used andCcspTraceWarning((" SETHU: _ONESTACK_PRODUCT_REQ_ \n"))becomes misleading. To avoid unused-variable warnings and confusing logs, declaredevice_modeonly inside the_ONESTACK_PRODUCT_REQ_block and adjust the log message (or remove it).
#if defined (_CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_)
char device_mode[32] = {0};
char dhcp_server_enabled[32] = {0};
CcspTraceWarning((" SETHU: _ONESTACK_PRODUCT_REQ_ \n"));
#if defined (_ONESTACK_PRODUCT_REQ_)
if(!syscfg_get( NULL, "devicemode", device_mode, sizeof(device_mode)))
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| CcspTraceWarning(("<%s> SETHU: IPAddress not found in lease file : IPAddress = %s, MAC Addr = %s \n",__FUNCTION__, pHost->pStringParaValue[LM_HOST_IPAddressId], pHost->pStringParaValue[LM_HOST_PhysAddressId])); | ||
| #if defined (_CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) | ||
| char device_mode[32] = {0}; | ||
| char dhcp_server_enabled[32] = {0}; | ||
|
|
||
| CcspTraceWarning((" SETHU: _ONESTACK_PRODUCT_REQ_ \n")); | ||
| #if defined (_ONESTACK_PRODUCT_REQ_) | ||
| if(!syscfg_get( NULL, "devicemode", device_mode, sizeof(device_mode))) | ||
| { | ||
| CcspTraceWarning((" SETHU: devicemode: %s\n", device_mode)); | ||
| if(strncmp(device_mode, "business", strlen("business")) == 0) | ||
| { | ||
| #endif | ||
| if(!syscfg_get( NULL, "dhcp_server_enabled", dhcp_server_enabled, sizeof(dhcp_server_enabled))) | ||
| { | ||
| CcspTraceWarning((" SETHU: dhcp_server_enabled: %s\n", dhcp_server_enabled)); | ||
| if(strncmp(dhcp_server_enabled, "0", strlen("0")) == 0) | ||
| { |
… Disabled.
Reason for change: Fix for Client IPv4 address display when LAN DHCP is Disabled.
Test Procedure: Build and Verify
Priority: P1
Risks: low