import CS linuxptp-4.4-4.el9_7

This commit is contained in:
eabdullin 2025-11-11 18:07:16 +00:00
parent 9e3752745e
commit 7fea844fc5
4 changed files with 193 additions and 11 deletions

View File

@ -1,4 +1,4 @@
commit b4c146daa086436807abcd75157bd9d0a44971cb
commit 4e172c83520852d41e5c2ec3ae324d50c42a0416
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Thu Aug 28 15:14:01 2025 +0200

View File

@ -0,0 +1,75 @@
commit 01de33e91f9717d0cbae5af6eee2beb45deee219
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Tue Mar 4 15:53:37 2025 +0100
port: Refresh link status on faults.
ptp4l gets the ENOBUFS error on the netlink socket when the kernel has
to drop messages due to full socket buffer. If ptp4l has a port in the
faulty state waiting for the link to go up and that event corresponds
to one of the dropped netlink messages, the port will be stuck in the
faulty state until the link goes down and up again.
To prevent the port from getting stuck, request the current link status
when dispatching the EV_FAULT_DETECTED event. Also, reopen the socket to
get rid of the buffered messages when handling the fault and again when
reinitializing the port.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
diff --git a/port.c b/port.c
index 7f945ac..1bb407c 100644
--- a/port.c
+++ b/port.c
@@ -1975,6 +1975,20 @@ static int port_cmlds_initialize(struct port *p)
return port_cmlds_renew(p, now.tv_sec);
}
+static void port_rtnl_initialize(struct port *p)
+{
+ /* Reopen the socket to get rid of buffered messages */
+ if (p->fda.fd[FD_RTNL] >= 0) {
+ rtnl_close(p->fda.fd[FD_RTNL]);
+ }
+ p->fda.fd[FD_RTNL] = rtnl_open();
+ if (p->fda.fd[FD_RTNL] >= 0) {
+ rtnl_link_query(p->fda.fd[FD_RTNL], interface_name(p->iface));
+ }
+
+ clock_fda_changed(p->clock);
+}
+
void port_disable(struct port *p)
{
int i;
@@ -2087,13 +2101,8 @@ int port_initialize(struct port *p)
if (p->bmca == BMCA_NOOP) {
port_set_delay_tmo(p);
}
- if (p->fda.fd[FD_RTNL] == -1) {
- p->fda.fd[FD_RTNL] = rtnl_open();
- }
- if (p->fda.fd[FD_RTNL] >= 0) {
- const char *ifname = interface_name(p->iface);
- rtnl_link_query(p->fda.fd[FD_RTNL], ifname);
- }
+
+ port_rtnl_initialize(p);
}
port_nrate_initialize(p);
@@ -3768,6 +3777,13 @@ int port_state_update(struct port *p, enum fsm_event event, int mdiff)
if (port_link_status_get(p) && clear_fault_asap(&i)) {
pr_notice("%s: clearing fault immediately", p->log_name);
next = p->state_machine(next, EV_FAULT_CLEARED, 0);
+ } else if (event == EV_FAULT_DETECTED) {
+ /*
+ * Reopen the netlink socket and refresh the link
+ * status in case the fault was triggered by a missed
+ * netlink message (ENOBUFS).
+ */
+ port_rtnl_initialize(p);
}
}

View File

@ -0,0 +1,104 @@
commit 71241f3fdcff59b35ad5de0b8b37cb07a4b677bd
Author: Vincent Cheng <vscheng@gmail.com>
Date: Tue Sep 17 15:23:54 2024 -0400
port: Fix unicast negotiation doesn't recover after FAULT_DETECTED
_Problem_
After a port link down/up or a tx_timestamp timeout issue, a port acting
as unicast master does not issue ANNC messages after granting unicast
request for ANNC.
_Analysis_
When a port FAULT occurs, the port transitions to FAULTY on FAULT_DETECTED
and subsequently port_disable(p) and port_initialize(p) are called on port recovery.
A port acting as a unicast master, stores clients in p->unicast_service->queue.
When a port receives a unicast request, unicast_service_add() is called.
In unicast_service_add(), if the request does not match an entry in
p->unicast_service->queue, FD_UNICAST_SRV_TIMER is started via
unicast_service_rearm_timer().
If the unicast request matches an existing p->unicast_service->queue entry
the request is considered an extension and FD_UNICAST_SRV_TIMER must
already be running.
port_disable() clears FD_UNICAST_SRV_TIMER, ie. stops FD_UNICAST_SRV_TIMER.
However, port_disable() does not clear p->unicast_service->queue.
When the port is restarted, the port retains the previous client data.
After port recovery, when the client attempts to restart the unicast
service, the request matches an existing entry in p->unicast_service->queue,
and so FD_UNICAST_SRV_TIMER is not started because the port expected
that the FD_UNICAST_SRV_TIMER is already running.
_Fix_
This patch clears the unicast client data in port_disable() so
that upon recovery, the initial unicast request will be considered
a new request and trigger the start of the FD_UNICAST_SRV_TIMER.
v2:
- Add missing sign-off
- Send to develop-request instead of users list
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
diff --git a/port.c b/port.c
index 1bb407c..90b0860 100644
--- a/port.c
+++ b/port.c
@@ -1999,6 +1999,7 @@ void port_disable(struct port *p)
flush_peer_delay(p);
p->best = NULL;
+ unicast_service_clear_clients(p);
free_foreign_masters(p);
transport_close(p->trp, &p->fda);
diff --git a/unicast_service.c b/unicast_service.c
index 2fc2fbe..cee6691 100644
--- a/unicast_service.c
+++ b/unicast_service.c
@@ -583,3 +583,24 @@ int unicast_service_timer(struct port *p)
}
return err;
}
+
+void unicast_service_clear_clients(struct port *p)
+{
+ struct unicast_client_address *client, *temp;
+ struct unicast_service_interval *interval;
+
+ if (!p->unicast_service) {
+ return;
+ }
+
+ while ((interval = pqueue_extract(p->unicast_service->queue)) != NULL) {
+
+ LIST_REMOVE(interval, list);
+
+ LIST_FOREACH_SAFE(client, &interval->clients, list, temp) {
+ LIST_REMOVE(client, list);
+ free(client);
+ }
+ free(interval);
+ }
+}
\ No newline at end of file
diff --git a/unicast_service.h b/unicast_service.h
index f0d6487..8ea1a59 100644
--- a/unicast_service.h
+++ b/unicast_service.h
@@ -87,4 +87,10 @@ void unicast_service_remove(struct port *p, struct ptp_message *m,
*/
int unicast_service_timer(struct port *p);
+/**
+ * Clears unicast clients on a given port.
+ * @param p The port in question.
+ */
+void unicast_service_clear_clients(struct port *p);
+
#endif

View File

@ -4,7 +4,7 @@
Name: linuxptp
Version: 4.4
Release: 1%{?dist}.4
Release: 4%{?dist}
Summary: PTP implementation for Linux
License: GPL-2.0-or-later
@ -37,6 +37,10 @@ Patch7: linuxptp-nowait.patch
Patch8: linuxptp-externalpps.patch
# add command to set external grandmaster properties
Patch9: linuxptp-externalgm.patch
# refresh link status on faults
Patch10: linuxptp-rtnlinit.patch
# fix unicast server to recover after port fault
Patch11: linuxptp-unirecover.patch
# check for EL-specific kernels with vclock support
Patch12: linuxptp-vclock.patch
# handle missing pulses in ts2phc
@ -123,18 +127,17 @@ PATH=..:$PATH ./run
%{_mandir}/man8/*.8*
%changelog
* Tue Sep 23 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-1.el9_6.4
- rebuild
* Tue Sep 23 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-4
- handle missing pulses in ts2phc (RHEL-112193)
* Tue Sep 02 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-1.el9_6.3
- handle missing pulses in ts2phc (RHEL-112342)
* Wed May 28 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-3
- fix unicast server to recover after port fault (RHEL-93496)
* Wed May 14 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-1.el9_6.2
- add command to set external grandmaster properties (RHEL-91297)
* Tue May 06 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-1.el9_6.1
* Wed May 14 2025 Miroslav Lichvar <mlichvar@redhat.com> 4.4-2
- add experimental option for external PPS in ts2phc automatic mode
(RHEL-89604)
(RHEL-72468)
- add command to set external grandmaster properties (RHEL-90585)
- refresh link status on faults (RHEL-56168)
* Tue Dec 03 2024 Miroslav Lichvar <mlichvar@redhat.com> 4.4-1
- update to 4.4 (RHEL-58213 RHEL-57040)