Blame SOURCES/ntp-4.2.6p5-dscp.patch

6e16f6
diff -up ntp-4.2.6p5/html/miscopt.html.dscp ntp-4.2.6p5/html/miscopt.html
6e16f6
--- ntp-4.2.6p5/html/miscopt.html.dscp	2015-06-04 15:50:44.726240345 +0200
6e16f6
+++ ntp-4.2.6p5/html/miscopt.html	2015-06-04 15:50:44.734240368 +0200
6e16f6
@@ -132,6 +132,8 @@
6e16f6
 				
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.
6e16f6
 			
<tt>ttl hop ...</tt>
6e16f6
 			
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.
6e16f6
+			
<tt>dscp dscp</tt>
6e16f6
+			
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).
6e16f6
 		
6e16f6
 		
6e16f6
 		<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
6e16f6
diff -up ntp-4.2.6p5/include/ntp_io.h.dscp ntp-4.2.6p5/include/ntp_io.h
6e16f6
--- ntp-4.2.6p5/include/ntp_io.h.dscp	2010-12-25 10:40:34.000000000 +0100
6e16f6
+++ ntp-4.2.6p5/include/ntp_io.h	2015-06-04 15:50:44.734240368 +0200
6e16f6
@@ -80,6 +80,7 @@ typedef enum {
6e16f6
 } nic_rule_action;
6e16f6
 
6e16f6
 
6e16f6
+extern int	qos;
6e16f6
 isc_boolean_t	get_broadcastclient_flag(void);
6e16f6
 extern int	is_ip_address(const char *, sockaddr_u *);
6e16f6
 extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
6e16f6
diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.dscp ntp-4.2.6p5/ntpd/keyword-gen.c
6e16f6
--- ntp-4.2.6p5/ntpd/keyword-gen.c.dscp	2015-06-04 15:50:44.727240348 +0200
6e16f6
+++ ntp-4.2.6p5/ntpd/keyword-gen.c	2015-06-04 15:50:44.734240368 +0200
6e16f6
@@ -38,6 +38,7 @@ struct key_tok ntp_keywords[] = {
6e16f6
 { "calldelay",		T_Calldelay,		FOLLBY_TOKEN },
6e16f6
 { "disable",		T_Disable,		FOLLBY_TOKEN },
6e16f6
 { "driftfile",		T_Driftfile,		FOLLBY_STRING },
6e16f6
+{ "dscp",		T_Dscp,			FOLLBY_TOKEN },
6e16f6
 { "enable",		T_Enable,		FOLLBY_TOKEN },
6e16f6
 { "end",		T_End,			FOLLBY_TOKEN },
6e16f6
 { "filegen",		T_Filegen,		FOLLBY_TOKEN },
6e16f6
diff -up ntp-4.2.6p5/ntpd/ntp_config.c.dscp ntp-4.2.6p5/ntpd/ntp_config.c
6e16f6
--- ntp-4.2.6p5/ntpd/ntp_config.c.dscp	2015-06-04 15:50:44.728240351 +0200
6e16f6
+++ ntp-4.2.6p5/ntpd/ntp_config.c	2015-06-04 15:50:44.735240371 +0200
6e16f6
@@ -204,9 +204,6 @@ int	cryptosw;		/* crypto command called
6e16f6
 extern int sys_maxclock;
6e16f6
 extern char *stats_drift_file;	/* name of the driftfile */
6e16f6
 extern char *leapseconds_file_name; /*name of the leapseconds file */
6e16f6
-#ifdef HAVE_IPTOS_SUPPORT
6e16f6
-extern unsigned int qos;				/* QoS setting */
6e16f6
-#endif /* HAVE_IPTOS_SUPPORT */
6e16f6
 
6e16f6
 #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED
6e16f6
 /*
6e16f6
@@ -3201,6 +3198,10 @@ config_vars(
6e16f6
 			} else
6e16f6
 				stats_config(STATS_FREQ_FILE, curr_var->value.s);
6e16f6
 			break;
6e16f6
+		case T_Dscp:
6e16f6
+			/* DSCP is in the upper 6 bits of the IP TOS/DS field */
6e16f6
+			qos = curr_var->value.i << 2;
6e16f6
+			break;
6e16f6
 		case T_WanderThreshold:
6e16f6
 			wander_threshold = curr_var->value.d;
6e16f6
 			break;
6e16f6
@@ -3737,7 +3738,6 @@ config_ntpd(
6e16f6
 	)
6e16f6
 {
6e16f6
 	config_nic_rules(ptree);
6e16f6
-	io_open_sockets();
6e16f6
 	config_monitor(ptree);
6e16f6
 	config_auth(ptree);
6e16f6
 	config_tos(ptree);
6e16f6
@@ -3750,6 +3750,9 @@ config_ntpd(
6e16f6
 	config_ttl(ptree);
6e16f6
 	config_trap(ptree);
6e16f6
 	config_vars(ptree);
6e16f6
+
6e16f6
+	io_open_sockets();
6e16f6
+
6e16f6
 	config_other_modes(ptree);
6e16f6
 	config_peers(ptree);
6e16f6
 	config_unpeers(ptree);
6e16f6
diff -up ntp-4.2.6p5/ntpd/ntp_io.c.dscp ntp-4.2.6p5/ntpd/ntp_io.c
6e16f6
--- ntp-4.2.6p5/ntpd/ntp_io.c.dscp	2015-06-04 15:50:44.725240342 +0200
6e16f6
+++ ntp-4.2.6p5/ntpd/ntp_io.c	2015-06-04 15:57:54.209359075 +0200
6e16f6
@@ -66,6 +66,9 @@
6e16f6
 
6e16f6
 extern int listen_to_virtual_ips;
6e16f6
 
6e16f6
+/* set IP_TOS/IPV6_TCLASS to minimize packet delay */
6e16f6
+int qos = IPTOS_PREC_INTERNETCONTROL;
6e16f6
+
6e16f6
 /*
6e16f6
  * NIC rule entry
6e16f6
  */
6e16f6
@@ -161,15 +164,6 @@ static int pktinfo_status = 0;		/* is IP
6e16f6
 static	struct refclockio *refio;
6e16f6
 #endif /* REFCLOCK */
6e16f6
 
6e16f6
-#if defined(HAVE_IPTOS_SUPPORT)
6e16f6
-/* set IP_TOS to minimize packet delay */
6e16f6
-# if defined(IPTOS_PREC_INTERNETCONTROL)
6e16f6
-	unsigned int qos = IPTOS_PREC_INTERNETCONTROL;
6e16f6
-# else
6e16f6
-	 unsigned int qos = IPTOS_LOWDELAY;
6e16f6
-# endif
6e16f6
-#endif
6e16f6
-
6e16f6
 /*
6e16f6
  * File descriptor masks etc. for call to select
6e16f6
  * Not needed for I/O Completion Ports
6e16f6
@@ -3034,6 +3028,13 @@ open_socket(
6e16f6
 	 * IPv6 specific options go here
6e16f6
 	 */
6e16f6
 	if (IS_IPV6(addr)) {
6e16f6
+#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS)
6e16f6
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, (char*)&qos,
6e16f6
+			       sizeof(qos)))
6e16f6
+			msyslog(LOG_ERR,
6e16f6
+				"setsockopt IPV6_TCLASS (%02x) fails on address %s: %m",
6e16f6
+				qos, stoa(addr));
6e16f6
+#endif /* IPPROTO_IPV6 && IPV6_TCLASS */
6e16f6
 #ifdef IPV6_V6ONLY
6e16f6
 		if (isc_net_probe_ipv6only() == ISC_R_SUCCESS
6e16f6
 		    && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,
6e16f6
diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.dscp ntp-4.2.6p5/ntpd/ntp_parser.y
6e16f6
--- ntp-4.2.6p5/ntpd/ntp_parser.y.dscp	2015-06-04 15:50:44.728240351 +0200
6e16f6
+++ ntp-4.2.6p5/ntpd/ntp_parser.y	2015-06-04 15:50:44.736240374 +0200
6e16f6
@@ -94,6 +94,7 @@
6e16f6
 %token	<Double>	T_Double
6e16f6
 %token	<Integer>	T_Driftfile
6e16f6
 %token	<Integer>	T_Drop
6e16f6
+%token	<Integer>	T_Dscp
6e16f6
 %token	<Integer>	T_Ellipsis	/* "..." not "ellipsis" */
6e16f6
 %token	<Integer>	T_Enable
6e16f6
 %token	<Integer>	T_End
6e16f6
@@ -268,6 +269,7 @@
6e16f6
 %type	<Attr_val>	log_config_command
6e16f6
 %type	<Queue>		log_config_list
6e16f6
 %type	<Integer>	misc_cmd_dbl_keyword
6e16f6
+%type	<Integer>	misc_cmd_int_keyword
6e16f6
 %type	<Integer>	misc_cmd_str_keyword
6e16f6
 %type	<Integer>	misc_cmd_str_lcl_keyword
6e16f6
 %type	<Integer>	nic_rule_class
6e16f6
@@ -920,6 +922,13 @@ miscellaneous_command
6e16f6
 			av = create_attr_dval($1, $2);
6e16f6
 			enqueue(cfgt.vars, av);
6e16f6
 		}
6e16f6
+	|	misc_cmd_int_keyword T_Integer
6e16f6
+		{
6e16f6
+			struct attr_val *av;
6e16f6
+
6e16f6
+			av = create_attr_ival($1, $2);
6e16f6
+			enqueue(cfgt.vars, av);
6e16f6
+		}
6e16f6
 	|	misc_cmd_str_keyword T_String
6e16f6
 		{
6e16f6
 			struct attr_val *av;
6e16f6
@@ -990,6 +999,10 @@ misc_cmd_dbl_keyword
6e16f6
 	|	T_Tick
6e16f6
 	;
6e16f6
 
6e16f6
+misc_cmd_int_keyword
6e16f6
+	:	T_Dscp
6e16f6
+	;
6e16f6
+
6e16f6
 misc_cmd_str_keyword
6e16f6
 	:	T_Leapfile
6e16f6
 	|	T_Pidfile