diff --git a/base/linuxptp/PKG-INFO b/base/linuxptp/PKG-INFO new file mode 100644 index 000000000..50b669829 --- /dev/null +++ b/base/linuxptp/PKG-INFO @@ -0,0 +1,18 @@ +Metadata-Version: 1.1 +Name: linuxptp +Version: 2.0-2 +Summary: linuxptp +Home-page: http://linuxptp.sourceforge.net/ +Author: +Author-email: +License: GPLv2 + +Description: +This software is an implementation of the Precision Time Protocol (PTP) +according to IEEE standard 1588 for Linux. The dual design goals are to +provide a robust implementation of the standard and to use the most +relevant and modern Application Programming Interfaces (API) offered by +the Linux kernel. Supporting legacy APIs and other platforms is not a +goal. + +Platform: UNKNOWN diff --git a/base/linuxptp/centos/build_srpm.data b/base/linuxptp/centos/build_srpm.data new file mode 100644 index 000000000..69abd61b8 --- /dev/null +++ b/base/linuxptp/centos/build_srpm.data @@ -0,0 +1 @@ +TIS_PATCH_VER=PKG_GITREVCOUNT diff --git a/base/linuxptp/centos/meta_patches/0001-Update-package-versioning-for-STX-format.patch b/base/linuxptp/centos/meta_patches/0001-Update-package-versioning-for-STX-format.patch new file mode 100644 index 000000000..ccade0a34 --- /dev/null +++ b/base/linuxptp/centos/meta_patches/0001-Update-package-versioning-for-STX-format.patch @@ -0,0 +1,25 @@ +From dce66cbf8eb0a132592039934629f4ceea6fed6f Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Mon, 21 Jun 2021 15:24:03 -0400 +Subject: [PATCH] Update package versioning for STX format + +--- + SPECS/linuxptp.spec | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/SPECS/linuxptp.spec b/SPECS/linuxptp.spec +index 6d97f12..60f340f 100644 +--- a/SPECS/linuxptp.spec ++++ b/SPECS/linuxptp.spec +@@ -3,7 +3,7 @@ + %global clknetsim_ver 8b4842 + Name: linuxptp + Version: 2.0 +-Release: 2%{?dist} ++Release: 2%{?_tis_dist}.%{tis_patch_ver} + Summary: PTP implementation for Linux + + Group: System Environment/Base +-- +2.29.2 + diff --git a/base/linuxptp/centos/meta_patches/0002-STX-patches-for-default_sync-and-BC-performance.patch b/base/linuxptp/centos/meta_patches/0002-STX-patches-for-default_sync-and-BC-performance.patch new file mode 100644 index 000000000..410d7905a --- /dev/null +++ b/base/linuxptp/centos/meta_patches/0002-STX-patches-for-default_sync-and-BC-performance.patch @@ -0,0 +1,48 @@ +From 2b59f59616f4c9d27ee094f5099011f3015d90c8 Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 13:21:58 -0400 +Subject: [PATCH] STX patches for default_sync and BC performance + +--- + SPECS/linuxptp.spec | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/SPECS/linuxptp.spec b/SPECS/linuxptp.spec +index 3f91582..63c4246 100644 +--- a/SPECS/linuxptp.spec ++++ b/SPECS/linuxptp.spec +@@ -34,6 +34,18 @@ Patch5: linuxptp-team.patch + Patch6: linuxptp-addreq.patch + # don't leak memory when allocation fails + Patch7: linuxptp-msgput.patch ++# StarlingX ++Patch8: 0001-p1-Reset-state-when-switching-port-with-same-best-cl.patch ++# StarlingX ++Patch9: 0002-p2-Reset-clock-check-on-best-clock-port-change.patch ++# StarlingX ++Patch10: 0003-p3-Only-check-timestamps-from-uncalibrated-and-slave.patch ++# StarlingX ++Patch11: 0004-p4-Do-not-renew-raw-transport-sockets.patch ++# StarlingX ++Patch12: 0005-p5-Increase-the-minimum-clockcheck-interval-for-stab.patch ++# StarlingX ++Patch13: 0006-Add-option-to-disable-default-port-selection-in-phc2.patch + + BuildRequires: kernel-headers > 3.10.0-1002 + BuildRequires: systemd-units +@@ -58,6 +70,12 @@ Supporting legacy APIs and other platforms is not a goal. + %patch5 -p1 -b .team + %patch6 -p1 -b .addreq + %patch7 -p1 -b .msgput ++%patch8 -p1 ++%patch9 -p1 ++%patch10 -p1 ++%patch11 -p1 ++%patch12 -p1 ++%patch13 -p1 + mv linuxptp-testsuite-%{testsuite_ver}* testsuite + mv clknetsim-%{clknetsim_ver}* testsuite/clknetsim + +-- +2.29.2 + diff --git a/base/linuxptp/centos/meta_patches/PATCH_ORDER b/base/linuxptp/centos/meta_patches/PATCH_ORDER new file mode 100644 index 000000000..0adb2efc4 --- /dev/null +++ b/base/linuxptp/centos/meta_patches/PATCH_ORDER @@ -0,0 +1,2 @@ +0001-Update-package-versioning-for-STX-format.patch +0002-STX-patches-for-default_sync-and-BC-performance.patch diff --git a/base/linuxptp/centos/patches/0001-p1-Reset-state-when-switching-port-with-same-best-cl.patch b/base/linuxptp/centos/patches/0001-p1-Reset-state-when-switching-port-with-same-best-cl.patch new file mode 100644 index 000000000..8a7f39820 --- /dev/null +++ b/base/linuxptp/centos/patches/0001-p1-Reset-state-when-switching-port-with-same-best-cl.patch @@ -0,0 +1,25 @@ +From fe89b71514d21e296988c540ed8a11f98307c36c Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 10:20:19 -0400 +Subject: [PATCH 1/6] p1 Reset state when switching port with same best clock + +--- + clock.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clock.c b/clock.c +index 9bbcefa..9fad542 100644 +--- a/clock.c ++++ b/clock.c +@@ -1737,7 +1737,7 @@ static void handle_state_decision_event(struct clock *c) + cid2str(&best_id)); + } + +- if (!cid_eq(&best_id, &c->best_id)) { ++ if (!cid_eq(&best_id, &c->best_id) || best != c->best) { + clock_freq_est_reset(c); + tsproc_reset(c->tsproc, 1); + if (!tmv_is_zero(c->initial_delay)) +-- +2.29.2 + diff --git a/base/linuxptp/centos/patches/0002-p2-Reset-clock-check-on-best-clock-port-change.patch b/base/linuxptp/centos/patches/0002-p2-Reset-clock-check-on-best-clock-port-change.patch new file mode 100644 index 000000000..2665647a4 --- /dev/null +++ b/base/linuxptp/centos/patches/0002-p2-Reset-clock-check-on-best-clock-port-change.patch @@ -0,0 +1,67 @@ +From da48222456566d63a940810733ff369895777bda Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 10:21:45 -0400 +Subject: [PATCH 2/6] p2 Reset clock check on best clock port change + +--- + clock.c | 2 ++ + clockcheck.c | 9 ++++++++- + clockcheck.h | 7 +++++++ + 3 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/clock.c b/clock.c +index 9fad542..7a66770 100644 +--- a/clock.c ++++ b/clock.c +@@ -1739,6 +1739,8 @@ static void handle_state_decision_event(struct clock *c) + + if (!cid_eq(&best_id, &c->best_id) || best != c->best) { + clock_freq_est_reset(c); ++ if (c->sanity_check) ++ clockcheck_reset(c->sanity_check); + tsproc_reset(c->tsproc, 1); + if (!tmv_is_zero(c->initial_delay)) + tsproc_set_delay(c->tsproc, c->initial_delay); +diff --git a/clockcheck.c b/clockcheck.c +index d48a578..544ce9b 100644 +--- a/clockcheck.c ++++ b/clockcheck.c +@@ -47,9 +47,16 @@ struct clockcheck *clockcheck_create(int freq_limit) + if (!cc) + return NULL; + cc->freq_limit = freq_limit; ++ clockcheck_reset(cc); ++ return cc; ++} ++ ++void clockcheck_reset(struct clockcheck *cc) ++{ ++ cc->freq_known = 0; + cc->max_freq = -CHECK_MAX_FREQ; + cc->min_freq = CHECK_MAX_FREQ; +- return cc; ++ cc->last_ts = 0; + } + + int clockcheck_sample(struct clockcheck *cc, uint64_t ts) +diff --git a/clockcheck.h b/clockcheck.h +index 78aca48..6c02ce3 100644 +--- a/clockcheck.h ++++ b/clockcheck.h +@@ -33,6 +33,13 @@ struct clockcheck; + */ + struct clockcheck *clockcheck_create(int freq_limit); + ++/** ++ * Reset a clock check. ++ * @param cc Pointer to a clock check obtained via @ref clockcheck_create(). ++ */ ++void clockcheck_reset(struct clockcheck *cc); ++ ++ + /** + * Perform the sanity check on a time stamp. + * @param cc Pointer to a clock check obtained via @ref clockcheck_create(). +-- +2.29.2 + diff --git a/base/linuxptp/centos/patches/0003-p3-Only-check-timestamps-from-uncalibrated-and-slave.patch b/base/linuxptp/centos/patches/0003-p3-Only-check-timestamps-from-uncalibrated-and-slave.patch new file mode 100644 index 000000000..03374af34 --- /dev/null +++ b/base/linuxptp/centos/patches/0003-p3-Only-check-timestamps-from-uncalibrated-and-slave.patch @@ -0,0 +1,35 @@ +From 8b4e9d4aad5e3b997838e1186b00403393309d35 Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 10:25:11 -0400 +Subject: [PATCH 3/6] p3 Only check timestamps from uncalibrated and slave + ports + +--- + port.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/port.c b/port.c +index c945c13..affa48b 100644 +--- a/port.c ++++ b/port.c +@@ -2541,10 +2541,13 @@ static enum fsm_event bc_event(struct port *p, int fd_index) + msg_put(msg); + return EV_NONE; + } +- if (msg_sots_valid(msg)) { +- ts_add(&msg->hwts.ts, -p->rx_timestamp_offset); +- clock_check_ts(p->clock, tmv_to_nanoseconds(msg->hwts.ts)); +- } ++ if (msg_sots_valid(msg)) { ++ ts_add(&msg->hwts.ts, -p->rx_timestamp_offset); ++ if (p->state == PS_SLAVE || p->state == PS_UNCALIBRATED) { ++ clock_check_ts(p->clock, ++ tmv_to_nanoseconds(msg->hwts.ts)); ++ } ++ } + + switch (msg_type(msg)) { + case SYNC: +-- +2.29.2 + diff --git a/base/linuxptp/centos/patches/0004-p4-Do-not-renew-raw-transport-sockets.patch b/base/linuxptp/centos/patches/0004-p4-Do-not-renew-raw-transport-sockets.patch new file mode 100644 index 000000000..372ec2467 --- /dev/null +++ b/base/linuxptp/centos/patches/0004-p4-Do-not-renew-raw-transport-sockets.patch @@ -0,0 +1,31 @@ +From 9587b2ed9460a6c5fc50166d94cb43814c4c3a32 Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 10:32:41 -0400 +Subject: [PATCH 4/6] p4 Do not renew raw transport sockets + +--- + port.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/port.c b/port.c +index affa48b..c96389a 100644 +--- a/port.c ++++ b/port.c +@@ -1650,6 +1650,14 @@ static int port_renew_transport(struct port *p) + if (!port_is_enabled(p)) { + return 0; + } ++ ++ ++ /* Closing and binding of raw sockets is too slow and unnecessary */ ++ if (transport_type(p->trp) == TRANS_IEEE_802_3) { ++ return 0; ++ } ++ ++ + transport_close(p->trp, &p->fda); + port_clear_fda(p, FD_FIRST_TIMER); + res = transport_open(p->trp, p->iface, &p->fda, p->timestamping); +-- +2.29.2 + diff --git a/base/linuxptp/centos/patches/0005-p5-Increase-the-minimum-clockcheck-interval-for-stab.patch b/base/linuxptp/centos/patches/0005-p5-Increase-the-minimum-clockcheck-interval-for-stab.patch new file mode 100644 index 000000000..b608a0760 --- /dev/null +++ b/base/linuxptp/centos/patches/0005-p5-Increase-the-minimum-clockcheck-interval-for-stab.patch @@ -0,0 +1,25 @@ +From 6463b1a125e270d7bdb58d2bf4bc1156bf4aa993 Mon Sep 17 00:00:00 2001 +From: Cole Walker +Date: Wed, 23 Jun 2021 10:33:35 -0400 +Subject: [PATCH 5/6] p5 Increase the minimum clockcheck interval for stability + +--- + clockcheck.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/clockcheck.c b/clockcheck.c +index 544ce9b..2588f7b 100644 +--- a/clockcheck.c ++++ b/clockcheck.c +@@ -23,7 +23,7 @@ + #include "clockcheck.h" + #include "print.h" + +-#define CHECK_MIN_INTERVAL 100000000 ++#define CHECK_MIN_INTERVAL 1000000000 + #define CHECK_MAX_FREQ 900000000 + + struct clockcheck { +-- +2.29.2 + diff --git a/base/linuxptp/centos/patches/0006-Add-option-to-disable-default-port-selection-in-phc2.patch b/base/linuxptp/centos/patches/0006-Add-option-to-disable-default-port-selection-in-phc2.patch new file mode 100644 index 000000000..f8f106d69 --- /dev/null +++ b/base/linuxptp/centos/patches/0006-Add-option-to-disable-default-port-selection-in-phc2.patch @@ -0,0 +1,97 @@ +From 9f3a0a3df4346fa15ed6573cc57092baba37354e Mon Sep 17 00:00:00 2001 +From: Cole Walker +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 + diff --git a/base/linuxptp/centos/srpm_path b/base/linuxptp/centos/srpm_path new file mode 100644 index 000000000..f65c44822 --- /dev/null +++ b/base/linuxptp/centos/srpm_path @@ -0,0 +1 @@ +mirror:Source/linuxptp-2.0-2.el7.src.rpm diff --git a/centos_iso_image.inc b/centos_iso_image.inc index 1d81494b9..0613e47af 100644 --- a/centos_iso_image.inc +++ b/centos_iso_image.inc @@ -112,6 +112,9 @@ lighttpd-fastcgi lighttpd-mod_geoip lighttpd-mod_mysql_vhost +# linuxptp +linuxptp + # logrotate logrotate diff --git a/centos_pkg_dirs b/centos_pkg_dirs index 1e262fb5d..1d4db4df6 100644 --- a/centos_pkg_dirs +++ b/centos_pkg_dirs @@ -1,6 +1,7 @@ base/initscripts base/setup base/dhcp +base/linuxptp base/openssh config/facter virt/qemu diff --git a/centos_srpms_centos.lst b/centos_srpms_centos.lst index f4fff40a9..24fccabd4 100644 --- a/centos_srpms_centos.lst +++ b/centos_srpms_centos.lst @@ -9,6 +9,7 @@ haproxy-1.5.18-8.el7.src.rpm initscripts-9.49.46-1.el7.src.rpm libevent-2.0.21-4.el7.src.rpm lighttpd-1.4.54-1.el7.src.rpm +linuxptp-2.0-2.el7.src.rpm logrotate-3.8.6-17.el7.src.rpm net-tools-2.0-0.24.20131004git.el7.src.rpm ntp-4.2.6p5-29.el7.centos.2.src.rpm