|
From: <wow...@us...> - 2015-10-19 23:57:59
|
Revision: 596
http://sourceforge.net/p/ptpd/code/596
Author: wowczarek
Date: 2015-10-19 23:57:56 +0000 (Mon, 19 Oct 2015)
Log Message:
-----------
- reworked bmc functions to work on ForeignMasterRecord,
allowing for extra fields in the record when needed
- added pointer to best master (vs. array), to be
factored into source, NULL checks needed(?)
- added "disqualified" flag to FMR for grace period,
instead of setting prio/clockcl to 255
- added missing wildcard condition for sig/mgmt message
acceptance: clkid=all1, port match
- added default empty templates.conf to distribution
- updated man pages with template file information
- re-generated full default config file
- added macro for looping over split string tokens
(to be completed / factored into source)
Modified Paths:
--------------
trunk/Makefile.am
trunk/TODO
trunk/configure.ac
trunk/packagebuild/rpm-rh/ptpd.spec
trunk/src/bmc.c
trunk/src/constants.h
trunk/src/datatypes.h
trunk/src/dep/configdefaults.c
trunk/src/dep/net.c
trunk/src/dep/ptpd_dep.h
trunk/src/dep/sys.c
trunk/src/protocol.c
trunk/src/ptpd2.8.in
trunk/src/ptpd2.conf.5.in
trunk/src/ptpd2.conf.default-full
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/Makefile.am 2015-10-19 23:57:56 UTC (rev 596)
@@ -23,6 +23,7 @@
src/dep/iniparser/AUTHORS\
src/dep/iniparser/LICENSE\
src/dep/iniparser/README\
+ src/templates.conf\
\
$(NULL)
@@ -40,6 +41,7 @@
ptpd2_DATA = src/leap-seconds.list \
src/ptpd2.conf.minimal \
src/ptpd2.conf.default-full \
+ src/templates.conf \
doc/PTPBASE-MIB.txt \
$(NULL)
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/TODO 2015-10-19 23:57:56 UTC (rev 596)
@@ -2,8 +2,18 @@
2.3.1.1 / 2.3.2:
-- man page updates for template files
+- man page updates for template files x
- clock ID printed in reverse in L2 mode
- with (grandmasterID present?)
+ with (grandmasterID present?) - not an issue, seems like a White Rabbit problem x
- complete built-in templates
-- add dummy or populated default template file
+- add dummy or populated default template file x
+- 16.1.1: may be granted in listening state or passive state <- but g.8265 is no BMCA x
+- sig/msg message acceptance 4 options: all1,port, clockid,port, clock,all1, all1,all1 x
+- rework config option parsing
+- SET messages to refresh the config properly
+- NVRAM write?
+- pointer to best master x
+- disqualification flag x
+- remove masteraddr in favour of bestMaster->sourceAddr
+- use split token loop
+- use pointer to best master
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/configure.ac 2015-10-19 23:57:56 UTC (rev 596)
@@ -458,6 +458,8 @@
esac
+
+
AC_SUBST(PTP_PCAP)
AM_CONDITIONAL([PCAP], [test x$ptpd_pcap_enabled = x1])
@@ -749,6 +751,7 @@
PTP_SLAVE_ONLY="-DPTPD_SLAVE_ONLY"
;;
esac
+
AC_SUBST(PTP_SLAVE_ONLY)
AM_CONDITIONAL([SLAVE_ONLY], [test x$enable_slave_only = xyes])
Modified: trunk/packagebuild/rpm-rh/ptpd.spec
===================================================================
--- trunk/packagebuild/rpm-rh/ptpd.spec 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/packagebuild/rpm-rh/ptpd.spec 2015-10-19 23:57:56 UTC (rev 596)
@@ -98,6 +98,7 @@
install -m 644 src/leap-seconds.list $RPM_BUILD_ROOT%{_datadir}/ptpd/leap-seconds.list
install -m 644 src/ptpd2.conf.minimal $RPM_BUILD_ROOT%{_datadir}/ptpd/ptpd2.conf.minimal
install -m 644 src/ptpd2.conf.default-full $RPM_BUILD_ROOT%{_datadir}/ptpd/ptpd2.conf.default-full
+install -m 644 src/templates.conf $RPM_BUILD_ROOT%{_datadir}/ptpd/templates.conf
{ cd $RPM_BUILD_ROOT
Modified: trunk/src/bmc.c
===================================================================
--- trunk/src/bmc.c 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/bmc.c 2015-10-19 23:57:56 UTC (rev 596)
@@ -85,6 +85,7 @@
memcpy(ptpClock->clockIdentity + 3, &pid, 2);
}
+ ptpClock->bestMaster = NULL;
ptpClock->numberPorts = NUMBER_PORTS;
ptpClock->clockQuality.clockAccuracy =
@@ -451,30 +452,40 @@
* return similar to memcmp() */
static Integer8
-bmcDataSetComparison(const MsgHeader *headerA, const MsgAnnounce *announceA, UInteger8 localPrefA,
- const MsgHeader *headerB, const MsgAnnounce *announceB, UInteger8 localPrefB,
- const PtpClock *ptpClock, const RunTimeOpts * rtOpts)
+bmcDataSetComparison(const ForeignMasterRecord *a, const ForeignMasterRecord *b, const PtpClock *ptpClock, const RunTimeOpts *rtOpts)
{
DBGV("Data set comparison \n");
short comp = 0;
+
+
+ /* disqualification comes above anything else */
+
+ if(a->disqualified > b->disqualified) {
+ return -1;
+ }
+
+ if(a->disqualified < b->disqualified) {
+ return 1;
+ }
+
/*Identity comparison*/
- comp = memcmp(announceA->grandmasterIdentity,announceB->grandmasterIdentity,CLOCK_IDENTITY_LENGTH);
+ comp = memcmp(a->announce.grandmasterIdentity,b->announce.grandmasterIdentity,CLOCK_IDENTITY_LENGTH);
if (comp!=0)
goto dataset_comp_part_1;
/* Algorithm part2 Fig 28 */
- if (announceA->stepsRemoved > announceB->stepsRemoved+1)
+ if (a->announce.stepsRemoved > b->announce.stepsRemoved+1)
return 1;
- if (announceA->stepsRemoved+1 < announceB->stepsRemoved)
+ if (a->announce.stepsRemoved+1 < b->announce.stepsRemoved)
return -1;
/* A within 1 of B */
- if (announceA->stepsRemoved > announceB->stepsRemoved) {
- comp = memcmp(headerA->sourcePortIdentity.clockIdentity,ptpClock->parentPortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
+ if (a->announce.stepsRemoved > b->announce.stepsRemoved) {
+ comp = memcmp(a->header.sourcePortIdentity.clockIdentity,ptpClock->parentPortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
if(comp < 0)
return -1;
if(comp > 0)
@@ -483,8 +494,8 @@
return 0;
}
- if (announceA->stepsRemoved < announceB->stepsRemoved) {
- comp = memcmp(headerB->sourcePortIdentity.clockIdentity,ptpClock->parentPortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
+ if (a->announce.stepsRemoved < b->announce.stepsRemoved) {
+ comp = memcmp(b->header.sourcePortIdentity.clockIdentity,ptpClock->parentPortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
if(comp < 0)
return -1;
@@ -494,7 +505,7 @@
return 0;
}
/* steps removed A = steps removed B */
- comp = memcmp(headerA->sourcePortIdentity.clockIdentity,headerB->sourcePortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
+ comp = memcmp(a->header.sourcePortIdentity.clockIdentity,b->header.sourcePortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH);
if (comp<0) {
return -1;
@@ -506,9 +517,9 @@
/* identity A = identity B */
- if (headerA->sourcePortIdentity.portNumber < headerB->sourcePortIdentity.portNumber)
+ if (a->header.sourcePortIdentity.portNumber < b->header.sourcePortIdentity.portNumber)
return -1;
- if (headerA->sourcePortIdentity.portNumber > headerB->sourcePortIdentity.portNumber)
+ if (a->header.sourcePortIdentity.portNumber > b->header.sourcePortIdentity.portNumber)
return 1;
DBG("Sender=Receiver : Error -2");
@@ -521,38 +532,38 @@
if(rtOpts->anyDomain) {
/* part 1: preferred domain wins */
- if(headerA->domainNumber == rtOpts->domainNumber && headerB->domainNumber != ptpClock->domainNumber)
+ if(a->header.domainNumber == rtOpts->domainNumber && b->header.domainNumber != ptpClock->domainNumber)
return -1;
- if(headerA->domainNumber != rtOpts->domainNumber && headerB->domainNumber == ptpClock->domainNumber)
+ if(a->header.domainNumber != rtOpts->domainNumber && b->header.domainNumber == ptpClock->domainNumber)
return 1;
/* part 2: lower domain wins */
- if(headerA->domainNumber < headerB->domainNumber)
+ if(a->header.domainNumber < b->header.domainNumber)
return -1;
- if(headerA->domainNumber > headerB->domainNumber)
+ if(a->header.domainNumber > b->header.domainNumber)
return 1;
}
/* Compare localPreference - only used by slaves when using unicast negotiation */
- DBGV("bmcDataSetComparison localPrefA: %d, localPrefB: %d\n", localPrefA, localPrefB);
- if(localPrefA < localPrefB) {
+ DBGV("bmcDataSetComparison a->localPreference: %d, b->localPreference: %d\n", a->localPreference, b->localPreference);
+ if(a->localPreference < b->localPreference) {
return -1;
}
- if(localPrefA > localPrefB) {
+ if(a->localPreference > b->localPreference) {
return 1;
}
/* Compare GM priority1 */
- if (announceA->grandmasterPriority1 < announceB->grandmasterPriority1)
+ if (a->announce.grandmasterPriority1 < b->announce.grandmasterPriority1)
return -1;
- if (announceA->grandmasterPriority1 > announceB->grandmasterPriority1)
+ if (a->announce.grandmasterPriority1 > b->announce.grandmasterPriority1)
return 1;
/* non-standard BMC extension to prioritise GMs with UTC valid */
if(rtOpts->preferUtcValid) {
- Boolean utcA = IS_SET(headerA->flagField1, UTCV);
- Boolean utcB = IS_SET(headerB->flagField1, UTCV);
+ Boolean utcA = IS_SET(a->header.flagField1, UTCV);
+ Boolean utcB = IS_SET(b->header.flagField1, UTCV);
if(utcA > utcB)
return -1;
if(utcA < utcB)
@@ -560,33 +571,33 @@
}
/* Compare GM class */
- if (announceA->grandmasterClockQuality.clockClass <
- announceB->grandmasterClockQuality.clockClass)
+ if (a->announce.grandmasterClockQuality.clockClass <
+ b->announce.grandmasterClockQuality.clockClass)
return -1;
- if (announceA->grandmasterClockQuality.clockClass >
- announceB->grandmasterClockQuality.clockClass)
+ if (a->announce.grandmasterClockQuality.clockClass >
+ b->announce.grandmasterClockQuality.clockClass)
return 1;
/* Compare GM accuracy */
- if (announceA->grandmasterClockQuality.clockAccuracy <
- announceB->grandmasterClockQuality.clockAccuracy)
+ if (a->announce.grandmasterClockQuality.clockAccuracy <
+ b->announce.grandmasterClockQuality.clockAccuracy)
return -1;
- if (announceA->grandmasterClockQuality.clockAccuracy >
- announceB->grandmasterClockQuality.clockAccuracy)
+ if (a->announce.grandmasterClockQuality.clockAccuracy >
+ b->announce.grandmasterClockQuality.clockAccuracy)
return 1;
/* Compare GM offsetScaledLogVariance */
- if (announceA->grandmasterClockQuality.offsetScaledLogVariance <
- announceB->grandmasterClockQuality.offsetScaledLogVariance)
+ if (a->announce.grandmasterClockQuality.offsetScaledLogVariance <
+ b->announce.grandmasterClockQuality.offsetScaledLogVariance)
return -1;
- if (announceA->grandmasterClockQuality.offsetScaledLogVariance >
- announceB->grandmasterClockQuality.offsetScaledLogVariance)
+ if (a->announce.grandmasterClockQuality.offsetScaledLogVariance >
+ b->announce.grandmasterClockQuality.offsetScaledLogVariance)
return 1;
/* Compare GM priority2 */
- if (announceA->grandmasterPriority2 < announceB->grandmasterPriority2)
+ if (a->announce.grandmasterPriority2 < b->announce.grandmasterPriority2)
return -1;
- if (announceA->grandmasterPriority2 > announceB->grandmasterPriority2)
+ if (a->announce.grandmasterPriority2 > b->announce.grandmasterPriority2)
return 1;
/* Compare GM identity */
@@ -598,16 +609,19 @@
}
/*State decision algorithm 9.3.3 Fig 26*/
-static UInteger8
-bmcStateDecision(MsgHeader *header, MsgAnnounce *announce, UInteger8 localPreference,
- const RunTimeOpts *rtOpts, PtpClock *ptpClock)
+static UInteger8
+bmcStateDecision(ForeignMasterRecord *foreign, const RunTimeOpts *rtOpts, PtpClock *ptpClock)
{
Integer8 comp;
Boolean newBM;
- UInteger8 currentLocalPref = 0;
- newBM = ((memcmp(header->sourcePortIdentity.clockIdentity,
+ ForeignMasterRecord me;
+
+ memset(&me, 0, sizeof(me));
+ me.localPreference = LOWEST_LOCALPREFERENCE;
+
+ newBM = ((memcmp(foreign->header.sourcePortIdentity.clockIdentity,
ptpClock->parentPortIdentity.clockIdentity,CLOCK_IDENTITY_LENGTH)) ||
- (header->sourcePortIdentity.portNumber != ptpClock->parentPortIdentity.portNumber));
+ (foreign->header.sourcePortIdentity.portNumber != ptpClock->parentPortIdentity.portNumber));
if (ptpClock->slaveOnly) {
@@ -615,17 +629,17 @@
if(newBM && (ptpClock->parentGrants != NULL)) {
ptpClock->previousGrants = ptpClock->parentGrants;
}
- s1(header,announce,ptpClock, rtOpts);
+ s1(&foreign->header,&foreign->announce,ptpClock, rtOpts);
if(rtOpts->unicastNegotiation) {
ptpClock->parentGrants = findUnicastGrants(&ptpClock->parentPortIdentity, 0,
- ptpClock->unicastGrants, &ptpClock->grantIndex, ptpClock->unicastDestinationCount ,
+ ptpClock->unicastGrants, &ptpClock->grantIndex, ptpClock->unicastDestinationCount,
FALSE);
}
if (newBM) {
ptpClock->masterAddr = getBestMaster(ptpClock)->sourceAddr;
- displayPortIdentity(&header->sourcePortIdentity,
+ displayPortIdentity(&foreign->header.sourcePortIdentity,
"New best master selected:");
ptpClock->counters.masterChanges++;
if (ptpClock->portState == PTP_SLAVE)
@@ -637,7 +651,7 @@
}
if(rtOpts->unicastNegotiation && ptpClock->parentGrants != NULL) {
ptpClock->logAnnounceInterval = ptpClock->parentGrants->grantData[ANNOUNCE].logInterval;
- currentLocalPref = ptpClock->parentGrants->localPreference;
+ me.localPreference = ptpClock->parentGrants->localPreference;
}
return PTP_SLAVE;
}
@@ -646,20 +660,21 @@
(ptpClock->portState == PTP_LISTENING))
return PTP_LISTENING;
- copyD0(&ptpClock->msgTmpHeader,&ptpClock->msgTmp.announce,ptpClock);
+// copyD0(&me.headerk->msgTmpHeader,&ptpClock->msgTmp.announce,ptpClock);
+ copyD0(&me.header, &me.announce, ptpClock);
DBGV("local clockQuality.clockClass: %d \n", ptpClock->clockQuality.clockClass);
- comp = bmcDataSetComparison(&ptpClock->msgTmpHeader, &ptpClock->msgTmp.announce, currentLocalPref, header, announce, localPreference, ptpClock, rtOpts);
+ comp = bmcDataSetComparison(&me, foreign, ptpClock, rtOpts);
if (ptpClock->clockQuality.clockClass < 128) {
if (comp < 0) {
m1(rtOpts, ptpClock);
return PTP_MASTER;
} else if (comp > 0) {
- s1(header,announce,ptpClock, rtOpts);
+ s1(&foreign->header, &foreign->announce, ptpClock, rtOpts);
if (newBM) {
ptpClock->masterAddr = getBestMaster(ptpClock)->sourceAddr;
- displayPortIdentity(&header->sourcePortIdentity,
+ displayPortIdentity(&foreign->header.sourcePortIdentity,
"New best master selected:");
ptpClock->counters.masterChanges++;
if(ptpClock->portState == PTP_PASSIVE)
@@ -674,9 +689,9 @@
m1(rtOpts,ptpClock);
return PTP_MASTER;
} else if (comp > 0) {
- s1(header,announce,ptpClock, rtOpts);
+ s1(&foreign->header, &foreign->announce,ptpClock, rtOpts);
if (newBM) {
- displayPortIdentity(&header->sourcePortIdentity,
+ displayPortIdentity(&foreign->header.sourcePortIdentity,
"New best master selected:");
ptpClock->counters.masterChanges++;
if(ptpClock->portState == PTP_SLAVE)
@@ -716,20 +731,14 @@
}
for (i=1,best = 0; i<ptpClock->number_foreign_records;i++)
- if ((bmcDataSetComparison(&foreignMaster[i].header,
- &foreignMaster[i].announce,
- foreignMaster[i].localPreference,
- &foreignMaster[best].header,
- &foreignMaster[best].announce,
- foreignMaster[best].localPreference,
+ if ((bmcDataSetComparison(&foreignMaster[i], &foreignMaster[best],
ptpClock, rtOpts)) < 0)
best = i;
DBGV("Best record : %d \n",best);
ptpClock->foreign_record_best = best;
- return (bmcStateDecision(&foreignMaster[best].header,
- &foreignMaster[best].announce,
- foreignMaster[best].localPreference,
+ ptpClock->bestMaster = &foreignMaster[best];
+ return (bmcStateDecision(ptpClock->bestMaster,
rtOpts,ptpClock));
}
Modified: trunk/src/constants.h
===================================================================
--- trunk/src/constants.h 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/constants.h 2015-10-19 23:57:56 UTC (rev 596)
@@ -70,6 +70,8 @@
#define DEFAULT_FOREIGN_MASTER_TIME_WINDOW 4
#define DEFAULT_FOREIGN_MASTER_THRESHOLD 2
+/* g.8265.1 local preference, lowest value */
+#define LOWEST_LOCALPREFERENCE 255
/*
section 7.6.2.4, page 55:
Modified: trunk/src/datatypes.h
===================================================================
--- trunk/src/datatypes.h 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/datatypes.h 2015-10-19 23:57:56 UTC (rev 596)
@@ -495,7 +495,8 @@
MsgAnnounce announce; /* announce message -> all datasets */
MsgHeader header; /* header -> some datasets */
UInteger8 localPreference; /* local preference - only used by telecom profile */
- UInteger32 sourceAddr; /* source address */
+ UInteger32 sourceAddr; /* source address */
+ Boolean disqualified; /* if true, this one always loses */
} ForeignMasterRecord;
/**
@@ -761,6 +762,8 @@
/* Foreign master data set */
ForeignMasterRecord *foreign;
+ /* Current best master (unless it's us) */
+ ForeignMasterRecord *bestMaster;
/* Other things we need for the protocol */
UInteger16 number_foreign_records;
Modified: trunk/src/dep/configdefaults.c
===================================================================
--- trunk/src/dep/configdefaults.c 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/dep/configdefaults.c 2015-10-19 23:57:56 UTC (rev 596)
@@ -98,6 +98,10 @@
{"ptpengine:time_traceable","y"},
{"ptpengine:frequency_traceable","y"},
{"clock:leap_seconds_file", DATADIR"/"PACKAGE_NAME"/leap-seconds.list"},
+ /*
+ * UTC offset value and UTC offset valid flag
+ * will be announced if leap file is parsed and up to date
+ */
{NULL}}
},
@@ -114,7 +118,7 @@
{NULL}}
},
- { "full-logging-instance", "Logging for all facilities using 'instance' variable which user should provide", {
+ { "full-logging-instance", "Logging for all facilities using 'instance' variable which the user should provide", {
{"global:log_status", "y"},
{"global:status_file", "@rundir@/ptpd2.@instance@.status"},
{"global:statistics_log_interval", "1"},
@@ -579,7 +583,7 @@
fileDict = dictionary_new(0);
dict = dictionary_new(0);
-//INFO("tf: %s",DEFAULT_TEMPLATE_FILE);
+
loadFileList(fileDict, DEFAULT_TEMPLATE_FILE);
loadFileList(fileDict, files);
Modified: trunk/src/dep/net.c
===================================================================
--- trunk/src/dep/net.c 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/dep/net.c 2015-10-19 23:57:56 UTC (rev 596)
@@ -902,10 +902,10 @@
for(text__=text_;found < total; text__=NULL) {
token=strtok_r(text__,", ;\t",&stash);
- tmp = 255;
+ tmp = LOWEST_LOCALPREFERENCE;
if(token!=NULL) {
if (sscanf(token,"%d", &tmp) != 1) {
- tmp = 255;
+ tmp = LOWEST_LOCALPREFERENCE;
}
}
Modified: trunk/src/dep/ptpd_dep.h
===================================================================
--- trunk/src/dep/ptpd_dep.h 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/dep/ptpd_dep.h 2015-10-19 23:57:56 UTC (rev 596)
@@ -188,6 +188,29 @@
#define clearFlag(x,y) ( *(UInteger8*)((x)+((y)<8?1:0)) &= ~(1<<((y)<8?(y):(y)-8)) )
/** \}*/
+#define DEFAULT_TOKEN_DELIM ", ;\t"
+
+/*
+ * foreach loop across substrings from var, delimited by delim, placing
+ * each token in targetvar on iteration, using id variable name prefix
+ * to allow nesting (each loop uses an individual set of variables)
+ */
+#define foreach_token_begin(id, var, targetvar, delim) {\
+ char* id_stash; \
+ char* id_text_; \
+ char* id_text__; \
+ char* targetvar; \
+ id_text_=strdup(var); \
+ for(id_text__ = id_text_;; id_text__=NULL) { \
+ targetvar = strtok_r(id_text__, delim, &id_stash); \
+ if(targetvar==NULL) break;
+
+#define foreach_token_end(id) } \
+ if(id_text_ != NULL) { \
+ free(id_text_); \
+ }\
+}
+
/** \name msg.c
*-Pack and unpack PTP messages */
/**\{*/
Modified: trunk/src/dep/sys.c
===================================================================
--- trunk/src/dep/sys.c 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/dep/sys.c 2015-10-19 23:57:56 UTC (rev 596)
@@ -336,7 +336,7 @@
/* Write a formatted string to file pointer */
int writeMessage(FILE* destination, uint32_t *lastHash, int priority, const char * format, va_list ap) {
- char buf[PATH_MAX +1];
+
extern RunTimeOpts rtOpts;
extern Boolean startupInProgress;
@@ -344,6 +344,7 @@
char time_str[MAXTIMESTR];
struct timeval now;
#ifndef RUNTIME_DEBUG
+ char buf[PATH_MAX +1];
uint32_t hash;
va_list ap1;
#endif /* RUNTIME_DEBUG */
@@ -1065,7 +1066,7 @@
if(rtOpts->unicastNegotiation && ptpClock->parentGrants != NULL ) {
fprintf(out, ", localPref %d", ptpClock->parentGrants->localPreference);
}
- fprintf(out, "\n");
+ fprintf(out, "%s\n", (ptpClock->bestMaster != NULL && ptpClock->bestMaster->disqualified) ? " (timeout)" : "");
}
if(ptpClock->clockQuality.clockClass < 128 ||
Modified: trunk/src/protocol.c
===================================================================
--- trunk/src/protocol.c 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/protocol.c 2015-10-19 23:57:56 UTC (rev 596)
@@ -745,6 +745,7 @@
ptpClock->clockQuality.clockClass != SLAVE_ONLY_CLOCK_CLASS) {
ptpClock->number_foreign_records = 0;
ptpClock->foreign_record_i = 0;
+ ptpClock->bestMaster = NULL;
m1(rtOpts,ptpClock);
toState(PTP_MASTER, rtOpts, ptpClock);
@@ -761,15 +762,8 @@
* otherwise, timer will cycle and we will reset.
* Also don't clear the FMR just yet.
*/
- if (ptpClock->grandmasterClockQuality.clockClass != 255 &&
- ptpClock->grandmasterPriority1 != 255 &&
- ptpClock->grandmasterPriority2 != 255) {
- ptpClock->grandmasterClockQuality.clockClass = 255;
- ptpClock->grandmasterPriority1 = 255;
- ptpClock->grandmasterPriority2 = 255;
- ptpClock->foreign[ptpClock->foreign_record_best].announce.grandmasterPriority1=255;
- ptpClock->foreign[ptpClock->foreign_record_best].announce.grandmasterPriority2=255;
- ptpClock->foreign[ptpClock->foreign_record_best].announce.grandmasterClockQuality.clockClass=255;
+ if (!ptpClock->bestMaster->disqualified) {
+ ptpClock->bestMaster->disqualified = TRUE;
WARNING("GM announce timeout, disqualified current best GM\n");
ptpClock->counters.announceTimeouts++;
}
@@ -790,7 +784,7 @@
WARNING("No active masters present. Resetting port.\n");
ptpClock->number_foreign_records = 0;
ptpClock->foreign_record_i = 0;
-
+ ptpClock->bestMaster = NULL;
/* if flipping between primary and backup interface, a full nework re-init is required */
if(rtOpts->backupIfaceEnabled) {
ptpClock->runningBackupInterface = !ptpClock->runningBackupInterface;
@@ -1436,7 +1430,7 @@
{
UnicastGrantTable *nodeTable = NULL;
- UInteger8 localPreference = 0;
+ UInteger8 localPreference = LOWEST_LOCALPREFERENCE;
DBGV("HandleAnnounce : Announce message received : \n");
@@ -1563,7 +1557,7 @@
if (rtOpts->announceTimeoutGracePeriod &&
ptpClock->announceTimeouts > 0) {
- NOTICE("Received Announce message from master - cancelling timeout\n");
+ NOTICE("Received Announce message from current master - cancelling timeout\n");
ptpClock->announceTimeouts = 0;
/* we are available for clock control again */
ptpClock->clockControl.available = TRUE;
@@ -2689,7 +2683,8 @@
}
}
-/* Only accept the management / signaling message if it satisfies 15.3.1 Table 36 */
+/* Only accept the management / signaling message if it satisfies 15.3.1 Table 36 */
+/* Also 13.12.1 table 32 */
Boolean
acceptPortIdentity(PortIdentity thisPort, PortIdentity targetPort)
{
@@ -2703,12 +2698,18 @@
return TRUE;
}
- /* equal clockIDs and target port number is wildcard - this was missing up to 12oct15 */
+ /* equal clockIDs and target port number is wildcard */
if(!memcmp(targetPort.clockIdentity, thisPort.clockIdentity, CLOCK_IDENTITY_LENGTH) &&
(targetPort.portNumber == allOnesPortNumber)) {
return TRUE;
}
+ /* target clock ID is wildcard, port number matches */
+ if(!memcmp(targetPort.clockIdentity, allOnesClkIdentity, CLOCK_IDENTITY_LENGTH) &&
+ (targetPort.portNumber == thisPort.portNumber)) {
+ return TRUE;
+ }
+
/* target port and clock IDs are both wildcard */
if(!memcmp(targetPort.clockIdentity, allOnesClkIdentity, CLOCK_IDENTITY_LENGTH) &&
(targetPort.portNumber == allOnesPortNumber)) {
@@ -3586,6 +3587,7 @@
DBGV("addForeign : AnnounceMessage incremented \n");
msgUnpackHeader(buf,&ptpClock->foreign[j].header);
msgUnpackAnnounce(buf,&ptpClock->foreign[j].announce);
+ ptpClock->foreign[j].disqualified = FALSE;
ptpClock->foreign[j].localPreference = localPreference;
break;
}
@@ -3600,7 +3602,7 @@
ptpClock->number_foreign_records++;
}
- /* Preserve best master record from overwriting (sf FR #22) - use next slot*/
+ /* Preserve best master record from overwriting (sf FR #22) - use next slot */
if (ptpClock->foreign_record_i == ptpClock->foreign_record_best) {
ptpClock->foreign_record_i++;
ptpClock->foreign_record_i %= ptpClock->number_foreign_records;
@@ -3615,7 +3617,8 @@
header->sourcePortIdentity.portNumber;
ptpClock->foreign[j].foreignMasterAnnounceMessages = 0;
ptpClock->foreign[j].localPreference = localPreference;
- ptpClock->foreign[j].sourceAddr = sourceAddr;
+ ptpClock->foreign[j].sourceAddr = sourceAddr;
+ ptpClock->foreign[j].disqualified = FALSE;
/*
* header and announce field of each Foreign Master are
* usefull to run Best Master Clock Algorithm
Modified: trunk/src/ptpd2.8.in
===================================================================
--- trunk/src/ptpd2.8.in 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/ptpd2.8.in 2015-10-19 23:57:56 UTC (rev 596)
@@ -83,7 +83,8 @@
Display built-in configuration templates
.TP
\fB-t --templates \fI[name],[name],...\fR
-Apply one or more configuration templates in this order (\fIsee man(5) ptpd2.conf\fR)
+Apply one or more configuration templates in this order (\fIsee man(5) ptpd2.conf\fR),
+also see \fIptpengine:template_files\fR and the \
.TP
\fB-S --statistics-file \fIPATH\fR
Path to statistics file (also \fIglobal:statistics_file\fR)
Modified: trunk/src/ptpd2.conf.5.in
===================================================================
--- trunk/src/ptpd2.conf.5.in 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/ptpd2.conf.5.in 2015-10-19 23:57:56 UTC (rev 596)
@@ -59,16 +59,34 @@
\fBNote:\fR for the same effect, ptpd can be run from command line, such as \fI --config=/path/to/file --variables:instance=server15\fR
-.SH CONFIGURATION TEMPLATES
-As of version 2.3.1.1, ptpd enables the user to minimise the configuration effort for common scenarios, using built-in templates.
-A template is a named set of pre-defined settings whic are prepended before any other settings, so user can still overwrite
-settings provided by the template. To use this feature, set \fIglobal:config_templates=[name],[name],...\fR in the configuration file,
-or run ptpd with \fI--global:config_templates=[name],[name],...\fR. Multiple templates can be specified, separated by comma, space
-or tab; they are applied in the order they are provided, so template settings override any overlapping settings from previous
-templates specified.
+.SH CONFIGURATION TEMPLATES AND TEMPLATE FILES
+As of version 2.3.1.1, ptpd enables the user to minimise the configuration effort for common scenarios, using built-in templates
+and template files. A template is a named set of pre-defined settings whic are prepended before any other settings, so user can
+still overwrite settings provided by the template. To use this feature, set \fIglobal:config_templates=[name],[name],...\fR in the
+configuration file, or run ptpd with \fI--global:config_templates=[name],[name],...\fR. Multiple templates can be specified,
+separated by comma, space or tab; they are applied in the order they are provided, so template settings override any overlapping
+settings from previous templates specified. Templates can include \fIuser-defined variables\fR.
-To see the list of available templates, run ptpd with \fI-T\fR or \fI--templates\fR
+A number of \fItemplate files\fR can also be supplied with the \fIglobal:template_files\fR setting
+(comma, space or tab separated lis of file paths). The template files will be processed in the order they are provided in,
+so for overlapping settings, the last template applied overrides settings applied by any previous
+templates. PTPd will also try to load a default template file on startup: \fItemplates.conf\fR
+from the default data directory: \fI@prefix@/share/@PACKAGE_NAME@/templates.conf\fR
+The template file is formatted in .ini style - each template is a section defined as
+\fI[template-name]\fR, followed by a number of settings specified as \fIsection:setting\fR.
+
+\fBExample\fR:
+
+[my-template]
+
+global:verbose_foreground=Y
+
+ptpengine:preset=slaveonly
+
+
+To see the list of available built-in templates, run ptpd with \fI-T\fR or \fI--show-templates\fR
+
.SH CONFIGURATION VARIABLES
.RS 0
.TP 8
@@ -181,7 +199,8 @@
uses multicast for sync and announce, and unicast for delay request and response
.TP 12
\fIunicast\fR
-uses unicast for all transmission. When unicast mode is selected, destination IP(s) (\fIptpengine:unicast_destinations\fR) must be configured
+uses unicast for all transmission. When unicast mode is selected, destination IP(s) (\fIptpengine:unicast_
+destinations\fR) must be configured
depending on unicast negotiation setting (\fIptpengine:unicast_negotiation\fR) and master or slave role
(see: \fIptpengine:unicast_destinations\fR)
.RE
@@ -2383,6 +2402,42 @@
.RE
.RS 0
.TP 8
+\fBglobal:config_templates [\fISTRING\fB]\fR
+.RS 8
+.TP 8
+\fBusage\fR
+Comma, space or tab-separated list of template names to be applied to the configuration
+(see \fICONFIGURATION TEMPLATES AND TEMPLATE FILES\fR section). Templates are applied in the order
+they are specified, so any overlapping settings from one template are overridden with settings
+from the following template(s). PTPd provides some built-in templates - see the templates section
+above; to see the built-in templates, run ptpd with \fI-T\fR or \fI--show-templates\fR.
+.TP 8
+\fBdefault\fR
+\fI[none]\fR
+
+.RE
+.RE
+.RS 0
+.TP 8
+\fBglobal:template_files [\fISTRING\fB]\fR
+.RS 8
+.TP 8
+\fBusage\fR
+Comma, space or tab-separated list of template file paths to be loaded
+(see \fICONFIGURATION TEMPLATES AND TEMPLATE FILES\fR section). Template
+files are also loaded in the order they are provided, so templates in one file
+can be extended by templates in the next file(s); any overlapping settings are overridden
+by following files. PTPd will not exit when one or more template files cannot be opened.
+PTPd will always try to load \fI@prefix@/share/@PACKAGE_NAME@/templates.conf\fR on startup.
+.TP 8
+\fBdefault\fR
+\fI[none]\fR
+
+
+.RE
+.RE
+.RS 0
+.TP 8
\fBglobal:enable_snmp [\fIBOOLEAN\fB]\fR
.RS 8
.TP 8
Modified: trunk/src/ptpd2.conf.default-full
===================================================================
--- trunk/src/ptpd2.conf.default-full 2015-10-16 19:49:23 UTC (rev 595)
+++ trunk/src/ptpd2.conf.default-full 2015-10-19 23:57:56 UTC (rev 596)
@@ -46,6 +46,18 @@
;
ptpengine:unicast_negotiation = N
+; When using unicast negotiation (slave), accept PTP messages from any master.
+; By default, only messages from acceptable masters (ptpengine:unicast_destinations)
+; are accepted, and only if transmission was granted by the master
+;
+ptpengine:unicast_any_master = N
+
+; PTP port number wildcard mask applied onto port identities when running
+; unicast negotiation: allows multiple port identities to be accepted as one.
+; This option can be used as a workaround where a node sends signaling messages and
+; timing messages with different port identities
+ptpengine:unicast_port_mask = 0
+
; Disable Best Master Clock Algorithm for unicast masters:
; Only effective for masteronly preset - all Announce messages
; will be ignored and clock will transition directly into MASTER state.
@@ -60,6 +72,12 @@
; in Ethernet mode).
ptpengine:use_libpcap = N
+; Disable UDP checksum validation on UDP sockets (Linux only).
+; Workaround for situations where a node (like Transparent Clock).
+; does not rewrite checksums
+;
+ptpengine:disable_udp_checksums = Y
+
; Delay detection mode used - use DELAY_DISABLED for syntonisation only
; (no full synchronisation).
; Options: E2E P2P DELAY_DISABLED
@@ -100,7 +118,7 @@
; announced by best master, even if the the
; currrentUtcOffsetValid flag is announced FALSE.
; NOTE: this behaviour is not part of the standard.
-ptpengine:always_respect_utc_offset = N
+ptpengine:always_respect_utc_offset = Y
; Compatibility extension to BMC algorithm: when enabled,
; BMC for both master and save clocks will prefer masters
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|