RDKB-65587: Vlan creation failed if device mac starts with 00#36
Open
vysakhav wants to merge 1 commit into
Open
RDKB-65587: Vlan creation failed if device mac starts with 00#36vysakhav wants to merge 1 commit into
vysakhav wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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
pEntryNULL validation inEthLink_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
pEntryin the error log (pEntry->InstanceNumber), which will crash whenpEntryis 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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