The current port code is very defensive. As the code now stands, we throw
a fault whenever we cannot send or receive a packet. Even a downed link
on an interface will cause a port fault.
This commit adds a very simple minded way of clearing the faults. We just
try to enable the port again after waiting a bit.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This commit makes each pair of port functions, open/close and
initialize/disable, balance each other in how they allocate or free
resources. This change lays some ground work to allow proper fault
handling and disable/enable logic later on.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
It was a cute idea to have the raw Ethernet layer use just one socket,
but it ended up not working on some specific PTP time stamping hardware.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
This change will make it easier to extend the configuration file contents
to include arbitrary new data structures.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In some error cases, no message is logged. Now we always complain loudly
when an error occurs.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In the course of development we added more and more allocations into the
port code without freeing them on close. We do not yet call the close
function, so there was never an issue. Once we start to reset the ports,
to clear faults for example, then we will need this.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Although the UDP/IPv4 layer does not need any state per instance (other
than the two file descriptors), the raw Ethernet layer will need this.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
When we create a discontinuity in the clock time, we must avoid mixing
local time stamps from before and after the jump.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
We always wait for the transmit time stamp after sending an event message.
Thus a missing time stamp is clearly a fault, even if the hardware can
only handle one time stamp at a time.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
If the networking stack fails to provide a transmit time stamp, then we
might feed uninitialized stack data to the CMSG(3) macros. This can result
in a segfault or other badness.
The fix is to simply clear the control buffer in advance.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Commit 32133050 introduced a bug that gives a bogus error message on
every 'general' (non-event) PTP packet. If we want to catch missing
time stamps, then it has to occur at the port level.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The state machine needs to know whether a new master has just been
selected in order to choose between the slave and uncalibrated states.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>