/* 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;
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")) {
/* ================================================== */
+int
+CNF_GetNtpDscp(void)
+{
+ return ntp_dscp;
+}
+
+/* ================================================== */
+
char *
CNF_GetNtpSigndSocket(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);
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.
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;
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;