From b2bde6f5ec13e6f9c8fbd966807ad30b1d17ed87 Mon Sep 17 00:00:00 2001 From: Delio Brignoli Date: Fri, 21 Feb 2014 18:18:08 +0100 Subject: [PATCH] config: Add min_neighbor_prop_delay configuration variable When peer delay is < min_neighbor_prop_delay the port is flagged as non 802.1AS capable. min_neighbor_prop_delay defaults to -20ms. Signed-off-by: Delio Brignoli --- config.c | 6 ++++++ ds.h | 1 + gPTP.cfg | 1 + port.c | 11 +++++++++++ ptp4l.8 | 4 ++++ ptp4l.c | 2 ++ 6 files changed, 25 insertions(+) diff --git a/config.c b/config.c index cfe36b8..03a4a45 100644 --- a/config.c +++ b/config.c @@ -125,6 +125,12 @@ static enum parser_result parse_pod_setting(const char *option, return r; pod->neighborPropDelayThresh = uval; + } else if (!strcmp(option, "min_neighbor_prop_delay")) { + r = get_ranged_int(value, &val, INT_MIN, -1); + if (r != PARSED_OK) + return r; + pod->min_neighbor_prop_delay = val; + } else if (!strcmp(option, "fault_badpeernet_interval")) { pod->flt_interval_pertype[FT_BAD_PEER_NETWORK].type = FTMO_LINEAR_SECONDS; if (!strcasecmp("ASAP", value)) { diff --git a/ds.h b/ds.h index 2ecda8d..ea25fbb 100644 --- a/ds.h +++ b/ds.h @@ -136,6 +136,7 @@ struct port_defaults { int freq_est_interval; /*log seconds*/ struct fault_interval flt_interval_pertype[FT_CNT]; UInteger32 neighborPropDelayThresh; /*nanoseconds*/ + int min_neighbor_prop_delay; /*nanoseconds*/ }; #endif diff --git a/gPTP.cfg b/gPTP.cfg index 249269e..6f09215 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -23,6 +23,7 @@ syncReceiptTimeout 3 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 800 +min_neighbor_prop_delay -20000000 # # Run time options # diff --git a/port.c b/port.c index 7e7b2c1..96a7eb2 100644 --- a/port.c +++ b/port.c @@ -101,6 +101,7 @@ struct port { Enumeration8 delayMechanism; Integer8 logMinPdelayReqInterval; UInteger32 neighborPropDelayThresh; + int min_neighbor_prop_delay; enum fault_type last_fault_type; unsigned int versionNumber; /*UInteger4*/ /* foreignMasterDS */ @@ -475,6 +476,15 @@ static int port_capable(struct port *p) goto not_capable; } + if (tmv_to_nanoseconds(p->peer_delay) < p->min_neighbor_prop_delay) { + if (p->asCapable) + pr_debug("port %hu: peer_delay (%" PRId64 ") < min_neighbor_prop_delay " + "(%" PRId32 "), resetting asCapable", portnum(p), + tmv_to_nanoseconds(p->peer_delay), + p->min_neighbor_prop_delay); + goto not_capable; + } + if (p->pdr_missing > ALLOWED_LOST_RESPONSES) { if (p->asCapable) pr_debug("port %hu: missed %d peer delay resp, " @@ -1378,6 +1388,7 @@ static int port_initialize(struct port *p) p->logSyncInterval = p->pod.logSyncInterval; p->logMinPdelayReqInterval = p->pod.logMinPdelayReqInterval; p->neighborPropDelayThresh = p->pod.neighborPropDelayThresh; + p->min_neighbor_prop_delay = p->pod.min_neighbor_prop_delay; for (i = 0; i < N_TIMER_FDS; i++) { fd[i] = -1; diff --git a/ptp4l.8 b/ptp4l.8 index dd5e33b..bce88f9 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -193,6 +193,10 @@ The default is UDPv4. Upper limit for peer delay in nanoseconds. If the estimated peer delay is greater than this value the port is marked as not 802.1AS capable. .TP +.B min_neighbor_prop_delay +Lower limit for peer delay in nanoseconds. If the estimated peer delay is +smaller than this value the port is marked as not 802.1AS capable. +.TP .B delay_filter Select the algorithm used to filter the measured delay and peer delay. Possible values are moving_average and moving_median. diff --git a/ptp4l.c b/ptp4l.c index d5a3aab..7e38435 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -17,6 +17,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include #include @@ -90,6 +91,7 @@ static struct config cfg_settings = { .freq_est_interval = 1, /* Default to very a large neighborPropDelay threshold */ .neighborPropDelayThresh = 20000000, + .min_neighbor_prop_delay = -20000000, }, .timestamping = TS_HARDWARE,