Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcc8b14

Browse files
committed
Remove configure probe for sockaddr_in6 and require AF_INET6.
SUSv3 <netinet/in.h> defines 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. This is similar to commits f558088 and 077bf2f for Unix sockets. Even though AF_INET6 is an "optional" component of SUSv3, there are no known modern operating system without it, and it seems even less likely to be omitted from future systems than AF_UNIX. Reviewed-by: Andres Freund <[email protected]> Discussion: https://postgr.es/m/CA+hUKGKErNfhmvb_H0UprEmp4LPzGN06yR2_0tYikjzB-2ECMw@mail.gmail.com
1 parent 28ec316 commit bcc8b14

File tree

16 files changed

+7
-105
lines changed

16 files changed

+7
-105
lines changed

configure

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16218,16 +16218,6 @@ cat >>confdefs.h <<_ACEOF
1621816218
_ACEOF
1621916219

1622016220

16221-
ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "$ac_includes_default
16222-
#include <netinet/in.h>
16223-
"
16224-
if test "x$ac_cv_type_struct_sockaddr_in6" = xyes; then :
16225-
16226-
$as_echo "#define HAVE_IPV6 1" >>confdefs.h
16227-
16228-
fi
16229-
16230-
1623116221
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PS_STRINGS" >&5
1623216222
$as_echo_n "checking for PS_STRINGS... " >&6; }
1623316223
if ${pgac_cv_var_PS_STRINGS+:} false; then :

configure.ac

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,12 +1801,6 @@ AC_CHECK_DECLS([pwritev], [], [AC_LIBOBJ(pwritev)], [#include <sys/uio.h>])
18011801
# This is probably only present on macOS, but may as well check always
18021802
AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
18031803

1804-
AC_CHECK_TYPE([struct sockaddr_in6],
1805-
[AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])],
1806-
[],
1807-
[$ac_includes_default
1808-
#include <netinet/in.h>])
1809-
18101804
AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
18111805
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
18121806
[#include <machine/vmparam.h>

doc/src/sgml/client-auth.sgml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ hostnogssenc <replaceable>database</replaceable> <replaceable>user</replaceabl
305305
An entry given in IPv4 format will match only IPv4 connections,
306306
and an entry given in IPv6 format will match only IPv6 connections,
307307
even if the represented address is in the IPv4-in-IPv6 range.
308-
Note that entries in IPv6 format will be rejected if the system's
309-
C library does not have support for IPv6 addresses.
310308
</para>
311309

312310
<para>

src/backend/libpq/auth.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,13 +3015,8 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
30153015
int packetlength;
30163016
pgsocket sock;
30173017

3018-
#ifdef HAVE_IPV6
30193018
struct sockaddr_in6 localaddr;
30203019
struct sockaddr_in6 remoteaddr;
3021-
#else
3022-
struct sockaddr_in localaddr;
3023-
struct sockaddr_in remoteaddr;
3024-
#endif
30253020
struct addrinfo hint;
30263021
struct addrinfo *serveraddrs;
30273022
int port;
@@ -3131,18 +3126,12 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
31313126
}
31323127

31333128
memset(&localaddr, 0, sizeof(localaddr));
3134-
#ifdef HAVE_IPV6
31353129
localaddr.sin6_family = serveraddrs[0].ai_family;
31363130
localaddr.sin6_addr = in6addr_any;
31373131
if (localaddr.sin6_family == AF_INET6)
31383132
addrsize = sizeof(struct sockaddr_in6);
31393133
else
31403134
addrsize = sizeof(struct sockaddr_in);
3141-
#else
3142-
localaddr.sin_family = serveraddrs[0].ai_family;
3143-
localaddr.sin_addr.s_addr = INADDR_ANY;
3144-
addrsize = sizeof(struct sockaddr_in);
3145-
#endif
31463135

31473136
if (bind(sock, (struct sockaddr *) &localaddr, addrsize))
31483137
{
@@ -3245,21 +3234,11 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
32453234
return STATUS_ERROR;
32463235
}
32473236

3248-
#ifdef HAVE_IPV6
32493237
if (remoteaddr.sin6_port != pg_hton16(port))
3250-
#else
3251-
if (remoteaddr.sin_port != pg_hton16(port))
3252-
#endif
32533238
{
3254-
#ifdef HAVE_IPV6
32553239
ereport(LOG,
32563240
(errmsg("RADIUS response from %s was sent from incorrect port: %d",
32573241
server, pg_ntoh16(remoteaddr.sin6_port))));
3258-
#else
3259-
ereport(LOG,
3260-
(errmsg("RADIUS response from %s was sent from incorrect port: %d",
3261-
server, pg_ntoh16(remoteaddr.sin_port))));
3262-
#endif
32633242
continue;
32643243
}
32653244

src/backend/libpq/hba.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,6 @@ ipv4eq(struct sockaddr_in *a, struct sockaddr_in *b)
645645
return (a->sin_addr.s_addr == b->sin_addr.s_addr);
646646
}
647647

648-
#ifdef HAVE_IPV6
649-
650648
static bool
651649
ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b)
652650
{
@@ -658,7 +656,6 @@ ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b)
658656

659657
return true;
660658
}
661-
#endif /* HAVE_IPV6 */
662659

663660
/*
664661
* Check whether host name matches pattern.
@@ -747,7 +744,6 @@ check_hostname(hbaPort *port, const char *hostname)
747744
break;
748745
}
749746
}
750-
#ifdef HAVE_IPV6
751747
else if (gai->ai_addr->sa_family == AF_INET6)
752748
{
753749
if (ipv6eq((struct sockaddr_in6 *) gai->ai_addr,
@@ -757,7 +753,6 @@ check_hostname(hbaPort *port, const char *hostname)
757753
break;
758754
}
759755
}
760-
#endif
761756
}
762757
}
763758

src/backend/libpq/ifaddr.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ static int range_sockaddr_AF_INET(const struct sockaddr_in *addr,
3434
const struct sockaddr_in *netaddr,
3535
const struct sockaddr_in *netmask);
3636

37-
#ifdef HAVE_IPV6
3837
static int range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr,
3938
const struct sockaddr_in6 *netaddr,
4039
const struct sockaddr_in6 *netmask);
41-
#endif
4240

4341

4442
/*
@@ -56,12 +54,10 @@ pg_range_sockaddr(const struct sockaddr_storage *addr,
5654
return range_sockaddr_AF_INET((const struct sockaddr_in *) addr,
5755
(const struct sockaddr_in *) netaddr,
5856
(const struct sockaddr_in *) netmask);
59-
#ifdef HAVE_IPV6
6057
else if (addr->ss_family == AF_INET6)
6158
return range_sockaddr_AF_INET6((const struct sockaddr_in6 *) addr,
6259
(const struct sockaddr_in6 *) netaddr,
6360
(const struct sockaddr_in6 *) netmask);
64-
#endif
6561
else
6662
return 0;
6763
}
@@ -78,9 +74,6 @@ range_sockaddr_AF_INET(const struct sockaddr_in *addr,
7874
return 0;
7975
}
8076

81-
82-
#ifdef HAVE_IPV6
83-
8477
static int
8578
range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr,
8679
const struct sockaddr_in6 *netaddr,
@@ -97,7 +90,6 @@ range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr,
9790

9891
return 1;
9992
}
100-
#endif /* HAVE_IPV6 */
10193

10294
/*
10395
* pg_sockaddr_cidr_mask - make a network mask of the appropriate family
@@ -147,7 +139,6 @@ pg_sockaddr_cidr_mask(struct sockaddr_storage *mask, char *numbits, int family)
147139
break;
148140
}
149141

150-
#ifdef HAVE_IPV6
151142
case AF_INET6:
152143
{
153144
struct sockaddr_in6 mask6;
@@ -172,7 +163,7 @@ pg_sockaddr_cidr_mask(struct sockaddr_storage *mask, char *numbits, int family)
172163
memcpy(mask, &mask6, sizeof(mask6));
173164
break;
174165
}
175-
#endif
166+
176167
default:
177168
return -1;
178169
}
@@ -207,13 +198,11 @@ run_ifaddr_callback(PgIfAddrCallback callback, void *cb_data,
207198
if (((struct sockaddr_in *) mask)->sin_addr.s_addr == INADDR_ANY)
208199
mask = NULL;
209200
}
210-
#ifdef HAVE_IPV6
211201
else if (mask->sa_family == AF_INET6)
212202
{
213203
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *) mask)->sin6_addr))
214204
mask = NULL;
215205
}
216-
#endif
217206
}
218207

219208
/* If mask is invalid, generate our own fully-set mask */
@@ -437,10 +426,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
437426
{
438427
struct sockaddr_in addr;
439428
struct sockaddr_storage mask;
440-
441-
#ifdef HAVE_IPV6
442429
struct sockaddr_in6 addr6;
443-
#endif
444430

445431
/* addr 127.0.0.1/8 */
446432
memset(&addr, 0, sizeof(addr));
@@ -452,7 +438,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
452438
(struct sockaddr *) &addr,
453439
(struct sockaddr *) &mask);
454440

455-
#ifdef HAVE_IPV6
456441
/* addr ::1/128 */
457442
memset(&addr6, 0, sizeof(addr6));
458443
addr6.sin6_family = AF_INET6;
@@ -462,7 +447,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
462447
run_ifaddr_callback(callback, cb_data,
463448
(struct sockaddr *) &addr6,
464449
(struct sockaddr *) &mask);
465-
#endif
466450

467451
return 0;
468452
}

src/backend/libpq/pqcomm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,9 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
413413
case AF_INET:
414414
familyDesc = _("IPv4");
415415
break;
416-
#ifdef HAVE_IPV6
417416
case AF_INET6:
418417
familyDesc = _("IPv6");
419418
break;
420-
#endif
421419
case AF_UNIX:
422420
familyDesc = _("Unix");
423421
break;

src/backend/utils/adt/network.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,9 +1725,7 @@ inet_client_addr(PG_FUNCTION_ARGS)
17251725
switch (port->raddr.addr.ss_family)
17261726
{
17271727
case AF_INET:
1728-
#ifdef HAVE_IPV6
17291728
case AF_INET6:
1730-
#endif
17311729
break;
17321730
default:
17331731
PG_RETURN_NULL();
@@ -1764,9 +1762,7 @@ inet_client_port(PG_FUNCTION_ARGS)
17641762
switch (port->raddr.addr.ss_family)
17651763
{
17661764
case AF_INET:
1767-
#ifdef HAVE_IPV6
17681765
case AF_INET6:
1769-
#endif
17701766
break;
17711767
default:
17721768
PG_RETURN_NULL();
@@ -1801,9 +1797,7 @@ inet_server_addr(PG_FUNCTION_ARGS)
18011797
switch (port->laddr.addr.ss_family)
18021798
{
18031799
case AF_INET:
1804-
#ifdef HAVE_IPV6
18051800
case AF_INET6:
1806-
#endif
18071801
break;
18081802
default:
18091803
PG_RETURN_NULL();
@@ -1840,9 +1834,7 @@ inet_server_port(PG_FUNCTION_ARGS)
18401834
switch (port->laddr.addr.ss_family)
18411835
{
18421836
case AF_INET:
1843-
#ifdef HAVE_IPV6
18441837
case AF_INET6:
1845-
#endif
18461838
break;
18471839
default:
18481840
PG_RETURN_NULL();
@@ -2102,13 +2094,11 @@ inetmi(PG_FUNCTION_ARGS)
21022094
void
21032095
clean_ipv6_addr(int addr_family, char *addr)
21042096
{
2105-
#ifdef HAVE_IPV6
21062097
if (addr_family == AF_INET6)
21072098
{
21082099
char *pct = strchr(addr, '%');
21092100

21102101
if (pct)
21112102
*pct = '\0';
21122103
}
2113-
#endif
21142104
}

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
735735
}
736736
else
737737
{
738-
if (beentry->st_clientaddr.addr.ss_family == AF_INET
739-
#ifdef HAVE_IPV6
740-
|| beentry->st_clientaddr.addr.ss_family == AF_INET6
741-
#endif
742-
)
738+
if (beentry->st_clientaddr.addr.ss_family == AF_INET ||
739+
beentry->st_clientaddr.addr.ss_family == AF_INET6)
743740
{
744741
char remote_host[NI_MAXHOST];
745742
char remote_port[NI_MAXSERV];
@@ -1105,9 +1102,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
11051102
switch (beentry->st_clientaddr.addr.ss_family)
11061103
{
11071104
case AF_INET:
1108-
#ifdef HAVE_IPV6
11091105
case AF_INET6:
1110-
#endif
11111106
break;
11121107
default:
11131108
PG_RETURN_NULL();
@@ -1152,9 +1147,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
11521147
switch (beentry->st_clientaddr.addr.ss_family)
11531148
{
11541149
case AF_INET:
1155-
#ifdef HAVE_IPV6
11561150
case AF_INET6:
1157-
#endif
11581151
break;
11591152
case AF_UNIX:
11601153
PG_RETURN_INT32(-1);

src/bin/initdb/initdb.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,6 @@ setup_config(void)
11761176

11771177
conflines = replace_token(conflines, "@remove-line-for-nolocal@", "");
11781178

1179-
#ifdef HAVE_IPV6
11801179

11811180
/*
11821181
* Probe to see if there is really any platform support for IPv6, and
@@ -1218,15 +1217,6 @@ setup_config(void)
12181217
"#host replication all ::1");
12191218
}
12201219
}
1221-
#else /* !HAVE_IPV6 */
1222-
/* If we didn't compile IPV6 support at all, always comment it out */
1223-
conflines = replace_token(conflines,
1224-
"host all all ::1",
1225-
"#host all all ::1");
1226-
conflines = replace_token(conflines,
1227-
"host replication all ::1",
1228-
"#host replication all ::1");
1229-
#endif /* HAVE_IPV6 */
12301220

12311221
/* Replace default authentication methods */
12321222
conflines = replace_token(conflines,

src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@
241241
/* Define to 1 if you have the global variable 'int timezone'. */
242242
#undef HAVE_INT_TIMEZONE
243243

244-
/* Define to 1 if you have support for IPv6. */
245-
#undef HAVE_IPV6
246-
247244
/* Define to 1 if __builtin_constant_p(x) implies "i"(x) acceptance. */
248245
#undef HAVE_I_CONSTRAINT__BUILTIN_CONSTANT_P
249246

src/include/utils/inet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ typedef struct
3131
* We use these values for the "family" field.
3232
*
3333
* Referencing all of the non-AF_INET types to AF_INET lets us work on
34-
* machines which may not have the appropriate address family (like
35-
* inet6 addresses when AF_INET6 isn't present) but doesn't cause a
34+
* machines which did not have the appropriate address family (like
35+
* inet6 addresses when AF_INET6 wasn't present) but didn't cause a
3636
* dump/reload requirement. Pre-7.4 databases used AF_INET for the family
3737
* type on disk.
3838
*/

src/interfaces/libpq/fe-connect.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len)
16521652
host_addr, host_addr_len) == NULL)
16531653
host_addr[0] = '\0';
16541654
}
1655-
#ifdef HAVE_IPV6
16561655
else if (addr->ss_family == AF_INET6)
16571656
{
16581657
if (pg_inet_net_ntop(AF_INET6,
@@ -1661,7 +1660,6 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len)
16611660
host_addr, host_addr_len) == NULL)
16621661
host_addr[0] = '\0';
16631662
}
1664-
#endif
16651663
else
16661664
host_addr[0] = '\0';
16671665
}

0 commit comments

Comments
 (0)