|
From: <wow...@us...> - 2015-06-12 14:26:05
|
Revision: 554
http://sourceforge.net/p/ptpd/code/554
Author: wowczarek
Date: 2015-06-12 14:26:02 +0000 (Fri, 12 Jun 2015)
Log Message:
-----------
- further fixes for the 100% CPU issue
- message counters (for rates) now exclude
packets sent to self
- ptpd now binds to the interface address
when using unicast - needs tested on all OSes
- updated INSTALL
- added --disable-so-timestamping as last resort
for cases where it's causing issues
- increased upper boundary of unciast destination
table to 1024.
- minor refactoring
- version bumped to 2.3.1-rc5
- fixed last minute showstopper where master would
not send messages in hybrid mode
- do not attempt retrieving IP addresses from
Ethernet frames anymore
- removed erroneous bind() to multicast address,
which was breaking ptpengine:pid_as_clock_identity
- added periodic warning when maximum unicast capacity
reached
Modified Paths:
--------------
trunk/INSTALL
trunk/configure.ac
trunk/m4/version.m4
trunk/src/Makefile.am
trunk/src/datatypes.h
trunk/src/dep/daemonconfig.c
trunk/src/dep/datatypes_dep.h
trunk/src/dep/msg.c
trunk/src/dep/net.c
trunk/src/dep/ptpd_dep.h
trunk/src/dep/servo.c
trunk/src/dep/snmp.c
trunk/src/dep/startup.c
trunk/src/dep/sys.c
trunk/src/protocol.c
trunk/src/ptpd.h
trunk/src/signaling.c
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/INSTALL 2015-06-12 14:26:02 UTC (rev 554)
@@ -1,80 +1,106 @@
PTP Daemon Version 2 Build and Installation Instructions
-20 March 2015
+12 June 2015
George V. Neville-Neil, Wojciech Owczarek
-The PTP Daemon is known to work on FreeBSD, NetBSD, Mac OS X and Linux systems.
+The PTP Daemon is known to work on FreeBSD, NetBSD, OpenBSD,
+OpenSolaris and its derivatives, Mac OS X and Linux systems.
*) Requirements
-You will need the following tools and libraries to build ptpd2
+You will need the following tools and libraries to build ptpd2:
-1. GNU autotools (automake, autoconf, libtool etc.)
-2. PCAP libraries
-3. SNMP libraries (optional)
+1. GNU autotools (automake, autoconf, libtool etc.) - essential
-*) Building
+2. PCAP libraries (libpcap/bpf) and development headers
+ (optional but recommended) - required for Ethernet transport
+ and generally recommended for message performance
+3. SNMP libraries (optional) - will allow building with SNMP
+ support
+
+*) Building
+
1. cd into the root of the tree (which is where the file you're
reading resides)
-2. autoreconf -vi
+2. If building from a repository such as Subversion, CVS or GIT, run:
-3. ./configure
+ autoreconf -vi
- To disable the statistics code in order to lower computational
+3. If building from a distribution .tar.gz package, you may run autoreconf -vi,
+ but in most cases running ./configure should be enough - must run
+ autoreconf if configure results in errors.
+
+4. ./configure
+
+ ========= configure script options for ptpd ========================
+
+ * To disable the statistics code in order to lower computational
expense and RAM usage, configure the build with the following options:
./configure --disable-statistics
- To add support for printing all message counters on a SIGUSR2,
- add --enable-sigusr2=counters to the configure parameters.
+ * To build a slave-only version (with GM logic disabled), build with:
- To build a slave-only version (with GM logic disabled), build with:
-
./configure --enable-slave-only
This will build a version incapable of running as master.
- As of 2.3.1, the default timer implamentation used for periodic
+ * As of 2.3.1, the default timer implamentation used for periodic
actions uses POSIX timers if only the OS supports it. To disable
POSIX timer support and use the old interval timer implementation,
the following switch can be used:
./configure --disable-posix-timers
- As of 2.3.1, support was added for multiple unicast destinations
+ * As of 2.3.1, support was added for multiple unicast destinations
(both GMs and slaves) - with negotiation (signaling) and without.
The default maximum number of unicast destinations (also the
maximum number of slaves for a signaling GM) is set to 16. This
- can be changed to a maximum of 512 using:
+ can be changed to a maximum of 1024 using:
- ./configure --with-max-unicast-destinations=[16...512]
+ ./configure --with-max-unicast-destinations=[16...1024]
-4. make
+ It is possible to change this limit to more than 1024, but realistically,
+ due to message scheduling, timer signal usage and single-thread
+ architecture, anywhere above 400 ptpd will struggle.
-5. Read the manual pages ptpd2(8) and ptpd2.conf(5). The man pages
+ * With certain NIC drivers on Linux providing the SO_TIMESTAMPING
+ functionality with software transmit timestamps (SOF_TIMESTAMPING_
+ TX_SOFTWARE), unpredictable transmit timestamp failures can occur,
+ which may cause unstable operation and in some cases high CPU usage
+ (see https://sourceforge.net/p/ptpd/discussion/469208/thread/4aea6e47).
+ While fixes have been implemented, there is still some risk.
+ To disable SO_TIMESTAMPING support completely on Linux,
+ regardless of OS support, use:
+
+ ./configure --disable-so-timestamping
+
+5. make
+
+6. Read the manual pages ptpd2(8) and ptpd2.conf(5). The man pages
are the most complete source of configuration information.
ptpd2 itself also provides an extensive help:
run ptpd2 --help to see the short help
run ptpd2 --long-help to see the long help for all settings
run ptpd2 -e [key:setting] to display help for a single setting
-6. Update test/client-e2e-socket.conf so that its
+7. Update test/client-e2e-socket.conf so that its
"ptpengine:interface = " setting points to a network interface on
your test machine that can see PTP packets from a grandmaster.
-6. Test it in place: ./src/ptpd2 -c test/client-e2e-socket.conf
+8. Test it in place: ./src/ptpd2 -c test/client-e2e-socket.conf
-7. Check the log output of the daemon in /var/run/ptpd2.event.log
+9. Check the log output of the daemon in /var/run/ptpd2.event.log
Check statistics output of the daemon in /var/run/ptpd2.stats.log
Check the status file /var/run/ptpd2.status.log
-8. If the results look good, make install
+10. If the results look good, make install
-The daemon may work on other Posix based systems but this is not
-guaranteed. Patches and fixes are welcome on the source forge page
+The daemon may work on other POSIX based systems but this is not
+guaranteed. Patches and fixes are welcome on the SourceForge page:
http://ptpd.sf.net
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/configure.ac 2015-06-12 14:26:02 UTC (rev 554)
@@ -592,7 +592,7 @@
AC_ARG_WITH(
[max-unicast-destinations],
[AS_HELP_STRING(
- [--with-max-unicast-destinations = [ 16 .. 512]],
+ [--with-max-unicast-destinations = [ 16 .. 1024]],
[Change maximum supported number of unicast destinations -
this determines the maximum supported number of slaves
in unicast mode (with and without signaling)]
@@ -602,7 +602,7 @@
)
test $max_destinations -lt 16 && max_destinations=16
-test $max_destinations -gt 512 && max_destinations=512
+test $max_destinations -gt 1024 && max_destinations=1024
PTP_UNICAST_MAX="-DPTPD_UNICAST_MAX=$max_destinations"
AC_SUBST([PTP_UNICAST_MAX])
AC_MSG_RESULT([$max_destinations])
@@ -663,6 +663,26 @@
AM_CONDITIONAL([STATISTICS], [test x$ptp_enable_statistics = xyes])
+AC_MSG_CHECKING([if we want to enable SO_TIMESTAMPING support on Linux if available])
+AC_ARG_ENABLE(
+ [so-timestamping],
+ [AS_HELP_STRING(
+ [--disable-so-timestamping],
+ [Disable support for SO_TIMESTAMPING on Linux builds]
+ )],
+ [ptp_enable_so_timestamping=no],
+ [ptp_enable_so_timestamping=yes]
+)
+AC_MSG_RESULT([$ptp_enable_so_timestamping])
+case "$ptp_enable_so_timestamping" in
+ no)
+ PTP_DISABLE_SOTIMESTAMPING="-DPTPD_DISABLE_SOTIMESTAMPING"
+ ;;
+esac
+AC_SUBST(PTP_DISABLE_SOTIMESTAMPING)
+
+AM_CONDITIONAL([DISABLE_SOTIMESTAMPING], [test x$ptp_enable_so_timestamping = xno])
+
AC_MSG_CHECKING([for slave-only build support])
AC_ARG_ENABLE(
[slave-only],
Modified: trunk/m4/version.m4
===================================================================
--- trunk/m4/version.m4 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/m4/version.m4 2015-06-12 14:26:02 UTC (rev 554)
@@ -1,4 +1,4 @@
m4_define([PTPD_URL],[http://ptpd.sourceforge.net])
m4_define([RELEASE_DATE],[June, 2015])
-m4_define([VERSION_NUMBER],[2.3.1-rc4])
+m4_define([VERSION_NUMBER],[2.3.1-rc5])
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/Makefile.am 2015-06-12 14:26:02 UTC (rev 554)
@@ -13,7 +13,7 @@
AM_CFLAGS += $(LINUX_KERNEL_INCLUDES)
endif
-AM_CPPFLAGS += $(PTP_DBL) $(PTP_DAEMON) $(PTP_EXP) $(PTP_SNMP) $(PTP_PCAP) $(PTP_STATISTICS) $(PTP_SLAVE_ONLY) $(PTP_PTIMERS) $(PTP_UNICAST_MAX)
+AM_CPPFLAGS += $(PTP_DBL) $(PTP_DAEMON) $(PTP_EXP) $(PTP_SNMP) $(PTP_PCAP) $(PTP_STATISTICS) $(PTP_SLAVE_ONLY) $(PTP_PTIMERS) $(PTP_UNICAST_MAX) $(PTP_DISABLE_SOTIMESTAMPING)
NULL=
Modified: trunk/src/datatypes.h
===================================================================
--- trunk/src/datatypes.h 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/datatypes.h 2015-06-12 14:26:02 UTC (rev 554)
@@ -856,6 +856,7 @@
int can_step_clock;
int warned_operator_slow_slewing;
int warned_operator_fast_slewing;
+ Boolean warnedUnicastCapacity;
int maxDelayRejected;
Boolean runningBackupInterface;
@@ -1085,7 +1086,7 @@
Boolean pcap; /* Receive and send packets using libpcap, bypassing the
network stack. */
int transport;
- int ip_mode;
+ int ipMode;
/* list of unicast destinations for use with unicast with or without signaling */
Modified: trunk/src/dep/daemonconfig.c
===================================================================
--- trunk/src/dep/daemonconfig.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/daemonconfig.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -822,7 +822,7 @@
rtOpts->timeProperties.frequencyTraceable = FALSE;
rtOpts->timeProperties.ptpTimescale = TRUE;
- rtOpts->ip_mode = IPMODE_MULTICAST;
+ rtOpts->ipMode = IPMODE_MULTICAST;
rtOpts->unicastNegotiation = FALSE;
rtOpts->unicastNegotiationListening = FALSE;
@@ -1239,15 +1239,7 @@
"ethernet", IEEE_802_3
);
-#ifdef PTPD_PCAP
- /* ethernet mode - cannot specify IP mode */
- CONFIG_KEY_CONDITIONAL_CONFLICT("ptpengine:ip_mode",
- rtOpts->transport == IEEE_802_3,
- "ethernet",
- "ptpengine:ip_mode");
-#endif
-
- CONFIG_MAP_SELECTVALUE("ptpengine:ip_mode", rtOpts->ip_mode, rtOpts->ip_mode,
+ CONFIG_MAP_SELECTVALUE("ptpengine:ip_mode", rtOpts->ipMode, rtOpts->ipMode,
"IP transmission mode (requires IP transport) - hybrid mode uses\n"
" multicast for sync and announce, and unicast for delay request and\n"
" response; unicast mode uses unicast for all transmission.\n"
@@ -1258,7 +1250,6 @@
"hybrid", IPMODE_HYBRID
);
-
CONFIG_MAP_BOOLEAN("ptpengine:unicast_negotiation",rtOpts->unicastNegotiation,rtOpts->unicastNegotiation,
"Enable unicast negotiation support using signaling messages\n");
@@ -1266,13 +1257,13 @@
"ptpengine:unicast_negotiation",
"Unicast negotiation cannot be used with Ethernet transport\n");
- CONFIG_KEY_CONDITIONAL_WARNING((rtOpts->ip_mode != IPMODE_UNICAST) && rtOpts->unicastNegotiation,
+ CONFIG_KEY_CONDITIONAL_WARNING((rtOpts->ipMode != IPMODE_UNICAST) && rtOpts->unicastNegotiation,
"ptpengine:unicast_negotiation",
"Unicast negotiation can only be used with unicast transmission\n");
/* disable unicast negotiation unless running unicast */
CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport == IEEE_802_3,rtOpts->unicastNegotiation,FALSE,rtOpts->unicastNegotiation);
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->ip_mode != IPMODE_UNICAST,rtOpts->unicastNegotiation,FALSE,rtOpts->unicastNegotiation);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->ipMode != IPMODE_UNICAST,rtOpts->unicastNegotiation,FALSE,rtOpts->unicastNegotiation);
CONFIG_MAP_BOOLEAN("ptpengine:disable_bmca",rtOpts->disableBMCA,rtOpts->disableBMCA,
"Disable Best Master Clock Algorithm for unicast masters:\n"
@@ -1620,13 +1611,13 @@
*/
/* hybrid mode -> should specify delayreq interval: override set in the bottom of this function */
- CONFIG_KEY_CONDITIONAL_WARNING(rtOpts->ip_mode == IPMODE_HYBRID,
+ CONFIG_KEY_CONDITIONAL_WARNING(rtOpts->ipMode == IPMODE_HYBRID,
"ptpengine:log_delayreq_interval",
"It is recommended to set the delay request interval (ptpengine:log_delayreq_interval) in hybrid mode"
);
/* unicast mode -> should specify delayreq interval if we can become a slave */
- CONFIG_KEY_CONDITIONAL_WARNING(rtOpts->ip_mode == IPMODE_UNICAST &&
+ CONFIG_KEY_CONDITIONAL_WARNING(rtOpts->ipMode == IPMODE_UNICAST &&
rtOpts->clockQuality.clockClass > 127,
"ptpengine:log_delayreq_interval",
"It is recommended to set the delay request interval (ptpengine:log_delayreq_interval) in unicast mode"
@@ -1637,7 +1628,7 @@
/* unicast signaling slave -> must specify unicast destination(s) */
CONFIG_KEY_CONDITIONAL_DEPENDENCY("ptpengine:ip_mode",
rtOpts->clockQuality.clockClass > 127 &&
- rtOpts->ip_mode == IPMODE_UNICAST &&
+ rtOpts->ipMode == IPMODE_UNICAST &&
rtOpts->unicastNegotiation,
"unicast",
"ptpengine:unicast_destinations");
@@ -1645,7 +1636,7 @@
/* unicast master without signaling - must specify unicast destinations */
CONFIG_KEY_CONDITIONAL_DEPENDENCY("ptpengine:ip_mode",
rtOpts->clockQuality.clockClass <= 127 &&
- rtOpts->ip_mode == IPMODE_UNICAST &&
+ rtOpts->ipMode == IPMODE_UNICAST &&
!rtOpts->unicastNegotiation,
"unicast",
"ptpengine:unicast_destinations");
@@ -1675,7 +1666,7 @@
/* unicast P2P - must specify unicast peer destination */
CONFIG_KEY_CONDITIONAL_DEPENDENCY("ptpengine:delay_mechanism",
rtOpts->delayMechanism == P2P &&
- rtOpts->ip_mode == IPMODE_UNICAST,
+ rtOpts->ipMode == IPMODE_UNICAST,
"P2P",
"ptpengine:unicast_peer_destination");
@@ -2484,7 +2475,7 @@
* We're in hybrid mode and we haven't specified the delay request interval:
* use override with a default value
*/
- if((rtOpts->ip_mode == IPMODE_HYBRID) &&
+ if((rtOpts->ipMode == IPMODE_HYBRID) &&
!CONFIG_ISSET("ptpengine:log_delayreq_interval"))
rtOpts->ignore_delayreq_interval_master=TRUE;
@@ -2492,7 +2483,7 @@
* We're in unicast slave-capable mode and we haven't specified the delay request interval:
* use override with a default value
*/
- if((rtOpts->ip_mode == IPMODE_UNICAST &&
+ if((rtOpts->ipMode == IPMODE_UNICAST &&
rtOpts->clockQuality.clockClass > 127) &&
!CONFIG_ISSET("ptpengine:log_delayreq_interval"))
rtOpts->ignore_delayreq_interval_master=TRUE;
Modified: trunk/src/dep/datatypes_dep.h
===================================================================
--- trunk/src/dep/datatypes_dep.h 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/datatypes_dep.h 2015-06-12 14:26:02 UTC (rev 554)
@@ -91,7 +91,7 @@
/* Typically MAC address - outer 6 octers of ClockIdendity */
Octet interfaceID[ETHER_ADDR_LEN];
/* source address of last received packet - used for unicast replies to Delay Requests */
- Integer32 lastRecvAddr;
+ Integer32 lastSourceAddr;
/* destination address of last received packet - used for unicast FollowUp for multiple slaves*/
Integer32 lastDestAddr;
Modified: trunk/src/dep/msg.c
===================================================================
--- trunk/src/dep/msg.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/msg.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -1544,7 +1544,7 @@
*(UInteger8 *) (buf + 32) = 0x00;
/* Table 24 - unless it's multicast, logMessageInterval remains 0x7F */
- if(rtOpts.transport == IEEE_802_3 || rtOpts.ip_mode == IPMODE_MULTICAST)
+ if(rtOpts.transport == IEEE_802_3 || rtOpts.ipMode == IPMODE_MULTICAST)
*(Integer8 *) (buf + 33) = ptpClock->logSyncInterval;
memset((buf + 8), 0, 8);
@@ -1591,7 +1591,7 @@
*(UInteger16 *) (buf + 30) = flip16(sequenceId);
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 24 - unless it's multicast, logMessageInterval remains 0x7F */
- if(rtOpts.transport == IEEE_802_3 || rtOpts.ip_mode == IPMODE_MULTICAST)
+ if(rtOpts.transport == IEEE_802_3 || rtOpts.ipMode == IPMODE_MULTICAST)
*(Integer8 *) (buf + 33) = ptpClock->logAnnounceInterval;
/* Announce message */
@@ -1671,7 +1671,7 @@
*(UInteger8 *) (buf + 32) = 0x02;
/* Table 24 - unless it's multicast, logMessageInterval remains 0x7F */
- if(rtOpts.transport == IEEE_802_3 || rtOpts.ip_mode == IPMODE_MULTICAST)
+ if(rtOpts.transport == IEEE_802_3 || rtOpts.ipMode == IPMODE_MULTICAST)
*(Integer8 *) (buf + 33) = ptpClock->logSyncInterval;
/* Follow_up message */
@@ -1784,7 +1784,7 @@
*(UInteger8 *) (buf + 32) = 0x03;
/* Table 24 - unless it's multicast, logMessageInterval remains 0x7F */
- if(rtOpts.transport == IEEE_802_3 || rtOpts.ip_mode == IPMODE_MULTICAST)
+ if(rtOpts.transport == IEEE_802_3 || rtOpts.ipMode == IPMODE_MULTICAST)
*(Integer8 *) (buf + 33) = ptpClock->logMinDelayReqInterval;
/* Pdelay_resp message */
Modified: trunk/src/dep/net.c
===================================================================
--- trunk/src/dep/net.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/net.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -489,7 +489,7 @@
if(!(info.flags & IFF_MULTICAST)
&& rtOpts->transport==UDP_IPV4
- && rtOpts->ip_mode != IPMODE_UNICAST) {
+ && rtOpts->ipMode != IPMODE_UNICAST) {
WARNING("Interface %s is not multicast capable.\n", ifaceName);
}
@@ -549,7 +549,7 @@
char addrStr[NET_ADDRESS_LENGTH+1];
/* do not join multicast in unicast mode */
- if(rtOpts->ip_mode == IPMODE_UNICAST)
+ if(rtOpts->ipMode == IPMODE_UNICAST)
return TRUE;
/* Init General multicast IP address */
@@ -628,7 +628,7 @@
fd_set tmpSet;
struct timeval timeOut = {0,0};
int val = 1;
-
+ int i = 0;
if(netPath->txTimestampFailure)
goto failure;
@@ -637,37 +637,52 @@
if(select(netPath->eventSock + 1, &tmpSet, NULL, NULL, &timeOut) > 0) {
if (FD_ISSET(netPath->eventSock, &tmpSet)) {
- length = netRecvEvent(G_ptpClock->msgIbuf, timeStamp,
+ length = netRecvEvent(G_ptpClock->msgIbuf, timeStamp,
netPath, MSG_ERRQUEUE);
-
if (length > 0) {
- DBG("Grabbed sent msg via errqueue: %d bytes, at %d.%d\n", length, timeStamp->seconds, timeStamp->nanoseconds);
+ DBG("getTxTimestamp: Grabbed sent msg via errqueue: %d bytes, at %d.%d\n", length, timeStamp->seconds, timeStamp->nanoseconds);
return TRUE;
} else if (length < 0) {
- DBG("Failed to poll error queue for SO_TIMESTAMPING transmit time");
+ DBG("getTxTimestamp: Failed to poll error queue for SO_TIMESTAMPING transmit time\n");
G_ptpClock->counters.messageRecvErrors++;
- goto failure;
} else if (length == 0) {
- DBG("Received no data from TX error queue");
+ DBG("getTxTimestamp: Received no data from TX error queue\n");
}
}
- }
+ }
- /* try again: sleep and poll the error queue, if nothing, consider SO_TIMESTAMPING inoperable */
+ /* we're desperate here, aren't we... */
+ for(i = 0; i < 3; i++) {
+ length = netRecvEvent(G_ptpClock->msgIbuf, timeStamp, netPath, MSG_ERRQUEUE);
+ if(length > 0) {
+ DBG("getTxTimestamp: SO_TIMESTAMPING - delayed TX timestamp caught\n");
+ return TRUE;
+ }
+ usleep(10);
+ }
+
+ /* try for the last time: sleep and poll the error queue, if nothing, consider SO_TIMESTAMPING inoperable */
usleep(LATE_TXTIMESTAMP_US);
+
length = netRecvEvent(G_ptpClock->msgIbuf, timeStamp, netPath, MSG_ERRQUEUE);
if(length > 0) {
- DBG("SO_TIMESTAMPING - delayed TX timestamp caught\n");
+ DBG("getTxTimestamp: SO_TIMESTAMPING - even more delayed TX timestamp caught\n");
return TRUE;
} else {
- DBG("SO_TIMESTAMPING - TX timestamp retry failed - will use loop from now on\n");
+ DBG("getTxTimestamp: SO_TIMESTAMPING - TX timestamp retry failed - will use loop from now on\n");
}
failure:
-
+ NOTICE("net.c: SO_TIMESTAMPING TX software timestamp failure - reverting to SO_TIMESTAMPNS\n");
+ /* unset SO_TIMESTAMPING first! otherwise we get an always-exiting select! */
+ val = 0;
+ if(setsockopt(netPath->eventSock, SOL_SOCKET, SO_TIMESTAMPING, &val, sizeof(int)) < 0) {
+ DBG("getTxTimestamp: failed to unset SO_TIMESTAMPING");
+ }
+ val = 1;
if(setsockopt(netPath->eventSock, SOL_SOCKET, SO_TIMESTAMPNS, &val, sizeof(int)) < 0) {
- DBG("gettxtimestamp: failed to revert to SO_TIMESTAMPNS");
+ DBG("getTxTimestamp: failed to revert to SO_TIMESTAMPNS");
}
return FALSE;
@@ -1005,7 +1020,7 @@
if (pcap_compile(netPath->pcapEvent, &program,
( rtOpts->transport == IEEE_802_3 ) ?
"ether proto 0x88f7":
- ( rtOpts->ip_mode != IPMODE_MULTICAST ) ?
+ ( rtOpts->ipMode != IPMODE_MULTICAST ) ?
"udp port 319" :
"host (224.0.1.129 or 224.0.0.107) and udp port 319" ,
1, 0) < 0) {
@@ -1032,7 +1047,7 @@
}
if (rtOpts->transport != IEEE_802_3) {
if (pcap_compile(netPath->pcapGeneral, &program,
- ( rtOpts->ip_mode != IPMODE_MULTICAST ) ?
+ ( rtOpts->ipMode != IPMODE_MULTICAST ) ?
"udp port 320" :
"host (224.0.1.129 or 224.0.0.107) and udp port 320" ,
1, 0) < 0) {
@@ -1083,18 +1098,15 @@
}
/* bind sockets */
/*
- * need INADDR_ANY to allow receipt of multicast and uni-cast
- * messages
+ * need INADDR_ANY to receive both unicast and multicast,
+ * but only need interface address for unicast
*/
- /* why??? */
- if (rtOpts->pidAsClockId) {
- if (inet_pton(AF_INET, DEFAULT_PTP_DOMAIN_ADDRESS, &addr.sin_addr) < 0) {
- PERROR("failed to convert address");
- return FALSE;
- }
- } else
+ if(rtOpts->ipMode == IPMODE_UNICAST) {
+ addr.sin_addr = netPath->interfaceAddr;
+ } else {
addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ }
addr.sin_family = AF_INET;
addr.sin_port = htons(PTP_EVENT_PORT);
@@ -1129,7 +1141,7 @@
* so may only be used for multicast-only
*/
- if ( rtOpts->ip_mode == IPMODE_MULTICAST ) {
+ if ( rtOpts->ipMode == IPMODE_MULTICAST ) {
if (setsockopt(netPath->eventSock, SOL_SOCKET, SO_BINDTODEVICE,
rtOpts->ifaceName, strlen(rtOpts->ifaceName)) < 0
|| setsockopt(netPath->generalSock, SOL_SOCKET, SO_BINDTODEVICE,
@@ -1162,7 +1174,7 @@
}
- if(rtOpts->delayMechanism==P2P && rtOpts->ip_mode==IPMODE_UNICAST) {
+ if(rtOpts->delayMechanism==P2P && rtOpts->ipMode==IPMODE_UNICAST) {
ptpClock->unicastPeerDestination.transportAddress = 0;
if(rtOpts->unicastPeerDestinationSet &&
rtOpts->delayMechanism==P2P && !hostLookup(rtOpts->unicastPeerDestination,
@@ -1181,7 +1193,7 @@
}
- if(rtOpts->ip_mode != IPMODE_UNICAST) {
+ if(rtOpts->ipMode != IPMODE_UNICAST) {
/* init UDP Multicast on both Default and Peer addresses */
if (!netInitMulticast(netPath, rtOpts))
@@ -1434,8 +1446,11 @@
#if defined(HAVE_DECL_MSG_ERRQUEUE) && HAVE_DECL_MSG_ERRQUEUE
if(!(flags & MSG_ERRQUEUE))
#endif
- netPath->lastRecvAddr = from_addr.sin_addr.s_addr;
- netPath->receivedPackets++;
+ netPath->lastSourceAddr = from_addr.sin_addr.s_addr;
+ /* do not report "from self" */
+ if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
+ netPath->receivedPackets++;
+ }
netPath->receivedPacketsTotal++;
if (msg.msg_controllen <= 0) {
@@ -1546,16 +1561,24 @@
}
/* Make sure this is IP (could dot1q get here?) */
- if( ntohs(*(u_short *)(pkt_data + 12)) != ETHERTYPE_IP)
- DBGV("PCAP payload received is not Ethernet: 0x%04x\n",
+ if( ntohs(*(u_short *)(pkt_data + 12)) != ETHERTYPE_IP) {
+ if( ntohs(*(u_short *)(pkt_data + 12)) != PTP_ETHER_TYPE) {
+ DBG("PCAP payload ethertype received not IP or PTP: 0x%04x\n",
ntohs(*(u_short *)(pkt_data + 12)));
- /* Retrieve source IP from the payload - 14 eth + 12 IP */
- netPath->lastRecvAddr = *(Integer32 *)(pkt_data + 26);
- /* Retrieve destination IP from the payload - 14 eth + 16 IP */
- netPath->lastDestAddr = *(Integer32 *)(pkt_data + 30);
+ }
+ } else {
+ /* Retrieve source IP from the payload - 14 eth + 12 IP */
+ netPath->lastSourceAddr = *(Integer32 *)(pkt_data + 26);
+ /* Retrieve destination IP from the payload - 14 eth + 16 IP */
+ netPath->lastDestAddr = *(Integer32 *)(pkt_data + 30);
+ }
+ /* do not report "from self" */
+ if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
- netPath->receivedPacketsTotal++;
+ }
+ netPath->receivedPacketsTotal++;
+
/* XXX Total cheat */
memcpy(buf, pkt_data + netPath->headerOffset,
pkt_header->caplen - netPath->headerOffset);
@@ -1597,11 +1620,18 @@
#endif
socklen_t from_addr_len = sizeof(from_addr);
+ netPath->lastSourceAddr = 0;
+
#ifdef PTPD_PCAP
if (netPath->pcapGeneral == NULL) {
#endif
ret=recvfrom(netPath->generalSock, buf, PACKET_SIZE, MSG_DONTWAIT, (struct sockaddr*)&from_addr, &from_addr_len);
- netPath->lastRecvAddr = from_addr.sin_addr.s_addr;
+ netPath->lastSourceAddr = from_addr.sin_addr.s_addr;
+ /* do not report "from self" */
+ if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
+ netPath->receivedPackets++;
+ }
+ netPath->receivedPacketsTotal++;
return ret;
#ifdef PTPD_PCAP
}
@@ -1622,14 +1652,25 @@
return 0;
}
/* Make sure this is IP (could dot1q get here?) */
- if( ntohs(*(u_short *)(pkt_data + 12)) != ETHERTYPE_IP)
- DBGV("PCAP payload received is not Ethernet: 0x%04x\n",
- ntohs(*(u_short *)(pkt_data + 12)));
- /* Retrieve source IP from the payload - 14 eth + 12 IP src*/
- netPath->lastRecvAddr = *(Integer32 *)(pkt_data + 26);
+ if( ntohs(*(u_short *)(pkt_data + 12)) != ETHERTYPE_IP) {
+ if( ntohs(*(u_short *)(pkt_data + 12)) != PTP_ETHER_TYPE) {
+ DBG("PCAP payload ethertype received not IP or PTP: 0x%04x\n",
+ ntohs(*(u_short *)(pkt_data + 12)));
+ }
+ } else {
+ /* Retrieve source IP from the payload - 14 eth + 12 IP */
+ netPath->lastSourceAddr = *(Integer32 *)(pkt_data + 26);
+ /* Retrieve destination IP from the payload - 14 eth + 16 IP */
+ netPath->lastDestAddr = *(Integer32 *)(pkt_data + 30);
+ }
+ /* do not report "from self" */
+ if(!netPath->lastSourceAddr || (netPath->lastSourceAddr != netPath->interfaceAddr.s_addr)) {
netPath->receivedPackets++;
- netPath->receivedPacketsTotal++;
+ }
+
+ netPath->receivedPacketsTotal++;
+
/* XXX Total cheat */
memcpy(buf, pkt_data + netPath->headerOffset,
pkt_header->caplen - netPath->headerOffset);
Modified: trunk/src/dep/ptpd_dep.h
===================================================================
--- trunk/src/dep/ptpd_dep.h 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/ptpd_dep.h 2015-06-12 14:26:02 UTC (rev 554)
@@ -469,7 +469,7 @@
int parseLeapFile(char * path, LeapSecondInfo *info);
void
-reset_operator_messages(const RunTimeOpts * rtOpts, PtpClock * ptpClock);
+resetWarnings(const RunTimeOpts * rtOpts, PtpClock * ptpClock);
void setupPIservo(PIservo* servo, const RunTimeOpts* rtOpts);
void resetPIservo(PIservo* servo);
Modified: trunk/src/dep/servo.c
===================================================================
--- trunk/src/dep/servo.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/servo.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -58,11 +58,11 @@
#endif
void
-reset_operator_messages(const RunTimeOpts * rtOpts, PtpClock * ptpClock)
+resetWarnings(const RunTimeOpts * rtOpts, PtpClock * ptpClock)
{
ptpClock->warned_operator_slow_slewing = 0;
ptpClock->warned_operator_fast_slewing = 0;
-
+ ptpClock->warnedUnicastCapacity = FALSE;
//ptpClock->seen_servo_stable_first_time = FALSE;
}
@@ -97,7 +97,7 @@
ptpClock->char_last_msg='I';
- reset_operator_messages(rtOpts, ptpClock);
+ resetWarnings(rtOpts, ptpClock);
/* For Hybrid mode */
ptpClock->masterAddr = 0;
Modified: trunk/src/dep/snmp.c
===================================================================
--- trunk/src/dep/snmp.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/snmp.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -518,9 +518,9 @@
return SNMP_INTEGER(0);
case PTPBASE_CLOCK_PORT_RUNNING_TX_MODE:
case PTPBASE_CLOCK_PORT_RUNNING_RX_MODE:
- if (snmpRtOpts->ip_mode == IPMODE_UNICAST)
+ if (snmpRtOpts->ipMode == IPMODE_UNICAST)
return SNMP_INTEGER(SNMP_PTP_TX_UNICAST);
- if (snmpRtOpts->ip_mode == IPMODE_HYBRID)
+ if (snmpRtOpts->ipMode == IPMODE_HYBRID)
return SNMP_INTEGER(SNMP_PTP_TX_MULTICAST_MIX);
return SNMP_INTEGER(SNMP_PTP_TX_MULTICAST);
case PTPBASE_CLOCK_PORT_RUNNING_PACKETS_RECEIVED:
Modified: trunk/src/dep/startup.c
===================================================================
--- trunk/src/dep/startup.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/startup.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -150,7 +150,7 @@
NOTIFY("SIGHUP received\n");
#ifdef RUNTIME_DEBUG
- if(rtOpts->transport == UDP_IPV4 && rtOpts->ip_mode != IPMODE_UNICAST) {
+ if(rtOpts->transport == UDP_IPV4 && rtOpts->ipMode != IPMODE_UNICAST) {
DBG("SIGHUP - running an ipv4 multicast based mode, re-sending IGMP joins\n");
netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
}
Modified: trunk/src/dep/sys.c
===================================================================
--- trunk/src/dep/sys.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/dep/sys.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -1182,7 +1182,7 @@
if(ptpClock->portState == PTP_MASTER) {
if(rtOpts->unicastNegotiation) {
fprintf(out,", slaves %d", ptpClock->slaveCount);
- } else {
+ } else if (rtOpts->ipMode == IPMODE_UNICAST) {
fprintf(out,", slaves %d", ptpClock->unicastDestinationCount);
}
}
Modified: trunk/src/protocol.c
===================================================================
--- trunk/src/protocol.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/protocol.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -209,7 +209,7 @@
timerStop(&ptpClock->timers[PDELAYREQ_INTERVAL_TIMER]);
timerStop(&ptpClock->timers[MASTER_NETREFRESH_TIMER]);
- if(rtOpts->unicastNegotiation && rtOpts->ip_mode==IPMODE_UNICAST) {
+ if(rtOpts->unicastNegotiation && rtOpts->ipMode==IPMODE_UNICAST) {
cancelAllGrants(ptpClock->unicastGrants, UNICAST_MAX_DESTINATIONS,
rtOpts, ptpClock);
if(ptpClock->delayMechanism == P2P) {
@@ -222,7 +222,7 @@
case PTP_SLAVE:
timerStop(&ptpClock->timers[ANNOUNCE_RECEIPT_TIMER]);
- if(rtOpts->unicastNegotiation && rtOpts->ip_mode==IPMODE_UNICAST && ptpClock->parentGrants != NULL) {
+ if(rtOpts->unicastNegotiation && rtOpts->ipMode==IPMODE_UNICAST && ptpClock->parentGrants != NULL) {
cancelUnicastTransmission(&ptpClock->parentGrants->grantData[SYNC], rtOpts, ptpClock);
cancelUnicastTransmission(&ptpClock->parentGrants->grantData[DELAY_RESP], rtOpts, ptpClock);
ptpClock->parentGrants = NULL;
@@ -323,7 +323,7 @@
case PTP_DISABLED:
/* well, theoretically we're still in the previous state, so we're not in breach of standard */
- if(rtOpts->unicastNegotiation && rtOpts->ip_mode==IPMODE_UNICAST) {
+ if(rtOpts->unicastNegotiation && rtOpts->ipMode==IPMODE_UNICAST) {
cancelAllGrants(ptpClock->unicastGrants, ptpClock->unicastDestinationCount,
rtOpts, ptpClock);
}
@@ -347,8 +347,8 @@
/* This is (re) started on clock updates only */
timerStop(&ptpClock->timers[CLOCK_UPDATE_TIMER]);
- /* if we're ignoring announces (telecom), go straight to master */
- if(rtOpts->ip_mode == IPMODE_UNICAST && ptpClock->clockQuality.clockClass <= 127 && rtOpts->disableBMCA) {
+ /* if we're ignoring announces (disable_bmca), go straight to master */
+ if(ptpClock->clockQuality.clockClass <= 127 && rtOpts->disableBMCA) {
DBG("unicast master only and ignoreAnnounce: going into MASTER state\n");
ptpClock->number_foreign_records = 0;
ptpClock->foreign_record_i = 0;
@@ -378,7 +378,7 @@
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) {
+ if (rtOpts->ipMode != IPMODE_UNICAST && rtOpts->do_IGMP_refresh && rtOpts->transport != IEEE_802_3) {
/* 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");
@@ -419,7 +419,7 @@
pow(2,ptpClock->logMinPdelayReqInterval));
if( rtOpts->do_IGMP_refresh &&
rtOpts->transport == UDP_IPV4 &&
- rtOpts->ip_mode != IPMODE_UNICAST &&
+ rtOpts->ipMode != IPMODE_UNICAST &&
rtOpts->masterRefreshInterval > 9 )
timerStart(&ptpClock->timers[MASTER_NETREFRESH_TIMER],
rtOpts->masterRefreshInterval);
@@ -669,7 +669,7 @@
ptpClock->counters.announceTimeouts++;
}
- if (rtOpts->ip_mode != IPMODE_UNICAST && rtOpts->do_IGMP_refresh && rtOpts->transport != IEEE_802_3) {
+ if (rtOpts->ipMode != IPMODE_UNICAST && rtOpts->do_IGMP_refresh && rtOpts->transport != IEEE_802_3) {
/* 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");
@@ -732,7 +732,7 @@
}
if (timerExpired(&ptpClock->timers[OPERATOR_MESSAGES_TIMER])) {
- reset_operator_messages(rtOpts, ptpClock);
+ resetWarnings(rtOpts, ptpClock);
}
if(ptpClock->portState==PTP_SLAVE && rtOpts->calibrationDelay && !ptpClock->isCalibrated) {
@@ -755,7 +755,7 @@
if(!rtOpts->unicastNegotiation ||
(ptpClock->parentGrants &&
ptpClock->parentGrants->grantData[DELAY_RESP].granted)) {
- issueDelayReq(rtOpts,ptpClock);
+ issueDelayReq(rtOpts,ptpClock);
}
}
} else if (ptpClock->delayMechanism == P2P) {
@@ -818,7 +818,7 @@
#ifndef PTPD_SLAVE_ONLY
case PTP_MASTER:
/*
- * handle SLAVE timers:
+ * handle MASTER timers:
* - Time to send new Announce(s)
* - Time to send new PathDelay
* - Time to send new Sync(s) (last order - so that follow-up always follows sync
@@ -909,7 +909,7 @@
if(rtOpts->do_IGMP_refresh &&
rtOpts->transport == UDP_IPV4 &&
- rtOpts->ip_mode != IPMODE_UNICAST &&
+ rtOpts->ipMode != IPMODE_UNICAST &&
rtOpts->masterRefreshInterval > 9 &&
timerExpired(&ptpClock->timers[MASTER_NETREFRESH_TIMER])) {
DBGV("Master state periodic IGMP refresh - next in %d seconds...\n",
@@ -932,7 +932,20 @@
issueSync(rtOpts, ptpClock);
}
+ if(!ptpClock->warnedUnicastCapacity) {
+ if(ptpClock->slaveCount >= UNICAST_MAX_DESTINATIONS ||
+ ptpClock->unicastDestinationCount >= UNICAST_MAX_DESTINATIONS) {
+ if(rtOpts->ipMode == IPMODE_UNICAST) {
+ WARNING("Maximum unicast slave capacity reached: %d\n",UNICAST_MAX_DESTINATIONS);
+ ptpClock->warnedUnicastCapacity = TRUE;
+ }
+ }
+ }
+ if (timerExpired(&ptpClock->timers[OPERATOR_MESSAGES_TIMER])) {
+ resetWarnings(rtOpts, ptpClock);
+ }
+
// TODO: why is handle() below expiretimer, while in slave is the opposite
handle(rtOpts, ptpClock);
@@ -1049,15 +1062,15 @@
msgUnpackHeader(ptpClock->msgIbuf, &ptpClock->msgTmpHeader);
/* packet is not from self, and is from a non-zero source address - check ACLs */
- if(ptpClock->netPath.lastRecvAddr &&
- (ptpClock->netPath.lastRecvAddr != ptpClock->netPath.interfaceAddr.s_addr)) {
+ if(ptpClock->netPath.lastSourceAddr &&
+ (ptpClock->netPath.lastSourceAddr != ptpClock->netPath.interfaceAddr.s_addr)) {
struct in_addr in;
- in.s_addr=ptpClock->netPath.lastRecvAddr;
+ in.s_addr=ptpClock->netPath.lastSourceAddr;
if(ptpClock->msgTmpHeader.messageType == MANAGEMENT) {
if(rtOpts->managementAclEnabled) {
if (!matchIpv4AccessList(
ptpClock->netPath.managementAcl,
- ntohl(ptpClock->netPath.lastRecvAddr))) {
+ ntohl(ptpClock->netPath.lastSourceAddr))) {
DBG("ACL dropped management message from %s\n", inet_ntoa(in));
ptpClock->counters.aclManagementDiscardedMessages++;
return;
@@ -1066,7 +1079,7 @@
}
} else if(rtOpts->timingAclEnabled) {
if(!matchIpv4AccessList(ptpClock->netPath.timingAcl,
- ntohl(ptpClock->netPath.lastRecvAddr))) {
+ ntohl(ptpClock->netPath.lastSourceAddr))) {
DBG("ACL dropped timing message from %s\n", inet_ntoa(in));
ptpClock->counters.aclTimingDiscardedMessages++;
return;
@@ -1116,8 +1129,8 @@
/* received a UNICAST message */
if((ptpClock->msgTmpHeader.flagField0 & PTP_UNICAST) == PTP_UNICAST) {
/* in multicast mode, accept only management unicast messages, in hybrid mode accept only unicast delay messages */
- if((rtOpts->ip_mode == IPMODE_MULTICAST && ptpClock->msgTmpHeader.messageType != MANAGEMENT) ||
- (rtOpts->ip_mode == IPMODE_HYBRID && ptpClock->msgTmpHeader.messageType != DELAY_REQ &&
+ if((rtOpts->ipMode == IPMODE_MULTICAST && ptpClock->msgTmpHeader.messageType != MANAGEMENT) ||
+ (rtOpts->ipMode == IPMODE_HYBRID && ptpClock->msgTmpHeader.messageType != DELAY_REQ &&
ptpClock->msgTmpHeader.messageType != DELAY_RESP)) {
DBG("ignord unicast message in multicast mode%d\n");
ptpClock->counters.discardedMessages++;
@@ -1126,7 +1139,7 @@
/* received a MULTICAST message */
} else {
/* in unicast mode, accept only management multicast messages */
- if(rtOpts->ip_mode == IPMODE_UNICAST && ptpClock->msgTmpHeader.messageType != MANAGEMENT) {
+ if(rtOpts->ipMode == IPMODE_UNICAST && ptpClock->msgTmpHeader.messageType != MANAGEMENT) {
DBG("ignord multicast message in unicast mode%d\n");
ptpClock->counters.discardedMessages++;
return;
@@ -1165,7 +1178,7 @@
break;
case SYNC:
handleSync(&ptpClock->msgTmpHeader,
- length, timeStamp, isFromSelf, ptpClock->netPath.lastRecvAddr, ptpClock->netPath.lastDestAddr, rtOpts, ptpClock);
+ length, timeStamp, isFromSelf, ptpClock->netPath.lastSourceAddr, ptpClock->netPath.lastDestAddr, rtOpts, ptpClock);
break;
case FOLLOW_UP:
handleFollowUp(&ptpClock->msgTmpHeader,
@@ -1173,11 +1186,11 @@
break;
case DELAY_REQ:
handleDelayReq(&ptpClock->msgTmpHeader,
- length, timeStamp, ptpClock->netPath.lastRecvAddr, isFromSelf, rtOpts, ptpClock);
+ length, timeStamp, ptpClock->netPath.lastSourceAddr, isFromSelf, rtOpts, ptpClock);
break;
case PDELAY_REQ:
handlePdelayReq(&ptpClock->msgTmpHeader,
- length, timeStamp, ptpClock->netPath.lastRecvAddr, isFromSelf, rtOpts, ptpClock);
+ length, timeStamp, ptpClock->netPath.lastSourceAddr, isFromSelf, rtOpts, ptpClock);
break;
case DELAY_RESP:
handleDelayResp(&ptpClock->msgTmpHeader,
@@ -1185,7 +1198,7 @@
break;
case PDELAY_RESP:
handlePdelayResp(&ptpClock->msgTmpHeader,
- timeStamp, length, isFromSelf, ptpClock->netPath.lastRecvAddr, ptpClock->netPath.lastDestAddr, rtOpts, ptpClock);
+ timeStamp, length, isFromSelf, ptpClock->netPath.lastSourceAddr, ptpClock->netPath.lastDestAddr, rtOpts, ptpClock);
break;
case PDELAY_RESP_FOLLOW_UP:
handlePdelayRespFollowUp(&ptpClock->msgTmpHeader,
@@ -1197,7 +1210,7 @@
break;
case SIGNALING:
handleSignaling(&ptpClock->msgTmpHeader, isFromSelf,
- ptpClock->netPath.lastRecvAddr, rtOpts, ptpClock);
+ ptpClock->netPath.lastSourceAddr, rtOpts, ptpClock);
break;
default:
DBG("handle: unrecognized message\n");
@@ -1323,13 +1336,13 @@
}
/* if we're ignoring announces (telecom) */
- if(rtOpts->ip_mode == IPMODE_UNICAST && ptpClock->clockQuality.clockClass <= 127 && rtOpts->disableBMCA) {
+ if(ptpClock->clockQuality.clockClass <= 127 && rtOpts->disableBMCA) {
DBG("unicast master only and disableBMCA: dropping Announce\n");
ptpClock->counters.discardedMessages++;
return;
}
- if(rtOpts->unicastNegotiation && rtOpts->ip_mode == IPMODE_UNICAST) {
+ if(rtOpts->unicastNegotiation && rtOpts->ipMode == IPMODE_UNICAST) {
nodeTable = findUnicastGrants(&header->sourcePortIdentity, 0,
ptpClock->unicastGrants, ptpClock->unicastDestinationCount,
@@ -1445,7 +1458,7 @@
// remember IP address of our master for hybrid mode
// todo: add this to bmc(), to cover the very first packet
- ptpClock->masterAddr = ptpClock->netPath.lastRecvAddr;
+ ptpClock->masterAddr = ptpClock->netPath.lastSourceAddr;
break;
@@ -1508,7 +1521,7 @@
/* update datasets (file bmc.c) */
s1(header,&ptpClock->msgTmp.announce,ptpClock, rtOpts);
- ptpClock->masterAddr = ptpClock->netPath.lastRecvAddr;
+ ptpClock->masterAddr = ptpClock->netPath.lastSourceAddr;
DBG("___ Announce: received Announce from current Master, so reset the Announce timer\n\n");
@@ -1860,7 +1873,7 @@
if (ptpClock->delayMechanism == E2E) {
- if(!isFromSelf && rtOpts->unicastNegotiation && rtOpts->ip_mode == IPMODE_UNICAST) {
+ if(!isFromSelf && rtOpts->unicastNegotiation && rtOpts->ipMode == IPMODE_UNICAST) {
nodeTable = findUnicastGrants(&header->sourcePortIdentity, 0,
ptpClock->unicastGrants, UNICAST_MAX_DESTINATIONS,
FALSE);
@@ -1934,7 +1947,7 @@
ptpClock->counters.delayReqMessagesReceived++;
// remember IP address of this client for hybrid mode
- ptpClock->LastSlaveAddr = ptpClock->netPath.lastRecvAddr;
+ ptpClock->LastSlaveAddr = ptpClock->netPath.lastSourceAddr;
issueDelayResp(tint,&ptpClock->delayReqHeader, sourceAddress,
rtOpts,ptpClock);
@@ -2134,7 +2147,7 @@
if (ptpClock->delayMechanism == P2P) {
- if(!isFromSelf && rtOpts->unicastNegotiation && rtOpts->ip_mode == IPMODE_UNICAST) {
+ if(!isFromSelf && rtOpts->unicastNegotiation && rtOpts->ipMode == IPMODE_UNICAST) {
nodeTable = findUnicastGrants(&header->sourcePortIdentity, 0,
ptpClock->unicastGrants, UNICAST_MAX_DESTINATIONS,
FALSE);
@@ -2790,7 +2803,7 @@
/* If the management message we received was unicast, we also reply with unicast */
if((header->flagField0 & PTP_UNICAST) == PTP_UNICAST)
- ptpClock->LastSlaveAddr = ptpClock->netPath.lastRecvAddr;
+ ptpClock->LastSlaveAddr = ptpClock->netPath.lastSourceAddr;
else ptpClock->LastSlaveAddr = 0;
/* send management message response or acknowledge */
@@ -2823,7 +2836,7 @@
Boolean okToSend = TRUE;
/* send Announce to Ethernet or multicast */
- if(rtOpts->transport == IEEE_802_3 || rtOpts->ip_mode == IPMODE_MULTICAST) {
+ if(rtOpts->transport == IEEE_802_3 || (rtOpts->ipMode != IPMODE_UNICAST)) {
issueAnnounceSingle(dst, &ptpClock->sentAnnounceSequenceId, rtOpts, ptpClock);
/* send Announce to unicast destination(s) */
} else {
@@ -2887,8 +2900,9 @@
Boolean okToSend = TRUE;
/* send Sync to Ethernet or multicast */
- if(rtOpts->transport == IEEE_802_3 || rtOpts->ip_mode == IPMODE_MULTICAST) {
+ if(rtOpts->transport == IEEE_802_3 || (rtOpts->ipMode != IPMODE_UNICAST)) {
issueSyncSingle(dst, &ptpClock->sentSyncSequenceId, rtOpts, ptpClock);
+
/* send Sync to unicast destination(s) */
} else {
/* send to granted only */
@@ -3038,7 +3052,7 @@
Integer32 dst = 0;
/* in hybrid mode or unicast mode, send delayReq to current master */
- if (rtOpts->ip_mode == IPMODE_HYBRID || rtOpts->ip_mode == IPMODE_UNICAST) {
+ if (rtOpts->ipMode == IPMODE_HYBRID || rtOpts->ipMode == IPMODE_UNICAST) {
dst = ptpClock->masterAddr;
}
@@ -3101,7 +3115,7 @@
}
fromInternalTime(&internalTime,&originTimestamp);
- if(rtOpts->ip_mode == IPMODE_UNICAST && ptpClock->unicastPeerDestination.transportAddress) {
+ if(rtOpts->ipMode == IPMODE_UNICAST && ptpClock->unicastPeerDestination.transportAddress) {
dst = ptpClock->unicastPeerDestination.transportAddress;
}
@@ -3146,7 +3160,7 @@
}
/* if request was unicast and we're running unicast, reply to source */
- if ( (rtOpts->ip_mode != IPMODE_MULTICAST) &&
+ if ( (rtOpts->ipMode != IPMODE_MULTICAST) &&
(header->flagField0 & PTP_UNICAST) == PTP_UNICAST) {
dst = sourceAddress;
}
@@ -3190,7 +3204,7 @@
Integer32 dst = 0;
/* if request was unicast and we're running unicast, reply to source */
- if ( (rtOpts->ip_mode != IPMODE_MULTICAST) &&
+ if ( (rtOpts->ipMode != IPMODE_MULTICAST) &&
(header->flagField0 & PTP_UNICAST) == PTP_UNICAST) {
dst = sourceAddress;
}
Modified: trunk/src/ptpd.h
===================================================================
--- trunk/src/ptpd.h 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/ptpd.h 2015-06-12 14:26:02 UTC (rev 554)
@@ -22,6 +22,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
+
#ifdef linux
# ifndef _GNU_SOURCE
# define _GNU_SOURCE
@@ -129,6 +130,17 @@
#include "constants.h"
#include "limits.h"
+/* Disable SO_TIMESTAMPING if configured to do so */
+#ifdef PTPD_DISABLE_SOTIMESTAMPING
+
+#ifdef SO_TIMESTAMPING
+
+#undef SO_TIMESTAMPING
+
+#endif /* SO_TIMESTAMPING */
+
+#endif /* PTPD_DISABLE_SOTIMESTAMPING */
+
#include "dep/ipv4_acl.h"
#include "dep/constants_dep.h"
Modified: trunk/src/signaling.c
===================================================================
--- trunk/src/signaling.c 2015-06-12 12:14:20 UTC (rev 553)
+++ trunk/src/signaling.c 2015-06-12 14:26:02 UTC (rev 554)
@@ -879,7 +879,7 @@
{
case TLV_REQUEST_UNICAST_TRANSMISSION:
DBGV("handleSignaling: Request Unicast Transmission\n");
- if(!rtOpts->unicastNegotiation || rtOpts->ip_mode!=IPMODE_UNICAST) {
+ if(!rtOpts->unicastNegotiation || rtOpts->ipMode!=IPMODE_UNICAST) {
DBGV("handleSignaling: Ignoring unicast negotiation message - not running unicast or negotiation not enabled\n");
ptpClock->counters.discardedMessages++;
goto end;
@@ -901,7 +901,7 @@
break;
case TLV_CANCEL_UNICAST_TRANSMISSION:
DBGV("handleSignaling: Cancel Unicast Transmission\n");
- if(!rtOpts->unicastNegotiation || rtOpts->ip_mode!=IPMODE_UNICAST) {
+ if(!rtOpts->unicastNegotiation || rtOpts->ipMode!=IPMODE_UNICAST) {
DBGV("handleSignaling: Ignoring unicast negotiation message - not running unicast or negotiation not enabled\n");
ptpClock->counters.discardedMessages++;
goto end;
@@ -922,7 +922,7 @@
break;
case TLV_ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION:
DBGV("handleSignaling: Acknowledge Cancel Unicast Transmission\n");
- if(!rtOpts->unicastNegotiation || rtOpts->ip_mode!=IPMODE_UNICAST) {
+ if(!rtOpts->unicastNegotiation || rtOpts->ipMode!=IPMODE_UNICAST) {
DBGV("handleSignaling: Ignoring unicast negotiation message - not running unicast or negotiation not enabled\n");
ptpClock->counters.discardedMessages++;
goto end;
@@ -940,7 +940,7 @@
break;
case TLV_GRANT_UNICAST_TRANSMISSION:
DBGV("handleSignaling: Grant Unicast Transmission\n");
- if(!rtOpts->unicastNegotiation || rtOpts->ip_mode!=IPMODE_UNICAST) {
+ if(!rtOpts->unicastNegotiation || rtOpts->ipMode!=IPMODE_UNICAST) {
DBGV("handleSignaling: Ignoring unicast negotiation message - not running unicast or negotiation not enabled\n");
ptpClock->counters.discardedMessages++;
goto end;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|