From 90628c014aab293e9e654931cfcb860e456e25f8 Mon Sep 17 00:00:00 2001 From: Parthiban Selvaraj Date: Fri, 18 Oct 2024 12:13:05 +0000 Subject: [PATCH] RDKB-57269 : MAPT handling when only IANA renewed. Fixing ipv4 DNS teardown when MAPT configured.(Comcast) Fixing Ipv4 lease time (webui) Signed-off-by: Parthiban Selvaraj --- source/TR-181/include/wanmgr_dml.h | 3 ++- source/WanManager/wanmgr_dhcpv4_apis.c | 3 ++- source/WanManager/wanmgr_dhcpv6_apis.c | 6 ++++++ source/WanManager/wanmgr_interface_sm.c | 22 ++++++++++++---------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/source/TR-181/include/wanmgr_dml.h b/source/TR-181/include/wanmgr_dml.h index 3fd6ee3..da4b73a 100644 --- a/source/TR-181/include/wanmgr_dml.h +++ b/source/TR-181/include/wanmgr_dml.h @@ -304,6 +304,7 @@ typedef struct _WANMGR_IPV4_DATA char dnsServer[BUFLEN_64]; /** New dns Server, if addressAssigned==TRUE */ char dnsServer1[BUFLEN_64]; /** New dns Server, if addressAssigned==TRUE */ uint32_t mtuSize; /** New MTU size, if mtuAssigned==TRUE */ + uint32_t leaseReceivedTime; /** Lease received time*/ #if defined(FEATURE_RDKB_CONFIGURABLE_WAN_INTERFACE) int32_t timeOffset; /** New time offset, if addressAssigned==TRUE */ bool isTimeOffsetAssigned; /** Is the time offset assigned ? */ @@ -312,7 +313,7 @@ typedef struct _WANMGR_IPV4_DATA uint32_t downstreamCurrRate; /** Downstream rate */ char dhcpServerId[BUFLEN_64]; /** Dhcp server id */ char dhcpState[BUFLEN_64]; /** Dhcp state. */ - uint32_t leaseTime; /** Lease time, , if addressAssigned==TRUE */ + uint32_t leaseTime; /** Lease time */ #endif } WANMGR_IPV4_DATA; diff --git a/source/WanManager/wanmgr_dhcpv4_apis.c b/source/WanManager/wanmgr_dhcpv4_apis.c index 31cbac5..d3c8c8e 100644 --- a/source/WanManager/wanmgr_dhcpv4_apis.c +++ b/source/WanManager/wanmgr_dhcpv4_apis.c @@ -218,7 +218,7 @@ ANSC_STATUS wanmgr_handle_dhcpv4_event_data(DML_VIRTUAL_IFACE* pVirtIf) // update current IPv4 data wanmgr_dchpv4_get_ipc_msg_info(&(pVirtIf->IP.Ipv4Data), pDhcpcInfo); - + pVirtIf->IP.Ipv4Data.leaseReceivedTime = up_time; /* Assign the address to the inetrface when received. Remaining configurations are updated when activated from VISM*/ CcspTraceInfo(("%s %d - Received Ipv4 lease for interface %s. Configuring address on interface\n", __FUNCTION__, __LINE__, pVirtIf->IP.Ipv4Data.ifname)); /** Setup IPv4: such as @@ -940,6 +940,7 @@ WanMgr_DmlDhcpcGetInfo pInfo->DNSServers[0].Value = inet_addr(p_VirtIf->IP.Ipv4Data.dnsServer); pInfo->DNSServers[1].Value = inet_addr(p_VirtIf->IP.Ipv4Data.dnsServer1); pInfo->DHCPStatus = (strcmp(p_VirtIf->IP.Ipv4Data.dhcpState, DHCP_STATE_UP) == 0) ? DML_DHCPC_STATUS_Bound : DML_DHCPC_STATUS_Init; + pInfo->LeaseTimeRemaining = (p_VirtIf->IP.Ipv4Data.leaseReceivedTime + p_VirtIf->IP.Ipv4Data.leaseTime) - WanManager_getUpTime(); WanMgrDml_GetIfaceData_release(NULL); } pInfo->NumDnsServers = 2; diff --git a/source/WanManager/wanmgr_dhcpv6_apis.c b/source/WanManager/wanmgr_dhcpv6_apis.c index 5588314..1f4093f 100644 --- a/source/WanManager/wanmgr_dhcpv6_apis.c +++ b/source/WanManager/wanmgr_dhcpv6_apis.c @@ -1686,6 +1686,12 @@ ANSC_STATUS wanmgr_handle_dhcpv6_event_data(DML_VIRTUAL_IFACE * pVirtIf) strncpy(Ipv6DataNew.pdIfAddress, pDhcp6cInfoCur->pdIfAddress, sizeof(Ipv6DataNew.pdIfAddress)); pNewIpcMsg->prefixAssigned = true; Ipv6DataNew.prefixAssigned = true; +#ifdef FEATURE_MAPT + //get MAP-T previous data + CcspTraceWarning(("%s %d Using previous MAPT configuration\n", __FUNCTION__, __LINE__)); + memcpy(&(pNewIpcMsg->mapt), &(pVirtIf->MAP.dhcp6cMAPTparameters), sizeof(ipc_mapt_data_t)); + pNewIpcMsg->maptAssigned = (pVirtIf->MAP.MaptStatus == WAN_IFACE_MAPT_STATE_UP); +#endif } #else diff --git a/source/WanManager/wanmgr_interface_sm.c b/source/WanManager/wanmgr_interface_sm.c index 9530aa2..fa9a659 100644 --- a/source/WanManager/wanmgr_interface_sm.c +++ b/source/WanManager/wanmgr_interface_sm.c @@ -1231,21 +1231,12 @@ static int wan_tearDownIPv4(WanMgr_IfaceSM_Controller_t * pWanIfaceCtrl) } #endif - /*TODO: - *Should be removed once MAPT Unified. After PandM Added V4 default route, it got deleted here. - */ -#if defined(FEATURE_SUPPORT_MAPT_NAT46) - if (p_VirtIf->EnableMAPT == FALSE) - { -#endif if (WanManager_DelDefaultGatewayRoute(DeviceNwMode, pWanIfaceCtrl->DeviceNwModeChanged, &p_VirtIf->IP.Ipv4Data) != RETURN_OK) { CcspTraceError(("%s %d - Failed to Del default system gateway", __FUNCTION__, __LINE__)); ret = RETURN_ERR; } -#if defined(FEATURE_SUPPORT_MAPT_NAT46) - } -#endif + /* ReSet the required sysevents. */ sysevent_set(sysevent_fd, sysevent_token, SYSEVENT_IPV4_CONNECTION_STATE, WAN_STATUS_DOWN, 0); sysevent_set(sysevent_fd, sysevent_token, SYSEVENT_CURRENT_IPV4_LINK_STATE, WAN_STATUS_DOWN, 0); @@ -2645,6 +2636,17 @@ static eWanState_t wan_transition_mapt_up(WanMgr_IfaceSM_Controller_t* pWanIface { wan_transition_ipv4_down(pWanIfaceCtrl); + /** Reset IPv4 DNS configuration. This call is to make sure IPv4 DNS is removed. **/ + if (wan_updateDNS(pWanIfaceCtrl, FALSE, TRUE) != RETURN_OK) + { + CcspTraceError(("%s %d - Failed to configure IPv6 DNS servers \n", __FUNCTION__, __LINE__)); + ret = RETURN_ERR; + } + else + { + CcspTraceInfo(("%s %d - IPv6 DNS servers configured successfully \n", __FUNCTION__, __LINE__)); + } + #if defined(FEATURE_MAPT) #if defined(IVI_KERNEL_SUPPORT) snprintf(cmdEnableIpv4Traffic,sizeof(cmdEnableIpv4Traffic),"ip ro rep default dev %s", p_VirtIf->Name);