RDKB-64265 Hardcoded WAN Interface Name (erouter0) in Business Gateway Feature#282
RDKB-64265 Hardcoded WAN Interface Name (erouter0) in Business Gateway Feature#282
Conversation
vs residential Partner ID as part of single build
Reason for change: Prefix delegation handling
Test Procedure:
- Build OneStack Image
- In Business-mode, Check dibbler server is started and server.conf
has prefix-delegation class
- In Residential-mode, check whether device behaves as a non-CBR device
Risks: None
Priority: P1
Signed-off-by: rirfha948 <rasina_irfhan@comcast.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to remove the hardcoded erouter0-based DHCPv6 prefix sysevent key usage in the IPv6 firewall path by dynamically building the prefix sysevent name from the current WAN interface name, improving reusability across platforms where the WAN interface name differs.
Changes:
- Removes the fixed
COSA_DML_DHCPV6C_PREF_SYSEVENT_NAMEusage in the IPv6 firewall. - Builds
tr_<current_wan_ifname>_dhcpv6_client_v6prefat runtime (with a fallback whencurrent_wan_ifnameis unset) and uses it to fetch the delegated prefix in multiple code paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fprintf(fp, "-A FORWARD -i brlan0 -o erouter0 -s %s -j REJECT --reject-with icmp6-policy-fail\n", prev_prefix); | ||
| } | ||
| #endif | ||
| if ( '\0' != prefix[0] ) { | ||
| if (( '\0' != prefix[0] ) && (strlen(current_wan_interface) != 0)) { | ||
| //fprintf(fp, "-A FORWARD ! -s %s -i %s -m limit --limit 10/sec -j LOG --log-level %d --log-prefix \"UTOPIA: FW. IPv6 FORWARD anti-spoofing\"\n", prefix, lan_ifname,syslog_level); |
There was a problem hiding this comment.
current_wan_interface is declared only under _ONESTACK_PRODUCT_REQ_, but it’s referenced unconditionally in the if (( '\0' != prefix[0] ) && (strlen(current_wan_interface) != 0)) check. This will fail to compile for non-Onestack builds, and even on Onestack it can incorrectly skip adding IPv6 anti-spoofing rules when FEATURE_IPV6_DELEGATION is not supported (since current_wan_interface is never populated in the non-delegation branch). Consider either (a) guarding the current_wan_interface check with _ONESTACK_PRODUCT_REQ_ and only requiring it when delegation is enabled, or (b) always initializing current_wan_interface (e.g., from current_wan_ifname) before this check.
ac70375 to
6fca25f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e0163ce to
5144bd6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #ifdef _ONESTACK_PRODUCT_REQ_ | ||
| if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) | ||
| { | ||
| sysevent_get(sysevent_fd, sysevent_token, COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME, prefix, sizeof(prefix)); | ||
| strncpy(prefix, ipv6_delegation_prefix, sizeof(prefix) - 1); | ||
| } |
There was a problem hiding this comment.
prefix is only initialized with prefix[0] = 0; and then filled via strncpy(..., sizeof(prefix) - 1). If ipv6_delegation_prefix is length >= sizeof(prefix)-1, strncpy won’t NUL-terminate and prefix[sizeof(prefix)-1] is uninitialized, leading to undefined behavior in later strlen/fprintf uses. Zero-initialize prefix (e.g., memset(prefix, 0, sizeof(prefix))) or explicitly set prefix[sizeof(prefix)-1] = '\0' after the copy (or use a guaranteed NUL-terminating copy helper).
| #ifdef _ONESTACK_PRODUCT_REQ_ | ||
| if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) | ||
| { | ||
| sysevent_get(sysevent_fd, sysevent_token, COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME, prefix, sizeof(prefix)); | ||
| strncpy(prefix, ipv6_delegation_prefix, sizeof(prefix) - 1); | ||
| } |
There was a problem hiding this comment.
Same strncpy NUL-termination issue here: prefix isn’t fully initialized before the copy and strncpy(..., sizeof(prefix) - 1) can leave the destination unterminated when the source is long/truncated. Ensure prefix is zeroed or force prefix[sizeof(prefix)-1] = '\0' after copying (or use a NUL-terminating helper).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if defined (_ONESTACK_PRODUCT_REQ_) | ||
| static char ipv6_delegation_prefix[129] ={0}; | ||
| #endif |
There was a problem hiding this comment.
PR title/description indicates removing hardcoded WAN interface name ("erouter0"), but this file still contains several hardcoded "erouter0" references (e.g., forwarding rules and a wan6_ifname fallback). If the intent is to fully remove the hardcode for reusability, these remaining occurrences should be updated to use the current WAN interface variable (or otherwise derived interface) as well; otherwise, please narrow the PR title/description to clarify that only the DHCPv6-PD sysevent key construction was generalized here.
Reason for change: Removing erouter0 hardcode for reusability for different wan interface
Test Procedure:
Build OneStack Image
In Business-mode, Check dibbler server is started and server.conf has prefix-delegation class
In Residential-mode, check whether device behaves as a non-CBR device Risks: None
Priority: P1
[] Is this a User Story (US)?
This is a bug ticket
Have all dependent PRs from other components been listed ?
Does the commit message include both the User Story ticket and the Subtask ticket?
Will be all changes related to the User Story squashed and merged in a single commit?
Has the PR been raised only after completing all changes for the User Story (no partial changes)?
Has code development for the User Story been completed?
If yes, has the Gerrit topic or list of all dependent PRs across components (including meta-layer changes) been shared?
https://gerrit.teamccp.com/#/c/946157/
Is there a validation log available in the Jira ticket for verifying builds with the updated generic-srcrev.inc across all platforms?