From: Harlan Stenn Date: Thu, 25 Oct 2007 05:14:55 +0000 (-0400) Subject: [Bug 752] Update the QoS tagging (code only - configuration to follow) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20d0cd680e6a8e8445bdc6b2b5d5d2c34cfcbc33;p=thirdparty%2Fntp.git [Bug 752] Update the QoS tagging (code only - configuration to follow) bk: 4720264fmMShWjtrwJpGairh5M9Hdw --- diff --git a/ChangeLog b/ChangeLog index b53a8d4fdd..147fd78735 100644 --- 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. diff --git a/configure.ac b/configure.ac index dfc56f1cb8..acd46dd6f0 100644 --- a/configure.ac +++ b/configure.ac @@ -424,6 +424,24 @@ AC_CHECK_HEADERS(netinet/ip.h, [], [], #include #endif ]) + +# Check for IPTOS_PREC +AC_MSG_CHECKING(IPPROTO_IP IP_TOS IPTOS_LOWDELAY) +AC_EGREP_CPP(yes, + [#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_NETINET_IP_H +#include +#include +#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) diff --git a/include/ntp_io.h b/include/ntp_io.h index f616a9b9f7..39ae146650 100644 --- a/include/ntp_io.h +++ b/include/ntp_io.h @@ -32,6 +32,12 @@ #include #include + +#if HAVE_NETINET_IN_H && HAVE_NETINET_IP_H +#include +#include +#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 diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index c89d5786a9..0b51a48263 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -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); } /*