On Sun, Aug 14, 2022 at 10:03 AM Thomas Munro <thomas.mu...@gmail.com> wrote: > All green on CI... Next stop, build farm.
All good so far (except for an admonishment from crake, for which my penance was to fix headerscheck, see separate thread...). I did figure out one thing that I mentioned I was confused by before: the reason Windows didn't like my direct calls to gai_strerror() is because another header of ours clobbered one of Windows' own macros. This new batch includes a fix for that. Remove configure probe for IPv6. Remove dead ifaddrs.c fallback code. Remove configure probe for net/if.h. Fix macro problem with gai_strerror on Windows. Remove configure probe for netinet/tcp.h. mstcpip.h is not missing on MinGW. The interesting one is a continuation of my "all computers have X" series. This episode: IPv6.
From cd6ba7f0b275a5c2840ee93849a54b94e40a6450 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 14:47:58 +1200 Subject: [PATCH 1/6] Remove configure probe for IPv6. SUSv3 requires <netinet/in.h> to define struct sockaddr_in6, and all targeted Unix systems have it. Windows has it in ws2ipdef.h. Remove the configure probe, the macro and a small amount of dead code. Also remove a mention of IPv6-less builds from the documentation, since there aren't any. --- configure | 10 ---------- configure.ac | 6 ------ doc/src/sgml/client-auth.sgml | 2 -- src/backend/libpq/auth.c | 21 --------------------- src/backend/libpq/hba.c | 5 ----- src/backend/libpq/ifaddr.c | 29 +---------------------------- src/backend/libpq/pqcomm.c | 2 -- src/backend/utils/adt/network.c | 10 ---------- src/backend/utils/adt/pgstatfuncs.c | 11 ++--------- src/bin/initdb/initdb.c | 10 ---------- src/include/pg_config.h.in | 3 --- src/interfaces/libpq/fe-connect.c | 2 -- src/tools/ifaddrs/test_ifaddrs.c | 2 -- src/tools/msvc/Solution.pm | 1 - 14 files changed, 3 insertions(+), 111 deletions(-) diff --git a/configure b/configure index 176e0f9b00..8178f290a9 100755 --- a/configure +++ b/configure @@ -16279,16 +16279,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "$ac_includes_default -#include <netinet/in.h> -" -if test "x$ac_cv_type_struct_sockaddr_in6" = xyes; then : - -$as_echo "#define HAVE_IPV6 1" >>confdefs.h - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PS_STRINGS" >&5 $as_echo_n "checking for PS_STRINGS... " >&6; } if ${pgac_cv_var_PS_STRINGS+:} false; then : diff --git a/configure.ac b/configure.ac index eed7019c4a..ee45d856c7 100644 --- a/configure.ac +++ b/configure.ac @@ -1804,12 +1804,6 @@ AC_CHECK_DECLS([pwritev], [], [AC_LIBOBJ(pwritev)], [#include <sys/uio.h>]) # This is probably only present on macOS, but may as well check always AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>]) -AC_CHECK_TYPE([struct sockaddr_in6], - [AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])], - [], -[$ac_includes_default -#include <netinet/in.h>]) - AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS], [AC_LINK_IFELSE([AC_LANG_PROGRAM( [#include <machine/vmparam.h> diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml index 433759928b..c6f1b70fd3 100644 --- a/doc/src/sgml/client-auth.sgml +++ b/doc/src/sgml/client-auth.sgml @@ -305,8 +305,6 @@ hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceabl An entry given in IPv4 format will match only IPv4 connections, and an entry given in IPv6 format will match only IPv6 connections, even if the represented address is in the IPv4-in-IPv6 range. - Note that entries in IPv6 format will be rejected if the system's - C library does not have support for IPv6 addresses. </para> <para> diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 290eb17325..7760d714a0 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -3014,13 +3014,8 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por int packetlength; pgsocket sock; -#ifdef HAVE_IPV6 struct sockaddr_in6 localaddr; struct sockaddr_in6 remoteaddr; -#else - struct sockaddr_in localaddr; - struct sockaddr_in remoteaddr; -#endif struct addrinfo hint; struct addrinfo *serveraddrs; int port; @@ -3130,18 +3125,12 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por } memset(&localaddr, 0, sizeof(localaddr)); -#ifdef HAVE_IPV6 localaddr.sin6_family = serveraddrs[0].ai_family; localaddr.sin6_addr = in6addr_any; if (localaddr.sin6_family == AF_INET6) addrsize = sizeof(struct sockaddr_in6); else addrsize = sizeof(struct sockaddr_in); -#else - localaddr.sin_family = serveraddrs[0].ai_family; - localaddr.sin_addr.s_addr = INADDR_ANY; - addrsize = sizeof(struct sockaddr_in); -#endif if (bind(sock, (struct sockaddr *) &localaddr, addrsize)) { @@ -3244,21 +3233,11 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por return STATUS_ERROR; } -#ifdef HAVE_IPV6 if (remoteaddr.sin6_port != pg_hton16(port)) -#else - if (remoteaddr.sin_port != pg_hton16(port)) -#endif { -#ifdef HAVE_IPV6 ereport(LOG, (errmsg("RADIUS response from %s was sent from incorrect port: %d", server, pg_ntoh16(remoteaddr.sin6_port)))); -#else - ereport(LOG, - (errmsg("RADIUS response from %s was sent from incorrect port: %d", - server, pg_ntoh16(remoteaddr.sin_port)))); -#endif continue; } diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 857b9e5eb2..3be94244f5 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -645,8 +645,6 @@ ipv4eq(struct sockaddr_in *a, struct sockaddr_in *b) return (a->sin_addr.s_addr == b->sin_addr.s_addr); } -#ifdef HAVE_IPV6 - static bool ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b) { @@ -658,7 +656,6 @@ ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b) return true; } -#endif /* HAVE_IPV6 */ /* * Check whether host name matches pattern. @@ -747,7 +744,6 @@ check_hostname(hbaPort *port, const char *hostname) break; } } -#ifdef HAVE_IPV6 else if (gai->ai_addr->sa_family == AF_INET6) { if (ipv6eq((struct sockaddr_in6 *) gai->ai_addr, @@ -757,7 +753,6 @@ check_hostname(hbaPort *port, const char *hostname) break; } } -#endif } } diff --git a/src/backend/libpq/ifaddr.c b/src/backend/libpq/ifaddr.c index 5494c9b303..cb1645bc57 100644 --- a/src/backend/libpq/ifaddr.c +++ b/src/backend/libpq/ifaddr.c @@ -36,11 +36,9 @@ static int range_sockaddr_AF_INET(const struct sockaddr_in *addr, const struct sockaddr_in *netaddr, const struct sockaddr_in *netmask); -#ifdef HAVE_IPV6 static int range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr, const struct sockaddr_in6 *netaddr, const struct sockaddr_in6 *netmask); -#endif /* @@ -58,12 +56,10 @@ pg_range_sockaddr(const struct sockaddr_storage *addr, return range_sockaddr_AF_INET((const struct sockaddr_in *) addr, (const struct sockaddr_in *) netaddr, (const struct sockaddr_in *) netmask); -#ifdef HAVE_IPV6 else if (addr->ss_family == AF_INET6) return range_sockaddr_AF_INET6((const struct sockaddr_in6 *) addr, (const struct sockaddr_in6 *) netaddr, (const struct sockaddr_in6 *) netmask); -#endif else return 0; } @@ -80,9 +76,6 @@ range_sockaddr_AF_INET(const struct sockaddr_in *addr, return 0; } - -#ifdef HAVE_IPV6 - static int range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr, const struct sockaddr_in6 *netaddr, @@ -99,7 +92,6 @@ range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr, return 1; } -#endif /* HAVE_IPV6 */ /* * pg_sockaddr_cidr_mask - make a network mask of the appropriate family @@ -149,7 +141,6 @@ pg_sockaddr_cidr_mask(struct sockaddr_storage *mask, char *numbits, int family) break; } -#ifdef HAVE_IPV6 case AF_INET6: { struct sockaddr_in6 mask6; @@ -174,7 +165,7 @@ pg_sockaddr_cidr_mask(struct sockaddr_storage *mask, char *numbits, int family) memcpy(mask, &mask6, sizeof(mask6)); break; } -#endif + default: return -1; } @@ -209,13 +200,11 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data, if (((struct sockaddr_in *) mask)->sin_addr.s_addr == INADDR_ANY) mask = NULL; } -#ifdef HAVE_IPV6 else if (mask->sa_family == AF_INET6) { if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *) mask)->sin6_addr)) mask = NULL; } -#endif } /* If mask is invalid, generate our own fully-set mask */ @@ -358,10 +347,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) size_t n_buffer = 1024; pgsocket sock, fd; - -#ifdef HAVE_IPV6 pgsocket sock6; -#endif int i, total; @@ -404,7 +390,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) break; } -#ifdef HAVE_IPV6 /* We'll need an IPv6 socket too for the SIOCGLIFNETMASK ioctls */ sock6 = socket(AF_INET6, SOCK_DGRAM, 0); if (sock6 == PGINVALID_SOCKET) @@ -413,7 +398,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) close(sock); return -1; } -#endif total = lifc.lifc_len / sizeof(struct lifreq); lifr = lifc.lifc_req; @@ -421,11 +405,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { addr = (struct sockaddr *) &lifr[i].lifr_addr; memcpy(&lmask, &lifr[i], sizeof(struct lifreq)); -#ifdef HAVE_IPV6 fd = (addr->sa_family == AF_INET6) ? sock6 : sock; -#else - fd = sock; -#endif if (ioctl(fd, SIOCGLIFNETMASK, &lmask) < 0) mask = NULL; else @@ -435,9 +415,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) free(buffer); close(sock); -#ifdef HAVE_IPV6 close(sock6); -#endif return 0; } #elif defined(SIOCGIFCONF) @@ -554,10 +532,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) { struct sockaddr_in addr; struct sockaddr_storage mask; - -#ifdef HAVE_IPV6 struct sockaddr_in6 addr6; -#endif /* addr 127.0.0.1/8 */ memset(&addr, 0, sizeof(addr)); @@ -569,7 +544,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) (struct sockaddr *) &addr, (struct sockaddr *) &mask); -#ifdef HAVE_IPV6 /* addr ::1/128 */ memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; @@ -579,7 +553,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) run_ifaddr_callback(callback, cb_data, (struct sockaddr *) &addr6, (struct sockaddr *) &mask); -#endif return 0; } diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 3ec4328613..f7ba2fc5f5 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -415,11 +415,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber, case AF_INET: familyDesc = _("IPv4"); break; -#ifdef HAVE_IPV6 case AF_INET6: familyDesc = _("IPv6"); break; -#endif case AF_UNIX: familyDesc = _("Unix"); break; diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index ea1c7390d0..6d580ea78f 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -1725,9 +1725,7 @@ inet_client_addr(PG_FUNCTION_ARGS) switch (port->raddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; default: PG_RETURN_NULL(); @@ -1764,9 +1762,7 @@ inet_client_port(PG_FUNCTION_ARGS) switch (port->raddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; default: PG_RETURN_NULL(); @@ -1801,9 +1797,7 @@ inet_server_addr(PG_FUNCTION_ARGS) switch (port->laddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; default: PG_RETURN_NULL(); @@ -1840,9 +1834,7 @@ inet_server_port(PG_FUNCTION_ARGS) switch (port->laddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; default: PG_RETURN_NULL(); @@ -2102,7 +2094,6 @@ inetmi(PG_FUNCTION_ARGS) void clean_ipv6_addr(int addr_family, char *addr) { -#ifdef HAVE_IPV6 if (addr_family == AF_INET6) { char *pct = strchr(addr, '%'); @@ -2110,5 +2101,4 @@ clean_ipv6_addr(int addr_family, char *addr) if (pct) *pct = '\0'; } -#endif } diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index d9e2a79382..4cca30aae7 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -735,11 +735,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS) } else { - if (beentry->st_clientaddr.addr.ss_family == AF_INET -#ifdef HAVE_IPV6 - || beentry->st_clientaddr.addr.ss_family == AF_INET6 -#endif - ) + if (beentry->st_clientaddr.addr.ss_family == AF_INET || + beentry->st_clientaddr.addr.ss_family == AF_INET6) { char remote_host[NI_MAXHOST]; char remote_port[NI_MAXSERV]; @@ -1105,9 +1102,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS) switch (beentry->st_clientaddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; default: PG_RETURN_NULL(); @@ -1152,9 +1147,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS) switch (beentry->st_clientaddr.addr.ss_family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif break; case AF_UNIX: PG_RETURN_INT32(-1); diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index a779153c74..29c28b7315 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1176,7 +1176,6 @@ setup_config(void) conflines = replace_token(conflines, "@remove-line-for-nolocal@", ""); -#ifdef HAVE_IPV6 /* * Probe to see if there is really any platform support for IPv6, and @@ -1218,15 +1217,6 @@ setup_config(void) "#host replication all ::1"); } } -#else /* !HAVE_IPV6 */ - /* If we didn't compile IPV6 support at all, always comment it out */ - conflines = replace_token(conflines, - "host all all ::1", - "#host all all ::1"); - conflines = replace_token(conflines, - "host replication all ::1", - "#host replication all ::1"); -#endif /* HAVE_IPV6 */ /* Replace default authentication methods */ conflines = replace_token(conflines, diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 3087883401..2bc962ca2f 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -241,9 +241,6 @@ /* Define to 1 if you have the global variable 'int timezone'. */ #undef HAVE_INT_TIMEZONE -/* Define to 1 if you have support for IPv6. */ -#undef HAVE_IPV6 - /* Define to 1 if __builtin_constant_p(x) implies "i"(x) acceptance. */ #undef HAVE_I_CONSTRAINT__BUILTIN_CONSTANT_P diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 1e057db336..0dcce48888 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -1656,7 +1656,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len) host_addr, host_addr_len) == NULL) host_addr[0] = '\0'; } -#ifdef HAVE_IPV6 else if (addr->ss_family == AF_INET6) { if (pg_inet_net_ntop(AF_INET6, @@ -1665,7 +1664,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len) host_addr, host_addr_len) == NULL) host_addr[0] = '\0'; } -#endif else host_addr[0] = '\0'; } diff --git a/src/tools/ifaddrs/test_ifaddrs.c b/src/tools/ifaddrs/test_ifaddrs.c index b8dbb84945..b9a1b7b5e8 100644 --- a/src/tools/ifaddrs/test_ifaddrs.c +++ b/src/tools/ifaddrs/test_ifaddrs.c @@ -26,11 +26,9 @@ print_addr(struct sockaddr *addr) case AF_INET: len = sizeof(struct sockaddr_in); break; -#ifdef HAVE_IPV6 case AF_INET6: len = sizeof(struct sockaddr_in6); break; -#endif default: len = sizeof(struct sockaddr_storage); break; diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 92722a1271..2c4b888266 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -277,7 +277,6 @@ sub GenerateFiles HAVE_INTTYPES_H => undef, HAVE_INT_OPTERR => undef, HAVE_INT_OPTRESET => undef, - HAVE_IPV6 => 1, HAVE_I_CONSTRAINT__BUILTIN_CONSTANT_P => undef, HAVE_KQUEUE => undef, HAVE_LANGINFO_H => undef, -- 2.35.1
From 4fc436b20807a25576d4652e6d4069e88a5b566a Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 15:19:13 +1200 Subject: [PATCH 2/6] Remove dead ifaddr.c fallback code. We carried a special implementation using Solaris-specific ioctl SIOCGLIFCONF, but Solaris 11 and illumos adopted BSD-style getifaddrs() a bit over a decade ago, and Solaris 10 is EOL'd. Remove the dead code. Our comment about which OSes have getifaddrs() incorrectly listed AIX, so fix that. It is in fact the only Unix in the build farm that *doesn't* have it today, so the implementation based on SIOCGIFCONF (note, no 'L') is still live. There may be a better way to do this on AIX, though (not investigated). The last-stop fallback is dead code in practice, but it's hard to justify removing it because our better options are all non-standard. --- src/backend/libpq/ifaddr.c | 101 +------------------------------------ 1 file changed, 2 insertions(+), 99 deletions(-) diff --git a/src/backend/libpq/ifaddr.c b/src/backend/libpq/ifaddr.c index cb1645bc57..876a1dac08 100644 --- a/src/backend/libpq/ifaddr.c +++ b/src/backend/libpq/ifaddr.c @@ -291,7 +291,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) * for each one. Returns 0 if successful, -1 if trouble. * * This version uses the getifaddrs() interface, which is available on - * BSDs, AIX, and modern Linux. + * BSDs, macOS, Solaris, illumos and Linux. */ int pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) @@ -321,104 +321,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) #include <sys/sockio.h> #endif -/* - * SIOCGIFCONF does not return IPv6 addresses on Solaris. - * So we prefer SIOCGLIFCONF if it's available. - */ - -#if defined(SIOCGLIFCONF) - -/* - * Enumerate the system's network interface addresses and call the callback - * for each one. Returns 0 if successful, -1 if trouble. - * - * This version uses ioctl(SIOCGLIFCONF). - */ -int -pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) -{ - struct lifconf lifc; - struct lifreq *lifr, - lmask; - struct sockaddr *addr, - *mask; - char *ptr, - *buffer = NULL; - size_t n_buffer = 1024; - pgsocket sock, - fd; - pgsocket sock6; - int i, - total; - - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == PGINVALID_SOCKET) - return -1; - - while (n_buffer < 1024 * 100) - { - n_buffer += 1024; - ptr = realloc(buffer, n_buffer); - if (!ptr) - { - free(buffer); - close(sock); - errno = ENOMEM; - return -1; - } - - memset(&lifc, 0, sizeof(lifc)); - lifc.lifc_family = AF_UNSPEC; - lifc.lifc_buf = buffer = ptr; - lifc.lifc_len = n_buffer; - - if (ioctl(sock, SIOCGLIFCONF, &lifc) < 0) - { - if (errno == EINVAL) - continue; - free(buffer); - close(sock); - return -1; - } - - /* - * Some Unixes try to return as much data as possible, with no - * indication of whether enough space allocated. Don't believe we have - * it all unless there's lots of slop. - */ - if (lifc.lifc_len < n_buffer - 1024) - break; - } - - /* We'll need an IPv6 socket too for the SIOCGLIFNETMASK ioctls */ - sock6 = socket(AF_INET6, SOCK_DGRAM, 0); - if (sock6 == PGINVALID_SOCKET) - { - free(buffer); - close(sock); - return -1; - } - - total = lifc.lifc_len / sizeof(struct lifreq); - lifr = lifc.lifc_req; - for (i = 0; i < total; ++i) - { - addr = (struct sockaddr *) &lifr[i].lifr_addr; - memcpy(&lmask, &lifr[i], sizeof(struct lifreq)); - fd = (addr->sa_family == AF_INET6) ? sock6 : sock; - if (ioctl(fd, SIOCGLIFNETMASK, &lmask) < 0) - mask = NULL; - else - mask = (struct sockaddr *) &lmask.lifr_addr; - run_ifaddr_callback(callback, cb_data, addr, mask); - } - - free(buffer); - close(sock); - close(sock6); - return 0; -} -#elif defined(SIOCGIFCONF) +#if defined(SIOCGIFCONF) /* * Remaining Unixes use SIOCGIFCONF. Some only return IPv4 information -- 2.35.1
From 2b842b038fe86a1f43341254f6f86edce37352f9 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 16:05:44 +1200 Subject: [PATCH 3/6] Remove configure probe for net/if.h. <net/if.h> is in SUSv3 and all targeted Unixes have it. It's used in a region that is already ifdef'd out for Windows. According to the standard it's for the if_nameindex facilities, which we aren't using directly, but AIX needs it for a related non-standard ioctl. --- configure | 2 +- configure.ac | 1 - src/backend/libpq/ifaddr.c | 3 --- src/include/pg_config.h.in | 3 --- src/tools/msvc/Solution.pm | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/configure b/configure index 8178f290a9..dd27cc4f85 100755 --- a/configure +++ b/configure @@ -13761,7 +13761,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi -for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h +for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/configure.ac b/configure.ac index ee45d856c7..d04372e29d 100644 --- a/configure.ac +++ b/configure.ac @@ -1450,7 +1450,6 @@ AC_CHECK_HEADERS(m4_normalize([ ifaddrs.h langinfo.h mbarrier.h - net/if.h netinet/tcp.h sys/epoll.h sys/event.h diff --git a/src/backend/libpq/ifaddr.c b/src/backend/libpq/ifaddr.c index 876a1dac08..eb4de5ec2f 100644 --- a/src/backend/libpq/ifaddr.c +++ b/src/backend/libpq/ifaddr.c @@ -312,10 +312,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data) #else /* !HAVE_GETIFADDRS && !WIN32 */ #include <sys/ioctl.h> - -#ifdef HAVE_NET_IF_H #include <net/if.h> -#endif #ifdef HAVE_SYS_SOCKIO_H #include <sys/sockio.h> diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 2bc962ca2f..4a2914a780 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -322,9 +322,6 @@ /* Define to 1 if you have the <netinet/tcp.h> header file. */ #undef HAVE_NETINET_TCP_H -/* Define to 1 if you have the <net/if.h> header file. */ -#undef HAVE_NET_IF_H - /* Define to 1 if you have the `OPENSSL_init_ssl' function. */ #undef HAVE_OPENSSL_INIT_SSL diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 2c4b888266..26217e6d19 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -304,7 +304,6 @@ sub GenerateFiles HAVE_MEMSET_S => undef, HAVE_MKDTEMP => undef, HAVE_NETINET_TCP_H => undef, - HAVE_NET_IF_H => undef, HAVE_OPENSSL_INIT_SSL => undef, HAVE_OSSP_UUID_H => undef, HAVE_PAM_PAM_APPL_H => undef, -- 2.35.1
From 967bdf2d3acfcb8ee20942577d51cbeb6cca5c9b Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 16:19:08 +1200 Subject: [PATCH 4/6] Fix macro problem with gai_strerror on Windows. Commit 5579388d was confused about why gai_strerror() didn't work on Windows, and had to be redirected with a macro to gai_strerrorA(). It turns out that we explicitly undefined Windows' own macro for that somewhere else. Oops. Get rid of all that, so now we can use gai_sterror() directly using declarations from the system headers. --- src/include/port/win32/netdb.h | 2 -- src/include/port/win32/sys/socket.h | 7 ------- 2 files changed, 9 deletions(-) diff --git a/src/include/port/win32/netdb.h b/src/include/port/win32/netdb.h index f0cc2c2367..9ed13e457b 100644 --- a/src/include/port/win32/netdb.h +++ b/src/include/port/win32/netdb.h @@ -4,6 +4,4 @@ #include <ws2tcpip.h> -#define gai_strerror gai_strerrorA - #endif diff --git a/src/include/port/win32/sys/socket.h b/src/include/port/win32/sys/socket.h index 9b2cdf3b9b..0c32c0f7b2 100644 --- a/src/include/port/win32/sys/socket.h +++ b/src/include/port/win32/sys/socket.h @@ -23,11 +23,4 @@ #define ERROR PGERROR #endif -/* - * we can't use the windows gai_strerror{AW} functions because - * they are defined inline in the MS header files. So we'll use our - * own - */ -#undef gai_strerror - #endif /* WIN32_SYS_SOCKET_H */ -- 2.35.1
From d95e2533c0bdea3d1346879f31fb1718fc1f27cc Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 16:28:28 +1200 Subject: [PATCH 5/6] Remove configure probe for netinet/tcp.h. <netinet/tcp.h> is in SUSv3 and all targeted Unix systems have it. For Windows, we can provide a stub include file, to avoid some #ifdef noise. --- configure | 2 +- configure.ac | 1 - src/backend/libpq/be-secure-openssl.c | 2 -- src/backend/libpq/be-secure.c | 2 -- src/backend/libpq/ifaddr.c | 2 -- src/backend/libpq/pqcomm.c | 2 -- src/common/ip.c | 2 -- src/include/libpq/libpq-be.h | 2 -- src/include/pg_config.h.in | 3 --- src/include/port/win32/netinet/tcp.h | 3 +++ src/interfaces/libpq/fe-connect.c | 2 -- src/interfaces/libpq/fe-protocol3.c | 2 -- src/interfaces/libpq/fe-secure-openssl.c | 2 -- src/interfaces/libpq/fe-secure.c | 2 -- src/tools/msvc/Solution.pm | 1 - 15 files changed, 4 insertions(+), 26 deletions(-) create mode 100644 src/include/port/win32/netinet/tcp.h diff --git a/configure b/configure index dd27cc4f85..554348c413 100755 --- a/configure +++ b/configure @@ -13761,7 +13761,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi -for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h +for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/configure.ac b/configure.ac index d04372e29d..e17f54d1e6 100644 --- a/configure.ac +++ b/configure.ac @@ -1450,7 +1450,6 @@ AC_CHECK_HEADERS(m4_normalize([ ifaddrs.h langinfo.h mbarrier.h - netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index 9cec6866a3..55d4b29f7e 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -24,10 +24,8 @@ #include <unistd.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> #include <arpa/inet.h> -#endif #include "libpq/libpq.h" #include "miscadmin.h" diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index a05f67afb5..e3e54713e8 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -24,10 +24,8 @@ #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> #include <arpa/inet.h> -#endif #include "libpq/libpq.h" #include "miscadmin.h" diff --git a/src/backend/libpq/ifaddr.c b/src/backend/libpq/ifaddr.c index eb4de5ec2f..18e70741d7 100644 --- a/src/backend/libpq/ifaddr.c +++ b/src/backend/libpq/ifaddr.c @@ -24,9 +24,7 @@ #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #include <sys/file.h> #include "libpq/ifaddr.h" diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index f7ba2fc5f5..3352ddb23b 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -67,9 +67,7 @@ #include <sys/time.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #include <utime.h> #ifdef _MSC_VER /* mstcpip.h is missing on mingw */ #include <mstcpip.h> diff --git a/src/common/ip.c b/src/common/ip.c index dd9193feb1..0149d07ae7 100644 --- a/src/common/ip.c +++ b/src/common/ip.c @@ -28,9 +28,7 @@ #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #include <arpa/inet.h> #include <sys/file.h> diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index fa2fd03009..32d3a4b085 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -23,9 +23,7 @@ #include <openssl/ssl.h> #include <openssl/err.h> #endif -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #ifdef ENABLE_GSS #if defined(HAVE_GSSAPI_H) diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 4a2914a780..1ae65cfe81 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -319,9 +319,6 @@ /* Define to 1 if you have the `mkdtemp' function. */ #undef HAVE_MKDTEMP -/* Define to 1 if you have the <netinet/tcp.h> header file. */ -#undef HAVE_NETINET_TCP_H - /* Define to 1 if you have the `OPENSSL_init_ssl' function. */ #undef HAVE_OPENSSL_INIT_SSL diff --git a/src/include/port/win32/netinet/tcp.h b/src/include/port/win32/netinet/tcp.h new file mode 100644 index 0000000000..c1b5062674 --- /dev/null +++ b/src/include/port/win32/netinet/tcp.h @@ -0,0 +1,3 @@ +/* src/include/port/win32/netinet/tcp.h */ + +#include <sys/socket.h> diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 0dcce48888..36aabeef65 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -51,10 +51,8 @@ #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> #endif -#endif #ifdef ENABLE_THREAD_SAFETY #ifdef WIN32 diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index f267dfd33c..bbfb55542d 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -21,10 +21,8 @@ #include "win32.h" #else #include <unistd.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> #endif -#endif #include "libpq-fe.h" #include "libpq-int.h" diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 8117cbd40f..29a575588e 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -38,9 +38,7 @@ #include <unistd.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #include <arpa/inet.h> #endif diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index a1dc7b796d..3df4a97f2e 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -29,9 +29,7 @@ #include <unistd.h> #include <netdb.h> #include <netinet/in.h> -#ifdef HAVE_NETINET_TCP_H #include <netinet/tcp.h> -#endif #include <arpa/inet.h> #endif diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 26217e6d19..d80efbd95c 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -303,7 +303,6 @@ sub GenerateFiles HAVE_MEMORY_H => 1, HAVE_MEMSET_S => undef, HAVE_MKDTEMP => undef, - HAVE_NETINET_TCP_H => undef, HAVE_OPENSSL_INIT_SSL => undef, HAVE_OSSP_UUID_H => undef, HAVE_PAM_PAM_APPL_H => undef, -- 2.35.1
From 69615f6072a4cdad07dd31fe077b46d70391ce4f Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 15 Aug 2022 16:37:06 +1200 Subject: [PATCH 6/6] mstcpip.h is not missing on MinGW. Remove a small difference between MinGW and MSVC builds which is no longer necessary. --- src/backend/libpq/pqcomm.c | 2 +- src/interfaces/libpq/fe-connect.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 3352ddb23b..d2f18dfe50 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -69,7 +69,7 @@ #include <netinet/in.h> #include <netinet/tcp.h> #include <utime.h> -#ifdef _MSC_VER /* mstcpip.h is missing on mingw */ +#ifdef WIN32 #include <mstcpip.h> #endif diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 36aabeef65..917b19e0e9 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -44,9 +44,7 @@ #endif #define near #include <shlobj.h> -#ifdef _MSC_VER /* mstcpip.h is missing on mingw */ #include <mstcpip.h> -#endif #else #include <sys/socket.h> #include <netdb.h> -- 2.35.1