Files
integ/base/linuxptp/debian/patches/0026-phc2sys-Fix-null-pointer-de-reference-in-manual-mode.patch
Andre Mauricio Zelak 59b3912596 GM clock accuracy and offset scaled log variance
Include GM clock quality parameters clock accuracy and offset
scaled log variance to the clock selection algorithm. Those
checks together with the clock class can check the remote
clock quality, enhancing T-BC support.

The existing ha_min_local_clockClass, ha_min_clockAccuracy,
ha_min_gm_offsetScaledLogVariance and ha_min_gm_ClockClass were
renamed. Now their names are ha_max* because they represent the
maximum value the clock can present to be considered valid.

The existing ha_timeTraceable and ha_frequencyTraceable were
renamed. Now their names contain gm to explain and show they
correspond to the GM time and frequency traceability.

The ha_min_local_clockClass is now ha_max_local_clockClass, and
Its default value was changed to 255.

The ha_min_clockAccuracy is now ha_max_local_clockAccuracy, its
name now contains the local key to differentiate from the GM
configuration option.

The ha_min_offsetScaledLogVariance is now
ha_max_local_offsetScaledLogVar. Its name now contains the
local key to differentiate from the GM configuration option,
and the word Variace was shortened Var due to the size limit
of the name.

The ha_min_gm_ClockClass is now ha_max_gm_clockClass, and its
default value was changed to 6.

The ha_max_local_clockClass and ha_max_gm_clockClass default values
were changed to make it easier to configure both T-GM and T-BC
scenarios.

The new ha_max_gm_clockAccuracy option is a global setting for the
maximum GM clock accuracy requirement. It ranges from 0x00 to 0xff
and its default is 0xfe.

The new ha_max_gm_offsetScaledLogVar option is a global setting for
the maximum GM offset scaled log variance requirement. It ranges
from 0x0000 to 0xffff and its default is 0xffff.

The status command now includes the GM clock accuracy and offset scaled
log variance values.

Test plan: new GM fields
PASS Verify the clock is discarded because GM clock accuracy is out of
requirement
PASS Verify the clock is discarded because GM offset scaled log
variance is out of the requirement
PASS Verify the status command shows the new fields gm.clockAcc and
gm.offset

Test plan: new default values
PASS Verify the ha_max_gm_ClockClass and ha_max_local_clockClass
default values.

Test plan: renamed fields
PASS Verify the a configuration containing all HA configuration options
is accepted.

Story: 2010723
Task: 48675

Change-Id: I7ed1300a51cbdcaa44d7f350dcdc92e54469a497
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
2023-08-28 12:48:19 -03:00

92 lines
2.6 KiB
Diff

From 5aacbe319db97907a15741005e2790bbf4c742a0 Mon Sep 17 00:00:00 2001
From: Andre Mauricio Zelak <andre.zelak@windriver.com>
Date: Mon, 12 Jun 2023 15:37:46 -0300
Subject: [PATCH 26/49] phc2sys: Fix null pointer de-reference in manual mode.
If both the -w and -O command line options are specified (or when
using -w when both source and destination clocks are PHCs), then
pointer to the PMC agent will be incorrectly freed.
Fix the segfault by introducing a method to "disable" the agent as was
done before the PMC agent code was introduced.
Unfortunately the resulting PMC agent API now has both create/destroy
and init/disable methods. This clunky arrangement can be cleaned up
later on, but it entails re-factoring the phc2sys program even more.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Fixes: 8266987 ("pmc_agent: Hide the implementation.")
[commit 68fd0b010e9761e3dc580026eb6f2366c7c8e82d upstream]
Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
---
phc2sys.c | 7 ++-----
pmc_agent.c | 8 ++++++++
pmc_agent.h | 6 ++++++
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index cbe80f2..3cafbb2 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1340,8 +1340,7 @@ int main(int argc, char *argv[])
if (priv.forced_sync_offset ||
(src->clkid != CLOCK_REALTIME && dst->clkid != CLOCK_REALTIME) ||
src->clkid == CLOCK_INVALID) {
- pmc_agent_destroy(priv.node);
- priv.node = NULL;
+ pmc_agent_disable(priv.node);
}
}
@@ -1355,9 +1354,7 @@ int main(int argc, char *argv[])
}
end:
- if (priv.node) {
- pmc_agent_destroy(priv.node);
- }
+ pmc_agent_destroy(priv.node);
clock_cleanup(&priv);
port_cleanup(&priv);
config_destroy(cfg);
diff --git a/pmc_agent.c b/pmc_agent.c
index 22af306..833d1c1 100644
--- a/pmc_agent.c
+++ b/pmc_agent.c
@@ -366,6 +366,14 @@ void pmc_agent_destroy(struct pmc_agent *agent)
free(agent);
}
+void pmc_agent_disable(struct pmc_agent *agent)
+{
+ if (agent->pmc) {
+ pmc_destroy(agent->pmc);
+ }
+ agent->pmc = NULL;
+}
+
int pmc_agent_get_leap(struct pmc_agent *agent)
{
return agent->leap;
diff --git a/pmc_agent.h b/pmc_agent.h
index 483a21b..0ed10f8 100644
--- a/pmc_agent.h
+++ b/pmc_agent.h
@@ -55,6 +55,12 @@ struct pmc_agent *pmc_agent_create(void);
*/
void pmc_agent_destroy(struct pmc_agent *agent);
+/**
+ * Disconnects the PMC agent from the ptp4l service.
+ * @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
+ */
+void pmc_agent_disable(struct pmc_agent *agent);
+
/**
* Gets the current leap adjustment.
* @param agent Pointer to a PMC instance obtained via @ref pmc_agent_create().
--
2.25.1