From 4cab4fdec12992e637e11cadcd8e287ac3e7fbe0 Mon Sep 17 00:00:00 2001 From: S-Parthiban-Selvaraj Date: Fri, 10 Jul 2026 11:27:45 +0100 Subject: [PATCH 1/5] XER10-3108 : Restart SSH after lease change. Restart WAN management services on IPv4 and IPv6 setup to ensure proper binding of management services to the new WAN addresses. --- source/WanManager/wanmgr_interface_sm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/WanManager/wanmgr_interface_sm.c b/source/WanManager/wanmgr_interface_sm.c index 0ba5ccbe..04ca3162 100644 --- a/source/WanManager/wanmgr_interface_sm.c +++ b/source/WanManager/wanmgr_interface_sm.c @@ -1463,7 +1463,6 @@ static int wan_setUpIPv4(WanMgr_IfaceSM_Controller_t * pWanIfaceCtrl) { syscfg_set_commit(NULL, SYSCFG_WAN_INTERFACE_NAME, p_VirtIf->IP.Ipv4Data.ifname); } - wanmgr_services_restart(); //Get WAN uptime WanManager_GetDateAndUptime( buffer, &uptime ); LOG_CONSOLE("%s [tid=%ld] v4: Wan_init_complete for interface index %d at %d\n", buffer, syscall(SYS_gettid), pWanIfaceCtrl->interfaceIdx, uptime); @@ -1476,7 +1475,13 @@ static int wan_setUpIPv4(WanMgr_IfaceSM_Controller_t * pWanIfaceCtrl) #endif /* Firewall restart. */ sysevent_set(sysevent_fd, sysevent_token, SYSEVENT_FIREWALL_RESTART, NULL, 0); + + /* Restart WAN management services (sshd etc.) so that reverse SSH and other management services (re)bind to the WAN IPv4 address. + * Runs on both first-time bring-up and on a lease/address change. */ + wanmgr_services_restart(); + WanMgr_StartConnectivityCheck(pWanIfaceCtrl); + return ret; } @@ -1690,7 +1695,6 @@ static int wan_setUpIPv6(WanMgr_IfaceSM_Controller_t * pWanIfaceCtrl) { syscfg_set_commit(NULL, SYSCFG_WAN_INTERFACE_NAME, p_VirtIf->IP.Ipv6Data.ifname); } - wanmgr_services_restart(); #if (!defined (_XB6_PRODUCT_REQ_) && !defined (_CBR2_PRODUCT_REQ_) && !defined(_PLATFORM_RASPBERRYPI_)) || defined (_RDKB_GLOBAL_PRODUCT_REQ_) //parodus uses cmac for xb platforms #if defined(_RDKB_GLOBAL_PRODUCT_REQ_) @@ -1715,8 +1719,13 @@ static int wan_setUpIPv6(WanMgr_IfaceSM_Controller_t * pWanIfaceCtrl) } #endif } - + + /* Restart WAN management services (sshd etc.) so that reverse SSH and other management services (re)bind to the WAN IPv6 address. + * Runs on both first-time bring-up and on a lease/address change. */ + wanmgr_services_restart(); + WanMgr_StartConnectivityCheck(pWanIfaceCtrl); + return ret; } From 34f934adc7046c8b1c9c2ec04b721e922d8b4352 Mon Sep 17 00:00:00 2001 From: S-Parthiban-Selvaraj Date: Fri, 10 Jul 2026 12:02:26 +0100 Subject: [PATCH 2/5] Add addrConstructedFromIAPD flag to WANMGR_IPV6_DATA structure and update related logic --- source/TR-181/include/wanmgr_dml.h | 1 + source/WanManager/wanmgr_dhcpv6_apis.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/TR-181/include/wanmgr_dml.h b/source/TR-181/include/wanmgr_dml.h index feee2ebe..720364cb 100644 --- a/source/TR-181/include/wanmgr_dml.h +++ b/source/TR-181/include/wanmgr_dml.h @@ -393,6 +393,7 @@ typedef struct _WANMGR_IPV6_DATA uint32_t ipv6_TimeOffset; /* Params to store the IPv6 IPC message */ bool addrAssigned; /**< Have we been assigned an IPv6 address ? */ + bool addrConstructedFromIAPD; /**< TRUE if the WAN address was derived from the delegated prefix (IAPD) instead of a real IANA lease */ uint32_t addrCmd; bool prefixAssigned; /**< Have we been assigned a site prefix ? */ uint32_t prefixCmd; diff --git a/source/WanManager/wanmgr_dhcpv6_apis.c b/source/WanManager/wanmgr_dhcpv6_apis.c index 2aafa2dd..adbe40e6 100644 --- a/source/WanManager/wanmgr_dhcpv6_apis.c +++ b/source/WanManager/wanmgr_dhcpv6_apis.c @@ -1671,6 +1671,7 @@ int wanmgr_construct_wan_address_from_IAPD(WANMGR_IPV6_DATA *pIpv6DataNew) } pIpv6DataNew->addrAssigned = true; + pIpv6DataNew->addrConstructedFromIAPD = true; pIpv6DataNew->addrCmd = IFADDRCONF_ADD; CcspTraceInfo(("%s %d Calculated WAN address %s/128\n", __FUNCTION__, __LINE__, pIpv6DataNew->address)); @@ -1774,12 +1775,17 @@ ANSC_STATUS wanmgr_handle_dhcpv6_event_data(DML_VIRTUAL_IFACE * pVirtIf) */ } } - else if(pDhcp6cInfoCur->addrAssigned && Ipv6DataNew.prefixAssigned) + else if(pDhcp6cInfoCur->addrAssigned && !pDhcp6cInfoCur->addrConstructedFromIAPD && Ipv6DataNew.prefixAssigned) { /* In an IPv6 lease, both IANA and IAPD details are sent together in a struct. * If only one of them is renewed, the other field will be set to its default value. * In this scenario, we should not consider IANA or IAPD as deleted. * If we reach this point, only IAPD has been renewed. Use the previous IANA details. + * + * Note: This only applies when the previous address was a real IANA lease. If the previous + * address was derived from the delegated prefix (addrConstructedFromIAPD), we fall through + * to the branch below so the WAN address is re-derived from the newly delegated prefix + * instead of reusing the stale address from the old prefix. */ CcspTraceWarning(("%s %d IANA is not assigned in this IPC msg, but we have IANA configured from previous lease. Assuming only IAPD renewed. \n", __FUNCTION__, __LINE__)); @@ -1792,7 +1798,9 @@ ANSC_STATUS wanmgr_handle_dhcpv6_event_data(DML_VIRTUAL_IFACE * pVirtIf) { /* In an IPv6 lease, if only IAPD is received and we never received IANA, * We can use the received IAPD to construct a Ipv6 /128 address which can be used for managerment and voice ... - * If we reach this point, only IAPD has been received. Calculate Wan Ipv6 address + * If we reach this point, only IAPD has been received (either for the first time, or the + * previously assigned address was itself derived from a now-stale prefix). Calculate the + * WAN Ipv6 address from the newly delegated prefix. */ CcspTraceInfo(("IANA is not assigned by DHCPV6. Constructing WAN address from the IAPD for Wan Interface \n")); From e63d4bf67932db863040ddbd8c40b91df164f817 Mon Sep 17 00:00:00 2001 From: S-Parthiban-Selvaraj Date: Fri, 10 Jul 2026 12:11:44 +0100 Subject: [PATCH 3/5] Set addrConstructedFromIAPD flag to false in copyDhcpv6Data function --- source/WanManager/wanmgr_dhcp_event_handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/WanManager/wanmgr_dhcp_event_handler.c b/source/WanManager/wanmgr_dhcp_event_handler.c index 1f0e1184..263f4c92 100644 --- a/source/WanManager/wanmgr_dhcp_event_handler.c +++ b/source/WanManager/wanmgr_dhcp_event_handler.c @@ -114,6 +114,7 @@ static void copyDhcpv6Data(WANMGR_IPV6_DATA* pDhcpv6Data, const DHCP_MGR_IPV6_MS #ifdef FEATURE_DSLITE_V2 strncpy(pDhcpv6Data->aftr, leaseInfo->aftr, sizeof(pDhcpv6Data->aftr) - 1); #endif + pDhcpv6Data->addrConstructedFromIAPD = false; if(!pDhcpv6Data->addrAssigned && pDhcpv6Data->prefixAssigned) { /* In an IPv6 lease, if only IAPD is received and we never received IANA, From 0079bb8a05f5fa2503cdf26665788a187095cd0e Mon Sep 17 00:00:00 2001 From: S-Parthiban-Selvaraj Date: Fri, 10 Jul 2026 13:32:36 +0100 Subject: [PATCH 4/5] Enhance SLAAC detection logic to skip stale IAPD-derived addresses --- source/WanManager/wanmgr_dhcpv6_apis.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/WanManager/wanmgr_dhcpv6_apis.c b/source/WanManager/wanmgr_dhcpv6_apis.c index adbe40e6..85605385 100644 --- a/source/WanManager/wanmgr_dhcpv6_apis.c +++ b/source/WanManager/wanmgr_dhcpv6_apis.c @@ -1957,9 +1957,13 @@ ANSC_STATUS wanmgr_handle_dhcpv6_event_data(DML_VIRTUAL_IFACE * pVirtIf) /* Even when dhcp6c is not used to get the WAN interface IP address, * * use this message as a trigger to check the WAN interface IP. - * * Maybe we've been assigned an address by SLAAC.*/ + * * Maybe we've been assigned an address by SLAAC. + * Skip this SLAAC detection when our current WAN address was derived from the delegated prefix + * (addrConstructedFromIAPD): in that case a global address still lingering on the interface is + * our own stale IAPD-derived /128, not a genuine SLAAC address, and must not be used to keep + * IPv6 up. Letting the code continue leaves 'connected' FALSE so IPv6 is not marked up. */ - if (!pNewIpcMsg->addrAssigned) + if (!pNewIpcMsg->addrAssigned && !pDhcp6cInfoCur->addrConstructedFromIAPD) { char guAddrPrefix[IP_ADDR_LENGTH] = {0}; char guAddr[IP_ADDR_LENGTH] = {0}; From c9ce298953e62e3c1b64a5c6d2b4b8ad743f5f1e Mon Sep 17 00:00:00 2001 From: S-Parthiban-Selvaraj Date: Fri, 10 Jul 2026 17:30:02 +0100 Subject: [PATCH 5/5] Handle DHCPv6 renew failure by marking IPv6 connection down when prefix matches current lease --- source/WanManager/wanmgr_dhcpv6_apis.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/WanManager/wanmgr_dhcpv6_apis.c b/source/WanManager/wanmgr_dhcpv6_apis.c index 85605385..c6f9f4d1 100644 --- a/source/WanManager/wanmgr_dhcpv6_apis.c +++ b/source/WanManager/wanmgr_dhcpv6_apis.c @@ -1846,6 +1846,17 @@ ANSC_STATUS wanmgr_handle_dhcpv6_event_data(DML_VIRTUAL_IFACE * pVirtIf) CcspTraceWarning(("%s %d IAPD is not assigned in this IPC msg, but we have IAPD configured from previous lease. Assuming only IANA renewed. \n", __FUNCTION__, __LINE__)); WanMgr_CopyPreviousPrefix(pDhcp6cInfoCur, &Ipv6DataNew); } + else if(!pNewIpcMsg->addrAssigned && !pNewIpcMsg->prefixAssigned && + !IS_EMPTY_STRING(pNewIpcMsg->sitePrefix) && + strcmp(pDhcp6cInfoCur->sitePrefix, pNewIpcMsg->sitePrefix) == 0) + { + /* Neither IANA nor IAPD was assigned in this lease (e.g. a DHCPv6 renew failure reports the + * previously delegated prefix with zero lifetimes). As the reported prefix matches the one + * currently in use, treat this as the WAN IPv6 lease no longer being valid and bring the + * IPv6 connection down. */ + CcspTraceInfo(("%s %d Neither IANA nor IAPD assigned and prefix matches the current lease. Marking IPv6 connection down. \n", __FUNCTION__, __LINE__)); + WanManager_UpdateInterfaceStatus(pVirtIf, WANMGR_IFACE_CONNECTION_IPV6_DOWN); + } #else /* dhcp6c receives an IPv6 address for WAN interface */