Skip to content

Commit

Permalink
2.3.1-rc3 - first batch
Browse files Browse the repository at this point in the history
- increased robustness to network failures:
  * issue full network reset if multicast refresh
    failed (both master and slave)
  * issue full network reset after N slave resets
    (default is 5) - covers unicast cases
- minor config file parser reload flag fixes
- cleaned up multicast init failure error messages
- version updated to 2.3.1-rc3
  • Loading branch information
wowczarek committed Sep 9, 2014
1 parent c978d29 commit 922c1f0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 21 deletions.
4 changes: 2 additions & 2 deletions m4/version.m4
@@ -1,4 +1,4 @@
m4_define([PTPD_URL],[http://ptpd.sourceforge.net])
m4_define([RELEASE_DATE],[August, 2014])
m4_define([VERSION_NUMBER],[2.3.1-rc2])
m4_define([RELEASE_DATE],[September, 2014])
m4_define([VERSION_NUMBER],[2.3.1-rc3])

7 changes: 4 additions & 3 deletions packagebuild/rpm-rh/ptpd.spec
Expand Up @@ -12,11 +12,11 @@
Summary: Synchronises system time using the Precision Time Protocol (PTP) implementing the IEEE 1588-2008 (PTP v 2) standard
Name: ptpd
Version: 2.3.1
Release: 0.99.rc2%{distver}
Release: 0.99.rc3%{distver}
License: distributable
Group: System Environment/Daemons
Vendor: PTPd project team
Source0: ptpd-2.3.1-rc2.tar.gz
Source0: ptpd-2.3.1-rc3.tar.gz
Source1: ptpd.init
Source2: ptpd.sysconfig
Source3: ptpd.conf
Expand All @@ -42,7 +42,7 @@ time synchronised via the PTP protocol.

%prep

%setup -n ptpd-2.3.1-rc2
%setup -n ptpd-2.3.1-rc3

%build

Expand Down Expand Up @@ -150,6 +150,7 @@ fi


%changelog
* Tue Sep 09 25 2014 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc3
* Fri Jul 25 2014 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc2
* Thu Jun 26 2014 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.1-0.99.rc1
* Thu Nov 21 2013 Wojciech Owczarek <wojciech@owczarek.co.uk> 2.3.0-1
Expand Down
4 changes: 4 additions & 0 deletions src/datatypes.h
Expand Up @@ -751,6 +751,7 @@ typedef struct {
/*Stats header will be re-printed when set to true*/
Boolean resetStatisticsLog;

int listenCount; // number of consecutive resets to listening
int resetCount;
int announceTimeouts;
int current_init_clock;
Expand Down Expand Up @@ -999,6 +1000,9 @@ typedef struct {

int maxDelayMaxRejected;

/* max reset cycles in LISTENING before full network restart */
int maxListen;

Boolean managementEnabled;
Boolean managementSetEnable;

Expand Down
11 changes: 8 additions & 3 deletions src/dep/daemonconfig.c
Expand Up @@ -944,6 +944,8 @@ loadDefaultSettings( RunTimeOpts* rtOpts )
rtOpts->panicModeDuration = 2;
rtOpts->panicModeExitThreshold = 0;

/* full network reset after 5 times in listening */
rtOpts->maxListen = 5;

#ifdef PTPD_NTPDC
rtOpts->panicModeNtp = FALSE;
Expand Down Expand Up @@ -1406,6 +1408,9 @@ parseConfig ( dictionary* dict, RunTimeOpts *rtOpts )
"Priority 2 announced in master state, used for Best Master\n"
" Clock selection.",0,248);

CONFIG_MAP_INT_MIN( "ptpengine:max_listen",rtOpts->maxListen,rtOpts->maxListen,
"Number of consecutive resets to LISTENING before full network reset\n",1);

/*
* TODO: in unicast and hybrid mode, automativally override master delayreq interval with a default,
* rather than require setting it manually.
Expand Down Expand Up @@ -2830,7 +2835,7 @@ int checkSubsystemRestart(dictionary* newConfig, dictionary* oldConfig)
COMPONENT_RESTART_REQUIRED("ptpengine:clock_class", PTPD_UPDATE_DATASETS );
COMPONENT_RESTART_REQUIRED("ptpengine:priority1", PTPD_UPDATE_DATASETS );
COMPONENT_RESTART_REQUIRED("ptpengine:priority2", PTPD_UPDATE_DATASETS );
COMPONENT_RESTART_REQUIRED("ptpengine:priority2", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:max_listen", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:always_respect_utc_offset", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:prefer_utc_offset_valid", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:require_utc_offset_valid", PTPD_RESTART_NONE );
Expand All @@ -2851,7 +2856,7 @@ int checkSubsystemRestart(dictionary* newConfig, dictionary* oldConfig)
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_action", PTPD_RESTART_NONE );
COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_capacity", PTPD_RESTART_PEIRCE );
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_threshold", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_autotune_enable", PTPD_RESTART_PEIRCE );
COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_autotune_enable", PTPD_RESTART_PEIRCE );
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_autotune_minpercent", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_autotune_maxpercent", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:delay_outlier_filter_autotune_step", PTPD_RESTART_NONE );
Expand All @@ -2865,7 +2870,7 @@ int checkSubsystemRestart(dictionary* newConfig, dictionary* oldConfig)
COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_capacity", PTPD_RESTART_PEIRCE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_threshold", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_weight", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_autotune_enable", PTPD_RESTART_PEIRCE );
COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_autotune_enable", PTPD_RESTART_PEIRCE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_autotune_minpercent", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_autotune_maxpercent", PTPD_RESTART_NONE );
// COMPONENT_RESTART_REQUIRED("ptpengine:sync_outlier_filter_autotune_minthreshold", PTPD_RESTART_NONE );
Expand Down
13 changes: 7 additions & 6 deletions src/dep/net.c
Expand Up @@ -521,15 +521,16 @@ netInitMulticastIPv4(NetPath * netPath, Integer32 multicastAddr)
|| setsockopt(netPath->generalSock, IPPROTO_IP, IP_MULTICAST_IF,
&netPath->interfaceAddr, sizeof(struct in_addr))
< 0) {
PERROR("failed to enable multi-cast on the interface");
PERROR("error while setting outgoig multicast interface "
"(IP_MULTICAST_IF)");
return FALSE;
}
/* join multicast group (for receiving) on specified interface */
if (setsockopt(netPath->eventSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq)) < 0
|| setsockopt(netPath->generalSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&imr, sizeof(struct ip_mreq)) < 0) {
PERROR("failed to join the multi-cast group");
PERROR("failed to join the multicast group");
return FALSE;
}
return TRUE;
Expand Down Expand Up @@ -574,7 +575,7 @@ netInitMulticast(NetPath * netPath, RunTimeOpts * rtOpts)
/* Init Peer multicast IP address */
strncpy(addrStr, PEER_PTP_DOMAIN_ADDRESS, NET_ADDRESS_LENGTH);
if (!inet_aton(addrStr, &netAddr)) {
ERROR("failed to encode multi-cast address: %s\n", addrStr);
ERROR("failed to encode multicast address: %s\n", addrStr);
return FALSE;
}
netPath->peerMulticastAddr = netAddr.s_addr;
Expand Down Expand Up @@ -993,7 +994,7 @@ netInit(NetPath * netPath, RunTimeOpts * rtOpts, PtpClock * ptpClock)
}
/* bind sockets */
/*
* need INADDR_ANY to allow receipt of multi-cast and uni-cast
* need INADDR_ANY to allow receipt of multicast and uni-cast
* messages
*/

Expand Down Expand Up @@ -1717,7 +1718,7 @@ netSendPeerGeneral(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpt
netPath->pcapGeneral);

if (ret <= 0)
DBG("error sending ether multi-cast general message\n");
DBG("error sending ether multicast general message\n");
} else if (netPath->unicastAddr)
#else
if (netPath->unicastAddr)
Expand Down Expand Up @@ -1772,7 +1773,7 @@ netSendPeerEvent(Octet * buf, UInteger16 length, NetPath * netPath, RunTimeOpts
netPath->pcapGeneral);

if (ret <= 0)
DBG("error sending ether multi-cast general message\n");
DBG("error sending ether multicast general message\n");
} else if (netPath->unicastAddr)
#else
if (netPath->unicastAddr)
Expand Down
39 changes: 32 additions & 7 deletions src/protocol.c
Expand Up @@ -348,8 +348,12 @@ toState(UInteger8 state, RunTimeOpts *rtOpts, PtpClock *ptpClock)

case PTP_LISTENING:
timerStop(ANNOUNCE_RECEIPT_TIMER, ptpClock->itimer);
/* we're leaving LISTENING - reset counter */
if(state != PTP_LISTENING) {
ptpClock->listenCount = 0;
}
break;

default:
break;
}
Expand Down Expand Up @@ -410,16 +414,28 @@ toState(UInteger8 state, RunTimeOpts *rtOpts, PtpClock *ptpClock)
*/
if (ptpClock->portState != PTP_LISTENING) {
ptpClock->resetCount++;
}
} else {
ptpClock->listenCount++;
if( ptpClock->listenCount >= rtOpts->maxListen ) {
WARNING("Stilll in LISTENING after x restarts - will do a full network reset\n");
toState(PTP_FAULTY, rtOpts, ptpClock);
ptpClock->listenCount = 0;
break;
}
}

/* Revert to the original DelayReq interval, and ignore the one for the last master */
ptpClock->logMinDelayReqInterval = rtOpts->initial_delayreq;

/* force a IGMP refresh per reset */
if (rtOpts->ip_mode != IPMODE_UNICAST && rtOpts->do_IGMP_refresh && rtOpts->transport != IEEE_802_3) {
netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
/* if multicast refresh failed, restart network - helps recover after driver reloads and such */
if(!netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock)) {
WARNING("Error while refreshing multicast - will do a full network reset\n");
toState(PTP_FAULTY, rtOpts, ptpClock);
break;
}
}


timerStart(ANNOUNCE_RECEIPT_TIMER,
(ptpClock->announceReceiptTimeout) *
Expand Down Expand Up @@ -779,7 +795,12 @@ doState(RunTimeOpts *rtOpts, PtpClock *ptpClock)
}

if (rtOpts->ip_mode != IPMODE_UNICAST && rtOpts->do_IGMP_refresh && rtOpts->transport != IEEE_802_3) {
netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
/* if multicast refresh failed, restart network - helps recover after driver reloads and such */
if(!netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock)) {
WARNING("Error while refreshing multicast - will do a full network reset\n");
toState(PTP_FAULTY, rtOpts, ptpClock);
break;
}
}

/*
Expand Down Expand Up @@ -963,8 +984,12 @@ doState(RunTimeOpts *rtOpts, PtpClock *ptpClock)
timerExpired(MASTER_NETREFRESH_TIMER, ptpClock->itimer)) {
DBGV("Master state periodic IGMP refresh - next in %d seconds...\n",
rtOpts->masterRefreshInterval);
netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);

/* if multicast refresh failed, restart network - helps recover after driver reloads and such */
if(!netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock)) {
WARNING("Error while refreshing multicast - will do a full network reset\n");
toState(PTP_FAULTY, rtOpts, ptpClock);
break;
}
}

if (timerExpired(SYNC_INTERVAL_TIMER, ptpClock->itimer)) {
Expand Down
13 changes: 13 additions & 0 deletions src/ptpd2.conf.5.in
Expand Up @@ -566,6 +566,19 @@ Priority 2 announced in master state, used for Best Master
\fBdefault\fR
\fI128\fR

.RE
.RE
.RS 0
.TP 8
\fBptpengine:max_listen [\fIINT\fB: min: 1 ]\fR
.RS 8
.TP 8
\fBusage\fR
Number of consecutive protocol resets to LISTENING before full network reset.
.TP 8
\fBdefault\fR
\fI5\fR

.RE
.RE
.RS 0
Expand Down

0 comments on commit 922c1f0

Please sign in to comment.