From: Harlan Stenn Date: Fri, 14 Sep 2012 22:33:31 +0000 (-0400) Subject: [Bug 752] Use proper ToS network packet markings for IPv4 and IPv6 X-Git-Tag: NTP_4_2_7P305~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d9650fd06a19efba3b76c792e64834768a372c9;p=thirdparty%2Fntp.git [Bug 752] Use proper ToS network packet markings for IPv4 and IPv6 bk: 5053b0bbvALMnoXyfuWiIIyphWS8KQ --- diff --git a/ChangeLog b/ChangeLog index a5c216d36..fccaa4757 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 752] Use proper ToS network packet markings for IPv4 and IPv6. * [Bug 2271] Decode refclock types when built with --disable-all-clocks. (4.2.7p304) 2012/09/06 Released by Harlan Stenn * [Bug 2264] Cleanup SEL240X Refclock. diff --git a/configure.ac b/configure.ac index a0b1ead12..521a97dc8 100644 --- a/configure.ac +++ b/configure.ac @@ -265,33 +265,6 @@ AC_CHECK_HEADERS([net/route.h], [], [], [ #include ]) -# Check for IPTOS_PREC -AC_CACHE_CHECK( - [IPPROTO_IP IP_TOS IPTOS_LOWDELAY], - [ntp_cv_ip_tos], - [AC_EGREP_CPP( - [yes], - [ - #ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_NETINET_IP_H - # include - # include - #endif - #if defined(IPPROTO_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY) - yes - #endif - ], - [ntp_cv_ip_tos=yes], - [ntp_cv_ip_tos=no] - )] -) -case "$ntp_cv_ip_tos" in - yes) - AC_DEFINE([HAVE_IPTOS_SUPPORT], [1], [Do we have IPTOS support?]) -esac - AC_CHECK_HEADERS([netinfo/ni.h]) case "$ac_cv_header_netinfo_ni_h" in yes) diff --git a/include/libntp.h b/include/libntp.h index f20a03f0d..8d87c024f 100644 --- a/include/libntp.h +++ b/include/libntp.h @@ -12,7 +12,5 @@ #define GETDTABLESIZE() (FOPEN_MAX + FD_CHUNK) #endif -extern unsigned int qos; - extern void make_socket_nonblocking( SOCKET fd ); extern SOCKET move_fd( SOCKET fd ); diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 3836bdacf..099106467 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -189,9 +189,6 @@ int cryptosw; /* crypto command called */ extern int sys_maxclock; extern char *stats_drift_file; /* name of the driftfile */ extern char *leapseconds_file_name; /*name of the leapseconds file */ -#ifdef HAVE_IPTOS_SUPPORT -extern unsigned int qos; /* QoS setting */ -#endif /* HAVE_IPTOS_SUPPORT */ #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED /* @@ -228,7 +225,6 @@ static void free_config_tinker(config_tree *); static void free_config_system_opts(config_tree *); static void free_config_logconfig(config_tree *); static void free_config_phone(config_tree *); -static void free_config_qos(config_tree *); static void free_config_setvar(config_tree *); static void free_config_ttl(config_tree *); static void free_config_trap(config_tree *); @@ -313,7 +309,6 @@ static void config_other_modes(config_tree *); static void config_auth(config_tree *); static void config_access(config_tree *); static void config_phone(config_tree *); -static void config_qos(config_tree *); static void config_setvar(config_tree *); static void config_ttl(config_tree *); static void config_trap(config_tree *); @@ -430,7 +425,6 @@ free_config_tree( free_config_system_opts(ptree); free_config_logconfig(ptree); free_config_phone(ptree); - free_config_qos(ptree); free_config_setvar(ptree); free_config_ttl(ptree); free_config_trap(ptree); @@ -904,14 +898,6 @@ dump_config_tree( fprintf(df, "\n"); } - atrv = HEAD_PFIFO(ptree->qos); - if (atrv != NULL) { - fprintf(df, "qos"); - for (; atrv != NULL; atrv = atrv->link) - fprintf(df, " %s", atrv->value.s); - fprintf(df, "\n"); - } - setv_node = HEAD_PFIFO(ptree->setvar); for ( ; setv_node != NULL; setv_node = setv_node->link) { s1 = quote_if_needed(setv_node->var); @@ -2977,75 +2963,6 @@ free_config_phone( #endif /* FREE_CFG_T */ -#ifndef SIM -static void -config_qos( - config_tree *ptree - ) -{ - attr_val * my_qc; - char * s; -#ifdef HAVE_IPTOS_SUPPORT - unsigned int qtos = 0; -#endif - - my_qc = HEAD_PFIFO(ptree->qos); - for (; my_qc != NULL; my_qc = my_qc->link) { - s = my_qc->value.s; -#ifdef HAVE_IPTOS_SUPPORT - if (!strcmp(s, "lowdelay")) - qtos = CONF_QOS_LOWDELAY; - else if (!strcmp(s, "throughput")) - qtos = CONF_QOS_THROUGHPUT; - else if (!strcmp(s, "reliability")) - qtos = CONF_QOS_RELIABILITY; - else if (!strcmp(s, "mincost")) - qtos = CONF_QOS_MINCOST; -#ifdef IPTOS_PREC_INTERNETCONTROL - else if (!strcmp(s, "routine") || !strcmp(s, "cs0")) - qtos = CONF_QOS_CS0; - else if (!strcmp(s, "priority") || !strcmp(s, "cs1")) - qtos = CONF_QOS_CS1; - else if (!strcmp(s, "immediate") || !strcmp(s, "cs2")) - qtos = CONF_QOS_CS2; - else if (!strcmp(s, "flash") || !strcmp(s, "cs3")) - qtos = CONF_QOS_CS3; /* overlapping prefix on keyword */ - if (!strcmp(s, "flashoverride") || !strcmp(s, "cs4")) - qtos = CONF_QOS_CS4; - else if (!strcmp(s, "critical") || !strcmp(s, "cs5")) - qtos = CONF_QOS_CS5; - else if(!strcmp(s, "internetcontrol") || !strcmp(s, "cs6")) - qtos = CONF_QOS_CS6; - else if (!strcmp(s, "netcontrol") || !strcmp(s, "cs7")) - qtos = CONF_QOS_CS7; -#endif /* IPTOS_PREC_INTERNETCONTROL */ - if (qtos == 0) - msyslog(LOG_ERR, "parse error, qos %s not accepted\n", s); - else - qos = qtos; -#endif /* HAVE IPTOS_SUPPORT */ - /* - * value is set, but not being effective. Need code to - * change the current connections to notice. Might - * also consider logging a message about the action. - * XXX msyslog(LOG_INFO, "QoS %s requested by config\n", s); - */ - } -} -#endif /* !SIM */ - - -#ifdef FREE_CFG_T -static void -free_config_qos( - config_tree *ptree - ) -{ - FREE_ATTR_VAL_FIFO(ptree->qos); -} -#endif /* FREE_CFG_T */ - - #ifndef SIM static void config_setvar( @@ -4267,7 +4184,6 @@ config_ntpd( config_peers(ptree); config_unpeers(ptree); config_fudge(ptree); - config_qos(ptree); config_reset_counters(ptree); #ifdef TEST_BLOCKING_WORKER diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 79828edf9..edf3961ad 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -2756,6 +2756,11 @@ open_socket( int on = 1; int off = 0; +#ifndef IPTOS_DSCP_EF +#define IPTOS_DSCP_EF 0xb8 +#endif + int qos = IPTOS_DSCP_EF; /* QoS RFC3246 */ + if (IS_IPV6(addr) && !ipv6_works) return INVALID_SOCKET; @@ -2825,13 +2830,13 @@ open_socket( * IPv4 specific options go here */ if (IS_IPV4(addr)) { -#if defined(HAVE_IPTOS_SUPPORT) - if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char *)&qos, +#if defined(IPPROTO_IP) && defined(IP_TOS) + if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char*)&qos, sizeof(qos))) msyslog(LOG_ERR, "setsockopt IP_TOS (%02x) fails on address %s: %m", qos, stoa(addr)); -#endif /* HAVE_IPTOS_SUPPORT */ +#endif /* IPPROTO_IP && IP_TOS */ if (bcast) socket_broadcast_enable(interf, fd, addr); } @@ -2840,6 +2845,13 @@ open_socket( * IPv6 specific options go here */ if (IS_IPV6(addr)) { +#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) + if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, (char*)&qos, + sizeof(qos))) + msyslog(LOG_ERR, + "setsockopt IPV6_TCLASS (%02x) fails on address %s: %m", + qos, stoa(addr)); +#endif /* IPPROTO_IPV6 && IPV6_TCLASS */ #ifdef IPV6_V6ONLY if (isc_net_probe_ipv6only() == ISC_R_SUCCESS && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,