Skip to content

RDKB-65587: Vlan creation failed if device mac starts with 00#36

Open
vysakhav wants to merge 1 commit into
mainfrom
feature/xer2_bringup
Open

RDKB-65587: Vlan creation failed if device mac starts with 00#36
vysakhav wants to merge 1 commit into
mainfrom
feature/xer2_bringup

Conversation

@vysakhav

@vysakhav vysakhav commented Jul 6, 2026

Copy link
Copy Markdown

Reason for change: Noticed vlan mac creation failed in case if device mac starts with 00:.

This change improves the robustness and correctness of Ethernet MAC address generation by adding NULL pointer validation, validating MAC address parsing results, preserving leading zeros in 48-bit MAC addresses, and ensuring safe string handling. These enhancements prevent potential crashes, eliminate invalid MAC address formatting, improve error reporting, and increase overall reliability of Ethernet interface initialization while maintaining existing functionality for valid inputs.

Test Procedure:
Make sure vlan creation is happening properly
device should have wan ip connectivity

Priority:P2
Signed-off-by: Vysakh A V vysakh.venugopal@sky.uk

Reason for change: Noticed vlan mac creation failed in case
if device mac starts with 00:.

This change improves the robustness and correctness of Ethernet MAC
address generation by adding NULL pointer validation, validating MAC
address parsing results, preserving leading zeros in 48-bit MAC addresses,
and ensuring safe string handling. These enhancements prevent potential crashes,
eliminate invalid MAC address formatting, improve error reporting, and
increase overall reliability of Ethernet interface initialization
while maintaining existing functionality for valid inputs.

Test Procedure:
Make sure vlan creation is happening properly
device should have wan ip connectivity

Priority:P2
Signed-off-by: Vysakh A V <vysakh.venugopal@sky.uk>
Copilot AI review requested due to automatic review settings July 6, 2026 10:34
@vysakhav
vysakhav requested a review from a team as a code owner July 6, 2026 10:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Improves VLAN Ethernet MAC address generation to avoid failures when the base device MAC begins with 00, and to make MAC derivation safer/more reliable during interface creation.

Changes:

  • Adds pEntry NULL validation in EthLink_GetMacAddr.
  • Adds parsing error handling for the base MAC address string.
  • Preserves leading zeros by formatting derived MACs as 12 hex digits and ensures safer string termination.
Comments suppressed due to low confidence (1)

source/TR-181/middle_layer_src/ethernet_apis.c:1253

  • The new NULL check still dereferences pEntry in the error log (pEntry->InstanceNumber), which will crash when pEntry is NULL. Split the checks so the NULL case logs safely.
    if (!pEntry || pEntry->InstanceNumber <= 0)
    {
        CcspTraceError(("%s-%d: Failed to get Mac Address, EthLinkInstance=%ld ", __FUNCTION__, __LINE__, pEntry->InstanceNumber));
        return ANSC_STATUS_FAILURE;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1271 to +1276
if (sscanf(acTmpReturnValue, "%llx", &number) != 1)
{
CcspTraceError(("[%s][%d] Failed to parse MAC address %s\n",
__FUNCTION__, __LINE__, acTmpReturnValue));
return ANSC_STATUS_FAILURE;
}
Comment on lines +1278 to +1281
new_mac = number + pEntry->MACAddrOffSet;

/* Always preserve leading zeros of a 48-bit MAC */
snprintf(hex, sizeof(hex), "%012llx", new_mac);
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.

2 participants