Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7d54a8c
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj May 26, 2026
ef8d346
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj May 26, 2026
7a9be28
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj May 27, 2026
4307424
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj May 29, 2026
ad152a5
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj May 29, 2026
405a0d6
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 1, 2026
576dfc4
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 3, 2026
21a4525
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 3, 2026
eddd9c6
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 3, 2026
0038b91
Update wanmgr_interface_sm.c
LakshminarayananShenbagaraj Jun 3, 2026
ffb68d8
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 3, 2026
3396693
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jun 3, 2026
90da3d0
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 7, 2026
2857a26
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 7, 2026
3e8b6ac
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 7, 2026
5cab1a9
Merge branch 'main' into RDKB-65029-Test
LakshminarayananShenbagaraj Jul 9, 2026
edf7939
Potential fix for pull request finding
LakshminarayananShenbagaraj Jul 9, 2026
503dca3
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 9, 2026
b9b625a
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 10, 2026
673c055
RDKB-65187 - WAN Manager - Telemetry for Ignite.
LakshminarayananShenbagaraj Jul 10, 2026
d34fc11
Updated code comments.
LakshminarayananShenbagaraj Jul 13, 2026
eaf996f
Merge branch 'main' into RDKB-65029-Test
LakshminarayananShenbagaraj Jul 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion source/TR-181/middle_layer_src/wanmgr_rdkbus_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "wanmgr_rdkbus_apis.h"
#include "dmsb_tr181_psm_definitions.h"
#include "wanmgr_net_utils.h"
#include <time.h>
#include "wanmgr_interface_sm.h"
#ifdef RBUS_BUILD_FLAG_ENABLE
#include "wanmgr_rbus_handler_apis.h"
Expand Down Expand Up @@ -1965,6 +1966,64 @@ int Update_Current_ActiveDNS(char* CurrentActiveDNS)
return RETURN_OK;
}

/* ── WAN failure timer state ─────────────────────────────────────────────────
* All outage-tracking state collected in one struct; zeroing it resets everything.
* ─────────────────────────────────────────────────────────────────────────── */
typedef struct {
struct timespec startTime; ///< Monotonic clock at outage start
bool active; ///< Timer is running
char lastKnownAlias[BUFLEN_64]; ///< Alias of the last fully-active interface
} WanFailureTimer_t;

static WanFailureTimer_t gWanFailureTimer = {0};

static void WanMgr_RecordWanFailureStart(void)
{
if (!gWanFailureTimer.active)
{
clock_gettime(CLOCK_MONOTONIC_RAW, &gWanFailureTimer.startTime);
gWanFailureTimer.active = true;
CcspTraceInfo(("%s %d - WAN failure timer started at %ld (prev active: %s)\n",
__FUNCTION__, __LINE__, gWanFailureTimer.startTime.tv_sec,
gWanFailureTimer.lastKnownAlias[0] ? gWanFailureTimer.lastKnownAlias : "NONE"));
}
}

static void WanMgr_PrintWanFailureTimeMarker(const char *currentAlias)
{
if (!gWanFailureTimer.active)
return;

struct timespec now = {0};
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
long duration = now.tv_sec - gWanFailureTimer.startTime.tv_sec;
if (duration < 0)
duration = 0;
Comment thread
guto86 marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.
const char *prevAlias = (gWanFailureTimer.lastKnownAlias[0] != '\0') ? gWanFailureTimer.lastKnownAlias : "NONE";

char durStr[BUFLEN_256] = {0};
snprintf(durStr, sizeof(durStr), "%s|%s|%ld",
prevAlias,
(currentAlias ? currentAlias : "unknown"),
duration);
Comment thread
guto86 marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.

#ifdef ENABLE_FEATURE_TELEMETRY2_0
t2_event_s("WAN_DOWN_DURATION", durStr);
#endif
Comment thread
guto86 marked this conversation as resolved.
CcspTraceInfo(("%s %d - WAN_DOWN_DURATION:%s\n",
__FUNCTION__, __LINE__, durStr));
Comment thread
guto86 marked this conversation as resolved.

gWanFailureTimer.active = false;
memset(&gWanFailureTimer.startTime, 0, sizeof(gWanFailureTimer.startTime));
}

void WanMgr_FailureTimer_Init(void)
{
CcspTraceInfo(("%s %d - WAN failure timer initialised at process start\n",
__FUNCTION__, __LINE__));
WanMgr_RecordWanFailureStart();
}
Comment thread
guto86 marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.

ANSC_STATUS Update_Interface_Status()
{
struct IFACE_INFO *head = NULL;
Expand All @@ -1982,6 +2041,9 @@ ANSC_STATUS Update_Interface_Status()
CHAR prevCurrentStandbyInterface[BUFLEN_64] = {0};
CHAR prevCurrentActiveDNS[BUFLEN_256] = {0};

CHAR activeIfaceAlias[BUFLEN_64] = {0};
bool bIsInterfaceActive = false;

#ifdef RBUS_BUILD_FLAG_ENABLE
CHAR CurrentWanStatus[BUFLEN_16] = "Down";
bool publishAvailableStatus = FALSE;
Expand Down Expand Up @@ -2020,7 +2082,19 @@ ANSC_STATUS Update_Interface_Status()
{
continue;
}


/* Capture alias and PHY/link state of the ACTIVE interface for
* the WAN failure timer decision (backup vs. primary recovery). */
if (pWanIfaceData->Selection.Status == WAN_IFACE_ACTIVE)
{
snprintf(activeIfaceAlias, sizeof(activeIfaceAlias), "%s",
pWanIfaceData->AliasName);

/* VirtIf UP means WAN service is fully established */
if (p_VirtIf->Status == WAN_IFACE_STATUS_UP)
bIsInterfaceActive = true;
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
}
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.

struct IFACE_INFO *newIface = calloc(1, sizeof( struct IFACE_INFO));
newIface->next = NULL;

Expand Down Expand Up @@ -2124,6 +2198,7 @@ ANSC_STATUS Update_Interface_Status()
if (pWanConfigData != NULL)
{
DML_WANMGR_CONFIG* pWanDmlData = &(pWanConfigData->data);

if(strcmp(pWanDmlData->InterfaceAvailableStatus,InterfaceAvailableStatus) != 0)
{
strncpy(prevInterfaceAvailableStatus,pWanDmlData->InterfaceAvailableStatus, sizeof(prevInterfaceAvailableStatus)-1);
Expand Down Expand Up @@ -2238,6 +2313,34 @@ ANSC_STATUS Update_Interface_Status()
publishCurrentStandbyInf = TRUE;
#endif //RBUS_BUILD_FLAG_ENABLE
}

if (!bIsInterfaceActive && !gWanFailureTimer.active)
{
CcspTraceInfo(("%s %d - WAN service lost (bIsInterfaceActive=%d)"
" — starting failure timer (last known active: %s)\n",
__FUNCTION__, __LINE__,
bIsInterfaceActive,
gWanFailureTimer.lastKnownAlias[0] ? gWanFailureTimer.lastKnownAlias : "NONE"));
Comment thread
guto86 marked this conversation as resolved.
WanMgr_RecordWanFailureStart();
}
else if (bIsInterfaceActive && gWanFailureTimer.active)
{
/* WAN service restored — lastKnownAlias still holds the previous
* interface alias because we haven't updated it yet this cycle. */
CcspTraceInfo(("%s %d - Interface '%s' (alias '%s') became fully active,"
" emitting WAN_DOWN_DURATION\n",
__FUNCTION__, __LINE__,
CurrentActiveInterface, activeIfaceAlias));
WanMgr_PrintWanFailureTimeMarker(activeIfaceAlias);
}

/* Update lastKnownAlias AFTER timer logic (see comment above). */
if (bIsInterfaceActive && activeIfaceAlias[0] != '\0')
{
snprintf(gWanFailureTimer.lastKnownAlias, sizeof(gWanFailureTimer.lastKnownAlias),
"%s", activeIfaceAlias);
}

WanMgrDml_GetConfigData_release(pWanConfigData);
}
#ifdef RBUS_BUILD_FLAG_ENABLE
Expand Down
1 change: 1 addition & 0 deletions source/TR-181/middle_layer_src/wanmgr_rdkbus_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ANSC_STATUS WanMgr_WanIfaceMarkingInit ();
ANSC_STATUS WanMgr_Publish_WanStatus(UINT IfaceIndex, UINT VirId);
ANSC_STATUS DmlSetWanActiveLinkInPSMDB( UINT uiInterfaceIdx, bool flag );
ANSC_STATUS WanController_ClearWanConfigurationsInPSM();
void WanMgr_FailureTimer_Init(void);
ANSC_STATUS Update_Interface_Status();
void WanMgr_getRemoteWanParamsFromPSM(DML_VIRTUAL_IFACE * pVirtIf);
int get_Wan_Interface_ParametersFromPSM(ULONG instancenum, DML_WAN_IFACE* p_Interface);
Expand Down
5 changes: 5 additions & 0 deletions source/WanManager/wanmgr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "wanmgr_core.h"
#include "wanmgr_data.h"
#include "wanmgr_webconfig_apis.h"
#include "wanmgr_rdkbus_apis.h"
#include "stdlib.h"
#include "ccsp_dm_api.h"

Expand Down Expand Up @@ -376,6 +377,10 @@ int main(int argc, char* argv[])
close(fd_ret);
}

/* Start the WAN outage timer now so the full boot-to-first-WAN duration
* is captured by the WAN_DOWN_DURATION telemetry marker. */
WanMgr_FailureTimer_Init();
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
LakshminarayananShenbagaraj marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.
Comment thread
guto86 marked this conversation as resolved.

Comment thread
guto86 marked this conversation as resolved.
//CORE INT
WanMgr_Core_Init();

Expand Down