]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove the incomplete code for IPv6 pktinfo
authorOndřej Surý <ondrej@isc.org>
Tue, 20 Aug 2024 10:12:47 +0000 (12:12 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 27 Nov 2024 14:03:27 +0000 (15:03 +0100)
The code that listens on individual interfaces is now stable and doesn't
require any changes.  The code that would bind to IPv6 wildcard address
and then use IPv6 pktinfo structure to get the source address is not
going to be completed, so it's better to just remove the dead cruft.

lib/isc/include/isc/net.h
lib/isc/net.c
lib/ns/interfacemgr.c

index 7d04bfe6b07e48d49dc82d79be3f35878b8db1d4..7d7ad6b7e120c728fb51dd2ee48dcb91dc3194ce 100644 (file)
@@ -207,19 +207,6 @@ isc_net_probeipv6(void);
  *\li  #ISC_R_DISABLED         IPv6 is disabled.
  */
 
-isc_result_t
-isc_net_probe_ipv6pktinfo(void);
-/*
- * Check if the system's kernel supports the IPV6_(RECV)PKTINFO socket option
- * for UDP sockets.
- *
- * Returns:
- *
- * \li #ISC_R_SUCCESS          the option is supported.
- * \li #ISC_R_NOTFOUND         IPv6 itself or the option is not supported.
- * \li #ISC_R_UNEXPECTED
- */
-
 void
 isc_net_disableipv4(void);
 
index 90989e08f3017726b2adb324e50601283c1ef59b..8d65e1bb98989a6ab705da0837cc7ea3f5135c12 100644 (file)
 
 #endif /* HAVE_SYSCTLBYNAME */
 
-#ifdef __notyet__
-static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
-#endif /* ifdef __notyet__ */
-
 #ifndef ISC_CMSG_IP_TOS
 #ifdef __APPLE__
 #define ISC_CMSG_IP_TOS 0 /* As of 10.8.2. */
@@ -99,7 +95,6 @@ static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
 
 static isc_result_t ipv4_result = ISC_R_SUCCESS;
 static isc_result_t ipv6_result = ISC_R_SUCCESS;
-static isc_result_t ipv6pktinfo_result = ISC_R_NOTFOUND;
 
 isc_result_t
 isc_net_probeipv4(void) {
@@ -111,68 +106,6 @@ isc_net_probeipv6(void) {
        return ipv6_result;
 }
 
-#ifdef __notyet__
-static void
-try_ipv6pktinfo(void) {
-       int s, on;
-       isc_result_t result;
-       int optname;
-
-       result = isc_net_probeipv6();
-       if (result != ISC_R_SUCCESS) {
-               ipv6pktinfo_result = result;
-               return;
-       }
-
-       /* we only use this for UDP sockets */
-       s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
-       if (s == -1) {
-               UNEXPECTED_SYSERROR(errno, "socket()");
-               ipv6pktinfo_result = ISC_R_UNEXPECTED;
-               return;
-       }
-
-#ifdef IPV6_RECVPKTINFO
-       optname = IPV6_RECVPKTINFO;
-#else  /* ifdef IPV6_RECVPKTINFO */
-       optname = IPV6_PKTINFO;
-#endif /* ifdef IPV6_RECVPKTINFO */
-       on = 1;
-       if (setsockopt(s, IPPROTO_IPV6, optname, &on, sizeof(on)) < 0) {
-               ipv6pktinfo_result = ISC_R_NOTFOUND;
-               goto close;
-       }
-
-       ipv6pktinfo_result = ISC_R_SUCCESS;
-
-close:
-       close(s);
-       return;
-}
-
-static void
-initialize_ipv6pktinfo(void) {
-       isc_once_do(&once_ipv6pktinfo, try_ipv6pktinfo);
-}
-#endif /* ifdef __notyet__ */
-
-isc_result_t
-isc_net_probe_ipv6pktinfo(void) {
-/*
- * XXXWPK if pktinfo were supported then we could listen on :: for ipv6 and get
- * the information about the destination address from pktinfo structure passed
- * in recvmsg but this method is not portable and libuv doesn't support it - so
- * we need to listen on all interfaces.
- * We should verify that this doesn't impact performance (we already do it for
- * ipv4) and either remove all the ipv6pktinfo detection code from above
- * or think of fixing libuv.
- */
-#ifdef __notyet__
-       initialize_ipv6pktinfo();
-#endif /* ifdef __notyet__ */
-       return ipv6pktinfo_result;
-}
-
 #if defined(USE_SYSCTL_PORTRANGE)
 #if defined(HAVE_SYSCTLBYNAME)
 static isc_result_t
index 7902b1a0da934f77d70d88481fc9cb9b62aa641e..5569cf3029ed9bdb259552ffabf6535dd2ae38fa 100644 (file)
@@ -1085,11 +1085,9 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
        isc_interfaceiter_t *iter = NULL;
        bool scan_ipv4 = false;
        bool scan_ipv6 = false;
-       bool ipv6pktinfo = true;
        isc_result_t result;
        isc_netaddr_t zero_address, zero_address6;
        ns_listenelt_t *le = NULL;
-       isc_sockaddr_t listen_addr;
        ns_interface_t *ifp = NULL;
        bool log_explicit = false;
        bool dolistenon;
@@ -1115,60 +1113,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
                              "no IPv4 interfaces found");
        }
 
-       /*
-        * A special, but typical case; listen-on-v6 { any; }.
-        * When we can make the socket IPv6-only, open a single wildcard
-        * socket for IPv6 communication.  Otherwise, make separate
-        * socket for each IPv6 address in order to avoid accepting IPv4
-        * packets as the form of mapped addresses unintentionally
-        * unless explicitly allowed.
-        */
-       if (scan_ipv6 && isc_net_probe_ipv6pktinfo() != ISC_R_SUCCESS) {
-               ipv6pktinfo = false;
-               log_explicit = true;
-       }
-       if (scan_ipv6 && ipv6pktinfo) {
-               for (le = ISC_LIST_HEAD(mgr->listenon6->elts); le != NULL;
-                    le = ISC_LIST_NEXT(le, link))
-               {
-                       struct in6_addr in6a;
-
-                       if (!listenon_is_ip6_any(le)) {
-                               continue;
-                       }
-
-                       in6a = in6addr_any;
-                       isc_sockaddr_fromin6(&listen_addr, &in6a, le->port);
-
-                       ifp = find_matching_interface(mgr, &listen_addr);
-                       if (ifp != NULL) {
-                               bool cont = interface_update_or_shutdown(
-                                       mgr, ifp, le, config);
-                               if (cont) {
-                                       continue;
-                               }
-                       }
-
-                       isc_log_write(NS_LOGCATEGORY_NETWORK,
-                                     NS_LOGMODULE_INTERFACEMGR, ISC_LOG_INFO,
-                                     "listening on IPv6 "
-                                     "interfaces, port %u",
-                                     le->port);
-                       result = interface_setup(mgr, &listen_addr, "<any>",
-                                                &ifp, le, NULL);
-                       if (result == ISC_R_SUCCESS) {
-                               ifp->flags |= NS_INTERFACEFLAG_ANYADDR;
-                       } else {
-                               isc_log_write(NS_LOGCATEGORY_NETWORK,
-                                             NS_LOGMODULE_INTERFACEMGR,
-                                             ISC_LOG_ERROR,
-                                             "listening on all IPv6 "
-                                             "interfaces failed");
-                       }
-                       /* Continue. */
-               }
-       }
-
        isc_netaddr_any(&zero_address);
        isc_netaddr_any6(&zero_address6);
 
@@ -1248,7 +1192,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
                {
                        int match;
                        bool addr_in_use = false;
-                       bool ipv6_wildcard = false;
                        isc_sockaddr_t listen_sockaddr;
 
                        isc_sockaddr_fromnetaddr(&listen_sockaddr,
@@ -1274,16 +1217,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
                                dolistenon = false;
                        }
 
-                       /*
-                        * The case of "any" IPv6 address will require
-                        * special considerations later, so remember it.
-                        */
-                       if (family == AF_INET6 && ipv6pktinfo &&
-                           listenon_is_ip6_any(le))
-                       {
-                               ipv6_wildcard = true;
-                       }
-
                        ifp = find_matching_interface(mgr, &listen_sockaddr);
                        if (ifp != NULL) {
                                bool cont = interface_update_or_shutdown(
@@ -1293,10 +1226,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
                                }
                        }
 
-                       if (ipv6_wildcard) {
-                               continue;
-                       }
-
                        if (log_explicit && family == AF_INET6 &&
                            listenon_is_ip6_any(le))
                        {