Skip to content

XB10-2559: Fix for Client IPv4 Address Display in UI. - #90

Open
sethumcacit-bot wants to merge 6 commits into
developfrom
Bug/XB10-2559
Open

XB10-2559: Fix for Client IPv4 Address Display in UI.#90
sethumcacit-bot wants to merge 6 commits into
developfrom
Bug/XB10-2559

Conversation

@sethumcacit-bot

Copy link
Copy Markdown

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

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
@sethumcacit-bot
sethumcacit-bot requested a review from a team as a code owner July 24, 2026 14:26
Copilot AI review requested due to automatic review settings July 24, 2026 14:26
@sethumcacit-bot
sethumcacit-bot requested a review from a team as a code owner July 24, 2026 14:26

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

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.

Comment thread source/lm/lm_wrapper.c Outdated
Comment on lines +1843 to +1846
else
{
CcspTraceDebug(("client is in stale state: MAC %s IP %s\n", physAddress, output));
}
Comment thread source/lm/lm_main.c Outdated
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__));
Copilot AI review requested due to automatic review settings July 26, 2026 18:29

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

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 CcspTraceDebug so warning logs remain actionable.
        CcspTraceWarning(("%s:%d Valid IP Address %s\n",__FUNCTION__,__LINE__, pIpSrc->pStringParaValue[LM_HOST_IPAddress_IPAddressId]));

Comment thread source/lm/lm_main.c Outdated
Comment thread source/lm/lm_main.c Outdated
Comment on lines +516 to +517
char device_mode[32] = {0};
char dhcp_server_enabled[32] = {0};
Comment thread source/lm/cosa_hosts_dml.c Outdated
/*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]));
Comment thread source/lm/lm_main.c Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 18:37

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

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]));

Comment thread source/lm/lm_main.c Outdated
Comment on lines +769 to +772
#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))
{
Comment thread source/lm/lm_wrapper.c Outdated
Comment on lines +1815 to +1819
BOOL isDHCPServerDisable = FALSE;
#if defined (_CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_)
PLmObjectHost pHost;
pHost = Hosts_FindHostByPhysAddress((char *)physAddress);
if(pHost)
Comment thread source/lm/lm_main.c Outdated
Comment thread source/lm/lm_wrapper.c Fixed
Copilot AI review requested due to automatic review settings July 28, 2026 11:57

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

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", prefer strcmp for 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, isArpIpMatchOnDNSMasq remains 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, use strcmp.

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]));

Comment thread source/lm/lm_main.c
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,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread source/lm/lm_main.c Outdated
{
Host_SetIPAddress(pIP, LM_HOST_RETRY_LIMIT, "NONE");
}
while(fgets(buf, sizeof(buf), fp)!= NULL)
Comment thread source/lm/lm_main.c Outdated
break;
}
}
fclose(fp);
Copilot AI review requested due to automatic review settings July 28, 2026 13:32

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

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
Copilot AI review requested due to automatic review settings July 29, 2026 12:33

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

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, isArpIpMatchOnDNSMasq remains 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_FILE points 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__));
                            }

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

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_SyncArp into an O(N*M) hot path while holding presence locks (blocking other operations). Consider loading the leases once per Hosts_SyncArp run (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, isArpIpMatchOnDNSMasq stays 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.leases is missing/locked. Fall back to the previous retry-count update path (or at least skip removal) when fopen fails.
                            if((fp=fopen(DNSMASQ_FILE, "r")) == NULL)
                            {
                                CcspTraceDebug(("%s:%d, Failed to open dnsmasq configuration file\n",__FUNCTION__,__LINE__));
                            }

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.

3 participants