Skip to content

Checking zebra restart issue in cbr2#286

Open
aj970-crypto wants to merge 12 commits into
developfrom
feature/cbr_zeb_restart
Open

Checking zebra restart issue in cbr2#286
aj970-crypto wants to merge 12 commits into
developfrom
feature/cbr_zeb_restart

Conversation

@aj970-crypto
Copy link
Copy Markdown
Contributor

Checking zebra restart issue in CBRv2

Signed-off-by: aj970 <akshaya_j@comcast.com>
@aj970-crypto aj970-crypto requested review from a team as code owners April 13, 2026 04:43
Copilot AI review requested due to automatic review settings April 13, 2026 04:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional diagnostics to help investigate zebra restart behavior on CBRv2 by emitting timestamped logs from multiple services and the service_routed init script.

Changes:

  • Added APPLY_PRINT timestamped file logging macros and new debug prints across routed/ipv6/dslite/dhcp/devicemode services.
  • Added extra runtime checks/logs around zebra start/restart paths (e.g., post-start is_daemon_running in service_routed).
  • Added a log() helper in service_routed.sh to log sysevent-driven start/stop decisions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped debug logging around radv/zebra start/stop paths and service init.
source/service_ipv6/service_ipv6.c Adds timestamped debug logging around LAN IPv6 setup and zebra restart requests.
source/service_dslite/service_dslite.c Adds timestamped debug logging around zebra restart decision logic.
source/service_dhcp/service_dhcp.c Adds timestamped debug logging in the main event dispatcher (currently breaks compilation).
source/service_dhcp/lan_handler.c Adds timestamped debug logging in LAN restart/stop flows.
source/service_deviceMode/service_devicemode.c Adds timestamped debug logging for mode service start/stop (contains a compile-time typo).
source/scripts/init/service.d/service_routed.sh Adds a logging helper and additional logs for WAN/LAN sysevent handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/service_dhcp/service_dhcp.c Outdated
Comment on lines 491 to 496
APPLY_PRINT("%s: Checking lan-status \n", __FUNCTION__);
char store[24] = {0};
sysevent_get(sysevent_fd, sysevent_token, "lan-status", store, sizeof(store));
CcspTraceWarning(("%s : lan-status is %s\n", __func__, store));
else if (!strncmp(argv[1], "lan-status", 10))
{
Comment thread source/service_dhcp/service_dhcp.c Outdated
Comment on lines 519 to 523
APPLY_PRINT("%s: Restart LAN \n", __FUNCTION__);
else if (!strncmp(argv[1], "lan-restart", 11))
{
APPLY_PRINT("%s: call lan_restart \n", __FUNCTION__);
lan_restart();
Comment thread source/service_dhcp/service_dhcp.c Outdated
Comment on lines 604 to 606
APPLY_PRINT("%s: Flushing ipv6 address of LAN \n", __FUNCTION__);
else if (!strncmp(argv[1], "lan-start", 9))
{

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
Comment on lines 44 to +75
@@ -59,19 +72,24 @@ case "$1" in
wan-status)
status=$(sysevent get wan-status)
if [ "$status" == "started" ]; then
log INFO "WAN status started. Starting routed service."
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed_$(date +'%Y-%m-%d').log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Copilot AI review requested due to automatic review settings April 13, 2026 06:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional instrumentation to help diagnose zebra restart behavior in CBRv2 by emitting timestamps and status messages across multiple networking services and the service_routed init script.

Changes:

  • Introduces a new APPLY_PRINT-style file logger in several C services and adds log points around zebra start/restart and LAN/WAN readiness checks.
  • Adds extra zebra restart visibility in IPv6/DSLite/DHCP/device-mode flows.
  • Adds a logging helper to service_routed.sh and logs WAN/LAN event handling.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds file-based debug logging around radv_start/stop/restart, zebra start, and init readiness flags.
source/service_ipv6/service_ipv6.c Adds file-based debug logging around IPv6 LAN address setup and zebra restart signaling.
source/service_dslite/service_dslite.c Adds file-based debug logging around zebra restart decision logic.
source/service_dhcp/service_dhcp.c Adds file-based debug logging around LAN events and syslog restart request path.
source/service_dhcp/lan_handler.c Adds file-based debug logging inside LAN restart/stop paths and some sysevent/syscfg values.
source/service_deviceMode/service_devicemode.c Adds file-based debug logging around mode transitions and zebra stop/restart.
source/scripts/init/service.d/service_routed.sh Adds a logging helper and logs WAN/LAN event actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +108 to +112
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
Comment on lines +101 to +104
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/service_routed.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
Comment on lines +2207 to 2215
if(is_daemon_running(ZEBRA_PID_FILE, "zebra") == 0)
{
APPLY_PRINT("%s: Failed to start zebra process\n", __FUNCTION__);
}
else {
APPLY_PRINT("%s: Zebra is running\n", __FUNCTION__);
}

return 0;
Comment on lines +58 to +69
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
Comment on lines +56 to +60
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/utopia_service_ipv6.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +41 to +53
#include <time.h>
#define LOG_FILE_ROUTED "/rdklogs/logs/Consolelog.txt.0"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
Comment on lines +75 to +86
#define LOG_FILE_ROUTED "/tmp/service_deviceMode.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
Comment on lines +76 to +77
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed_$(date +'%Y-%m-%d').log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Copilot AI review requested due to automatic review settings April 13, 2026 10:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional logging and runtime checks around zebra/radv (IPv6 RA) startup/restart paths to help diagnose the “zebra restart issue” in CBRv2 and related service flows.

Changes:

  • Introduces an APPLY_PRINT logging macro (timestamped file logging) across multiple services.
  • Adds additional log points and a post-start is_daemon_running() verification when starting zebra from service_routed.
  • Adds shell-script logging to service_routed.sh for WAN/LAN status-triggered actions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped logging, extra zebra/radv start/stop/restart logs, and zebra running verification after start
source/service_ipv6/service_ipv6.c Adds timestamped logging around IPv6 LAN setup and zebra-restart triggers
source/service_dslite/service_dslite.c Adds timestamped logging around zebra restart decision logic
source/service_dhcp/service_dhcp.c Adds timestamped logging in DHCP main command handling (lan-status/lan-start/lan-stop/etc.)
source/service_dhcp/lan_handler.c Adds timestamped logging inside LAN restart/stop handling for additional state visibility
source/service_deviceMode/service_devicemode.c Adds timestamped logging around device mode service start/stop, including zebra interactions
source/scripts/init/service.d/service_routed.sh Adds a log helper and emits logs for WAN/LAN triggered start/stop actions
Comments suppressed due to low confidence (1)

source/service_routed/service_routed.c:2225

  • radv_stop() returns early when is_daemon_running() indicates zebra is running, so the daemon never gets stopped. This looks inverted; the early return should happen when zebra is not running, and daemon_stop() should be called when it is running.
    APPLY_PRINT("%s : Stopping radv services \n", __FUNCTION__);
    if(is_daemon_running(ZEBRA_PID_FILE, "zebra"))
    {
        return 0;
    }
    return daemon_stop(ZEBRA_PID_FILE, "zebra");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +103 to +113
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
Comment on lines +43 to +54
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
#include "errno.h"
#include "util.h"

#include <time.h>
Comment on lines +46 to +57
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +42 to +54
#define LOG_FILE_ROUTED "/rdklogs/logs/Consolelog.txt.0"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
Comment on lines +76 to +87
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
Copilot AI review requested due to automatic review settings April 15, 2026 12:22
@aj970-crypto aj970-crypto force-pushed the feature/cbr_zeb_restart branch from 2b6a145 to c3c695d Compare April 15, 2026 12:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional diagnostic logging across routed/IPv6/DHCP/DSLite/device-mode services and related init scripts to help investigate zebra restart behavior in CBRv2 environments.

Changes:

  • Adds per-component timestamped file logging (APPLY_PRINT) and inserts additional runtime log points around zebra/radv start/stop/restart paths.
  • Adds a post-start zebra “is it running” check in service_routed and extra sysevent/value logging in DHCP/LAN handlers.
  • Adds lightweight logging helpers to init scripts to record service lifecycle events to /tmp/*.log.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds new logging macro + additional radv/zebra lifecycle logging and a zebra running check
source/service_ipv6/service_ipv6.c Adds new logging macro + logs around IPv6 prefix divide and zebra-restart trigger
source/service_dslite/service_dslite.c Adds new logging macro + logs to explain zebra restart decision
source/service_dhcp/service_dhcp.c Adds new logging macro + logs around lan-status/lan-restart/lan-start/lan-stop flows
source/service_dhcp/lan_handler.c Adds new logging macro + logs to capture LAN restart/stop state and key sysevent values
source/service_deviceMode/service_devicemode.c Adds new logging macro + logs around starting/stopping services and zebra handling
source/scripts/init/service.d/service_routed.sh Adds a shell log() helper and logs for wan/lan status triggers
source/scripts/init/service.d/service_lan.sh Adds a shell log() helper and additional lifecycle/status logging
source/scripts/init/service.d/lan_handler.sh Adds a shell log() helper and logs for key entry points/events
Comments suppressed due to low confidence (1)

source/service_routed/service_routed.c:2225

  • radv_stop() returns success without stopping zebra when is_daemon_running() indicates zebra is running (it returns a PID when running). This makes the stop path a no-op. Invert the condition so the function stops zebra when it is running and returns 0 when it is not running.
    APPLY_PRINT("%s : Stopping radv services \n", __FUNCTION__);
    if(is_daemon_running(ZEBRA_PID_FILE, "zebra"))
    {
        return 0;
    }
    return daemon_stop(ZEBRA_PID_FILE, "zebra");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
#include "errno.h"
#include "util.h"

#include <time.h>
Comment on lines +37 to +43
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_lan.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines 2197 to +2213

APPLY_PRINT("%s : Starting Zebra Process\n", __FUNCTION__);
v_secure_system("zebra -d -f %s -P 0 2> /tmp/.zedra_error", ZEBRA_CONF_FILE);
APPLY_PRINT("%s : Zebra Process Started\n", __FUNCTION__);
printf("DHCPv6 is %s. Starting zebra Process\n", (bEnabled?"Enabled":"Disabled"));
#else
v_secure_system("zebra -d -f %s -P 0 2> /tmp/.zedra_error", ZEBRA_CONF_FILE);
APPLY_PRINT("%s : Zebra Process Started\n", __FUNCTION__);
#endif

if(is_daemon_running(ZEBRA_PID_FILE, "zebra") == 0)
{
APPLY_PRINT("%s: Failed to start zebra process\n", __FUNCTION__);
}
else {
APPLY_PRINT("%s: Zebra is running\n", __FUNCTION__);
}
Comment on lines +101 to +115
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/service_routed.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines 44 to 76
@@ -59,19 +72,24 @@ case "$1" in
wan-status)
status=$(sysevent get wan-status)
if [ "$status" == "started" ]; then
log INFO "WAN status started. Starting routed service."
service_routed start
fi
#unregister wecb_master from pmon to let this script to bring it up when lan restart.
log INFO "Unregistering wecb_master from pmon"
echo_t "service_lan : Unregistering web_master from pmon"
Comment on lines +44 to +52
log() {
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/lan_handler.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
}
@aj970-crypto aj970-crypto force-pushed the feature/cbr_zeb_restart branch from c3c695d to cb58011 Compare April 20, 2026 10:55
Signed-off-by: aj970 <akshaya_j@comcast.com>
Copilot AI review requested due to automatic review settings April 20, 2026 10:59
@aj970-crypto aj970-crypto force-pushed the feature/cbr_zeb_restart branch from cb58011 to 15c64fa Compare April 20, 2026 10:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional instrumentation to help diagnose zebra/radvd restart behavior on CBRv2 by adding timestamped logging in several C services and init scripts, plus a post-start zebra running check.

Changes:

  • Added APPLY_PRINT timestamped logging macros and numerous debug log statements across routed/ipv6/dslite/dhcp/devicemode paths.
  • Added zebra start verification logging in service_routed after launching zebra.
  • Added lightweight logging helpers to init scripts (service_routed.sh, service_lan.sh, lan_handler.sh) to track event-driven execution.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped debug logging around radv/zebra start/stop/restart and readiness state.
source/service_ipv6/service_ipv6.c Adds timestamped debug logging around IPv6 LAN address setup and zebra restart triggers.
source/service_dslite/service_dslite.c Adds timestamped debug logging around zebra restart decision logic.
source/service_dhcp/service_dhcp.c Adds timestamped debug logging for LAN-related event handling in DHCP service.
source/service_dhcp/lan_handler.c Adds timestamped debug logging in LAN restart/stop flows and sysevent-derived values.
source/service_deviceMode/service_devicemode.c Adds timestamped debug logging around device mode service start/stop actions.
source/scripts/init/service.d/service_routed.sh Adds a logging function and logs key wan/lan status-triggered actions.
source/scripts/init/service.d/service_lan.sh Adds a logging function and logs LAN start/stop progress and decisions.
source/scripts/init/service.d/lan_handler.sh Adds a logging function and logs key event handling paths and retries.
Comments suppressed due to low confidence (1)

source/service_routed/service_routed.c:2225

  • radv_stop() currently returns success when zebra is running, so it never stops the daemon. Since is_daemon_running() returns a PID when running (non-zero), this condition should be inverted (return 0 only when zebra is not running) and call daemon_stop() when it is running.
    APPLY_PRINT("%s : Stopping radv services \n", __FUNCTION__);
    if(is_daemon_running(ZEBRA_PID_FILE, "zebra"))
    {
        return 0;
    }
    return daemon_stop(ZEBRA_PID_FILE, "zebra");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +42 to +55
#define LOG_FILE_ROUTED "/rdklogs/logs/Consolelog.txt.0"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
done
else
echo_t "RDKB_SYSTEM_BOOT_UP_LOG : INST rerurned null, retrying"
log INFO "else case : INST rerurned null, retrying"
fi
#unregister wecb_master from pmon to let this script to bring it up when lan restart.
log INFO "Unregistering wecb_master from pmon"
echo_t "service_lan : Unregistering web_master from pmon"

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
Comment on lines +44 to +45
#include <time.h>
#define LOG_FILE_ROUTED "/rdklogs/logs/Consolelog.txt.0"
Signed-off-by: aj970 <akshaya_j@comcast.com>
Copilot AI review requested due to automatic review settings April 21, 2026 06:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional instrumentation around zebra/radv start/stop/restart flows to help diagnose the “zebra restart” issue in CBRv2, and introduces new ad-hoc log files for multiple services and init scripts.

Changes:

  • Added per-component APPLY_PRINT timestamped logging macros across several C services (routed/ipv6/dslite/dhcp/devicemode).
  • Added zebra start-status logging in service_routed and additional debug logging around LAN/WAN readiness and restart paths.
  • Added simple logging helpers to init scripts (service_routed.sh, service_lan.sh, lan_handler.sh) to persist event traces to /tmp/*.log.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped logging + zebra start verification instrumentation around radv/zebra.
source/service_ipv6/service_ipv6.c Adds timestamped logging around IPv6 LAN setup and zebra-restart triggers.
source/service_dslite/service_dslite.c Adds timestamped logging around zebra restart decision logic.
source/service_dhcp/service_dhcp.c Adds timestamped logging around DHCP LAN event handling.
source/service_dhcp/lan_handler.c Adds timestamped logging throughout LAN bring-up/restart/stop flows.
source/service_deviceMode/service_devicemode.c Adds timestamped logging during device mode service start/stop.
source/scripts/init/service.d/service_routed.sh Adds a logging helper and logs on WAN/LAN status events.
source/scripts/init/service.d/service_lan.sh Adds a logging helper and logs start/stop flow milestones.
source/scripts/init/service.d/lan_handler.sh Adds a logging helper and logs key event dispatch points.
Comments suppressed due to low confidence (1)

source/service_routed/service_routed.c:2225

  • radv_stop() currently returns success without stopping zebra when it is running (if (is_daemon_running(...)) return 0;). That makes radv_restart() ineffective and likely contributes to the zebra restart issue. Invert this condition so zebra is stopped when running (and only do a no-op when it's already stopped / only stale pid cleanup is needed).
    APPLY_PRINT("%s : Stopping radv services \n", __FUNCTION__);
    if(is_daemon_running(ZEBRA_PID_FILE, "zebra"))
    {
        return 0;
    }
    return daemon_stop(ZEBRA_PID_FILE, "zebra");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +89
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\

Comment on lines 879 to 884
if (CCSP_SUCCESS == l_iRetVal || l_cpPsm_Get != NULL)
{
/*CID 135444 : BUFFER_SIZE_WARNING */
APPLY_PRINT(" First PSM value for %s is %s\n", l_cPsm_Parameter, l_cpPsm_Get);
strncpy(l_cPsmGetLanIp, l_cpPsm_Get, sizeof(l_cPsmGetLanIp)-1);
l_cPsmGetLanIp[sizeof(l_cPsmGetLanIp)-1] = '\0';
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_lan.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/lan_handler.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +43 to +56
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\

Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +42 to +55
#define LOG_FILE_ROUTED "/tmp/lan_handler.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines 897 to 904
l_iRetVal = PSM_VALUE_GET_STRING(l_cPsm_Parameter, l_cpPsm_Get);
if (CCSP_SUCCESS == l_iRetVal || l_cpPsm_Get != NULL)
{
/* CID 163349 : BUFFER_SIZE */
APPLY_PRINT("PSM value for %s is %s\n", l_cPsm_Parameter, l_cpPsm_Get);
strncpy(l_cPsmGetLanSubNet, l_cpPsm_Get, sizeof(l_cPsmGetLanSubNet)-1);
l_cPsmGetLanSubNet[sizeof(l_cPsmGetLanSubNet)-1] = '\0';
}
Comment on lines 74 to 91
if [ "$status" == "started" ]; then
log INFO "WAN status started. Starting routed service."
service_routed start
elif [ "$status" == "stopped" ]; then
log INFO "WAN status stopped. Stopping routed service."
service_routed stop
fi
;;
lan-status)
status=$(sysevent get lan-status)
if [ "$status" == "started" ]; then
log INFO "LAN status started. Starting routed service."
service_routed start
if [ "$BOX_TYPE" == "WNXL11BWL" ]; then
log INFO "LAN status started. Starting zebra"
service_routed radv-start
fi
elif [ "$status" == "stopped" ]; then
Comment on lines +2206 to 2215

if(is_daemon_running(ZEBRA_PID_FILE, "zebra") == 0)
{
APPLY_PRINT("%s: Failed to start zebra process\n", __FUNCTION__);
}
else {
APPLY_PRINT("%s: Zebra is running\n", __FUNCTION__);
}

return 0;
Copilot AI review requested due to automatic review settings April 21, 2026 11:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional runtime logging around routed/IPv6/LAN flows to help diagnose a “zebra restart” issue on CBRv2-class devices.

Changes:

  • Add APPLY_PRINT-based logging in multiple C services (routed, ipv6, dslite, dhcp/lan_handler, devicemode) around zebra/radv and LAN/WAN readiness.
  • Add basic “zebra running” verification after launching zebra in service_routed.c.
  • Add lightweight logging helpers to several /bin/sh init scripts to track event handling.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped debug logging and a post-start zebra “running” check.
source/service_ipv6/service_ipv6.c Adds debug logging around IPv6 start and zebra restart triggers.
source/service_dslite/service_dslite.c Adds debug logging when deciding whether to request zebra restart.
source/service_dhcp/service_dhcp.c Adds debug logging around LAN events and syslog restart request; introduces APPLY_PRINT.
source/service_dhcp/lan_handler.c Adds extensive debug logging around LAN bring-up/restart/stop and sysevent/PSM reads.
source/service_deviceMode/service_devicemode.c Adds debug logging around mode-based service start/stop (including zebra stop/restart).
source/scripts/init/service.d/service_routed.sh Adds a log helper and logs around WAN/LAN event handling.
source/scripts/init/service.d/service_lan.sh Adds a log helper and more lifecycle logging for LAN start/stop.
source/scripts/init/service.d/lan_handler.sh Adds a log helper and more event/lifecycle logging for lan_handler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 877 to 883
l_iRetVal = PSM_VALUE_GET_STRING(l_cPsm_Parameter, l_cpPsm_Get);
if (CCSP_SUCCESS == l_iRetVal || l_cpPsm_Get != NULL)
{
/*CID 135444 : BUFFER_SIZE_WARNING */
APPLY_PRINT(" First PSM value for %s is %s\n", l_cPsm_Parameter, l_cpPsm_Get);
strncpy(l_cPsmGetLanIp, l_cpPsm_Get, sizeof(l_cPsmGetLanIp)-1);
l_cPsmGetLanIp[sizeof(l_cPsmGetLanIp)-1] = '\0';
Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +41 to +54
#define LOG_FILE_ROUTED "/tmp/lan_handler.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines +44 to +52
log() {
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
}
Comment on lines +45 to +51
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/lan_handler.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines 896 to 902
l_iRetVal = PSM_VALUE_GET_STRING(l_cPsm_Parameter, l_cpPsm_Get);
if (CCSP_SUCCESS == l_iRetVal || l_cpPsm_Get != NULL)
{
/* CID 163349 : BUFFER_SIZE */
APPLY_PRINT("PSM value for %s is %s\n", l_cPsm_Parameter, l_cpPsm_Get);
strncpy(l_cPsmGetLanSubNet, l_cpPsm_Get, sizeof(l_cPsmGetLanSubNet)-1);
l_cPsmGetLanSubNet[sizeof(l_cPsmGetLanSubNet)-1] = '\0';
Comment on lines +75 to +88
#define LOG_FILE_ROUTED "/tmp/service_deviceMode.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines +56 to +70
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/utopia_service_ipv6.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines +101 to +115
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/service_routed.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines +48 to +51
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +40 to +43
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_lan.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Copilot AI review requested due to automatic review settings April 28, 2026 06:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds additional instrumentation to help diagnose zebra restart/startup behavior (CBRv2 context) by introducing new file-based logging in multiple networking services and init scripts.

Changes:

  • Added APPLY_PRINT debug logging (timestamped file append) across service_routed, service_ipv6, service_dslite, service_dhcp, and service_devicemode.
  • Added additional zebra start logging/verification in service_routed and zebra restart visibility in other services.
  • Added log() helpers + additional event tracing in init scripts for routed/LAN/lan_handler flows.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped file logging and extra zebra start/run diagnostics.
source/service_ipv6/service_ipv6.c Adds timestamped file logging around IPv6/LAN zebra restart triggers.
source/service_dslite/service_dslite.c Adds timestamped file logging around zebra restart checks.
source/service_dhcp/service_dhcp.c Adds timestamped file logging around LAN events and syslog restart request.
source/service_dhcp/lan_handler.c Adds extensive logging, but currently contains merge conflicts + invalid global-scope statement.
source/service_deviceMode/service_devicemode.c Adds timestamped file logging; introduces a compile-breaking typo in __FUNCTION__.
source/scripts/init/service.d/service_routed.sh Adds a log() helper and logs routed reactions to WAN/LAN events.
source/scripts/init/service.d/service_lan.sh Adds a log() helper and logs LAN start/stop flow.
source/scripts/init/service.d/lan_handler.sh Adds a log() helper and detailed logging for lan_handler event processing.
Comments suppressed due to low confidence (1)

source/service_routed/service_routed.c:2225

  • radv_stop() currently returns success without stopping anything when zebra is running (if (is_daemon_running(...)) return 0;). Since is_daemon_running() returns a PID when the daemon is running, this condition looks inverted; it should likely return 0 only when zebra is not running, otherwise call daemon_stop().
    if(is_daemon_running(ZEBRA_PID_FILE, "zebra"))
    {
        return 0;
    }
    return daemon_stop(ZEBRA_PID_FILE, "zebra");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to +51
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +42 to +56
#define LOG_FILE_ROUTED "/tmp/utopia_service_dslite.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\

#include "errno.h"
#include "util.h"

#include <time.h>
Comment on lines +101 to +115
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/service_routed.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment on lines +40 to +43
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_lan.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +56 to +71
#include <time.h>
#define LOG_FILE_ROUTED "/tmp/utopia_service_ipv6.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\

Comment on lines +75 to +88
#define LOG_FILE_ROUTED "/tmp/service_deviceMode.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
if (logfp){\
time_t s = time(NULL);\
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
}\
}\
Comment thread source/service_dhcp/lan_handler.c Outdated
Comment on lines +41 to +49
<<<<<<< HEAD
=======
<<<<<<< HEAD
#include <time.h>
>>>>>>> df73d87 (Checking lan start event)
#define LOG_FILE_ROUTED "/tmp/lan_handler.txt"
=======
#define LOG_FILE_ROUTED "/rdklogs/logs/lan_handler.txt"
>>>>>>> 49895a5 (Checking lan start event)
Comment thread source/service_dhcp/lan_handler.c Outdated
extern int executeCmd(char *);
extern FILE* g_fArmConsoleLog; //Global file pointer declaration

APPLY_PRINT("Entering into the lan_handler C file \n");

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
Signed-off-by: aj970 <akshaya_j@comcast.com>
Copilot AI review requested due to automatic review settings April 28, 2026 11:02
@aj970-crypto aj970-crypto force-pushed the feature/cbr_zeb_restart branch from b203de9 to e4eb09f Compare April 28, 2026 11:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional instrumentation to help diagnose the zebra/radv restart behavior in CBRv2 by logging key state transitions across routing/IPv6/LAN services and init scripts.

Changes:

  • Add APPLY_PRINT timestamped debug logging to multiple C services (routed/ipv6/dhcp/dslite/devicemode).
  • Add zebra start/run-state logging in service_routed (including a post-start is_daemon_running() check).
  • Add lightweight logging helpers and additional trace logs to service_routed.sh, service_lan.sh, and lan_handler.sh.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
source/service_routed/service_routed.c Adds timestamped debug logging around radv/zebra lifecycle and readiness checks; adds zebra run-state check after start.
source/service_ipv6/service_ipv6.c Adds timestamped debug logging around IPv6 LAN setup and zebra-restart triggering.
source/service_dslite/service_dslite.c Adds timestamped debug logging around zebra restart decision logic.
source/service_dhcp/service_dhcp.c Adds timestamped debug logging for LAN-related event handling and syslog restart request.
source/service_deviceMode/service_devicemode.c Adds timestamped debug logging around service start/stop per device mode.
source/scripts/init/service.d/service_routed.sh Adds log function and logs around WAN/LAN status driven routed actions.
source/scripts/init/service.d/service_lan.sh Adds log function and extensive start/stop trace logging.
source/scripts/init/service.d/lan_handler.sh Adds log function and extensive event-path trace logging for lan_handler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);
#include "errno.h"
#include "util.h"

#include <time.h>
Comment on lines 504 to +505
echo_t "RDKB_SYSTEM_BOOT_UP_LOG : INST rerurned null, retrying"
log INFO "else case : INST rerurned null, retrying"
Comment on lines +2207 to +2213
if(is_daemon_running(ZEBRA_PID_FILE, "zebra") == 0)
{
APPLY_PRINT("%s: Failed to start zebra process\n", __FUNCTION__);
}
else {
APPLY_PRINT("%s: Zebra is running\n", __FUNCTION__);
}
fi
#unregister wecb_master from pmon to let this script to bring it up when lan restart.
log INFO "Unregistering wecb_master from pmon"
echo_t "service_lan : Unregistering web_master from pmon"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants