linuxptp: address review nits from round 4

- ptp4l.init: add fast pre-check for ptp_interface UCI sections before
  the clock-sync wait, so a misconfigured box fails in milliseconds
  rather than burning the full max_tries budget inside rcS
- ptp4l.init: fix Waiting... progress line when clock_sync_max_tries
  is 0 (was rendering as '3/0'; now shows 'attempt N, unlimited')
- ptp4l.init, phc2sys.init: downgrade 'not configured' log messages
  from err to notice; an unconfigured package is expected state, not
  a fault
- linuxptp.config: replace '~2 min' with the actual formula
  (clock_sync_check_interval x (tries - 1)) so the comment stays
  accurate when either knob is changed

Signed-off-by: Aleks Mariusz <a+git-commit@alek.cx>
This commit is contained in:
Aleks Mariusz authored and Hannu Nyman committed 2026-10-24 16:59:03 +03:00
1 parent 71666498b7
commit 6cb82d3f97
3 files changed
+16 -4

No files matched your search

+2 -1
View File
@@ -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
+1 -1
View File
@@ -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'
+13 -2
View File
@@ -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"