Skip to content

RDKB-64265 Hardcoded WAN Interface Name (erouter0) in Business Gateway Feature#282

Open
rirfha948 wants to merge 10 commits intodevelopfrom
topic/RDKB-64265
Open

RDKB-64265 Hardcoded WAN Interface Name (erouter0) in Business Gateway Feature#282
rirfha948 wants to merge 10 commits intodevelopfrom
topic/RDKB-64265

Conversation

@rirfha948
Copy link
Copy Markdown
Contributor

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?

            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>
@rirfha948 rirfha948 requested review from a team as code owners April 1, 2026 11:32
Copilot AI review requested due to automatic review settings April 1, 2026 11:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_NAME usage in the IPv6 firewall.
  • Builds tr_<current_wan_ifname>_dhcpv6_client_v6pref at runtime (with a fallback when current_wan_ifname is 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.

Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment on lines 1299 to 1303
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);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread source/firewall/firewall_ipv6.c
Comment thread source/firewall/firewall_ipv6.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 08:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 11:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment thread source/firewall/firewall_ipv6.c
Comment thread source/firewall/firewall_ipv6.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment thread source/firewall/firewall_ipv6.c
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Comment thread source/firewall/firewall_ipv6.c Outdated
Copilot AI review requested due to automatic review settings April 26, 2026 11:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment on lines 1270 to 1274
#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);
}
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment on lines 1285 to 1289
#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);
}
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Comment thread source/firewall/firewall_ipv6.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.

Comment on lines +190 to 192
#if defined (_ONESTACK_PRODUCT_REQ_)
static char ipv6_delegation_prefix[129] ={0};
#endif
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

4 participants