]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 752] Use proper ToS network packet markings for IPv4 and IPv6
authorHarlan Stenn <stenn@ntp.org>
Fri, 14 Sep 2012 22:33:31 +0000 (18:33 -0400)
committerHarlan Stenn <stenn@ntp.org>
Fri, 14 Sep 2012 22:33:31 +0000 (18:33 -0400)
bk: 5053b0bbvALMnoXyfuWiIIyphWS8KQ

ChangeLog
configure.ac
include/libntp.h
ntpd/ntp_config.c
ntpd/ntp_io.c

index a5c216d36de771e72d47eb8dcf1e5d72fb0a9d6d..fccaa475763365de834a0ab7481ec98e8b63d3a1 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 2264] Cleanup SEL240X Refclock.
index a0b1ead124fa34218e16d5bd85adbca043a82930..521a97dc8d78512421979f1ec9553b0bd5930c91 100644 (file)
@@ -265,33 +265,6 @@ AC_CHECK_HEADERS([net/route.h], [], [], [
     #include <net/if.h>
 ])
 
-# 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 <sys/types.h>
-           #endif
-           #ifdef HAVE_NETINET_IP_H
-           # include <netinet/in.h>
-           # include <netinet/ip.h>
-           #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)
index f20a03f0de785dfc015e006e5e7250c5655ba3f8..8d87c024f42ec608dd02c81f37d5382da70218b4 100644 (file)
@@ -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 );
index 3836bdacf6f6444955a84fc48bd9cc81876600aa..0991064674027eda148cc6a862fb3b8ed4799eb5 100644 (file)
@@ -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
index 79828edf924cb90313a7997fe789602a800fd775..edf3961ad93b311f6d13eee7aece6cc76aa418fe 100644 (file)
@@ -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,