]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 752] Update the QoS tagging (code only - configuration to follow)
authorHarlan Stenn <stenn@ntp.org>
Thu, 25 Oct 2007 05:14:55 +0000 (01:14 -0400)
committerHarlan Stenn <stenn@ntp.org>
Thu, 25 Oct 2007 05:14:55 +0000 (01:14 -0400)
bk: 4720264fmMShWjtrwJpGairh5M9Hdw

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

index b53a8d4fdd4ffd276fc8d9778c6e1defd746077c..147fd787355eba57967421cd8d2c53dbae6f7848 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 752] Update the QoS tagging (code only - configuration to follow).
 * Orphan mode and other protocol cleanup from Dave Mills.
 * Documentation cleanup from Dave Mills.
 * [Bug 940] ntp-keygen uses -v.  Disallow it as a shortcut for --version.
index dfc56f1cb8e8841d101aa95419a5dfb802287407..acd46dd6f0a8cad0157e1827bdb439817ff4d6df 100644 (file)
@@ -424,6 +424,24 @@ AC_CHECK_HEADERS(netinet/ip.h, [], [],
 #include <netinet/in_systm.h>
 #endif
 ])
+
+# Check for IPTOS_PREC
+AC_MSG_CHECKING(IPPROTO_IP IP_TOS IPTOS_LOWDELAY)
+AC_EGREP_CPP(yes,
+    [#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if 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
+    ],
+    [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_IPTOS_SUPPORT, 1, [Do we have IPTOS support?])],
+    [AC_MSG_RESULT([no])])
+
 AC_CHECK_HEADERS(netinfo/ni.h, [AC_DEFINE(HAVE_NETINFO, 1, [NetInfo support?])])
 AC_CHECK_HEADERS(sun/audioio.h sys/audioio.h)
 dnl AC_CHECK_HEADERS(sys/chudefs.h)
index f616a9b9f7cc863f929643b005dd6c04e43d8829..39ae1466502c74fa6ee8ece1ef0dd6a3879dd0ee 100644 (file)
 
 #include <isc/boolean.h>
 #include <isc/netaddr.h>
+
+#if HAVE_NETINET_IN_H && HAVE_NETINET_IP_H
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#endif
+
 /*
  * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
  * to (and can).  This is here initially for QNX, but may help for
index c89d5786a9810d094b30abd1eb5ddbc8b2f85038..0b51a482631370f0edc645ad863cf6d88253cdd8 100644 (file)
@@ -169,6 +169,14 @@ volatile int disable_dynamic_updates;   /* when set to != 0 dynamic updates won'
 static struct refclockio *refio;
 #endif /* REFCLOCK */
 
+#if defined(HAVE_IPTOS_SUPPORT)
+/* set IP_TOS to minimize packet delay */
+# if defined(IPTOS_PREC_INTERNETCONTROL)
+const int tos = IPTOS_PREC_INTERNETCONTROL;
+# else
+const int tos = IPTOS_LOWDELAY;
+# endif
+#endif
 
 /*
  * Define what the possible "soft" errors can be.  These are non-fatal returns
@@ -2450,9 +2458,6 @@ open_socket(
        SOCKET fd;
        int on = 1, off = 0;    /* int is OK for REUSEADR per */
                                /* http://www.kohala.com/start/mcast.api.txt */
-#if defined(IPTOS_LOWDELAY) && defined(IPPROTO_IP) && defined(IP_TOS)
-       int tos;
-#endif /* IPTOS_LOWDELAY && IPPROTO_IP && IP_TOS */
 
        if ((addr->ss_family == AF_INET6) && (isc_net_probeipv6() != ISC_R_SUCCESS))
                return (INVALID_SOCKET);
@@ -2515,17 +2520,16 @@ open_socket(
         * IPv4 specific options go here
         */
        if (addr->ss_family == AF_INET) {
-#if defined(IPTOS_LOWDELAY) && defined(IPPROTO_IP) && defined(IP_TOS)
-       /* set IP_TOS to minimize packet delay */
-               tos = IPTOS_LOWDELAY;
-               if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos)) < 0)
-               {
-                       netsyslog(LOG_ERR, "setsockopt IPTOS_LOWDELAY on fails on address %s: %m",
-                               stoa(addr));
-               }
-#endif /* IPTOS_LOWDELAY && IPPROTO_IP && IP_TOS */
-       if ((flags & INT_BROADCAST))
-               socket_broadcast_enable(interf, fd, addr);
+#if defined(HAVE_IPTOS_SUPPORT)
+               if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char *) &tos,
+                   sizeof(tos)) < 0) {
+                       netsyslog(LOG_ERR,
+                           "setsockopt IP_TOS (%02x) fails on address %s: %m",
+                           tos, stoa(addr));
+               }
+#endif /* HAVE_IPTOS_SUPPORT */
+               if ((flags & INT_BROADCAST))
+                       socket_broadcast_enable(interf, fd, addr);
        }
 
        /*