From: Delio Brignoli <dbrign...@audioscience.com>

When peer delay is < min_neighbor_prop_delay the port is flagged
as non 802.1AS capable. min_neighbor_prop_delay defaults to INT_MIN.

Signed-off-by: Delio Brignoli <dbrign...@audioscience.com>
---

Changes since v1:
 * limit INT32_MIN <= min_neighbor_prop_delay <= -1 
    so we are sure that min_neighbor_prop_delay < neighborPropDelayThresh
 * change type of min_neighbor_prop_delay from Integer32 to int

 config.c |    6 ++++++
 ds.h     |    1 +
 port.c   |   11 +++++++++++
 ptp4l.8  |    4 ++++
 ptp4l.c  |    2 ++
 5 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/config.c b/config.c
index cfe36b8..78f1655 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, INT32_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/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..c8e12e1 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 <limits.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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 = INT_MIN,
        },
 
        .timestamping = TS_HARDWARE,
-- 
1.7.0.4




------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to