conf: add dscp directive
The directive sets the DSCP value in transmitted NTP packets, which can be useful in local networks where switches/routers are configured to prioritise packets with specific DSCP values.
This commit is contained in:
parent
e5cf006378
commit
6a5665ca58
4 changed files with 36 additions and 1 deletions
13
conf.c
13
conf.c
|
@ -201,6 +201,9 @@ static char *bind_cmd_iface = NULL;
|
|||
/* Path to the Unix domain command socket. */
|
||||
static char *bind_cmd_path = NULL;
|
||||
|
||||
/* Differentiated Services Code Point (DSCP) in transmitted NTP packets */
|
||||
static int ntp_dscp = 0;
|
||||
|
||||
/* Path to Samba (ntp_signd) socket. */
|
||||
static char *ntp_signd_socket = NULL;
|
||||
|
||||
|
@ -560,6 +563,8 @@ CNF_ParseLine(const char *filename, int number, char *line)
|
|||
parse_allow_deny(p, ntp_restrictions, 0);
|
||||
} else if (!strcasecmp(command, "driftfile")) {
|
||||
parse_string(p, &drift_file);
|
||||
} else if (!strcasecmp(command, "dscp")) {
|
||||
parse_int(p, &ntp_dscp);
|
||||
} else if (!strcasecmp(command, "dumpdir")) {
|
||||
parse_string(p, &dumpdir);
|
||||
} else if (!strcasecmp(command, "dumponexit")) {
|
||||
|
@ -2297,6 +2302,14 @@ CNF_GetBindCommandAddress(int family, IPAddr *addr)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
CNF_GetNtpDscp(void)
|
||||
{
|
||||
return ntp_dscp;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
char *
|
||||
CNF_GetNtpSigndSocket(void)
|
||||
{
|
||||
|
|
1
conf.h
1
conf.h
|
@ -83,6 +83,7 @@ extern char *CNF_GetBindNtpInterface(void);
|
|||
extern char *CNF_GetBindAcquisitionInterface(void);
|
||||
extern char *CNF_GetBindCommandInterface(void);
|
||||
extern char *CNF_GetBindCommandPath(void);
|
||||
extern int CNF_GetNtpDscp(void);
|
||||
extern char *CNF_GetNtpSigndSocket(void);
|
||||
extern char *CNF_GetPidFile(void);
|
||||
extern REF_LeapMode CNF_GetLeapSecMode(void);
|
||||
|
|
|
@ -652,6 +652,19 @@ An example of the directive is:
|
|||
bindacqdevice eth0
|
||||
----
|
||||
|
||||
[[dscp]]*dscp* _point_::
|
||||
The *dscp* directive sets the Differentiated Services Code Point (DSCP) in
|
||||
transmitted NTP packets to the specified value. It can improve stability of NTP
|
||||
measurements in local networks where switches or routers are configured to
|
||||
prioritise forwarding of packets with specific DSCP values. The default value
|
||||
is 0 and the maximum value is 63.
|
||||
+
|
||||
An example of the directive (setting the Expedited Forwarding class) is:
|
||||
+
|
||||
----
|
||||
dscp 46
|
||||
----
|
||||
|
||||
[[dumpdir]]*dumpdir* _directory_::
|
||||
To compute the rate of gain or loss of time, *chronyd* has to store a
|
||||
measurement history for each of the time sources it uses.
|
||||
|
|
10
ntp_io.c
10
ntp_io.c
|
@ -83,7 +83,7 @@ static void read_from_socket(int sock_fd, int event, void *anything);
|
|||
static int
|
||||
open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr)
|
||||
{
|
||||
int sock_fd, sock_flags, events = SCH_FILE_INPUT;
|
||||
int sock_fd, sock_flags, dscp, events = SCH_FILE_INPUT;
|
||||
IPSockAddr local_addr;
|
||||
char *iface;
|
||||
|
||||
|
@ -111,6 +111,14 @@ open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr
|
|||
return INVALID_SOCK_FD;
|
||||
}
|
||||
|
||||
dscp = CNF_GetNtpDscp();
|
||||
if (dscp > 0 && dscp < 64) {
|
||||
#ifdef IP_TOS
|
||||
if (!SCK_SetIntOption(sock_fd, IPPROTO_IP, IP_TOS, dscp << 2))
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!client_only && family == IPADDR_INET4 && local_addr.port > 0)
|
||||
bound_server_sock_fd4 = local_addr.ip_addr.addr.in4 != INADDR_ANY;
|
||||
|
||||
|
|
Loading…
Reference in a new issue