integ/base/linuxptp/centos/patches/0006-Add-option-to-disable-...

98 lines
3.2 KiB
Diff

From 9f3a0a3df4346fa15ed6573cc57092baba37354e Mon Sep 17 00:00:00 2001
From: Cole Walker <cole.walker@windriver.com>
Date: Wed, 23 Jun 2021 11:14:41 -0400
Subject: [PATCH 6/6] Add option to disable default port selection in phc2sys
---
config.c | 1 +
phc2sys.c | 19 ++++++++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/config.c b/config.c
index 7914ba4..de5e68e 100644
--- a/config.c
+++ b/config.c
@@ -273,6 +273,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_STR("userDescription", ""),
GLOB_ITEM_INT("utc_offset", CURRENT_UTC_OFFSET, 0, INT_MAX),
GLOB_ITEM_INT("verbose", 0, 0, 1),
+ GLOB_ITEM_INT("default_sync", 1, 0, 1),
};
static struct unicast_master_table *current_uc_mtab;
diff --git a/phc2sys.c b/phc2sys.c
index b8f1ea0..45dba55 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -120,6 +120,7 @@ struct node {
LIST_HEAD(clock_head, clock) clocks;
LIST_HEAD(dst_clock_head, clock) dst_clocks;
struct clock *master;
+ int default_sync;
};
static struct config *phc2sys_config;
@@ -465,7 +466,7 @@ static void reconfigure(struct node *node)
}
last = c;
}
- if (dst_cnt > 1 && !src) {
+ if (dst_cnt > 1 && !src && node->default_sync) {
if (!rt || rt->dest_only) {
node->master = last;
/* Reset to original state in next reconfiguration. */
@@ -1363,6 +1364,7 @@ static void usage(char *progname)
" -N [num] number of master clock readings per update (5)\n"
" -L [limit] sanity frequency limit in ppb (200000000)\n"
" -M [num] NTP SHM segment number (0)\n"
+ " -D [num] fall back to default clock in automatic mode (1)\n"
" -u [num] number of clock updates in summary stats (0)\n"
" -n [num] domain number (0)\n"
" -x apply leap seconds by servo instead of kernel\n"
@@ -1383,7 +1385,7 @@ int main(int argc, char *argv[])
struct clock *src, *dst;
struct config *cfg;
struct option *opts;
- int autocfg = 0, c, domain_number = 0, index, ntpshm_segment;
+ int autocfg = 0, c, domain_number = 0, default_sync = 1, index, ntpshm_segment;
int pps_fd = -1, print_level = LOG_INFO, r = -1, rt = 0, wait_sync = 0;
double phc_rate, tmp;
struct node node = {
@@ -1407,7 +1409,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt_long(argc, argv,
- "arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh",
+ "arc:d:f:s:E:P:I:S:F:R:N:O:L:M:D:i:u:wn:xz:l:t:mqvh",
opts, &index))) {
switch (c) {
case 0:
@@ -1559,6 +1561,12 @@ int main(int argc, char *argv[])
version_show(stdout);
config_destroy(cfg);
return 0;
+ case 'D':
+ if (get_arg_val_i(c, optarg, &default_sync, 0, 1) ||
+ config_set_int(cfg, "default_sync", default_sync)) {
+ goto end;
+ }
+ break;
case 'h':
usage(progname);
config_destroy(cfg);
@@ -1607,8 +1615,9 @@ int main(int argc, char *argv[])
}
node.kernel_leap = config_get_int(cfg, NULL, "kernel_leap");
node.sanity_freq_limit = config_get_int(cfg, NULL, "sanity_freq_limit");
-
- if (autocfg) {
+ node.default_sync = config_get_int(cfg, NULL, "default_sync");
+
+ if (autocfg) {
if (init_pmc(cfg, &node))
goto end;
if (auto_init_ports(&node, rt) < 0)
--
2.29.2