ntp: make NTP-over-PTP domain configurable
Add ptpdomain directive to set the domain number of transmitted and accepted NTP-over-PTP messages. It might need to be changed in networks using a PTP profile with the same domain number. The default domain number of 123 follows the current NTP-over-PTP specification.
This commit is contained in:
parent
c46e0549ab
commit
4da088ec2f
6 changed files with 37 additions and 3 deletions
12
conf.c
12
conf.c
|
@ -287,6 +287,8 @@ static double hwts_timeout = 0.001;
|
|||
|
||||
/* PTP event port (disabled by default) */
|
||||
static int ptp_port = 0;
|
||||
/* PTP domain number of NTP-over-PTP messages */
|
||||
static int ptp_domain = 123;
|
||||
|
||||
typedef struct {
|
||||
NTP_Source_Type type;
|
||||
|
@ -708,6 +710,8 @@ CNF_ParseLine(const char *filename, int number, char *line)
|
|||
parse_source(p, command, 1);
|
||||
} else if (!strcasecmp(command, "port")) {
|
||||
parse_int(p, &ntp_port);
|
||||
} else if (!strcasecmp(command, "ptpdomain")) {
|
||||
parse_int(p, &ptp_domain);
|
||||
} else if (!strcasecmp(command, "ptpport")) {
|
||||
parse_int(p, &ptp_port);
|
||||
} else if (!strcasecmp(command, "ratelimit")) {
|
||||
|
@ -2572,6 +2576,14 @@ CNF_GetPtpPort(void)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
CNF_GetPtpDomain(void)
|
||||
{
|
||||
return ptp_domain;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
CNF_GetRefresh(void)
|
||||
{
|
||||
|
|
1
conf.h
1
conf.h
|
@ -159,6 +159,7 @@ extern int CNF_GetHwTsInterface(unsigned int index, CNF_HwTsInterface **iface);
|
|||
extern double CNF_GetHwTsTimeout(void);
|
||||
|
||||
extern int CNF_GetPtpPort(void);
|
||||
extern int CNF_GetPtpDomain(void);
|
||||
|
||||
extern int CNF_GetRefresh(void);
|
||||
|
||||
|
|
|
@ -2802,6 +2802,11 @@ hwtimestamp * rxfilter ptp
|
|||
ptpport 319
|
||||
----
|
||||
|
||||
[[ptpdomain]]*ptpdomain* _domain_::
|
||||
The *ptpdomain* directive sets the PTP domain number of transmitted and
|
||||
accepted NTP-over-PTP messages. Messages from other domains are ignored.
|
||||
The default is 123, the minimum is 0, and the maximum is 255.
|
||||
|
||||
[[sched_priority]]*sched_priority* _priority_::
|
||||
On Linux, FreeBSD, NetBSD, and illumos, the *sched_priority* directive will
|
||||
select the SCHED_FIFO real-time scheduler at the specified priority (which must
|
||||
|
|
4
ntp_io.c
4
ntp_io.c
|
@ -517,7 +517,7 @@ NIO_UnwrapMessage(SCK_Message *message, int sock_fd, double *net_correction)
|
|||
(msg->header.version != PTP_VERSION_2 &&
|
||||
(msg->header.version != PTP_VERSION_2_1 || msg->header.min_sdoid != 0)) ||
|
||||
ntohs(msg->header.length) != message->length ||
|
||||
msg->header.domain != PTP_DOMAIN_NTP ||
|
||||
msg->header.domain != CNF_GetPtpDomain() ||
|
||||
ntohs(msg->header.flags) != PTP_FLAG_UNICAST ||
|
||||
ntohs(msg->tlv_header.type) != PTP_TLV_NTP ||
|
||||
ntohs(msg->tlv_header.length) != message->length - PTP_NTP_PREFIX_LENGTH) {
|
||||
|
@ -565,7 +565,7 @@ wrap_message(SCK_Message *message, int sock_fd)
|
|||
ptp_message->header.type = PTP_TYPE_DELAY_REQ;
|
||||
ptp_message->header.version = PTP_VERSION_2;
|
||||
ptp_message->header.length = htons(PTP_NTP_PREFIX_LENGTH + message->length);
|
||||
ptp_message->header.domain = PTP_DOMAIN_NTP;
|
||||
ptp_message->header.domain = CNF_GetPtpDomain();
|
||||
ptp_message->header.flags = htons(PTP_FLAG_UNICAST);
|
||||
ptp_message->header.sequence_id = htons(sequence_id++);
|
||||
ptp_message->tlv_header.type = htons(PTP_TLV_NTP);
|
||||
|
|
1
ptp.h
1
ptp.h
|
@ -35,7 +35,6 @@
|
|||
#define PTP_VERSION_2_1 (2 | 1 << 4)
|
||||
#define PTP_TYPE_SYNC 0
|
||||
#define PTP_TYPE_DELAY_REQ 1
|
||||
#define PTP_DOMAIN_NTP 123
|
||||
#define PTP_FLAG_UNICAST (1 << (2 + 8))
|
||||
#define PTP_TLV_NTP 0x2023
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ peers=2
|
|||
max_sync_time=420
|
||||
|
||||
server_conf="
|
||||
ptpdomain 123
|
||||
ptpport 319"
|
||||
client_conf="
|
||||
ptpport 319
|
||||
|
@ -103,4 +104,20 @@ if check_config_h 'FEAT_DEBUG 1'; then
|
|||
check_log_messages "apply_net_correction.*Applied" 0 0 || test_fail
|
||||
fi
|
||||
|
||||
freq_offset=-1e-4
|
||||
delay_correction=""
|
||||
server_conf="ptpport 319"
|
||||
client_conf="ptpport 319
|
||||
ptpdomain 124
|
||||
authselectmode ignore
|
||||
keyfile tmp/peer.keys"
|
||||
time_max_limit=$default_time_max_limit
|
||||
time_rms_limit=$default_time_rms_limit
|
||||
freq_max_limit=$default_freq_max_limit
|
||||
freq_rms_limit=$default_freq_rms_limit
|
||||
|
||||
run_test || test_fail
|
||||
check_chronyd_exit || test_fail
|
||||
check_sync || test_fail
|
||||
|
||||
test_pass
|
||||
|
|
Loading…
Reference in a new issue