import CS linuxptp-3.1.1-9.el9

This commit is contained in:
eabdullin 2023-09-21 19:21:58 +00:00
parent 8cfb44fe79
commit 3c782d7309
4 changed files with 181 additions and 1 deletions

View File

@ -0,0 +1,52 @@
commit 134dc3c4655fcd9f314a5e56cd50db2f87366f5a
Author: davidjm via Linuxptp-devel <linuxptp-devel@lists.sourceforge.net>
Date: Wed Nov 23 15:50:30 2022 -0800
Don't re-arm fault clearing timer on unrelated netlink events
Set the timer only when an event causes the port to transition to the
FAULTY state, rather than potentially re-arming the timeout when an
event occurs while the port was already FAULTY.
Concretely this occurs when a port is in fault, perhaps due to a
single time out while polling for tx-timestamp. If any other port in the
system (including unrelated ones ptp4l does not even know about) cause
netlink messages to be sent. As it stands, clock_poll() will note that
the port is in fault (from before, not due to the current event) and
reset the timeout to its original value.
If such unrelated netlink messages arrive at a regular enough cadence
the timeout may be repeatedly reset, not trigger on time (if at all) and
the port may not get a chance to clear its fault, perhaps indefinitely.
Signed-off-by: David Mirabito <davidjm@arista.com>
diff --git a/clock.c b/clock.c
index eea7983..451473e 100644
--- a/clock.c
+++ b/clock.c
@@ -1586,6 +1586,7 @@ void clock_set_sde(struct clock *c, int sde)
int clock_poll(struct clock *c)
{
int cnt, i;
+ enum port_state prior_state;
enum fsm_event event;
struct pollfd *cur;
struct port *p;
@@ -1609,6 +1610,7 @@ int clock_poll(struct clock *c)
/* Let the ports handle their events. */
for (i = 0; i < N_POLLFD; i++) {
if (cur[i].revents & (POLLIN|POLLPRI|POLLERR)) {
+ prior_state = port_state(p);
if (cur[i].revents & POLLERR) {
pr_err("port %d: unexpected socket error",
port_number(p));
@@ -1624,7 +1626,7 @@ int clock_poll(struct clock *c)
}
port_dispatch(p, event, 0);
/* Clear any fault after a little while. */
- if (PS_FAULTY == port_state(p)) {
+ if ((PS_FAULTY == port_state(p)) && (prior_state != PS_FAULTY)) {
clock_fault_timeout(p, 1);
break;
}

View File

@ -0,0 +1,84 @@
commit 2db8da6d1e3db074c01516c74899d42089039bc8
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed Apr 26 13:45:41 2023 +0200
Clear pending errors on sockets.
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). Include the error in the log message together
with the descriptor index to make it easier to debug issues like this in
future.
(Rebased to 3.1.1)
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
diff --git a/clock.c b/clock.c
index 469aab6..2821fc4 100644
--- a/clock.c
+++ b/clock.c
@@ -1611,8 +1611,10 @@ int clock_poll(struct clock *c)
if (cur[i].revents & (POLLIN|POLLPRI|POLLERR)) {
prior_state = port_state(p);
if (cur[i].revents & POLLERR) {
- pr_err("port %d: unexpected socket error",
- port_number(p));
+ int error = sk_get_error(cur[i].fd);
+ pr_err("port %d: error on fda[%d]: %s",
+ port_number(p), i,
+ strerror(error));
event = EV_FAULT_DETECTED;
} else {
event = port_event(p, i);
diff --git a/sk.c b/sk.c
index 3595649..47d8c3b 100644
--- a/sk.c
+++ b/sk.c
@@ -413,6 +413,20 @@ int sk_receive(int fd, void *buf, int buflen,
return cnt < 0 ? -errno : cnt;
}
+int sk_get_error(int fd)
+{
+ socklen_t len;
+ int error;
+
+ len = sizeof (error);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
+ pr_err("getsockopt SO_ERROR failed: %m");
+ return -1;
+ }
+
+ return error;
+}
+
int sk_set_priority(int fd, int family, uint8_t dscp)
{
int level, optname, tos;
diff --git a/sk.h b/sk.h
index 04d26ee..ba88e2f 100644
--- a/sk.h
+++ b/sk.h
@@ -109,6 +109,13 @@ int sk_interface_addr(const char *name, int family, struct address *addr);
int sk_receive(int fd, void *buf, int buflen,
struct address *addr, struct hw_timestamp *hwts, int flags);
+/**
+ * Get and clear a pending socket error.
+ * @param fd An open socket.
+ * @return The error.
+ */
+int sk_get_error(int fd);
+
/**
* Set DSCP value for socket.
* @param fd An open socket.

View File

@ -420,3 +420,32 @@ index ae9c4d3..96e097a 100644
/* /*
* A port going down can affect the BMCA result. * A port going down can affect the BMCA result.
commit 8cf63218e4cc33d63bb783bf322d4a0d2f4be73e
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Wed Mar 15 11:24:16 2023 +0100
port: Don't switch to PHC with SW timestamping.
When ptp4l was configured to use SW timestamping, but the interface
supported also HW timestamping, ptp4l detected a change of the PHC on
start, switched to it from the system clock, and tried to control the
PHC using SW timestamps.
Don't switch the PHC if the current PHC index is -1, which is expected
with SW timestamping and in the free-running mode.
Fixes: afeabf3c90ed ("ptp4l: add VLAN over bond support")
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
diff --git a/port.c b/port.c
index 96e097a..32ee83b 100644
--- a/port.c
+++ b/port.c
@@ -2570,6 +2570,7 @@ static void port_change_phc(struct port *p)
/* Try to switch only if the interface is up, it has HW time stamping
using a non-vclock PHC, and the PHC actually changed. */
if (!(p->link_status & LINK_UP) ||
+ p->phc_index < 0 ||
!interface_tsinfo_valid(p->iface) ||
interface_get_vclock(p->iface) >= 0 ||
interface_phc_index(p->iface) < 0 ||

View File

@ -4,7 +4,7 @@
Name: linuxptp Name: linuxptp
Version: 3.1.1 Version: 3.1.1
Release: 6%{?dist} Release: 9%{?dist}
Summary: PTP implementation for Linux Summary: PTP implementation for Linux
License: GPLv2+ License: GPLv2+
@ -51,6 +51,10 @@ Patch14: linuxptp-vlanbond.patch
Patch15: linuxptp-eintr.patch Patch15: linuxptp-eintr.patch
# check for unexpected changes in frequency offset # check for unexpected changes in frequency offset
Patch16: linuxptp-freqcheck.patch Patch16: linuxptp-freqcheck.patch
# don't re-arm fault clearing timer on unrelated netlink events
Patch17: linuxptp-faultrearm.patch
# clear pending errors on sockets
Patch18: linuxptp-soerror.patch
BuildRequires: gcc gcc-c++ make systemd BuildRequires: gcc gcc-c++ make systemd
@ -80,6 +84,8 @@ Supporting legacy APIs and other platforms is not a goal.
%patch14 -p1 -b .vlanbond %patch14 -p1 -b .vlanbond
%patch15 -p1 -b .eintr %patch15 -p1 -b .eintr
%patch16 -p1 -b .freqcheck %patch16 -p1 -b .freqcheck
%patch17 -p1 -b .faultrearm
%patch18 -p1 -b .soerror
mv linuxptp-testsuite-%{testsuite_ver}* testsuite mv linuxptp-testsuite-%{testsuite_ver}* testsuite
mv clknetsim-%{clknetsim_ver}* testsuite/clknetsim mv clknetsim-%{clknetsim_ver}* testsuite/clknetsim
@ -142,6 +148,15 @@ PATH=..:$PATH ./run
%{_mandir}/man8/*.8* %{_mandir}/man8/*.8*
%changelog %changelog
* Wed May 03 2023 Miroslav Lichvar <mlichvar@redhat.com> 3.1.1-9
- clear pending errors on sockets (#2192559)
* Mon Mar 20 2023 Miroslav Lichvar <mlichvar@redhat.com> 3.1.1-8
- don't switch from system clock to PHC with SW timestamping (#2179041)
* Thu Mar 09 2023 Miroslav Lichvar <mlichvar@redhat.com> 3.1.1-7
- don't re-arm fault clearing timer on unrelated netlink events (#2172650)
* Thu Jan 05 2023 Miroslav Lichvar <mlichvar@redhat.com> 3.1.1-6 * Thu Jan 05 2023 Miroslav Lichvar <mlichvar@redhat.com> 3.1.1-6
- add support for VLAN over bond (#2120521) - add support for VLAN over bond (#2120521)
- handle EINTR when waiting for transmit timestamp (#2128786) - handle EINTR when waiting for transmit timestamp (#2128786)