Checking zebra restart issue in cbr2#286
Conversation
Signed-off-by: aj970 <akshaya_j@comcast.com>
There was a problem hiding this comment.
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_PRINTtimestamped 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_runninginservice_routed). - Added a
log()helper inservice_routed.shto 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.
| 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)) | ||
| { |
| 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(); |
| 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); |
| @@ -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" |
There was a problem hiding this comment.
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.shand 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.
| fprintf(logfp, "[%02d:%02d:%02d] ",\ | ||
| current_time->tm_hour,\ | ||
| current_time->tm_min,\ | ||
| current_time->tm_sec);\ | ||
| fprintf(logfp, fmt);\ |
| #include <time.h> | ||
| #define LOG_FILE_ROUTED "/tmp/service_routed.txt" | ||
| #define APPLY_PRINT(fmt ...) {\ | ||
| FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\ |
| 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; |
| #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 <time.h> | ||
| #define LOG_FILE_ROUTED "/tmp/utopia_service_ipv6.txt" | ||
| #define APPLY_PRINT(fmt ...) {\ | ||
| FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\ | ||
| if (logfp){\ |
| #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);\ |
| #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); |
| #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" |
There was a problem hiding this comment.
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_PRINTlogging macro (timestamped file logging) across multiple services. - Adds additional log points and a post-start
is_daemon_running()verification when starting zebra fromservice_routed. - Adds shell-script logging to
service_routed.shfor 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 whenis_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, anddaemon_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.
| #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);\ |
| #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> |
| #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);\ | ||
| }\ |
| #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);\ | ||
| }\ |
| #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); |
2b6a145 to
c3c695d
Compare
There was a problem hiding this comment.
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_routedand 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 whenis_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> |
| 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" |
|
|
||
| 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__); | ||
| } |
| #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);\ | ||
| }\ | ||
| }\ |
| @@ -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" |
| 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" | ||
| } |
c3c695d to
cb58011
Compare
Signed-off-by: aj970 <akshaya_j@comcast.com>
cb58011 to
15c64fa
Compare
There was a problem hiding this comment.
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_PRINTtimestamped logging macros and numerous debug log statements across routed/ipv6/dslite/dhcp/devicemode paths. - Added zebra start verification logging in
service_routedafter 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. Sinceis_daemon_running()returns a PID when running (non-zero), this condition should be inverted (return 0 only when zebra is not running) and calldaemon_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.
| #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); |
| #include <time.h> | ||
| #define LOG_FILE_ROUTED "/rdklogs/logs/Consolelog.txt.0" |
Signed-off-by: aj970 <akshaya_j@comcast.com>
There was a problem hiding this comment.
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_PRINTtimestamped logging macros across several C services (routed/ipv6/dslite/dhcp/devicemode). - Added zebra start-status logging in
service_routedand 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 makesradv_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.
| #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);\ | ||
| }\ | ||
| }\ | ||
|
|
| 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" |
| #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);\ | ||
| }\ | ||
| }\ | ||
|
|
| #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);\ | ||
| }\ | ||
| }\ |
| 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'; | ||
| } |
| 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 |
|
|
||
| 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; |
There was a problem hiding this comment.
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/shinit 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.
| 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'; |
| #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);\ | ||
| }\ | ||
| }\ |
| 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" | ||
| } |
| 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" |
| 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'; |
| #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);\ | ||
| }\ | ||
| }\ |
| #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);\ | ||
| }\ | ||
| }\ |
| #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);\ | ||
| }\ | ||
| }\ |
| 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/service_lan.log" | ||
| echo "$timestamp [$level] $message" | tee -a "$log_file" |
Signed-off-by: aj970 <akshaya_j@comcast.com>
There was a problem hiding this comment.
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_PRINTdebug logging (timestamped file append) acrossservice_routed,service_ipv6,service_dslite,service_dhcp, andservice_devicemode. - Added additional zebra start logging/verification in
service_routedand 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;). Sinceis_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 calldaemon_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.
| 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" |
| #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> |
| #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);\ | ||
| }\ | ||
| }\ |
| 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" |
| #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);\ | ||
| }\ | ||
| }\ | ||
|
|
| #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);\ | ||
| }\ | ||
| }\ |
| <<<<<<< 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) |
| 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>
b203de9 to
e4eb09f
Compare
There was a problem hiding this comment.
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_PRINTtimestamped debug logging to multiple C services (routed/ipv6/dhcp/dslite/devicemode). - Add zebra start/run-state logging in
service_routed(including a post-startis_daemon_running()check). - Add lightweight logging helpers and additional trace logs to
service_routed.sh,service_lan.sh, andlan_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> |
| echo_t "RDKB_SYSTEM_BOOT_UP_LOG : INST rerurned null, retrying" | ||
| log INFO "else case : INST rerurned null, retrying" |
| 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" |
Checking zebra restart issue in CBRv2