Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDKB-57540 : UDHCPC process is not started by SelfHeal if failed to s… #81

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions source/TR-181/include/wanmgr_dml.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ typedef struct _DML_WANIFACE_IP
WANMGR_IPV6_RA_DATA Ipv6Route;
ipc_dhcpv4_data_t* pIpcIpv4Data;
ipc_dhcpv6_data_t* pIpcIpv6Data;
UINT Dhcp4cPid;
UINT Dhcp6cPid;
int Dhcp4cPid;
int Dhcp6cPid;
} DML_WANIFACE_IP;

#ifdef FEATURE_MAPT
Expand Down
33 changes: 21 additions & 12 deletions source/WanManager/wanmgr_interface_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,36 +447,44 @@ static void WanMgr_MonitorDhcpApps (WanMgr_IfaceSM_Controller_t* pWanIfaceCtrl)
{
CcspTraceInfo(("%s %d: IP Mode change processed. Resetting flag. \n", __FUNCTION__, __LINE__));
p_VirtIf->IP.RefreshDHCP = FALSE;
}
}
return;
}

//Check if IPv4 dhcp client is still running - handling runtime crash of dhcp scenario
if ((p_VirtIf->IP.Mode == DML_WAN_IP_MODE_IPV4_ONLY || p_VirtIf->IP.Mode == DML_WAN_IP_MODE_DUAL_STACK) && // IP.Mode supports V4
p_VirtIf->IP.IPv4Source == DML_WAN_IP_SOURCE_DHCP && (p_VirtIf->PPP.Enable == FALSE) && // uses DHCP client
p_VirtIf->MAP.MaptStatus == WAN_IFACE_MAPT_STATE_DOWN && // MAPT status is DOWN
p_VirtIf->IP.SelectedModeTimerStatus != RUNNING &&
p_VirtIf->IP.Dhcp4cPid > 0 && // dhcp started by ISM
(WanMgr_IsPIDRunning(p_VirtIf->IP.Dhcp4cPid) != TRUE)) // but DHCP client not running
p_VirtIf->IP.SelectedModeTimerStatus != RUNNING && // Prefered mode timer Running. Wait for it to expire.
(p_VirtIf->IP.Dhcp4cPid == -1 || // DHCP cleint failed to start OR
(p_VirtIf->IP.Dhcp4cPid > 0 && // dhcp started by ISM
WanMgr_IsPIDRunning(p_VirtIf->IP.Dhcp4cPid) != TRUE))) // but DHCP client not running
{
p_VirtIf->IP.Dhcp4cPid = WanManager_StartDhcpv4Client(p_VirtIf, pInterface->Name, pInterface->IfaceType);
CcspTraceInfo(("%s %d - SELFHEAL - Started dhcpc on interface %s, dhcpv4_pid %d \n", __FUNCTION__, __LINE__, p_VirtIf->Name, p_VirtIf->IP.Dhcp4cPid));
if (p_VirtIf->IP.Dhcp4cPid != -1 )
{
#ifdef ENABLE_FEATURE_TELEMETRY2_0
t2_event_d("SYS_ERROR_DHCPV4Client_notrunning", 1);
t2_event_d("SYS_ERROR_DHCPV4Client_notrunning", 1);
#endif
}
p_VirtIf->IP.Dhcp4cPid = WanManager_StartDhcpv4Client(p_VirtIf, pInterface->Name, pInterface->IfaceType);
CcspTraceInfo(("%s %d - SELFHEAL - Started dhcpc on interface %s, dhcpv4_pid %d \n", __FUNCTION__, __LINE__, p_VirtIf->Name, p_VirtIf->IP.Dhcp4cPid));
}

//Check if IPv6 dhcp client is still running - handling runtime crash of dhcp client
if ((p_VirtIf->IP.Mode == DML_WAN_IP_MODE_IPV6_ONLY || p_VirtIf->IP.Mode == DML_WAN_IP_MODE_DUAL_STACK) && // IP.Mode supports V6
p_VirtIf->IP.IPv6Source == DML_WAN_IP_SOURCE_DHCP && // uses DHCP client
p_VirtIf->IP.Dhcp6cPid > 0 && // dhcp started by ISM
(WanMgr_IsPIDRunning(p_VirtIf->IP.Dhcp6cPid) != TRUE)) // but DHCP client not running
(p_VirtIf->IP.Dhcp6cPid == -1 || // DHCP cleint failed to start
(p_VirtIf->IP.Dhcp6cPid > 0 && // dhcp started by ISM
WanMgr_IsPIDRunning(p_VirtIf->IP.Dhcp6cPid) != TRUE))) // but DHCP client not running
{
p_VirtIf->IP.Dhcp6cPid = WanManager_StartDhcpv6Client(p_VirtIf, pInterface->IfaceType);
CcspTraceInfo(("%s %d - SELFHEAL - Started dhcp6c on interface %s, dhcpv6_pid %d \n", __FUNCTION__, __LINE__, p_VirtIf->Name, p_VirtIf->IP.Dhcp6cPid));
if (p_VirtIf->IP.Dhcp6cPid != -1 )
{
#ifdef ENABLE_FEATURE_TELEMETRY2_0
t2_event_d("SYS_ERROR_DHCPV6Client_notrunning", 1);
t2_event_d("SYS_ERROR_DHCPV6Client_notrunning", 1);
#endif
}
p_VirtIf->IP.Dhcp6cPid = WanManager_StartDhcpv6Client(p_VirtIf, pInterface->IfaceType);
CcspTraceInfo(("%s %d - SELFHEAL - Started dhcp6c on interface %s, dhcpv6_pid %d \n", __FUNCTION__, __LINE__, p_VirtIf->Name, p_VirtIf->IP.Dhcp6cPid));
}

/* Handling Runtime IP.ConnectivityCheckType change */
Expand Down Expand Up @@ -2877,6 +2885,7 @@ static eWanState_t wan_transition_standby_deconfig_ips(WanMgr_IfaceSM_Controller
{
CcspTraceError(("%s %d - Failed to tear down IPv6 for %s Interface \n", __FUNCTION__, __LINE__, p_VirtIf->Name));
}
p_VirtIf->IP.Ipv6Changed = TRUE; //We have deconfigured Ipv6 from the device. set this flag to configure again when moves back to active.
}

WanMgr_Configure_accept_ra(p_VirtIf, FALSE);
Expand Down
19 changes: 15 additions & 4 deletions source/WanManager/wanmgr_net_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,15 @@ int WanManager_Ipv6AddrUtil(char *ifname, Ipv6OperType opr, int preflft, int val
return 0;
}

uint32_t WanManager_StartDhcpv6Client(DML_VIRTUAL_IFACE* pVirtIf, IFACE_TYPE IfaceType)
int WanManager_StartDhcpv6Client(DML_VIRTUAL_IFACE* pVirtIf, IFACE_TYPE IfaceType)
{
if (pVirtIf == NULL)
{
CcspTraceError(("%s %d: Invalid args \n", __FUNCTION__, __LINE__));
return 0;
}

uint32_t pid = 0;
int pid = 0;
dhcp_params params;
memset (&params, 0, sizeof(dhcp_params));
params.ifname = pVirtIf->Name;
Expand All @@ -560,6 +560,11 @@ uint32_t WanManager_StartDhcpv6Client(DML_VIRTUAL_IFACE* pVirtIf, IFACE_TYPE Ifa
CcspTraceInfo(("Enter WanManager_StartDhcpv6Client for %s \n", pVirtIf->Name));
WanManager_send_and_receive_rs(pVirtIf);
pid = start_dhcpv6_client(&params);
if (pid == 0)
{
CcspTraceError(("%s %d: dhcpv6 client failed to start. Returing pid -1.\n", __FUNCTION__, __LINE__));
pid = -1;
}
pVirtIf->IP.Dhcp6cPid = pid;

return pid;
Expand Down Expand Up @@ -604,7 +609,7 @@ ANSC_STATUS WanManager_StopDhcpv6Client(char * iface_name, DHCP_RELEASE_BEHAVIOU
}


uint32_t WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInterface, IFACE_TYPE IfaceType)
int WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInterface, IFACE_TYPE IfaceType)
{
if (pVirtIf == NULL)
{
Expand All @@ -617,7 +622,7 @@ uint32_t WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInte
return 0;//TODO:Read and return PID
#endif
dhcp_params params;
uint32_t pid = 0;
int pid = 0;

memset (&params, 0, sizeof(dhcp_params));
params.ifname = pVirtIf->Name;
Expand All @@ -626,6 +631,12 @@ uint32_t WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInte

CcspTraceInfo(("Starting DHCPv4 Client for iface: %s \n", params.ifname));
pid = start_dhcpv4_client(&params);

if (pid == 0)
{
CcspTraceError(("%s %d: dhcpv4 client failed to start. Returing pid -1.\n", __FUNCTION__, __LINE__));
pid = -1;
}
pVirtIf->IP.Dhcp4cPid = pid;
return pid;
}
Expand Down
6 changes: 3 additions & 3 deletions source/WanManager/wanmgr_net_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ typedef enum {
* @param isPPP indicates PPP enabled or nor
* @return ANSC_STATUS_SUCCESS upon success else returned error code.
***************************************************************************/
uint32_t WanManager_StartDhcpv6Client(DML_VIRTUAL_IFACE* pVirtIf, IFACE_TYPE IfaceType);
int WanManager_StartDhcpv6Client(DML_VIRTUAL_IFACE* pVirtIf, IFACE_TYPE IfaceType);

/***************************************************************************
* @brief API used to stop Dhcpv6 client application.
Expand All @@ -106,7 +106,7 @@ ANSC_STATUS WanManager_StopDhcpv6Client(char * iface_name, DHCP_RELEASE_BEHAVIOU
* @param intf Interface name on which the dhcpv4 needs to start
* @return ANSC_STATUS_SUCCESS upon success else returned error code.
***************************************************************************/
uint32_t WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInterface ,IFACE_TYPE IfaceType);
int WanManager_StartDhcpv4Client(DML_VIRTUAL_IFACE* pVirtIf, char* baseInterface ,IFACE_TYPE IfaceType);

/***************************************************************************
* @brief API used to stop Dhcpv4 client application.
Expand Down Expand Up @@ -153,7 +153,7 @@ int WanManager_Ipv6AddrUtil(char *ifname,Ipv6OperType opr,int preflft,int vallft
* @param pid PID of the process to be checked
* @return TRUE upon success else FALSE returned
***************************************************************************/
BOOL WanMgr_IsPIDRunning(UINT pid);
BOOL WanMgr_IsPIDRunning(int pid);

#if defined(FEATURE_464XLAT)
int xlat_configure(char *interface, char *xlat_address);
Expand Down
2 changes: 1 addition & 1 deletion source/WanManager/wanmgr_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ void WanManager_DoSystemAction(const char *from, char *cmd)
* @param pid PID of the process to be checked
* @return TRUE upon success else FALSE returned
***************************************************************************/
BOOL WanMgr_IsPIDRunning(UINT pid)
BOOL WanMgr_IsPIDRunning(int pid)
{
/* If sig is 0 (the null signal), error checking is performed but no signal is actually sent.
The null signal can be used to check the validity of pid. */
Expand Down