If more than one local UDS client subscribes to push notifications,
only the last one receives data from the ptp4l service. This happens
because ptp4l uses the PortIdentity as a unique key to track client
subscriptions. As a result, it is not possible for both phc2sys and
pmc to receive push notifications at the same time, for example.
This patch sets the PortIdentity.portNumber attribute of UDS clients
to the local process ID, making each such client subscription unique.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Allow interactive input like
set SUBSCRIBE_EVENTS_NP duration 60 NOTIFY_PORT_STATE on
to request push notifications from the ptp4l service.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The header file, pmc_common.h, makes some private macros public. The
intent was to use those macros in SNMP code, but that development never
materialized into production code. This patch removes the private macros
from public view.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The clock layer indeed replies to management GET actions for this item,
but it sends an empty management message by mistake. This patch fixes the
issue by replying with a payload of the correct length.
While we are at it, correct overly zealous line breaking according to our
coding style.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Currently there is a method to convert a timespec into a tmv_t, but
not the other way round. This patch adds the missing function in
anticipation of a new feature that will need this conversion.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In anticipation of support for external time stamping in PHC devices, this
patch adds wrapper functions around the pin functionality.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Upcoming functionality will need to configure the input and output pins of
PHC devices. However, this requires fairly recent kernel support. This
patch adds the needed definitions for compiling with older kernel headers.
In addition, kernel v5.4 introduced a second set of ioctls for the
ancillary PTP Hardware Clock functionality. The original ioctls
failed to enforce the various flags and reversed fields, but the
second version has fixed the issues. Going forward, our user space
PTP stack ought to use the newer ioctls (if available) from day one.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The one user of the function, posix_clock_open(), simply open codes
the closing call to phc_close(). This patch provides a method to
balance closing and opening of a posix clock. In addition, the
phc_ctl program never explicitly closed the opened clock, and so this
patch adds the missing call.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Unfortunately the SNMP code still has issues like not passing the
valgrind test, and no one is able to finish this up right now. This
patch removes the SNMP program so that the upcoming release does not
contain unfinished work, potentially misleading end users about the
scope and completeness of the features.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
When updating and potentially removing event subscribers, the code uses
the simple list traversal macro. As a result, the list will become
corrupted whenever a subscriber is removed. This patch fixes the issue
by using the appropriate macro.
Fixes: 5104e3e56b ("Event subscribing")
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reported-by: Michael Walle <michael@walle.cc>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
This novel use of the STA_UNSYNC flag breaks with the established,
traditional meaning of that flag, which is:
The clock has is believed to have an error larger than 16 seconds.
This reverts commit 944f5f7ac6.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In case there is no connection to the server, notify the kernel
that the clock is currently unsynchronized.
Signed-off-by: Ville Heikkinen <ville.heikkinen@nokia.com>
Now that all call sites have been converted to interface_create(), there
is no longer any needed for a way to set the interface's name. This patch
removes the useless method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
When compiling with gcc8 and -O2, the clever compiler complains:
interface.c: In function ‘interface_ensure_tslabel’:
interface.c:38:3: error: ‘strncpy’ output may be truncated copying 108 bytes from a string of length 108 [-Werror=stringop-truncation]
Even though this is a false positive, this patch silences the warning
by using memcpy instead of strncpy.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Now that a complete functional API is in place, there is no need to expose
the inner workings of the network interface data type. This patch converts
it into an opaque type while leaving the list marker visible to users
through a simple form of "friendly exposition".
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In order to eventually hide the implementation details of the interface,
users will need to be able to create and destroy instances thereof. This
patch adds the needed methods.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The ts_label field of the interface is set in different ways by different
callers. In order to prevent users from open coding the logic that sets
the label, this patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The name field of the interface is set in different ways by different
callers. In order to prevent users from open coding the logic that sets
the name, this patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
In many cases, the time stamping label will be the same as the name of
the interface. In order to prevent users from open coding the logic that
initializes the label from the interface name, this patch add an
appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
In order to prevent users from open coding this logic, this patch
provides a method that populates the time stamping information from
the interface label.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Many of the users only require a read only reference to the time
stamping label of the interface. This patch adds an appropriate
method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Many of the users only require a read only reference to the interface name.
This patch adds an appropriate method.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Up until now, the users of the interface data structure simply access
its fields without restriction. This patch takes the first step
towards abstracting this data structure by giving it a file of its
very own.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The function to open a posix clock never modifies the passed in
string. This patch adds the const keyword to ensure this function
stays that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Three of the rtnl methods never modify the strings passed in. This
patch adds the const keyword to ensure these functions stay that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
The two methods, config_create_interface and config_read, never modify the
strings passed in. This patch adds the const keyword to ensure these
functions stay that way.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Any program that links to the servo interface must also link with the
implementations of that interface. Similarly, the filter and network
transport interfaces each require their implementations. This patch
re-factors the makefile to reflect this fact in order to simplify
adding new programs making use of these interfaces.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
This fixes an issue with free running clocks. When the master clock id
changes the measured master/local ratio should be reset. If it isn't,
and the local clock becomes master, then the last measured ratio to
the old master continues to be used in peer delay calculations. If a
bad master/local ration calculation triggers this state change the
port can get "stuck" in not "asCapable" mode.
Signed-off-by: Erik Hons <erik.hons@ni.com>
Don't require each port to have its own master table specified in the
config. Instead of ports claming configured tables, clone the table in
each port, so different ports don't interfere with each other.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
A single, external PTP Hardware Clock device may be wired to one or more
MAC devices, providing the MACs with an input clock. This patch adds
support for such a hardware architecture by letting the command line PHC
override the one discovered via the ethtool ioctl.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
The sysoff_measure() function gained an additional parameter some time
ago, but the legacy method for older kernels without PTP_SYS_OFFSET was
overlooked. This patch brings the legacy method up to date again.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
In port_synchronize(), when the clock returned SERVO_UNLOCKED and
port_dispatch() triggered a switch of the PHC, the variable "s" would
point to a servo which was already freed and the following call of
servo_offset_threshold() would read invalid memory.
Don't save the servo before dispatching the port.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Fixes: 3f5f5653d7 ("port: Add interval update mechanism.")