From b7ebfab0cc2ccdf515db67e2feca9073c0b2ec19 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Thu, 29 Aug 2013 11:01:27 +0200 Subject: [PATCH] Add a configuration file option for the extra sync-fup check. Signed-off-by: Richard Cochran --- config.c | 6 ++++++ config.h | 1 + default.cfg | 1 + gPTP.cfg | 1 + ptp4l.8 | 12 ++++++++++++ ptp4l.c | 1 + 6 files changed, 22 insertions(+) diff --git a/config.c b/config.c index ebb19c9..8cae57f 100644 --- a/config.c +++ b/config.c @@ -301,6 +301,12 @@ static enum parser_result parse_global_setting(const char *option, return r; *cfg->tx_timestamp_timeout = val; + } else if (!strcmp(option, "check_fup_sync")) { + r = get_ranged_int(value, &val, 0, 1); + if (r != PARSED_OK) + return r; + *cfg->check_fup_sync = val; + } else if (!strcmp(option, "pi_proportional_const")) { r = get_ranged_double(value, &df, 0.0, DBL_MAX); if (r != PARSED_OK) diff --git a/config.h b/config.h index b014d7e..94704a4 100644 --- a/config.h +++ b/config.h @@ -70,6 +70,7 @@ struct config { struct port_defaults pod; int *assume_two_step; int *tx_timestamp_timeout; + int *check_fup_sync; enum servo_type clock_servo; diff --git a/default.cfg b/default.cfg index efdd0f2..72665a6 100644 --- a/default.cfg +++ b/default.cfg @@ -36,6 +36,7 @@ use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 +check_fup_sync 0 # # Servo Options # diff --git a/gPTP.cfg b/gPTP.cfg index 85865bc..30719b6 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -35,6 +35,7 @@ use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 +check_fup_sync 0 # # Servo options # diff --git a/ptp4l.8 b/ptp4l.8 index c68d01d..493626d 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -255,6 +255,18 @@ The number of milliseconds to poll waiting for the tx time stamp from the kernel when a message has recently been sent. The default is 1. .TP +.B check_fup_sync +Because of packet reordering that can occur in the network, in the +hardware, or in the networking stack, a follow up message can appear +to arrive in the application before the matching sync message. As this +is a normal occurrence, and the sequenceID message field ensures +proper matching, the ptp4l program accepts out of order packets. This +option adds an additional check using the software time stamps from +the networking stack to verify that the sync message did arrive +first. This option is only useful if you do not trust the sequence IDs +generated by the master. +The default is 0 (disabled). +.TP .B clock_servo The servo which is used to synchronize the local clock. Currently only one servo is implemented, a PI controller. diff --git a/ptp4l.c b/ptp4l.c index 9577250..b0d1c9c 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -92,6 +92,7 @@ static struct config cfg_settings = { .assume_two_step = &assume_two_step, .tx_timestamp_timeout = &sk_tx_timeout, + .check_fup_sync = &sk_check_fupsync, .clock_servo = CLOCK_SERVO_PI,