From: Michał Kępień Date: Tue, 8 Jan 2019 10:17:39 +0000 (+0100) Subject: Remove dead code handling address family mismatches for TCP sockets X-Git-Tag: v9.13.6~71^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef1da8731b7b176179ba5ca09ae884a524aadc98;p=thirdparty%2Fbind9.git Remove dead code handling address family mismatches for TCP sockets Before commit c2ec022f5784a2ff844f7d062c2022197dc4ad09, using the "-b" command line switch for dig did not disable use of the other address family than the one to which the address supplied to that option belonged to. Thus, bind9_getaddresses() could e.g. prepare an isc_sockaddr_t structure for an IPv6 address when an IPv4 address has been passed to the "-b" command line option. To avoid attempting the impossible (e.g. querying an IPv6 address from a socket bound to an IPv4 address), a certain code block in send_tcp_connect() checked whether the address family of the server to be queried was the same as the address family of the socket set up for sending that query; if there was a mismatch, that particular server address was skipped. Commit c2ec022f5784a2ff844f7d062c2022197dc4ad09 made bind9_getaddresses() fail upon an address family mismatch between the address the hostname passed to it resolved to and the address supplied to the "-b" command line option. Such failures were fatal to dig back then. Commit 7f658603910358db7ee27ffb9783096250afab62 made bind9_getaddresses() failures non-fatal, but also ensured that a get_address() failure in send_tcp_connect() still causes the given query address to be skipped (and also made such failures trigger an early return from send_tcp_connect()). Summing up, the code block handling address family mismatches in send_tcp_connect() has been redundant since commit c2ec022f5784a2ff844f7d062c2022197dc4ad09. Remove it. --- diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 2b6cab552e8..400fcaf34fe 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2730,27 +2730,6 @@ send_tcp_connect(dig_query_t *query) { return; } - if (specified_source && - (isc_sockaddr_pf(&query->sockaddr) != - isc_sockaddr_pf(&bind_address))) { - printf(";; Skipping server %s, incompatible " - "address family\n", query->servname); - query->waiting_connect = false; - if (ISC_LINK_LINKED(query, link)) - next = ISC_LIST_NEXT(query, link); - else - next = NULL; - l = query->lookup; - clear_query(query); - if (next == NULL) { - printf(";; No acceptable nameservers\n"); - check_next_lookup(l); - return; - } - send_tcp_connect(next); - return; - } - INSIST(query->sock == NULL); if (keep != NULL && isc_sockaddr_equal(&keepaddr, &query->sockaddr)) {