XB10-2559: Fix for Client IPv4 Address Display in UI. - #90
XB10-2559: Fix for Client IPv4 Address Display in UI.#90sethumcacit-bot wants to merge 6 commits into
Conversation
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
There was a problem hiding this comment.
Pull request overview
Fixes incorrect/stale IPv4 address display for WiFi clients in the UI when LAN DHCP is disabled (business mode), by preventing stale neighbor-table IPs from being propagated and by clearing IPv4 state when devices go offline.
Changes:
- Add business-mode DHCP-disabled detection via syscfg (
IsBusinessModeDHCPServerDisable()). - In
getIPAddress(), avoid copying STALE neighbor-table IPv4 into the output buffer when DHCP is disabled for WiFi clients. - When WiFi clients go offline and DHCP is disabled, clear IPv4 address state from the host table.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| source/lm/lm_wrapper.c | Adds DHCP-disabled gating to prevent propagating STALE neighbor IPv4 values for WiFi clients. |
| source/lm/lm_main.h | Declares the new IsBusinessModeDHCPServerDisable() helper under product conditionals. |
| source/lm/lm_main.c | Implements DHCP-disabled detection and clears host IPv4 state on WiFi client offline transitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else | ||
| { | ||
| CcspTraceDebug(("client is in stale state: MAC %s IP %s\n", physAddress, output)); | ||
| } |
| CcspTraceDebug(("%s:%d DHCP SERVER is %s\n",__FUNCTION__,__LINE__, dhcp_server_enabled)); | ||
| if(strncmp(dhcp_server_enabled, "0", strlen("0")) == 0) | ||
| { | ||
| CcspTraceDebug(("%s:%d Its BusinessMode and DHCP Server Disable\n",__FUNCTION__,__LINE__)); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
source/lm/lm_main.c:2039
- Logging every valid IP address at warning level can significantly increase log volume (this runs in the per-host IP enumeration loop). Consider changing this to
CcspTraceDebugso warning logs remain actionable.
CcspTraceWarning(("%s:%d Valid IP Address %s\n",__FUNCTION__,__LINE__, pIpSrc->pStringParaValue[LM_HOST_IPAddress_IPAddressId]));
| char device_mode[32] = {0}; | ||
| char dhcp_server_enabled[32] = {0}; |
| /*if both static/dhcp get failes, CPE will choose a 'primary' address.*/ | ||
| if ((pValue[0] == '\0') && (pHost->pStringParaValue[LM_HOST_IPAddressId])) | ||
| { | ||
| CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s, pValue is NULL\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId])); |
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 4 out of 4 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
source/lm/cosa_hosts_dml.c:1621
- Log message says "pValue is NULL", but this branch is triggered when the buffer is an empty string (
pValue[0] == '\0'). This is misleading when troubleshooting.
CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s, pValue is NULL\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
| #if defined (_CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) | ||
| CcspTraceWarning(("%s:%d IF: %s, state: %d, ipv4Active: %d \n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_Layer1InterfaceId], state, pHost->ipv4Active)); | ||
| if((strstr(pHost->pStringParaValue[LM_HOST_Layer1InterfaceId],"WiFi")) && (!state) && (pHost->ipv4Active == TRUE)) | ||
| { |
| BOOL isDHCPServerDisable = FALSE; | ||
| #if defined (_CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) | ||
| PLmObjectHost pHost; | ||
| pHost = Hosts_FindHostByPhysAddress((char *)physAddress); | ||
| if(pHost) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (5)
source/lm/lm_main.c:530
strncmp(dhcp_server_enabled, "0", strlen("0"))will treat any string starting with '0' as disabled (e.g., "0foo"). If syscfg is expected to return exactly "0"/"1", preferstrcmpfor correctness.
if(strncmp(dhcp_server_enabled, "0", strlen("0")) == 0)
source/lm/cosa_hosts_dml.c:1621
- The log says "pValue is NULL", but the condition checks for an empty string (
pValue[0] == '\0'). Also, logging this at Warning level can be noisy during normal operation.
CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s, pValue is NULL\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2829
- When
fopen(DNSMASQ_FILE, ...)fails,isArpIpMatchOnDNSMasqremains FALSE and the code will treat every non-reachable ARP entry as "not in dnsmasq" and remove the host IPv4 state. Mark it as matched (or otherwise skip removal) when the leases file can't be read.
if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
{
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
}
source/lm/lm_main.c:524
strncmp(device_mode, "business", strlen("business"))will also match values like "businessX". If you intend an exact match for the syscfg value, usestrcmp.
This issue also appears on line 530 of the same file.
if(strncmp(device_mode, "business", strlen("business")) == 0)
source/lm/cosa_hosts_dml.c:1627
- This emits a Warning-level log each time IPAddress is queried and the cached value exists; that is likely normal behavior and can flood logs. Consider lowering to Debug and clarifying the message.
CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
| 6885 f0:de:f1:0b:39:65 10.0.0.96 shiywang-WS 01:f0:de:f1:0b:39:65 6765 MSFT 5.0 | ||
| 6487 02:10:18:01:00:02 10.0.0.91 * * 6367 * | ||
| */ | ||
| ret = sscanf(buf, LM_DHCP_CLIENT_FORMAT, |
There was a problem hiding this comment.
The LM_DHCP_CLIENT_FORMAT macro has been migrated to source/lm/lm_main.h; therefore, it is now visible to both lm_main.c and lm_wrapper.c.
| { | ||
| Host_SetIPAddress(pIP, LM_HOST_RETRY_LIMIT, "NONE"); | ||
| } | ||
| while(fgets(buf, sizeof(buf), fp)!= NULL) |
| break; | ||
| } | ||
| } | ||
| fclose(fp); |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (7)
source/lm/cosa_hosts_dml.c:1621
- This warning is emitted in a normal fallback path (when pValue is empty, not NULL) and may unnecessarily spam warning logs. Consider lowering to Debug (and correcting the message).
CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s, pValue is NULL\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2852
- When validating whether an unreachable ARP IPv4 entry should be kept, the code only checks for an IP match in the dnsmasq leases file. If that IP is leased to a different client MAC, this can incorrectly preserve an IPv4 address on the wrong host record. Match both IP and MAC to ensure the lease corresponds to the same device.
if (!strcasecmp((const char *)hosts[i].ipAddr, (const char *)dhcpHost.ipAddr))
{
isArpIpMatchOnDNSMasq = TRUE;
break;
}
source/lm/lm_main.c:2826
- The file being opened here is the dnsmasq leases file (DNSMASQ_FILE points to "/nvram/dnsmasq.leases"), but the log message says "configuration file", which is misleading during troubleshooting.
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
source/lm/lm_main.c:523
- Using strncmp(..., "business", strlen("business")) treats any value with a "business" prefix as business mode (e.g., "business2"). If the syscfg value is expected to be exact, prefer strcmp for clarity and to avoid unintended matches.
if(strncmp(device_mode, "business", strlen("business")) == 0)
source/lm/lm_main.c:529
- Using strncmp(dhcp_server_enabled, "0", strlen("0")) only checks the first character, so values like "0x" would be treated as disabled. If the syscfg value is expected to be exactly "0"/"1", prefer strcmp to avoid accidental matches.
if(strncmp(dhcp_server_enabled, "0", strlen("0")) == 0)
source/lm/cosa_hosts_dml.c:1627
- This warning logs the cached IP address on every IPAddress query when LM_HOST_IPAddressId is set, which can be noisy at Warning level. Consider changing to Debug (or removing) to keep warning logs actionable.
CcspTraceWarning(("%s:%d, LM_HOST_IPAddressId: %s\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2826
- This code performs blocking file I/O (opening and scanning the dnsmasq leases file) while Hosts_SyncArp is holding the global presence/host mutexes (acquirePresencelocks() is held for the entire ARP sync). That can significantly increase lock hold time and stall concurrent host queries/updates. Consider parsing the leases file once outside the critical section (or caching its contents per sync) and then applying updates under the lock.
if(IsBusinessModeDHCPServerDisable())
{
if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
{
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
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
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
source/lm/lm_main.c:2864
- If
fopen(DNSMASQ_FILE, ...)fails,isArpIpMatchOnDNSMasqremains FALSE and the code will clear the host’s IPv4 address even though the leases file couldn’t be checked. Guard the removal so it only happens when the leases file was successfully opened/read.
if(!isArpIpMatchOnDNSMasq)
{
if(pHost->pStringParaValue[LM_HOST_IPAddressId])
{
CcspTraceDebug(("%s:%d IPv4 address %s removed from the host table and disabled\n",__FUNCTION__,__LINE__, pHost->pStringParaValue[LM_HOST_IPAddressId]));
source/lm/lm_main.c:2827
- The log message here says “dnsmasq configuration file”, but
DNSMASQ_FILEpoints to/nvram/dnsmasq.leases(the leases file). This makes troubleshooting harder when the file is missing/unreadable; include the file path in the message.
This issue also appears on line 2860 of the same file.
if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
{
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
source/lm/lm_main.c:2831
- This opens and linearly scans the entire dnsmasq leases file once per non-reachable ARP entry. With many clients, that can turn
Hosts_SyncArpinto an O(N*M) hot path while holding presence locks (blocking other operations). Consider loading the leases once perHosts_SyncArprun (e.g., build a set of leased IPs) or otherwise avoid per-host full-file scans.
if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
{
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
}
while((fp) && (fgets(buf, sizeof(buf), fp)!= NULL))
{
memset(&dhcpHost,0,sizeof(LM_host_entry_t));
source/lm/lm_main.c:2828
- If the dnsmasq leases file can’t be opened,
isArpIpMatchOnDNSMasqstays FALSE and we end up clearing the host’s IPv4 state purely due to an I/O failure. This can cause clients to lose their displayed IPv4 address transiently when/nvram/dnsmasq.leasesis missing/locked. Fall back to the previous retry-count update path (or at least skip removal) whenfopenfails.
if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
{
CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
}
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