Blame SOURCES/ntp-4.2.6p5-dscp.patch

6d3098
diff -up ntp-4.2.6p5/html/miscopt.html.dscp ntp-4.2.6p5/html/miscopt.html
6d3098
--- ntp-4.2.6p5/html/miscopt.html.dscp	2015-06-04 15:50:44.726240345 +0200
6d3098
+++ ntp-4.2.6p5/html/miscopt.html	2015-06-04 15:50:44.734240368 +0200
6d3098
@@ -132,6 +132,8 @@
6d3098
 				
The trap receiver will generally log event messages and other information from the server in a log file. While such monitor programs may also request their own trap dynamically, configuring a trap receiver will ensure that no messages are lost when the server is started.
6d3098
 			
<tt>ttl hop ...</tt>
6d3098
 			
This command specifies a list of TTL values in increasing order. up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
6d3098
+			
<tt>dscp dscp</tt>
6d3098
+			
This command specifies the Differentiated Services Code Point (DSCP) value that is used in sent NTP packets. The default value is 48 for Class Selector 6 (CS6).
6d3098
 		
6d3098
 		
6d3098
 		<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
6d3098
diff -up ntp-4.2.6p5/include/ntp_io.h.dscp ntp-4.2.6p5/include/ntp_io.h
6d3098
--- ntp-4.2.6p5/include/ntp_io.h.dscp	2010-12-25 10:40:34.000000000 +0100
6d3098
+++ ntp-4.2.6p5/include/ntp_io.h	2015-06-04 15:50:44.734240368 +0200
6d3098
@@ -80,6 +80,7 @@ typedef enum {
6d3098
 } nic_rule_action;
6d3098
 
6d3098
 
6d3098
+extern int	qos;
6d3098
 isc_boolean_t	get_broadcastclient_flag(void);
6d3098
 extern int	is_ip_address(const char *, sockaddr_u *);
6d3098
 extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
6d3098
diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.dscp ntp-4.2.6p5/ntpd/keyword-gen.c
6d3098
--- ntp-4.2.6p5/ntpd/keyword-gen.c.dscp	2015-06-04 15:50:44.727240348 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/keyword-gen.c	2015-06-04 15:50:44.734240368 +0200
6d3098
@@ -38,6 +38,7 @@ struct key_tok ntp_keywords[] = {
6d3098
 { "calldelay",		T_Calldelay,		FOLLBY_TOKEN },
6d3098
 { "disable",		T_Disable,		FOLLBY_TOKEN },
6d3098
 { "driftfile",		T_Driftfile,		FOLLBY_STRING },
6d3098
+{ "dscp",		T_Dscp,			FOLLBY_TOKEN },
6d3098
 { "enable",		T_Enable,		FOLLBY_TOKEN },
6d3098
 { "end",		T_End,			FOLLBY_TOKEN },
6d3098
 { "filegen",		T_Filegen,		FOLLBY_TOKEN },
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_config.c.dscp ntp-4.2.6p5/ntpd/ntp_config.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_config.c.dscp	2015-06-04 15:50:44.728240351 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_config.c	2015-06-04 15:50:44.735240371 +0200
6d3098
@@ -204,9 +204,6 @@ int	cryptosw;		/* crypto command called
6d3098
 extern int sys_maxclock;
6d3098
 extern char *stats_drift_file;	/* name of the driftfile */
6d3098
 extern char *leapseconds_file_name; /*name of the leapseconds file */
6d3098
-#ifdef HAVE_IPTOS_SUPPORT
6d3098
-extern unsigned int qos;				/* QoS setting */
6d3098
-#endif /* HAVE_IPTOS_SUPPORT */
6d3098
 
6d3098
 #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED
6d3098
 /*
6d3098
@@ -3201,6 +3198,10 @@ config_vars(
6d3098
 			} else
6d3098
 				stats_config(STATS_FREQ_FILE, curr_var->value.s);
6d3098
 			break;
6d3098
+		case T_Dscp:
6d3098
+			/* DSCP is in the upper 6 bits of the IP TOS/DS field */
6d3098
+			qos = curr_var->value.i << 2;
6d3098
+			break;
6d3098
 		case T_WanderThreshold:
6d3098
 			wander_threshold = curr_var->value.d;
6d3098
 			break;
6d3098
@@ -3737,7 +3738,6 @@ config_ntpd(
6d3098
 	)
6d3098
 {
6d3098
 	config_nic_rules(ptree);
6d3098
-	io_open_sockets();
6d3098
 	config_monitor(ptree);
6d3098
 	config_auth(ptree);
6d3098
 	config_tos(ptree);
6d3098
@@ -3750,6 +3750,9 @@ config_ntpd(
6d3098
 	config_ttl(ptree);
6d3098
 	config_trap(ptree);
6d3098
 	config_vars(ptree);
6d3098
+
6d3098
+	io_open_sockets();
6d3098
+
6d3098
 	config_other_modes(ptree);
6d3098
 	config_peers(ptree);
6d3098
 	config_unpeers(ptree);
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_io.c.dscp ntp-4.2.6p5/ntpd/ntp_io.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_io.c.dscp	2015-06-04 15:50:44.725240342 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_io.c	2015-06-04 15:57:54.209359075 +0200
6d3098
@@ -66,6 +66,9 @@
6d3098
 
6d3098
 extern int listen_to_virtual_ips;
6d3098
 
6d3098
+/* set IP_TOS/IPV6_TCLASS to minimize packet delay */
6d3098
+int qos = IPTOS_PREC_INTERNETCONTROL;
6d3098
+
6d3098
 /*
6d3098
  * NIC rule entry
6d3098
  */
6d3098
@@ -161,15 +164,6 @@ static int pktinfo_status = 0;		/* is IP
6d3098
 static	struct refclockio *refio;
6d3098
 #endif /* REFCLOCK */
6d3098
 
6d3098
-#if defined(HAVE_IPTOS_SUPPORT)
6d3098
-/* set IP_TOS to minimize packet delay */
6d3098
-# if defined(IPTOS_PREC_INTERNETCONTROL)
6d3098
-	unsigned int qos = IPTOS_PREC_INTERNETCONTROL;
6d3098
-# else
6d3098
-	 unsigned int qos = IPTOS_LOWDELAY;
6d3098
-# endif
6d3098
-#endif
6d3098
-
6d3098
 /*
6d3098
  * File descriptor masks etc. for call to select
6d3098
  * Not needed for I/O Completion Ports
6d3098
@@ -3034,6 +3028,13 @@ open_socket(
6d3098
 	 * IPv6 specific options go here
6d3098
 	 */
6d3098
 	if (IS_IPV6(addr)) {
6d3098
+#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS)
6d3098
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, (char*)&qos,
6d3098
+			       sizeof(qos)))
6d3098
+			msyslog(LOG_ERR,
6d3098
+				"setsockopt IPV6_TCLASS (%02x) fails on address %s: %m",
6d3098
+				qos, stoa(addr));
6d3098
+#endif /* IPPROTO_IPV6 && IPV6_TCLASS */
6d3098
 #ifdef IPV6_V6ONLY
6d3098
 		if (isc_net_probe_ipv6only() == ISC_R_SUCCESS
6d3098
 		    && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.dscp ntp-4.2.6p5/ntpd/ntp_parser.y
6d3098
--- ntp-4.2.6p5/ntpd/ntp_parser.y.dscp	2015-06-04 15:50:44.728240351 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_parser.y	2015-06-04 15:50:44.736240374 +0200
6d3098
@@ -94,6 +94,7 @@
6d3098
 %token	<Double>	T_Double
6d3098
 %token	<Integer>	T_Driftfile
6d3098
 %token	<Integer>	T_Drop
6d3098
+%token	<Integer>	T_Dscp
6d3098
 %token	<Integer>	T_Ellipsis	/* "..." not "ellipsis" */
6d3098
 %token	<Integer>	T_Enable
6d3098
 %token	<Integer>	T_End
6d3098
@@ -268,6 +269,7 @@
6d3098
 %type	<Attr_val>	log_config_command
6d3098
 %type	<Queue>		log_config_list
6d3098
 %type	<Integer>	misc_cmd_dbl_keyword
6d3098
+%type	<Integer>	misc_cmd_int_keyword
6d3098
 %type	<Integer>	misc_cmd_str_keyword
6d3098
 %type	<Integer>	misc_cmd_str_lcl_keyword
6d3098
 %type	<Integer>	nic_rule_class
6d3098
@@ -920,6 +922,13 @@ miscellaneous_command
6d3098
 			av = create_attr_dval($1, $2);
6d3098
 			enqueue(cfgt.vars, av);
6d3098
 		}
6d3098
+	|	misc_cmd_int_keyword T_Integer
6d3098
+		{
6d3098
+			struct attr_val *av;
6d3098
+
6d3098
+			av = create_attr_ival($1, $2);
6d3098
+			enqueue(cfgt.vars, av);
6d3098
+		}
6d3098
 	|	misc_cmd_str_keyword T_String
6d3098
 		{
6d3098
 			struct attr_val *av;
6d3098
@@ -990,6 +999,10 @@ misc_cmd_dbl_keyword
6d3098
 	|	T_Tick
6d3098
 	;
6d3098
 
6d3098
+misc_cmd_int_keyword
6d3098
+	:	T_Dscp
6d3098
+	;
6d3098
+
6d3098
 misc_cmd_str_keyword
6d3098
 	:	T_Leapfile
6d3098
 	|	T_Pidfile