[Linuxptp-devel] [PATCH v1] lstab: Update leapfile validity

2023-04-30 Thread Harlan Stenn

On 4/29/2023 4:45 PM, Richard Cochran wrote:

On Thu, Apr 27, 2023 at 09:58:13AM +0200, Maciek Machnikowski wrote:

No leap seconds will happen till the end of 2023.


(Only twelve more years of this BS to endure.  ;^)


A close link between UT0 and UT1 is considered to to be a feature by some.

I, for one, would rather see LSEM (leap second every month) than 
abolishing leap seconds.


If folks want contiguous monotonic time, they can use TAI instead of UTC.

My opinion, of course.


Update leapfile
validity accordingly.

Signed-off-by: Maciek Machnikowski 


Applied.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

---

This is the LinuxPTP Developer mailing list.
https://lists.nwtime.org/list/linuxptp-devel





--
Harlan Stenn 
http://networktimefoundation.org - be a member!


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH] Clear pending errors on sockets.

2023-04-30 Thread Richard Cochran
On Wed, Apr 26, 2023 at 02:44:27PM +0200, Miroslav Lichvar wrote:
> When the netlink socket of a port (used for receiving link up/down
> events) had an error (e.g. ENOBUFS due to the kernel sending too many
> messages), ptp4l switched the port to the faulty state, but it kept
> getting POLLERR on the socket and logged "port 1: unexpected socket
> error" in an infinite loop.
> 
> Unlike the PTP event and general sockets, the netlink sockets cannot be
> closed in the faulty state as they are needed to receive the link up event.
> 
> Instead, receive and clear the error on all descriptors getting POLLERR
> with getsockopt(SO_ERROR).

Never seen that before.  Learn something new every day...

> Include the error in the log message together
> with the descriptor index to make it easier to debug issues like this in
> future.
> 
> Signed-off-by: Miroslav Lichvar 

Applied.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] Bug caused by commit afeabf3 "ptp4l: add VLAN over bond support" on kernel 4.9

2023-04-30 Thread Richard Cochran
On Thu, Mar 30, 2023 at 11:16:44AM +0800, Hangbin Liu wrote:
> Richard, what do you think?

This code in hwts_init is wrong:

cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;
/* Fall back without flag if user run new build on old kernel */
if (ioctl(fd, SIOCGHWTSTAMP, ) == -EINVAL)
init_ifreq(, , device);

As `man ioctl` says:

 RETURN VALUE
   Usually, on success zero is returned.  A few ioctl() requests  use  the
   return  value  as an output parameter and return a nonnegative value on
   success.  On error, -1 is returned, and errno is set appropriately.

So I think what you meant to write is this:

cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;
err = ioctl(fd, SIOCGHWTSTAMP, );
if (err < 0) {
/* Fall back without flag if user run new build on old kernel */
if (errno == EINVAL) {
init_ifreq(, , device);
} else {
pr_err("ioctl SIOCGHWTSTAMP failed: %m");
return err;
}
}

@Martin would that also fix your issue?

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH] Fix power profile config option range to UINT32_MAX

2023-04-30 Thread Richard Cochran
On Mon, Apr 24, 2023 at 12:21:57PM -0700, Jacob Keller wrote:
> The power profile configuration options added in commit 7059a05a3fb2
> ("Introduce the power profile.") specify their maximum range as INT_MAX.
> The values are stored as UInteger32 values and the default value is
> 0x. On most platforms, a signed integer cannot hold 0x, and
> on these platforms ptp4l is unable to read the default configuration file:
> 
>   $ ./ptp4l -f configs/default.cfg -i eno0
>   0x is an out of range value for option 
> power_profile.2011.grandmasterTimeInaccuracy at line 44
>   failed to parse configuration file configs/default.cfg

Jacob,

Thanks for finding this.  I'd like to fix it in a simpler way.
Do you agree?

Thanks,
Richard

---
>From 5cfba921f9bf1f97028c5f999c399e9bb554cfd7 Mon Sep 17 00:00:00 2001
From: Richard Cochran 
Date: Sun, 30 Apr 2023 13:32:06 -0700
Subject: [PATCH] power profile: Fix regression in the default configuration
 file.

The recently added power profile introduced a regression when reading
the default configuration file:

  $ ./ptp4l -f configs/default.cfg -m -q
  0x is an out of range value for option 
power_profile.2011.grandmasterTimeInaccuracy at line 44
  failed to parse configuration file configs/default.cfg

Root cause is the fact that the value 0x exceeds the range of
the signed, four byte integer used in the configuration logic.

Considering that the power profile's "Inaccuracy" field uses
0x as a special value meaning "unknown", expand the range
of these options to include -1 as that special value.

Fixes: 7059a05a3fb2182e851217c8872cf47126ec4c4c ("Introduce the power profile.")
Reported-by: Jacob Keller 
Signed-off-by: Richard Cochran 
---
 config.c| 6 +++---
 configs/default.cfg | 6 +++---
 ptp4l.8 | 7 +++
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/config.c b/config.c
index cb4421f..b104f1b 100644
--- a/config.c
+++ b/config.c
@@ -309,9 +309,9 @@ struct config_item config_tab[] = {
GLOB_ITEM_DBL("pi_proportional_norm_max", 0.7, DBL_MIN, 1.0),
GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
PORT_ITEM_ENU("power_profile.version", IEEE_C37_238_VERSION_NONE, 
ieee_c37_238_enu),
-   PORT_ITEM_INT("power_profile.2011.grandmasterTimeInaccuracy", 
0x, 0, INT_MAX),
-   PORT_ITEM_INT("power_profile.2011.networkTimeInaccuracy", 0, 0, 
INT_MAX),
-   PORT_ITEM_INT("power_profile.2017.totalTimeInaccuracy", 0x, 0, 
INT_MAX),
+   PORT_ITEM_INT("power_profile.2011.grandmasterTimeInaccuracy", 
0x, -1, INT_MAX),
+   PORT_ITEM_INT("power_profile.2011.networkTimeInaccuracy", 0x, 
-1, INT_MAX),
+   PORT_ITEM_INT("power_profile.2017.totalTimeInaccuracy", 0x, -1, 
INT_MAX),
PORT_ITEM_INT("power_profile.grandmasterID", 0, 0, 0x),
GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX),
GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX),
diff --git a/configs/default.cfg b/configs/default.cfg
index a21ec66..00429b9 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -41,9 +41,9 @@ BMCAptp
 inhibit_announce0
 inhibit_delay_req   0
 ignore_source_id0
-power_profile.2011.grandmasterTimeInaccuracy   0x
-power_profile.2011.networkTimeInaccuracy   0
-power_profile.2017.totalTimeInaccuracy 0x
+power_profile.2011.grandmasterTimeInaccuracy   -1
+power_profile.2011.networkTimeInaccuracy   -1
+power_profile.2017.totalTimeInaccuracy -1
 power_profile.grandmasterID0
 power_profile.version  none
 #
diff --git a/ptp4l.8 b/ptp4l.8
index bb678c9..09ff108 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -365,22 +365,21 @@ the interface, or the device specified by the \fB-p\fP 
option.
 Specifies the time inaccuracy of the GM in nanoseconds.  Relevant only
 when power_profile.version is 2011.  This value may be changed
 dynamically using the POWER_PROFILE_SETTINGS_NP management message.
-The default is 0x.
+The default is -1 meaning unknown inaccuracy.
 
 .TP
 .B power_profile.2011.networkTimeInaccuracy
 Specifies the time inaccuracy of the network in nanoseconds.  Relevant
 only when power_profile.version is 2011.  This value may be changed
 dynamically using the POWER_PROFILE_SETTINGS_NP management message.
-The default is 0x.
+The default is -1 meaning unknown inaccuracy.
 
 .TP
 .B power_profile.2017.totalTimeInaccuracy
 Specifies the sum of the GM, network, and local node inaccuracies in
 nanoseconds.  Relevant only when power_profile.version is 2017.  This
 value may be changed dynamically using the POWER_PROFILE_SETTINGS_NP
-management message.  The default is 0x meaning unknown
-inaccuracy.
+management message.  The default is -1 meaning unknown inaccuracy.
 
 .TP
 .B power_profile.grandmasterID
-- 
2.30.2



___

Re: [Linuxptp-devel] bugs when reading ptp4l configuration files

2023-04-30 Thread Richard Cochran
On Wed, Mar 29, 2023 at 11:30:49AM -0700, Jacob Keller wrote:

> This appears to be caused by using a base of 0 to strtol which then
> interprets leading 0 numbers as octal. This is probably done in order to
> get handling of '0x' prefixed numbers as well, but the leading 0 ->
> octal interpretation is much less common.

Actually this convention is widely used.  After all, strtol is part of
the standard C library and has been forever:

 strtol(): POSIX.1-2001, POSIX.1-2008, C89, C99 SVr4, 4.3BSD.

> The manual page does use several '0x' prefixed values but does not seem
> to call out octal values or the implicit conversions.

Yeah, could be easily added into the doc...

Thanks,
Richard




___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH] Use lock file to check if uds_address in use

2023-04-30 Thread Richard Cochran
On Tue, Feb 28, 2023 at 01:47:03AM +0100, Andrew Zaborowski wrote:
> Use a lock file to be able to log an error when the UDS socket's path is
> in use by another instance, avoid silently unlink()ing it.
> 
> There's no way for multiple instances (e.g. in a multi-domain setup) to
> bind() to the same address, there's nothing like SO_REUSEADDR for unix
> sockets.  Just unlinking the socket makes for a behaviour that's
> initially confusing to the user, and creates a race condition where
> one instane's bind() call can happen between another instane's unlink()
> and bind() causing the latter to fail.  Resort to logging an error when
> uds_{,ro_}address is in use.

I think this adds unneeded complexity to the code base for little
benefit.  The issues you describe can be avoided by writing correct
start up scripts.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v2] ntpshm: Invalidate SHM data before releasing the servo

2023-04-30 Thread Richard Cochran
On Thu, Mar 16, 2023 at 03:47:47PM +0100, Maciek Machnikowski wrote:
> The SHM is not cleared upon servo release when exiting the tool. This
> leaves the last update in the shared memory region marked as valid.
> 
> Users may not expect such behavior. If the configuration changed, or the
> tool was restarted to reset the state after an unexpected clock step
> (e.g. after system suspend), an incorrec timestamp might be accepted by
> the consumer
> 
> To prevent such behavior - invalidate the SHM data when releasing
> the SHM servo.
> 
> v2: Fix commit message
> 
> Signed-off-by: Maciek Machnikowski 

Applied.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 1/1] msg: append TLV onto all PTP event messages

2023-04-30 Thread Richard Cochran
On Wed, Mar 01, 2023 at 01:04:34PM +0800, Tan Tee Min wrote:
> According to IEEE Std 1588-2019 Chapter 6.4 PTP message classes,
> all PTP messages can be extended by means of a standard
> Type, Length, Value (TLV) extension mechanism.

Since the present code does not append any TLVs on such message types,
this change is not needed.  The patch will become relevant if/when the
use case is implemented, not before.

Thanks,
Richard




___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel