Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions source/firewall/firewall_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ int numifs = sizeof(ifnames) / sizeof(*ifnames);
#define V6_PORTSCANPROTECT "v6_PortScanProtect"
#define V6_IPFLOODDETECT "v6_IPFloodDetect"

#ifdef _ONESTACK_PRODUCT_REQ_
#define COSA_DML_DHCPV6_CLIENT_IFNAME "erouter0"
#define COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME "tr_"COSA_DML_DHCPV6_CLIENT_IFNAME"_dhcpv6_client_v6pref"
#endif
/*
****************************************************************
* IPv6 Firewall *
Expand Down Expand Up @@ -496,6 +492,10 @@ void do_ipv6_filter_table(FILE *fp){
char request[256], response[256], cm_ipv6addr[40];
unsigned int a[16] = {0};
#endif
#if defined (_ONESTACK_PRODUCT_REQ_)
char current_wan_interface[64] = {0};
char sysevent_name[128] = {0};
#endif

fprintf(fp, "*filter\n");
fprintf(fp, ":INPUT ACCEPT [0:0]\n");
Expand Down Expand Up @@ -1263,22 +1263,27 @@ void do_ipv6_filter_table(FILE *fp){
#ifdef _ONESTACK_PRODUCT_REQ_
if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
{
sysevent_get(sysevent_fd, sysevent_token, COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME, prefix, sizeof(prefix));
sysevent_get(sysevent_fd, sysevent_token, "current_wan_ifname", current_wan_interface, sizeof(current_wan_interface));
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.

hello ,
Why can’t we use the existing ipv6_prefix sysevent?
Currently, the ipv6_prefix sysevent is used by the WAN component to inform the system of the LAN prefix.
These changes would alter the existing contract between components.

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.

ipv6_prefix doesn't show the right prefix length, even though server sends /56, ipv6_prefix hard codes it to /64 which is wrong.

If this issue is fixed, we can use ipv6_prefix.

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.

Hello @snayak002c
ipv6_prefix should be working. It sets /64 for the residential gateways for the LAN. In case of business, it will set the received prefix length as it is.
https://github.com/rdkcentral/wan-manager/blob/main/source/WanManager/wanmgr_dhcpv6_apis.c#L2097

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.

@S-Parthiban-Selvaraj , This change is on XB10 one stack which supports both residential / business mode based on the partnerID/device mode. We can't enable CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION MACRO on this platform.

BTW why are we setting ipv6 prefix length differently on residential/ business. Shouldn't it return what it received from the server?

snprintf(sysevent_name, sizeof(sysevent_name), "tr_%s_dhcpv6_client_v6pref", current_wan_interface);
sysevent_get(sysevent_fd, sysevent_token, sysevent_name, prefix, sizeof(prefix));
}
else
{
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
}
#else
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
#endif
}

#else
#ifdef _ONESTACK_PRODUCT_REQ_
if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
{
sysevent_get(sysevent_fd, sysevent_token, COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME, prefix, sizeof(prefix));
sysevent_get(sysevent_fd, sysevent_token, "current_wan_ifname", current_wan_interface, sizeof(current_wan_interface));
snprintf(sysevent_name, sizeof(sysevent_name), "tr_%s_dhcpv6_client_v6pref", current_wan_interface);
sysevent_get(sysevent_fd, sysevent_token, sysevent_name, prefix, sizeof(prefix));

}
else
{
Expand All @@ -1300,7 +1305,7 @@ void do_ipv6_filter_table(FILE *fp){
#if defined (_COSA_FOR_BCI_) || defined (_ONESTACK_PRODUCT_REQ_)
/* adding forward rule for PD traffic */
#ifdef _ONESTACK_PRODUCT_REQ_
if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
{
fprintf(fp, "-A FORWARD -s %s -i %s -j ACCEPT\n", prefix, lan_ifname);
if (strncasecmp(firewall_levelv6, "Custom", strlen("Custom")) == 0)
Expand Down Expand Up @@ -2134,6 +2139,10 @@ typedef enum{
void applyRoutingRules(FILE* fp,ipv6_type type)
{
FIREWALL_DEBUG("Entering applyRoutingRules, ipv6_type is %d \n" COMMA type);
#if defined (_ONESTACK_PRODUCT_REQ_)
char current_wan_interface[64] = {0};
char sysevent_name[128] = {0};
#endif
char prefix[64] ;
memset(prefix,0,sizeof(prefix));
int i ;
Expand All @@ -2143,20 +2152,37 @@ void applyRoutingRules(FILE* fp,ipv6_type type)
}
else
{
#ifdef _ONESTACK_PRODUCT_REQ_
if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
#ifdef _ONESTACK_PRODUCT_REQ_
if(isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION))
{
sysevent_get(sysevent_fd, sysevent_token, COSA_DML_DHCPV6C_PREF_SYSEVENT_NAME, prefix, sizeof(prefix));
sysevent_get(sysevent_fd, sysevent_token, "current_wan_ifname", current_wan_interface, sizeof(current_wan_interface));
if (current_wan_interface[0] != '\0')
{
snprintf(sysevent_name, sizeof(sysevent_name), "tr_%s_dhcpv6_client_v6pref", current_wan_interface);
sysevent_get(sysevent_fd, sysevent_token, sysevent_name, prefix, sizeof(prefix));
}
else
{
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
}
}
else
{
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
}
#else
#else
sysevent_get(sysevent_fd, sysevent_token, "ipv6_prefix", prefix, sizeof(prefix));
#endif
#endif
}
if (strlen(prefix) != 0 )
/* Add firewall rules only if prefix is non-empty and, when IPv6 delegation is enabled, current_wan_interface is also non-empty */
#ifdef _ONESTACK_PRODUCT_REQ_
if ((strlen(prefix) != 0) &&
(!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) ||
(ULA_IPV6 == type) ||
(strlen(current_wan_interface) != 0)))
#else
if (strlen(prefix) != 0)
#endif
{
char *token_pref =NULL;
token_pref = strtok(prefix,"/");
Expand Down
Loading