diff --git a/net/linuxptp/files/linuxptp.config b/net/linuxptp/files/linuxptp.config index 7fef7637d6..2e2787ceb5 100644 --- a/net/linuxptp/files/linuxptp.config +++ b/net/linuxptp/files/linuxptp.config @@ -11,7 +11,8 @@ config ptp4l 'ptp4l' # configures the ptp4l daemon #option clock_sync_check_interval '15' # Seconds between clock discipline checks (default: 15). # Only used when require_clock_sync is 1. - #option clock_sync_max_tries '8' # Max attempts before giving up clock sync wait (default: 8, ~2 min). + #option clock_sync_max_tries '8' # Max attempts before giving up clock sync wait (default: 8). + # Total wait = clock_sync_check_interval x (tries - 1), ~105s at defaults. # Set to 0 to wait indefinitely (blocks boot until clock disciplines). # For global lines in ptp4l.conf - Each item is one line like "key value" for the [global] section diff --git a/net/linuxptp/files/phc2sys.init b/net/linuxptp/files/phc2sys.init index ca5f239a33..77942cf813 100644 --- a/net/linuxptp/files/phc2sys.init +++ b/net/linuxptp/files/phc2sys.init @@ -20,7 +20,7 @@ make_cmdline() { echo $PROG config_get dev $cfg "phc_device" "" - [ -z "$dev" ] && { log err "phc_device not configured. Set 'option phc_device' in /etc/config/linuxptp."; return 1; } + [ -z "$dev" ] && { log notice "phc_device not configured, phc2sys not starting. Set 'option phc_device' in /etc/config/linuxptp."; return 1; } ! [ -c "$dev" ] && { log crit "PHC device '$dev' not found!"; return 1; } dir='phc_to_sys' diff --git a/net/linuxptp/files/ptp4l.init b/net/linuxptp/files/ptp4l.init index cb9a860e9f..d635bf1dbe 100644 --- a/net/linuxptp/files/ptp4l.init +++ b/net/linuxptp/files/ptp4l.init @@ -54,7 +54,11 @@ wait_disciplined() { log err "Increase 'clock_sync_max_tries' or set 'require_clock_sync 0' to skip." return 1 fi - log info "sysclock-discipline-check: $check_msg. Waiting... ($tries/$max_tries)" + if [ "$max_tries" -gt 0 ]; then + log info "sysclock-discipline-check: $check_msg. Waiting... ($tries/$max_tries)" + else + log info "sysclock-discipline-check: $check_msg. Waiting... (attempt $tries, unlimited)" + fi else log crit "Clock sync check FAILED: $check_msg." log err "ptp4l will NOT start. Resolve issue, or set 'require_clock_sync' to 0" @@ -118,7 +122,7 @@ make_configfile() { # Require at least one [interface] section beyond [global] iface_count=$(grep -c '^\[' "$CONFIGFILE" 2>/dev/null) if [ "${iface_count:-0}" -lt 2 ]; then - log err "No PTP interfaces configured. Add a 'config ptp_interface' section to /etc/config/linuxptp." + log notice "No PTP interfaces configured. Add a 'config ptp_interface' section to /etc/config/linuxptp." return 1 fi } @@ -146,6 +150,13 @@ start_service() { config_load linuxptp + # Fast pre-check: fail immediately if no ptp_interface sections exist in UCI, + # before potentially spending minutes in the clock-sync wait. + if ! uci -q get linuxptp.@ptp_interface[0] >/dev/null 2>&1; then + log notice "No ptp_interface sections configured in /etc/config/linuxptp. ptp4l will not start." + return 1 + fi + config_get role $ID "role" "auto" [ "$role" = "server" ] && should_have_disciplined_clock=1 config_get_bool clocksync_wanted $ID "require_clock_sync" "$should_have_disciplined_clock"