The default initial value for logAnnounceInterval should be 0 (once per second).
See chapter 10.6.2.2 of IEEE 802.1AS standard.
Signed-off-by: Christoph Seifert <christoph.seifert@posteo.me>
These functions are just wrappers. Make it possible for the compiler to
optimize the calls when compiled with optimization.
Signed-off-by: Michael Walle <michael@walle.cc>
The field is redundant with the length tlv_list. Replace it with a
function msg_tlv_count() instead. This iterates over the tlv_list. The
computational overhead should be small, because the lists are very short
and the tlv_count is only used in management paths (yet).
Signed-off-by: Michael Walle <michael@walle.cc>
Since commit 7fe69e7ba0 management
messages are dropped in some cases because the tlv_count isn't 1.
Further analysis shows that this is the case when the message is
forwarded in clock_forward_mgmt_msg(). This is because msg_post_recv()
will append TLVs and - in the forwarding case - there is already one TLV
in the list, which results in tlv_count being 2 and thus dropped in
subsequent code.
msg_post_recv() is intended to be the cleanup code for msg_pre_send()
which is called earlier. Therefore, make msg_post_recv() and
msg_pre_send() symmetrical and cleanup the tlv_list and tlv_count.
Signed-off-by: Michael Walle <michael@walle.cc>
TRUE and FALSE is also defined in net-snmp library. Without this check,
compilation and includes must be made in a certain order.
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
This patch adds new code that handles unicast service contracts,
sending messages according the negotiated schedule.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
There are two aspects. First, on the receive path, we reply to
unicast peer delay requests in kind. That is, if the peer sends a
unicast delay request, then reply with unicast, too, since this is
obviously what the peer expects.
Second, if configured, we transmit peer delay requests to the
specified unicast peer address.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds new code that runs the state machine and handles the
TLVs for requesting unicast service from a remote master.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In order to implement client side unicast negotiation, state is needed
per port and master. This patch adds the needed state machines.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds configuration file support for a table of unicast
masters. Each table lives in its own section and has a unique,
positive numerical ID. Entries in the table are a pair of transport
type and protocol address.
Each port may specify a table id to be used for unicast negotiation.
Tables may not be shared between ports, but nothing prevents table
entries from appearing in more than table.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
All of the callers of transport_peer() use hard coded magic numbers.
This patch fixes them to use the corresponding enumerated values instead.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Consistenly use the pid_eq() and cid_eq() helper functions. Move the
functions into utils.h (making them inline functions) because they are
used in multiple source files.
Signed-off-by: Michael Walle <michael@walle.cc>
If ptp4l is running as a boundary clock, and multiple master ports
share a hardware clock that is different than the slave port's
hardware clock, then phc2sys in autocfg mode will synchronize that
clock multiple times per sync loop, once per-port.
Example output when this happens:
CLOCK_REALTIME phc offset -9 s2 freq -355 delay 3635
eth9 phc offset 9 s2 freq +1762 delay 7488
eth8 phc offset 41 s2 freq +1985 delay 7424
eth7 phc offset 15 s2 freq +1952 delay 7440
eth6 phc offset 20 s2 freq +1059 delay 7440
eth1 phc offset 22 s2 freq +1783 delay 7424
eth12.400 phc offset 15 s2 freq -4207943 delay 7551
eth12.300 phc offset 388 s2 freq +2336645 delay 7536
eth12.200 phc offset 451 s2 freq +2516553 delay 7438
eth12.100 phc offset 268 s2 freq +64274 delay 7405
This is easily reproducible by adding VLANs to a single network
interface and configuring ptp4l to use those VLAN interfaces as PTP
ports.
This patch prevents this problem by introducing a new deduplicated
destination clock list to phc2sys. Each time phc2sys reconfigures,
the destination clock list is re-populated. In the synchronization
loop, phc2sys will only use the clocks in this list.
Example output of reconfiguration with this patch:
reconfiguring after port state change
selecting eth9 for synchronization
selecting eth8 for synchronization
selecting eth7 for synchronization
selecting eth6 for synchronization
selecting eth1 for synchronization
selecting eth13.400 for synchronization
skipping eth13.300: eth13.400 has the same clock and is already selected
skipping eth13.200: eth13.400 has the same clock and is already selected
skipping eth13.100: eth13.400 has the same clock and is already selected
selecting eth12.400 for synchronization
skipping eth12.300: eth12.400 has the same clock and is already selected
skipping eth12.200: eth12.400 has the same clock and is already selected
skipping eth12.100: eth12.400 has the same clock and is already selected
skipping eth13.500: eth13.400 has the same clock and is already selected
This patch was tested with autocfg mode and also when specifying source
and destination manually via commandline.
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
ptp4l runs clockcheck on an incoming PTP message before checking its
domain number. If the time on another domain is different, then
clockcheck will trigger spurious synchronization faults.
This patch reorders the logic so that clockcheck only runs on messages
in the same time domain.
Reported-By: Filip Perich <perich@google.com>
Signed-off-by: Cliff Spradlin <cspradlin@google.com>
With increasing unicast support, the code needs to identify unicast
messages more often. This patch replaces the open coded bit field
tests with a more readable in line helper function call.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
According to the standard, unicast Sync messages are to be sent with
the interval field set to 127. This patch adds a test to avoid
incorrectly adopting that value as a new interval.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Richard Hill reported an occasional NULL pointer deference in
port_delay_request() when in hybrid mode.
if (p->hybrid_e2e) {
struct ptp_message *dst = TAILQ_FIRST(&p->best->messages);
msg->address = dst->address;
...
}
The code assumes that the p->best->messages list can't be empty
because:
The function, port_delay_request(), is called only when
FD_DELAY_TIMER expires. That timer is only set by the function,
port_set_delay_tmo(), which is called:
1. from process_delay_resp(), but only when state is UNCALIBRATED
or SLAVE.
2. from port_e2e_transition(), but only when state is UNCALIBRATED
or SLAVE.
Looking at handle_state_decision_event(), a port can only enter
UNCALIBRATED or SLAVE when it has a valid foreign master record,
ie p->best->messages is not null.
A port also only clears p->best->messages when it leaves
UNCALIBRATED or SLAVE, at which point the FD_DELAY_TIMER is also
cleared.
*However* the p->best->messages list *can* be empty if the
FD_ANNOUNCE_TIMER and the FD_DELAY_TIMER expire at the same time. In
this case, the poll() call indicates events on both file descriptors.
The announce timeout is handled like this:
case FD_ANNOUNCE_TIMER:
case FD_SYNC_RX_TIMER:
if (p->best)
fc_clear(p->best);
So then the port_delay_request() call de-references the null
TAILQ_FIRST message pointer.
This patch fixes the issue by re-ordering the timer file descriptors
within the polling list.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Richard Hill <plonta@gmx.de>
Clearly indicate the value is the maximum offset for which clock skewing
will be used at the start. An offset of a lower value will be fixed by
frequency changes only, while a larger value will be fixed with an
initial clock jump. This matches similar wording found in the -S option
explanation.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
According to 1588, PTP message loops are simply someone else's problem
with respect to transparent clocks. Since we are running the BMCA for
syntonization anyway, we might as well go ahead and implement the spanning
tree for PTP messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This patch adds a new configuation option that enables transparent
clock mode. When TC mode is specified, the configured delay mechanism
must also match. The legacy behavior of upgrading a multi-port clock
from OC to BC is preserved.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>