From 519a3b82181454e947ea1c297bacbfcc5d85b34e Mon Sep 17 00:00:00 2001 From: RAFI <103924677+cmuhammedrafi@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:29:54 +0530 Subject: [PATCH] Enhanced connectivity monitor error fix (#5449) * Enahanced Connectivity monitor * ip address change event not coming when wifi reconnect happense (cherry picked from commit c4d1e81e1378f80f25214329cec9531f715edb89) --- NetworkManager/NetworkManagerConnectivity.cpp | 12 +++++++----- NetworkManager/NetworkManagerConnectivity.h | 3 +-- NetworkManager/NetworkManagerRDKProxy.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/NetworkManager/NetworkManagerConnectivity.cpp b/NetworkManager/NetworkManagerConnectivity.cpp index ad2599f623..7902006490 100644 --- a/NetworkManager/NetworkManagerConnectivity.cpp +++ b/NetworkManager/NetworkManagerConnectivity.cpp @@ -149,8 +149,8 @@ namespace WPEFramework /* set our custom set of headers */ curl_easy_setopt(curl_easy_handle, CURLOPT_HTTPHEADER, chunk); curl_easy_setopt(curl_easy_handle, CURLOPT_USERAGENT, "RDKCaptiveCheck/1.0"); - curl_easy_setopt(curl_easy_handle, CURLOPT_CONNECT_ONLY, 1L); - if(!headReq) { + if(!headReq) + { // NMLOG_TRACE("curlopt get request"); /* HTTPGET request added insted of HTTPHEAD request fix for DELIA-61526 */ curl_easy_setopt(curl_easy_handle, CURLOPT_HTTPGET, 1L); @@ -393,13 +393,13 @@ namespace WPEFramework nsm_internetState internetState = nsm_internetState::UNKNOWN; // If monitor connectivity is running take the cache value - if ( doContinuousMonitor && nsm_ipversion::NSM_IPRESOLVE_V4 == ipversion + if ( doContinuousMonitor && (nsm_ipversion::NSM_IPRESOLVE_V4 == ipversion || nsm_ipversion::NSM_IPRESOLVE_WHATEVER == ipversion) && gIpv4InternetState != nsm_internetState::UNKNOWN ) { NMLOG_WARNING("Reading Ipv4 internet state cached value %s", getInternetStateString(gIpv4InternetState)); internetState = gIpv4InternetState; } - else if ( doContinuousMonitor && nsm_ipversion::NSM_IPRESOLVE_V6 == ipversion - && gIpv6InternetState != nsm_internetState::UNKNOWN ) { + else if ( doContinuousMonitor && (nsm_ipversion::NSM_IPRESOLVE_V6 == ipversion || nsm_ipversion::NSM_IPRESOLVE_WHATEVER == ipversion) + && gIpv6InternetState != nsm_internetState::UNKNOWN ) { NMLOG_WARNING("Reading Ipv6 internet state cached value %s", getInternetStateString(gIpv6InternetState)); internetState = gIpv6InternetState; } @@ -476,6 +476,8 @@ namespace WPEFramework { ginterfaceStatus = interfaceStatus; /* this will give interface status connected/ disconnected */ gInternetState = UNKNOWN; + gIpv4InternetState = nsm_internetState::UNKNOWN; + gIpv6InternetState = nsm_internetState::UNKNOWN; if (doConnectivityMonitor) { cvConnectivityMonitor.notify_one(); diff --git a/NetworkManager/NetworkManagerConnectivity.h b/NetworkManager/NetworkManagerConnectivity.h index 9259aa8a06..2a39ce2341 100644 --- a/NetworkManager/NetworkManagerConnectivity.h +++ b/NetworkManager/NetworkManagerConnectivity.h @@ -64,13 +64,12 @@ enum nsm_connectivity_httpcode { #define NMCONNECTIVITY_CURL_HEAD_REQUEST true #define NMCONNECTIVITY_CURL_GET_REQUEST false -#define NMCONNECTIVITY_DNS_RESOLVE_FILE "/etc/resolv.dnsmasq" #define NMCONNECTIVITY_MONITOR_DEFAULT_INTERVAL 60 // sec #define NMCONNECTIVITY_MONITOR_MIN_INTERVAL 5 // sec #define NMCONNECTIVITY_CURL_REQUEST_TIMEOUT_MS 5000 // ms #define NMCONNECTIVITY_NO_INTERNET_RETRY_COUNT 4 // 4 retry -#define NMCONNECTIVITY_CONN_MONITOR_RETRY_COUNT 4 // 4 retry +#define NMCONNECTIVITY_CONN_MONITOR_RETRY_COUNT 3 // 3 retry #define NMCONNECTIVITY_CAPTIVE_MONITOR_INTERVAL 30 // sec #define NMCONNECTIVITY_CONN_MONITOR_RETRY_INTERVAL 30 // sec diff --git a/NetworkManager/NetworkManagerRDKProxy.cpp b/NetworkManager/NetworkManagerRDKProxy.cpp index c00f8a47ab..3bcbafe7d4 100644 --- a/NetworkManager/NetworkManagerRDKProxy.cpp +++ b/NetworkManager/NetworkManagerRDKProxy.cpp @@ -424,8 +424,13 @@ namespace WPEFramework NMLOG_INFO ("IARM_BUS_NETWORK_MANAGER_EVENT_INTERFACE_CONNECTION_STATUS :: %s", interface.c_str()); if(interface == "eth0" || interface == "wlan0") { - if (e->status) + if (e->status) { + if (interface == "wlan0") { + // ip address change event not coming when wifi reconnected + ::_instance->connectivityMonitor.startConnectivityMonitor(true); + } ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_UP, interface); + } else { ::_instance->ReportInterfaceStateChangedEvent(Exchange::INetworkManager::INTERFACE_LINK_DOWN, interface); /* when ever interface down we start connectivity monitor to post noInternet event */