]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1429] -4 command line option to ntpd does not reliably force IPv4 resolution
authorDave Hart <hart@ntp.org>
Wed, 23 Dec 2009 11:01:44 +0000 (11:01 +0000)
committerDave Hart <hart@ntp.org>
Wed, 23 Dec 2009 11:01:44 +0000 (11:01 +0000)
bk: 4b31f898YHtZqoxn5Lt3PCTkgJ6Vfw

ChangeLog
ntpd/cmd_args.c
ntpd/ntp_config.c
ntpd/ntp_scanner.h

index 83fa2c1077f851aeb1296d85252813153de65c1e..c62b4e6c01ed923af792be31be10e38bdbf8b706 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
 * [Bug 1426] scripts/VersionName needs . on the search path.
 * [Bug 1427] quote missing in ./build - shows up on NetBSD.
 * [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h
+* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.
 
 ---
 (4.2.6p1-RC1) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>
index 1047b8b7f19ad46c47dc720a824f911625de1fc4..49a9b465269ef56718088fd6954ed632824b61ce 100644 (file)
@@ -16,7 +16,6 @@
  */
 extern char const *progname;
 extern const char *specific_interface;
-extern short default_ai_family;
 
 #ifdef HAVE_NETINFO
 extern int     check_netinfo;
@@ -41,10 +40,18 @@ getCmdOpts(
         */
        errflg = 0;
 
-       if (HAVE_OPT( IPV4 ))
-               default_ai_family = AF_INET;
-       else if (HAVE_OPT( IPV6 ))
-               default_ai_family = AF_INET6;
+       if (ipv4_works && ipv6_works) {
+               if (HAVE_OPT( IPV4 ))
+                       ipv6_works = 0;
+               else if (HAVE_OPT( IPV6 ))
+                       ipv4_works = 0;
+       } else if (!ipv4_works && !ipv6_works) {
+               msyslog(LOG_ERR, "Neither IPv4 nor IPv6 networking detected, fatal.");
+               exit(1);
+       } else if (HAVE_OPT( IPV4 ) && !ipv4_works)
+               msyslog(LOG_WARNING, "-4/--ipv4 ignored, IPv4 networking not found.");
+       else if (HAVE_OPT( IPV6 ) && !ipv6_works)
+               msyslog(LOG_WARNING, "-6/--ipv6 ignored, IPv6 networking not found.");
 
        if (HAVE_OPT( AUTHREQ ))
                proto_config(PROTO_AUTHENTICATE, 1, 0., NULL);
index 414dcabf1f5280ee78b4e1e805d17c52b139036d..650c3844827ce50fa4b158d3b29fdf7fa05cc424 100644 (file)
@@ -132,11 +132,6 @@ struct FILE_INFO *fp[MAXINCLUDELEVEL+1];
 FILE *res_fp;
 struct config_tree cfgt;               /* Parser output stored here */
 struct config_tree *cfg_tree_history = NULL;   /* History of configs */
-#if 0
-short default_ai_family = AF_UNSPEC;   /* Default either IPv4 or IPv6 */
-#else
-short default_ai_family = AF_INET;     /* [Bug 891]: FIX ME */
-#endif
 char   *sys_phone[MAXPHONE] = {NULL};  /* ACTS phone numbers */
 char   default_keysdir[] = NTP_KEYSDIR;
 char   *keysdir = default_keysdir;     /* crypto keys directory */
@@ -2945,10 +2940,9 @@ config_trap(
                        /* port is at same location for v4 and v6 */
                        SET_PORT(&peeraddr, port_no ? port_no : TRAPPORT);
 
-                       if (NULL == localaddr) {
-                               AF(&peeraddr) = default_ai_family;
+                       if (NULL == localaddr)
                                localaddr = ANY_INTERFACE_CHOOSE(&peeraddr);
-                       else
+                       else
                                AF(&peeraddr) = AF(&addr_sock);
 
                        if (!ctlsettrap(&peeraddr, localaddr, 0,
index b2e83bf3f860ecd42c2f5bf66aee1b1afdfaa8cf..907d7c0ff5c24511133e64e4295b9d5818e54eff 100644 (file)
@@ -111,7 +111,6 @@ extern struct FILE_INFO *ip_file; /* Pointer to the configuration file stream */
 /* VARIOUS EXTERNAL DECLARATIONS
  * -----------------------------
  */
-extern short default_ai_family;
 extern int old_config_style;
 extern int input_from_file;
 extern struct FILE_INFO *fp[];