From: Dave Hart Date: Wed, 23 Dec 2009 11:01:44 +0000 (+0000) Subject: [Bug 1429] -4 command line option to ntpd does not reliably force IPv4 resolution X-Git-Tag: NTP_4_2_7P4~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aaebc48c272c4afe754ec8c47cde18067a37ce9;p=thirdparty%2Fntp.git [Bug 1429] -4 command line option to ntpd does not reliably force IPv4 resolution bk: 4b31f898YHtZqoxn5Lt3PCTkgJ6Vfw --- diff --git a/ChangeLog b/ChangeLog index 83fa2c107..c62b4e6c0 100644 --- 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 diff --git a/ntpd/cmd_args.c b/ntpd/cmd_args.c index 1047b8b7f..49a9b4652 100644 --- a/ntpd/cmd_args.c +++ b/ntpd/cmd_args.c @@ -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); diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 414dcabf1..650c38448 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -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, diff --git a/ntpd/ntp_scanner.h b/ntpd/ntp_scanner.h index b2e83bf3f..907d7c0ff 100644 --- a/ntpd/ntp_scanner.h +++ b/ntpd/ntp_scanner.h @@ -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[];