From c2e4e851510efb1966857269a6cb54f89d916912 Mon Sep 17 00:00:00 2001 From: rirfha948 Date: Thu, 26 Feb 2026 14:37:46 +0000 Subject: [PATCH 1/4] RDKB-63098: [ONESTACK]-Handle IPv6 delegation for business 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 --- source/firewall/Makefile.am | 5 + source/firewall/firewall.h | 3 +- source/firewall/firewall_ipv6.c | 25 +++- .../init/c_registration/15_dhcpv6_client.c | 2 +- .../init/c_registration/15_dhcpv6_server.c | 39 +++++- .../scripts/init/c_registration/20_routing.c | 50 ++++++- .../scripts/init/c_registration/Makefile.am | 3 + .../scripts/init/service.d/service_crond.sh | 2 +- .../service.d/service_dhcpv6_server_bci.sh | 12 +- .../service_registration_functions.sh | 3 +- .../init/service.d/service_routed_bci.sh | 5 +- source/service_ipv6/Makefile.am | 3 + source/service_ipv6/service_ipv6.c | 96 ++++++++++--- source/service_routed/Makefile.am | 16 ++- source/service_routed/service_routed.c | 128 +++++++++++++++--- source/util/utils/Makefile.am | 4 +- 16 files changed, 332 insertions(+), 64 deletions(-) diff --git a/source/firewall/Makefile.am b/source/firewall/Makefile.am index 0af5c826..54029855 100644 --- a/source/firewall/Makefile.am +++ b/source/firewall/Makefile.am @@ -43,3 +43,8 @@ nfq_handler_LDADD = $(top_builddir)/source/syscfg/lib/libsyscfg.la \ if CORE_NET_LIB_FEATURE_SUPPORT AM_LDFLAGS += -lnet endif + +if ONESTACK_PRODUCT_REQ +AM_LDFLAGS += -ldevicemode -lrdkb_feature_mode_gate +endif + diff --git a/source/firewall/firewall.h b/source/firewall/firewall.h index 7a82d772..f658b550 100644 --- a/source/firewall/firewall.h +++ b/source/firewall/firewall.h @@ -627,7 +627,8 @@ int prepare_multinet_filter_output_v6(FILE *fp); */ int prepare_ipv6_rule_ex_mode(FILE *raw_fp, FILE *mangle_fp, FILE *nat_fp, FILE *filter_fp); #endif -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) +#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) \ + || defined(_ONESTACK_PRODUCT_REQ_) /** * @brief Prepare IPv6 MultiNet rules with DHCPv6 prefix delegation support. * diff --git a/source/firewall/firewall_ipv6.c b/source/firewall/firewall_ipv6.c index 798a6b0a..2ea4691a 100644 --- a/source/firewall/firewall_ipv6.c +++ b/source/firewall/firewall_ipv6.c @@ -98,6 +98,9 @@ #include #endif +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif void* bus_handle ; int sysevent_fd; char sysevent_ip[19]; @@ -862,11 +865,17 @@ void do_ipv6_filter_table(FILE *fp){ } #endif /*_HUB4_PRODUCT_REQ_*/ - #if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && ! defined(_CBR_PRODUCT_REQ_) +#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if ( isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == true) + #endif + { + /*Add a simple logic here to make traffic allowed for lan interfaces * exclude primary lan*/ prepare_ipv6_multinet(fp); - #endif + } +#endif #if !defined(_XER5_PRODUCT_REQ_) && !defined (_SCER11BEL_PRODUCT_REQ_) && !defined(_COSA_QCA_ARM_) //wan0 is not applicable for XER5 /* not allow ping wan0 from brlan0 */ int i; @@ -1717,9 +1726,17 @@ void do_ipv6_filter_table(FILE *fp){ FIREWALL_DEBUG("Exiting prepare_ipv6_firewall \n"); } -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && ! defined(_CBR_PRODUCT_REQ_) -static int prepare_ipv6_multinet(FILE *fp) +#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) \ + || defined(_ONESTACK_PRODUCT_REQ_) +int prepare_ipv6_multinet(FILE *fp) { +#ifdef _ONESTACK_PRODUCT_REQ_ + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + { + /* PD feature disabled */ + return 0; + } +#endif char active_insts[32] = {0}; char lan_pd_if[128] = {0}; char *p = NULL; diff --git a/source/scripts/init/c_registration/15_dhcpv6_client.c b/source/scripts/init/c_registration/15_dhcpv6_client.c index 0ec17f83..b33d10f1 100644 --- a/source/scripts/init/c_registration/15_dhcpv6_client.c +++ b/source/scripts/init/c_registration/15_dhcpv6_client.c @@ -57,7 +57,7 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "lan-status|/usr/bin/service_dhcpv6_client", NULL }; -#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) const char* SERVICE_CUSTOM_EVENTS[] = { "erouter_mode-updated|/etc/utopia/service.d/service_dhcpv6_client.sh", "phylink_wan_state|/etc/utopia/service.d/service_dhcpv6_client.sh", diff --git a/source/scripts/init/c_registration/15_dhcpv6_server.c b/source/scripts/init/c_registration/15_dhcpv6_server.c index 0c45dfcd..f29bae80 100644 --- a/source/scripts/init/c_registration/15_dhcpv6_server.c +++ b/source/scripts/init/c_registration/15_dhcpv6_server.c @@ -35,10 +35,17 @@ #include #include "srvmgr.h" +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif const char* SERVICE_NAME = "dhcpv6_server"; const char* SERVICE_DEFAULT_HANDLER = "/etc/utopia/service.d/service_dhcpv6_server.sh"; +#if defined(_ONESTACK_PRODUCT_REQ_) +const char** SERVICE_CUSTOM_EVENTS = NULL; +#endif + #if defined(_CBR_PRODUCT_REQ_) && !defined(_CBR2_PRODUCT_REQ_) const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_option_changed|/usr/bin/service_ipv6", @@ -47,11 +54,28 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_server-restart|/usr/bin/service_ipv6", NULL }; -#elif defined (CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server.sh|NULL|"TUPLE_FLAG_EVENT, NULL }; +#elif defined(_ONESTACK_PRODUCT_REQ_) +const char* SERVICE_CUSTOM_EVENTS_RESIDENTIAL[] = { + "lan-status|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_nameserver|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_domain|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_ntp_server|/etc/utopia/service.d/service_dhcpv6_server.sh", + "dhcp_domain|/etc/utopia/service.d/service_dhcpv6_server.sh", + "current_lan_ipv6address|/etc/utopia/service.d/service_dhcpv6_server.sh", + NULL + }; +const char* SERVICE_CUSTOM_EVENTS_BUSINESS[] = { + "dhcpv6_server-start|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_server-stop|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_server-restart|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "ipv6_prefix_delegation|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server_bci.sh|NULL|"TUPLE_FLAG_EVENT,NULL + }; #else const char* SERVICE_CUSTOM_EVENTS[] = { "lan-status|/etc/utopia/service.d/service_dhcpv6_server.sh", @@ -64,8 +88,21 @@ const char* SERVICE_CUSTOM_EVENTS[] = { }; #endif +#if defined(_ONESTACK_PRODUCT_REQ_) +static void init_service_custom_events(void) +{ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_BUSINESS; + } else { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_RESIDENTIAL; + } +} +#endif void srv_register(void) { +#if defined(_ONESTACK_PRODUCT_REQ_) + init_service_custom_events(); +#endif sm_register(SERVICE_NAME, SERVICE_DEFAULT_HANDLER, SERVICE_CUSTOM_EVENTS); } diff --git a/source/scripts/init/c_registration/20_routing.c b/source/scripts/init/c_registration/20_routing.c index b68ce5fc..5a4d4cb3 100644 --- a/source/scripts/init/c_registration/20_routing.c +++ b/source/scripts/init/c_registration/20_routing.c @@ -40,11 +40,16 @@ #endif #include "srvmgr.h" #include "secure_wrapper.h" +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #define SERVICE_NAME "routed" #define SERVICE_DEFAULT_HANDLER "/etc/utopia/service.d/service_routed.sh" - -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(_ONESTACK_PRODUCT_REQ_) +const char** SERVICE_CUSTOM_EVENTS = NULL; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_routed.sh", "lan-status|/etc/utopia/service.d/service_routed.sh", @@ -54,6 +59,33 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "staticroute-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, NULL }; +#elif defined(_ONESTACK_PRODUCT_REQ_) +const char* SERVICE_CUSTOM_EVENTS_RESIDENTIAL[] = { + "wan-status|/etc/utopia/service.d/service_routed.sh", + "lan-status|/etc/utopia/service.d/service_routed.sh", + "ipv6_nameserver|/etc/utopia/service.d/service_routed.sh", + "ipv6_prefix|/etc/utopia/service.d/service_routed.sh", + "ripd-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + "zebra-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + "staticroute-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + #ifdef WAN_FAILOVER_SUPPORTED + "routeset-ula|/usr/bin/service_routed|NULL|"TUPLE_FLAG_EVENT, + "routeunset-ula|/usr/bin//service_routed|NULL|"TUPLE_FLAG_EVENT, + #endif + NULL + }; +const char* SERVICE_CUSTOM_EVENTS_BUSINESS[] = { + "wan-status|/etc/utopia/service.d/service_routed_bci.sh", + "lan-status|/etc/utopia/service.d/service_routed_bci.sh", + "dhcpv6_option_changed|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "ripd-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "zebra-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "staticroute-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "ipv6_prefix_delegation|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + NULL + }; + + #else const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_routed.sh", @@ -72,7 +104,21 @@ const char* SERVICE_CUSTOM_EVENTS[] = { #endif +#if defined(_ONESTACK_PRODUCT_REQ_) +static void init_service_custom_events(void) +{ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_BUSINESS; + } else { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_RESIDENTIAL; + } +} +#endif + void srv_register(void) { +#if defined(_ONESTACK_PRODUCT_REQ_) + init_service_custom_events(); +#endif // not sure is the rm is necessary anymore // system("rm -Rf /etc/iproute2/rt_tables"); DBG_PRINT("20_routing : %s Entry\n", __FUNCTION__); diff --git a/source/scripts/init/c_registration/Makefile.am b/source/scripts/init/c_registration/Makefile.am index ab532c93..c2b13bed 100644 --- a/source/scripts/init/c_registration/Makefile.am +++ b/source/scripts/init/c_registration/Makefile.am @@ -132,3 +132,6 @@ endif if ENABLE_HOTSPOT_SERVICE 15_hotspot_SOURCES = 15_hotspot.c endif +if ONESTACK_PRODUCT_REQ +LDFLAGS += -lrdkb_feature_mode_gate -ldevicemode +endif diff --git a/source/scripts/init/service.d/service_crond.sh b/source/scripts/init/service.d/service_crond.sh index 33b9757f..ea6aa1e4 100755 --- a/source/scripts/init/service.d/service_crond.sh +++ b/source/scripts/init/service.d/service_crond.sh @@ -120,7 +120,7 @@ service_start () echo "1 */12 * * * /usr/ccsp/tad/FileHandle_Monitor.sh" >> $CRONTAB_FILE - if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then + if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then echo "*/15 * * * * /usr/ccsp/tad/log_staticIP_client_info.sh" >> $CRONTAB_FILE fi diff --git a/source/scripts/init/service.d/service_dhcpv6_server_bci.sh b/source/scripts/init/service.d/service_dhcpv6_server_bci.sh index e83f1dc7..463fac25 100755 --- a/source/scripts/init/service.d/service_dhcpv6_server_bci.sh +++ b/source/scripts/init/service.d/service_dhcpv6_server_bci.sh @@ -262,21 +262,21 @@ service_init case "$1" in "${SERVICE_NAME}-start") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 start else service_ipv6 dhcpv6s-start fi ;; "${SERVICE_NAME}-stop") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 stop else service_ipv6 dhcpv6s-stop fi ;; "${SERVICE_NAME}-restart") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 restart else service_ipv6 dhcpv6s-restart @@ -285,11 +285,13 @@ fi #---------------------------------------------------------------------------------- # Add other event entry points here #---------------------------------------------------------------------------------- - + ipv6_prefix_delegation) + service_ipv6 restart + ;; # ipv6_nameserver|ipv6_dnssl) # service_ipv6 dhcpv6s-restart dhcpv6_option_changed) -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 restart else service_ipv6 dhcpv6s-restart diff --git a/source/scripts/init/service.d/service_registration_functions.sh b/source/scripts/init/service.d/service_registration_functions.sh index 729c2d4a..296549ff 100755 --- a/source/scripts/init/service.d/service_registration_functions.sh +++ b/source/scripts/init/service.d/service_registration_functions.sh @@ -306,7 +306,7 @@ sm_register_one_event() { if [ "NULL" = "$SMR_EVENT" ] ; then return 0 fi - + echo "[DEBUG] sm_rm_event ${SMR_SERVICE} ${SMR_EVENT_NAME}" # if this service has already registered for this event, then cancel the previous registration # this is probably overkill since we likely already called sm_unregister, but better safe than sorry sm_rm_event "${SMR_SERVICE}" "${SMR_EVENT_NAME}" @@ -445,6 +445,7 @@ sm_register() { IFS=';' for custom in $SM_CUSTOM_EVENTS ; do if [ -n "$custom" ] && [ " " != "$custom" ] ; then + echo "[DHCPV6][DEBUG] Registering custom event: '$custom' for service '$SM_SERVICE'" IFS=$SAVEIFS sm_register_one_event "$SM_SERVICE" "$custom" IFS=';' diff --git a/source/scripts/init/service.d/service_routed_bci.sh b/source/scripts/init/service.d/service_routed_bci.sh index c83dbb27..c510b546 100755 --- a/source/scripts/init/service.d/service_routed_bci.sh +++ b/source/scripts/init/service.d/service_routed_bci.sh @@ -80,11 +80,14 @@ case "$1" in staticroute-restart) service_routed radv-restart ;; + ipv6_prefix_delegation) + service_routed radv-restart + ;; # ipv6_nameserver|ipv6_dnssl) # service_routed radv-restart # ;; ipv6_prefix|ipv6_nameserver) -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_routed radv-restart fi ;; diff --git a/source/service_ipv6/Makefile.am b/source/service_ipv6/Makefile.am index 8e96cfff..6f4c7f9d 100644 --- a/source/service_ipv6/Makefile.am +++ b/source/service_ipv6/Makefile.am @@ -25,6 +25,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/source/include \ AM_LDFLAGS = -lccsp_common -lsecure_wrapper $(DBUS_LIBS) +if ONESTACK_PRODUCT_REQ +AM_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate +endif service_ipv6_SOURCES = service_ipv6.c service_ipv6_main.c service_ipv6_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ diff --git a/source/service_ipv6/service_ipv6.c b/source/service_ipv6/service_ipv6.c index a8d99354..c8b371d4 100644 --- a/source/service_ipv6/service_ipv6.c +++ b/source/service_ipv6/service_ipv6.c @@ -53,6 +53,9 @@ #include "ccsp_memory.h" #endif +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #ifdef _HUB4_PRODUCT_REQ_ #include "ccsp_dm_api.h" #include "ccsp_custom.h" @@ -257,8 +260,8 @@ struct dhcpv6_tag tag_list[] = else if ( val[0] ) out = atoi(val); \ } \ -#ifdef _CBR_PRODUCT_REQ_ -STATIC uint64_t helper_ntoh64(const uint64_t *inputval) +#if defined( _CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) +STATIC uint64_t helper_ntoh64(const long long unsigned int *inputval) { uint64_t returnval; uint8_t *data = (uint8_t *)&returnval; @@ -275,7 +278,7 @@ STATIC uint64_t helper_ntoh64(const uint64_t *inputval) return returnval; } -STATIC uint64_t helper_hton64(const uint64_t *inputval) +STATIC uint64_t helper_hton64(const long long unsigned int *inputval) { return (helper_ntoh64(inputval)); } @@ -391,10 +394,21 @@ STATIC int get_dhcpv6s_pool_cfg(struct serv_ipv6 *si6, dhcpv6s_pool_cfg_t *cfg) DHCPV6S_SYSCFG_GETI(DHCPV6S_NAME, "pool", cfg->index, "", 0, "X_RDKCENTRAL_COM_DNSServersEnabled", cfg->X_RDKCENTRAL_COM_DNSServersEnabled); #ifdef MULTILAN_FEATURE -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION - DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", iface_name); -#else - DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "Interface", iface_name); +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == true) + #endif + { + DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", iface_name); + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == false) + #endif + { + DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "Interface", iface_name); + } #endif #else DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", cfg->interface); @@ -449,7 +463,7 @@ STATIC int get_ia_info(struct serv_ipv6 *si6, char *config_file, ia_na_t *iana, if(iana == NULL || iapd == NULL) return -1; -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) sysevent_get(si6->sefd, si6->setok, COSA_DML_DHCPV6C_PREF_T1_SYSEVENT_NAME, action, sizeof(action)); errno_t rc = -1; if(action[0]!='\0') @@ -606,7 +620,7 @@ STATIC int get_prefix_info(const char *prefix, char *value, unsigned int val_le STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigned int *num) { int i = 0; -#if !defined(MULTILAN_FEATURE) || defined CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if !defined(MULTILAN_FEATURE) || defined CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION || defined(_ONESTACK_PRODUCT_REQ_) char active_insts[32] = {0}; char lan_pd_if[128] = {0}; char *p = NULL; @@ -628,7 +642,11 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne unsigned int max_active_if_count = 0; int primary_l3_instance = 0; -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { syscfg_get(NULL, "lan_pd_interfaces", lan_pd_if, sizeof(lan_pd_if)); if (lan_pd_if[0] == '\0') { *num = 0; @@ -648,7 +666,14 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne p = strtok(NULL, " "); } -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { + /* Get active bridge count from PSM */ if (!bus_handle) { fprintf(stderr, "DBUS not connected, returning \n"); @@ -718,6 +743,7 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne } /* Set active IPv6 instances */ sysevent_set(si6->sefd, si6->setok, "ipv6_active_inst", active_if_list, 0); + } #endif @@ -879,7 +905,7 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) p_prefix = sub_prefixes; memcpy((void *)&tmp_prefix, (void *)prefix, 8); // the first 64 bits of mso prefix value -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_ntoh64(&tmp_prefix); // The memcpy is copying in reverse order due to LEndianess #endif #ifdef MULTILAN_FEATURE @@ -892,7 +918,7 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) sub_prefix = tmp_prefix | (i << (delta_bits - bit_boundary)); #endif memset(buf, 0, sizeof(buf)); -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) sub_prefix = helper_hton64(&sub_prefix);// The memcpy is copying in reverse order due to LEndianess #endif memcpy((void *)buf, (void *)&sub_prefix, 8); @@ -920,13 +946,13 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) fprintf(stderr, "inet_pton failed\n"); } memcpy((void *)&tmp_prefix, (void *)prefix, 8); //the first 64 bits of the first sub-prefix -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_ntoh64(&tmp_prefix); // The memcpy is copying in reverse order due to LEndianess #endif for (i = 0; i < enabled_iface_num; i++) { //p_prefix->b_used = 1; memset(buf, 0, sizeof(buf)); -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_hton64(&tmp_prefix);// The memcpy is copying in reverse order due to LEndianess #endif memcpy((void *)buf, (void *)&tmp_prefix, 8); @@ -1682,7 +1708,7 @@ STATIC int gen_dibbler_conf(struct serv_ipv6 *si6) fprintf(fp, "inactive-mode\n"); /*Run scipt to config route */ -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) fprintf(fp, "script \"/lib/rdk/server-notify.sh\" \n"); #endif @@ -1778,7 +1804,7 @@ STATIC int gen_dibbler_conf(struct serv_ipv6 *si6) /*pd pool*/ if(get_pd_pool(si6, &pd_pool) == 0) { fprintf(fp, " pd-class {\n"); -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) fprintf(fp, " pd-pool %s /%d\n", pd_pool.start, pd_pool.prefix_length); #else fprintf(fp, " pd-pool %s - %s /%d\n", pd_pool.start, pd_pool.end, pd_pool.prefix_length); @@ -2079,6 +2105,7 @@ STATIC int dhcpv6s_restart(struct serv_ipv6 *si6) STATIC int serv_ipv6_start(struct serv_ipv6 *si6) { + fprintf(stderr, "Entered serv_ipv6_start \n"); char rtmod[16]; /* state check */ @@ -2098,10 +2125,17 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "starting", 0); /* Fix for IPv6 prefix not getting updated in dibbler server conf file on WAN mode change */ -#if defined(_CBR2_PRODUCT_REQ_) +#if defined(_CBR2_PRODUCT_REQ_) sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); sysevent_set(si6->sefd, si6->setok, "ipv6_prefix-divided", "", 0); #endif +#if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix_delegation", si6->mso_prefix, sizeof(si6->mso_prefix)); + sysevent_set(si6->sefd, si6->setok, "ipv6_prefix-divided", "", 0); + } +#endif /* * Update MTU of all the enabled IPv6 instances @@ -2118,13 +2152,22 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) * 5) Send RA, start DHCPv6 server */ /* For CBR product the lan(brlan0) v6 address set is done as part of PandM process*/ -#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) +#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) && !defined(_ONESTACK_PRODUCT_REQ_) if (lan_addr6_set(si6) !=0) { fprintf(stderr, "assign IPv6 address for lan interfaces error!\n"); sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); return -1; } #endif +#if defined (_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)){ + if (lan_addr6_set(si6) !=0) { + fprintf(stderr, "assign IPv6 address for lan interfaces error!\n"); + sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); + return -1; + } + } +#endif //Intel Proposed RDKB Generic Bug Fix from XB6 SDK /*start zebra*/ @@ -2152,6 +2195,7 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) { + fprintf(stderr, "Entered serv_ipv6_stop \n"); if (!serv_can_stop(si6->sefd, si6->setok, "service_ipv6")) return -1; @@ -2162,7 +2206,7 @@ STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); return -1; } -#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) +#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) && !defined(_ONESTACK_PRODUCT_REQ_) del_addr6_flg = false; if (lan_addr6_unset(si6) !=0) { fprintf(stderr, "unset IPv6 address for lan interfaces error!\n"); @@ -2171,6 +2215,18 @@ STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) return -1; } del_addr6_flg = true; +#endif +#if defined (_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)){ + del_addr6_flg = false; + if (lan_addr6_unset(si6) !=0) { + fprintf(stderr, "unset IPv6 address for lan interfaces error!\n"); + sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); + del_addr6_flg = true; + return -1; + } + del_addr6_flg = true; + } #endif sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "stopped", 0); return 0; diff --git a/source/service_routed/Makefile.am b/source/service_routed/Makefile.am index e869e8de..5cf9aa9d 100644 --- a/source/service_routed/Makefile.am +++ b/source/service_routed/Makefile.am @@ -19,7 +19,11 @@ bin_PROGRAMS = service_routed -AM_LDFLAGS = -lsecure_wrapper +AM_CPPFLAGS = -I$(top_srcdir)/source/include \ + -I$(top_srcdir)/source/util/utils \ + $(DBUS_CFLAGS) + +AM_LDFLAGS = -lsecure_wrapper -lccsp_common $(DBUS_LIBS) service_routed_SOURCES = service_routed.c service_routed_main.c @@ -29,8 +33,8 @@ service_routed_CFLAGS = -I$(top_srcdir)/source \ -I$(top_srcdir)/source/utapi/lib \ -I$(top_srcdir)/source/util/utils \ -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/dbus-1.0 \ - -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/dbus-1.0/include - + -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/dbus-1.0/include \ + -I${PKG_CONFIG_SYSROOT_DIR}$(includedir) service_routed_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ $(top_builddir)/source/services/lib/libsrvmgr.la \ @@ -40,6 +44,10 @@ service_routed_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ $(top_builddir)/source/utctx/lib/libutctx.la \ $(top_builddir)/source/ulog/libulog.la \ -ltelemetry_msgsender +service_routed_LDFLAGS = -L${PKG_CONFIG_SYSROOT_DIR}${libdir} +if ONESTACK_PRODUCT_REQ +service_routed_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate +endif if CORE_NET_LIB_FEATURE_SUPPORT -service_routed_LDFLAGS = -lnet +service_routed_LDFLAGS += -lnet endif diff --git a/source/service_routed/service_routed.c b/source/service_routed/service_routed.c index 34e7ca35..14417781 100644 --- a/source/service_routed/service_routed.c +++ b/source/service_routed/service_routed.c @@ -59,6 +59,9 @@ #include #endif +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #include "util.h" #include #include "sysevent/sysevent.h" @@ -425,8 +428,11 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign char *p = NULL; int i = 0; -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION - +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { char lan_pd_if[128] = {0}; char if_name[16] = {0}; char buf[64] = {0}; @@ -449,8 +455,13 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign p = strtok(NULL, " "); } - -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { /* service_ipv6 sets active IPv6 interfaces instances. */ sysevent_get(sefd, setok, "ipv6_active_inst", active_insts, sizeof(active_insts)); @@ -459,14 +470,14 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign insts[i++] = atoi(p); p = strtok(NULL, " "); } - + } #endif *num = i; return *num; } #else -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsigned int *num) { char active_insts[32] = {0}; @@ -505,7 +516,11 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign STATIC int route_set(struct serv_routed *sr) { -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; char evt_name[64] = {0}; @@ -560,6 +575,7 @@ STATIC int route_set(struct serv_routed *sr) lan_if, lan_if, lan_if, lan_if); #endif } + } #endif #if defined (_HUB4_PRODUCT_REQ_) && (!defined (_WNXL11BWL_PRODUCT_REQ_)) || defined(_SCER11BEL_PRODUCT_REQ_) @@ -657,7 +673,11 @@ STATIC int route_unset(struct serv_routed *sr) #ifdef CORE_NET_LIB libnet_status status; #endif -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) || defined(_ONESTACK_PRODUCT_REQ_) +#ifdef _ONESTACK_PRODUCT_REQ_ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) +#endif + { unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; char evt_name[64] = {0}; @@ -689,7 +709,8 @@ STATIC int route_unset(struct serv_routed *sr) #endif } -#elif !defined(WAN_MANAGER_UNIFICATION_ENABLED) //Default route is configured WanManager. + } +#elif !defined(WAN_MANAGER_UNIFICATION_ENABLED) #if defined (_HUB4_PRODUCT_REQ_) && (!defined (_WNXL11BWL_PRODUCT_REQ_)) || defined(_RDKB_GLOBAL_PRODUCT_REQ_) #ifdef CORE_NET_LIB status = rule_delete("-6 iif brlan0 table erouter"); @@ -901,7 +922,7 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) "!log stdout\n" "log file /var/tmp/zebra.log errors\n" "table 255\n"; -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) int i = 0; unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; @@ -1000,15 +1021,27 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) #endif syscfg_get(NULL, "ra_interval", ra_interval, sizeof(ra_interval)); -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION + +#ifdef WAN_FAILOVER_SUPPORTED + char last_broadcasted_prefix[64] = {0}; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { sysevent_get(sefd, setok, "previous_ipv6_prefix", orig_prefix, sizeof(orig_prefix)); sysevent_get(sefd, setok, "ipv6_prefix_prdtime", preferred_lft, sizeof(preferred_lft)); sysevent_get(sefd, setok, "ipv6_prefix_vldtime", valid_lft, sizeof(valid_lft)); -#else - + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { #ifdef WAN_FAILOVER_SUPPORTED - char last_broadcasted_prefix[64] ; memset(last_broadcasted_prefix,0,sizeof(last_broadcasted_prefix)); if (gIpv6AddrAssignment == ULA_IPV6) { @@ -1119,6 +1152,7 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) sysevent_get(sefd, setok, "ipv6_prefix_vldtime", valid_lft, sizeof(valid_lft)); #endif syscfg_get(NULL, "lan_ifname", lan_if, sizeof(lan_if)); + } #endif if (atoi(preferred_lft) <= 0) snprintf(preferred_lft, sizeof(preferred_lft), "300"); @@ -1131,7 +1165,24 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) sysevent_get(sefd, setok, "wan-status", wan_st, sizeof(wan_st)); syscfg_get(NULL, "last_erouter_mode", rtmod, sizeof(rtmod)); -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined (_ONESTACK_PRODUCT_REQ_) + int multilan_enabled = 0; + int pd_enabled = 0; + +#if defined(MULTILAN_FEATURE) + multilan_enabled = 1; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + pd_enabled = 1; +#endif + + #ifdef _ONESTACK_PRODUCT_REQ_ + pd_enabled = isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION); + #endif + + if (pd_enabled || multilan_enabled) + { get_active_lanif(sefd, setok, l2_insts, &enabled_iface_num); for (i = 0; i < enabled_iface_num; i++) { @@ -1438,11 +1489,22 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) if ((strncmp(buf,"true",4) == 0) && iresCode == 204) { #if defined (_COSA_BCM_MIPS_) -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { // For CBR platform, the captive portal redirection feature was removed // inWifiCp = 1; -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { inWifiCp = 1; + } #endif #else inWifiCp = 1; @@ -1557,16 +1619,32 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) } #endif /* static IPv6 DNS */ -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { snprintf(rec, sizeof(rec), "dhcpv6spool%d0::optionnumber", i); syscfg_get(NULL, rec, val, sizeof(val)); -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { syscfg_get(NULL, "dhcpv6spool00::optionnumber", val, sizeof(val)); + } #endif nopt = atoi(val); for (j = 0; j < nopt; j++) { -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { memset(name_servs, 0, sizeof(name_servs)); + } #endif snprintf(rec, sizeof(rec), "dhcpv6spool0option%d::bEnabled", j); /*RDKB-12965 & CID:-34147*/ syscfg_get(NULL, rec, val, sizeof(val)); @@ -1709,11 +1787,16 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) fprintf(fp, "interface %s\n", lan_if); fprintf(fp, " ip irdp multicast\n"); -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) } //for (i = 0; i < enabled_iface_num; i++) + } #endif -#ifndef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) +#ifdef _ONESTACK_PRODUCT_REQ_ +if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) +#endif +{ char cmd[100]; char out[100]; char interface_name[32] = {0}; @@ -1925,6 +2008,7 @@ if(!strncmp(out,"true",strlen(out))) memset(out,0,sizeof(out)); } } +} #endif fclose(fp); return 0; diff --git a/source/util/utils/Makefile.am b/source/util/utils/Makefile.am index dc8db498..62242b7e 100644 --- a/source/util/utils/Makefile.am +++ b/source/util/utils/Makefile.am @@ -26,4 +26,6 @@ libutopiautil_la_CPPFLAGS = -I$(top_srcdir)/source/include \ $(DBUS_CFLAGS) libutopiautil_la_LDFLAGS = -lccsp_common $(DBUS_LIBS) - +if ONESTACK_PRODUCT_REQ +libutopiautil_la_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate +endif From 31e582260c3915766216037d8cc8ddc61401b363 Mon Sep 17 00:00:00 2001 From: rirfha948 Date: Thu, 26 Feb 2026 14:37:46 +0000 Subject: [PATCH 2/4] RDKB-63098: [ONESTACK]-Handle IPv6 delegation for business 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 --- source/service_ipv6/service_ipv6.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/source/service_ipv6/service_ipv6.c b/source/service_ipv6/service_ipv6.c index c8b371d4..b0142fd4 100644 --- a/source/service_ipv6/service_ipv6.c +++ b/source/service_ipv6/service_ipv6.c @@ -2275,12 +2275,28 @@ STATIC int serv_ipv6_init(struct serv_ipv6 *si6) return -1; #endif } - +#if defined (_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix_delegation", si6->mso_prefix, sizeof(si6->mso_prefix)); + } + else + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); + } +#else sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); +#endif + fprintf(stderr, "IPv6 Prefix :%s\n", si6->mso_prefix); if (strlen(si6->mso_prefix)) + { si6->wan_ready = true; + } else + { + fprintf(stderr, "[%s] -- Init ipv6_prefix retrieval failed\n", PROG_NAME); return -1; + } sysevent_get(si6->sefd, si6->setok, "erouter_topology-mode", buf, sizeof(buf)); switch(atoi(buf)) { @@ -2363,8 +2379,10 @@ int service_ipv6_main(int argc, char *argv[]) } if (serv_ipv6_init(&si6) != 0) + { + fprintf(stderr, "[%s] -- Service IPV6 Initialization failed\n", PROG_NAME); exit(1); - + } for (i = 0; i < NELEMS(cmd_ops); i++) { if (strcmp(argv[1], cmd_ops[i].cmd) != 0 || !cmd_ops[i].exec) continue; @@ -2379,6 +2397,7 @@ int service_ipv6_main(int argc, char *argv[]) if (i == NELEMS(cmd_ops)) fprintf(stderr, "[%s] unknown command: %s\n", PROG_NAME, argv[1]); + fprintf(stderr, "[%s] -- DHCPv6 start in progress\n", PROG_NAME); if (serv_ipv6_term(&si6) != 0) exit(1); From 0443b75c2e88db51b7603cb2760d9fb0a3052d9c Mon Sep 17 00:00:00 2001 From: rirfha948 Date: Fri, 27 Feb 2026 09:25:51 +0000 Subject: [PATCH 3/4] Review Comment Addressal -Patch1 --- source/firewall/Makefile.am | 5 ----- source/firewall/firewall.h | 3 +-- source/firewall/firewall_ipv6.c | 21 ++------------------ source/service_routed/service_routed.c | 27 ++++++++------------------ 4 files changed, 11 insertions(+), 45 deletions(-) diff --git a/source/firewall/Makefile.am b/source/firewall/Makefile.am index 7583fac6..c0335581 100644 --- a/source/firewall/Makefile.am +++ b/source/firewall/Makefile.am @@ -47,8 +47,3 @@ nfq_handler_LDADD = $(top_builddir)/source/syscfg/lib/libsyscfg.la \ if CORE_NET_LIB_FEATURE_SUPPORT AM_LDFLAGS += -lnet endif - -if ONESTACK_PRODUCT_REQ -AM_LDFLAGS += -ldevicemode -lrdkb_feature_mode_gate -endif - diff --git a/source/firewall/firewall.h b/source/firewall/firewall.h index f658b550..7a82d772 100644 --- a/source/firewall/firewall.h +++ b/source/firewall/firewall.h @@ -627,8 +627,7 @@ int prepare_multinet_filter_output_v6(FILE *fp); */ int prepare_ipv6_rule_ex_mode(FILE *raw_fp, FILE *mangle_fp, FILE *nat_fp, FILE *filter_fp); #endif -#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) \ - || defined(_ONESTACK_PRODUCT_REQ_) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) /** * @brief Prepare IPv6 MultiNet rules with DHCPv6 prefix delegation support. * diff --git a/source/firewall/firewall_ipv6.c b/source/firewall/firewall_ipv6.c index 2ea4691a..b3da8517 100644 --- a/source/firewall/firewall_ipv6.c +++ b/source/firewall/firewall_ipv6.c @@ -98,9 +98,6 @@ #include #endif -#ifdef _ONESTACK_PRODUCT_REQ_ -#include -#endif void* bus_handle ; int sysevent_fd; char sysevent_ip[19]; @@ -865,16 +862,10 @@ void do_ipv6_filter_table(FILE *fp){ } #endif /*_HUB4_PRODUCT_REQ_*/ -#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) || defined(_ONESTACK_PRODUCT_REQ_) - #if defined(_ONESTACK_PRODUCT_REQ_) - if ( isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == true) - #endif - { - +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) /*Add a simple logic here to make traffic allowed for lan interfaces * exclude primary lan*/ prepare_ipv6_multinet(fp); - } #endif #if !defined(_XER5_PRODUCT_REQ_) && !defined (_SCER11BEL_PRODUCT_REQ_) && !defined(_COSA_QCA_ARM_) //wan0 is not applicable for XER5 /* not allow ping wan0 from brlan0 */ @@ -1726,17 +1717,9 @@ void do_ipv6_filter_table(FILE *fp){ FIREWALL_DEBUG("Exiting prepare_ipv6_firewall \n"); } -#if (defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_)) \ - || defined(_ONESTACK_PRODUCT_REQ_) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) int prepare_ipv6_multinet(FILE *fp) { -#ifdef _ONESTACK_PRODUCT_REQ_ - if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) - { - /* PD feature disabled */ - return 0; - } -#endif char active_insts[32] = {0}; char lan_pd_if[128] = {0}; char *p = NULL; diff --git a/source/service_routed/service_routed.c b/source/service_routed/service_routed.c index 14417781..3b5bd6c2 100644 --- a/source/service_routed/service_routed.c +++ b/source/service_routed/service_routed.c @@ -1488,28 +1488,17 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) if ((strncmp(buf,"true",4) == 0) && iresCode == 204) { -#if defined (_COSA_BCM_MIPS_) -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) - #if defined(_ONESTACK_PRODUCT_REQ_) - if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) - #endif - { - // For CBR platform, the captive portal redirection feature was removed - // inWifiCp = 1; - } -#endif -#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) - #if defined(_ONESTACK_PRODUCT_REQ_) - if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) - #endif - { - inWifiCp = 1; - } +#if defined (_COSA_BCM_MIPS_) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + // For CBR platform, the captive portal redirection feature was removed + // inWifiCp = 1; +#else + inWifiCp = 1; #endif #else - inWifiCp = 1; + inWifiCp = 1; #endif - } + } #if defined (_XB6_PROD_REQ_) syscfg_get(NULL, "enableRFCaptivePortal", rfCpEnable, sizeof(rfCpEnable)); if(rfCpEnable != NULL) From 7b599ffa47489c534e3ea79ec723f51c253f1da0 Mon Sep 17 00:00:00 2001 From: rirfha948 Date: Fri, 27 Feb 2026 11:55:42 +0000 Subject: [PATCH 4/4] Co-pilot and Reviewer-s review comment addressed --- source/firewall/firewall_ipv6.c | 8 ++++---- source/scripts/init/c_registration/15_dhcpv6_server.c | 3 ++- source/scripts/init/c_registration/20_routing.c | 2 +- source/scripts/init/c_registration/Makefile.am | 2 +- source/scripts/init/service.d/service_crond.sh | 2 +- .../init/service.d/service_registration_functions.sh | 2 -- source/service_ipv6/Makefile.am | 2 +- source/service_routed/Makefile.am | 2 +- source/util/utils/Makefile.am | 4 +--- 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/source/firewall/firewall_ipv6.c b/source/firewall/firewall_ipv6.c index b3da8517..798a6b0a 100644 --- a/source/firewall/firewall_ipv6.c +++ b/source/firewall/firewall_ipv6.c @@ -862,11 +862,11 @@ void do_ipv6_filter_table(FILE *fp){ } #endif /*_HUB4_PRODUCT_REQ_*/ -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) + #if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && ! defined(_CBR_PRODUCT_REQ_) /*Add a simple logic here to make traffic allowed for lan interfaces * exclude primary lan*/ prepare_ipv6_multinet(fp); -#endif + #endif #if !defined(_XER5_PRODUCT_REQ_) && !defined (_SCER11BEL_PRODUCT_REQ_) && !defined(_COSA_QCA_ARM_) //wan0 is not applicable for XER5 /* not allow ping wan0 from brlan0 */ int i; @@ -1717,8 +1717,8 @@ void do_ipv6_filter_table(FILE *fp){ FIREWALL_DEBUG("Exiting prepare_ipv6_firewall \n"); } -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && !defined(_CBR_PRODUCT_REQ_) -int prepare_ipv6_multinet(FILE *fp) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) && ! defined(_CBR_PRODUCT_REQ_) +static int prepare_ipv6_multinet(FILE *fp) { char active_insts[32] = {0}; char lan_pd_if[128] = {0}; diff --git a/source/scripts/init/c_registration/15_dhcpv6_server.c b/source/scripts/init/c_registration/15_dhcpv6_server.c index f29bae80..02d341e9 100644 --- a/source/scripts/init/c_registration/15_dhcpv6_server.c +++ b/source/scripts/init/c_registration/15_dhcpv6_server.c @@ -74,7 +74,8 @@ const char* SERVICE_CUSTOM_EVENTS_BUSINESS[] = { "dhcpv6_server-stop|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", "dhcpv6_server-restart|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", "ipv6_prefix_delegation|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", - "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server_bci.sh|NULL|"TUPLE_FLAG_EVENT,NULL + "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server_bci.sh|NULL|"TUPLE_FLAG_EVENT, + NULL }; #else const char* SERVICE_CUSTOM_EVENTS[] = { diff --git a/source/scripts/init/c_registration/20_routing.c b/source/scripts/init/c_registration/20_routing.c index 5a4d4cb3..2386bcf6 100644 --- a/source/scripts/init/c_registration/20_routing.c +++ b/source/scripts/init/c_registration/20_routing.c @@ -70,7 +70,7 @@ const char* SERVICE_CUSTOM_EVENTS_RESIDENTIAL[] = { "staticroute-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, #ifdef WAN_FAILOVER_SUPPORTED "routeset-ula|/usr/bin/service_routed|NULL|"TUPLE_FLAG_EVENT, - "routeunset-ula|/usr/bin//service_routed|NULL|"TUPLE_FLAG_EVENT, + "routeunset-ula|/usr/bin/service_routed|NULL|"TUPLE_FLAG_EVENT, #endif NULL }; diff --git a/source/scripts/init/c_registration/Makefile.am b/source/scripts/init/c_registration/Makefile.am index c2b13bed..f270b700 100644 --- a/source/scripts/init/c_registration/Makefile.am +++ b/source/scripts/init/c_registration/Makefile.am @@ -133,5 +133,5 @@ if ENABLE_HOTSPOT_SERVICE 15_hotspot_SOURCES = 15_hotspot.c endif if ONESTACK_PRODUCT_REQ -LDFLAGS += -lrdkb_feature_mode_gate -ldevicemode +LDFLAGS += -lrdkb_feature_mode_gate endif diff --git a/source/scripts/init/service.d/service_crond.sh b/source/scripts/init/service.d/service_crond.sh index ea6aa1e4..33b9757f 100755 --- a/source/scripts/init/service.d/service_crond.sh +++ b/source/scripts/init/service.d/service_crond.sh @@ -120,7 +120,7 @@ service_start () echo "1 */12 * * * /usr/ccsp/tad/FileHandle_Monitor.sh" >> $CRONTAB_FILE - if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then + if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then echo "*/15 * * * * /usr/ccsp/tad/log_staticIP_client_info.sh" >> $CRONTAB_FILE fi diff --git a/source/scripts/init/service.d/service_registration_functions.sh b/source/scripts/init/service.d/service_registration_functions.sh index 296549ff..45427183 100755 --- a/source/scripts/init/service.d/service_registration_functions.sh +++ b/source/scripts/init/service.d/service_registration_functions.sh @@ -306,7 +306,6 @@ sm_register_one_event() { if [ "NULL" = "$SMR_EVENT" ] ; then return 0 fi - echo "[DEBUG] sm_rm_event ${SMR_SERVICE} ${SMR_EVENT_NAME}" # if this service has already registered for this event, then cancel the previous registration # this is probably overkill since we likely already called sm_unregister, but better safe than sorry sm_rm_event "${SMR_SERVICE}" "${SMR_EVENT_NAME}" @@ -445,7 +444,6 @@ sm_register() { IFS=';' for custom in $SM_CUSTOM_EVENTS ; do if [ -n "$custom" ] && [ " " != "$custom" ] ; then - echo "[DHCPV6][DEBUG] Registering custom event: '$custom' for service '$SM_SERVICE'" IFS=$SAVEIFS sm_register_one_event "$SM_SERVICE" "$custom" IFS=';' diff --git a/source/service_ipv6/Makefile.am b/source/service_ipv6/Makefile.am index 6f4c7f9d..7d51d8b8 100644 --- a/source/service_ipv6/Makefile.am +++ b/source/service_ipv6/Makefile.am @@ -26,7 +26,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/source/include \ AM_LDFLAGS = -lccsp_common -lsecure_wrapper $(DBUS_LIBS) if ONESTACK_PRODUCT_REQ -AM_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate +AM_LDFLAGS += -lrdkb_feature_mode_gate endif service_ipv6_SOURCES = service_ipv6.c service_ipv6_main.c diff --git a/source/service_routed/Makefile.am b/source/service_routed/Makefile.am index 5cf9aa9d..2b537a86 100644 --- a/source/service_routed/Makefile.am +++ b/source/service_routed/Makefile.am @@ -46,7 +46,7 @@ service_routed_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ -ltelemetry_msgsender service_routed_LDFLAGS = -L${PKG_CONFIG_SYSROOT_DIR}${libdir} if ONESTACK_PRODUCT_REQ -service_routed_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate +service_routed_LDFLAGS += -lrdkb_feature_mode_gate endif if CORE_NET_LIB_FEATURE_SUPPORT service_routed_LDFLAGS += -lnet diff --git a/source/util/utils/Makefile.am b/source/util/utils/Makefile.am index 62242b7e..dc8db498 100644 --- a/source/util/utils/Makefile.am +++ b/source/util/utils/Makefile.am @@ -26,6 +26,4 @@ libutopiautil_la_CPPFLAGS = -I$(top_srcdir)/source/include \ $(DBUS_CFLAGS) libutopiautil_la_LDFLAGS = -lccsp_common $(DBUS_LIBS) -if ONESTACK_PRODUCT_REQ -libutopiautil_la_LDFLAGS += -ldevicemode -lonestack_syscfg -lonestack_log -lrdkb_feature_mode_gate -endif +