Blame SOURCES/openssl-1.1.1-detected-addr-ipv6.patch

b3353e
diff -up openssl-1.1.1k/apps/s_socket.c.addr-ipv6 openssl-1.1.1k/apps/s_socket.c
b3353e
--- openssl-1.1.1k/apps/s_socket.c.addr-ipv6	2021-07-16 15:14:08.491986682 +0200
b3353e
+++ openssl-1.1.1k/apps/s_socket.c	2021-07-16 15:23:21.271329197 +0200
b3353e
@@ -214,6 +214,8 @@ int do_server(int *accept_sock, const ch
b3353e
     const BIO_ADDRINFO *next;
b3353e
     int sock_family, sock_type, sock_protocol, sock_port;
b3353e
     const BIO_ADDR *sock_address;
b3353e
+    int sock_family_fallback = AF_UNSPEC;
b3353e
+    const BIO_ADDR *sock_address_fallback = NULL;
b3353e
     int sock_options = BIO_SOCK_REUSEADDR;
b3353e
     int ret = 0;
b3353e
 
b3353e
@@ -244,6 +246,10 @@ int do_server(int *accept_sock, const ch
b3353e
             && BIO_ADDRINFO_protocol(next) == sock_protocol) {
b3353e
         if (sock_family == AF_INET
b3353e
                 && BIO_ADDRINFO_family(next) == AF_INET6) {
b3353e
+            /* In case AF_INET6 is returned but not supported by the
b3353e
+             * kernel, retry with the first detected address family */
b3353e
+            sock_family_fallback = sock_family;
b3353e
+            sock_address_fallback = sock_address;
b3353e
             sock_family = AF_INET6;
b3353e
             sock_address = BIO_ADDRINFO_address(next);
b3353e
         } else if (sock_family == AF_INET6
b3353e
@@ -253,6 +259,10 @@ int do_server(int *accept_sock, const ch
b3353e
     }
b3353e
 
b3353e
     asock = BIO_socket(sock_family, sock_type, sock_protocol, 0);
b3353e
+	if (asock == INVALID_SOCKET && sock_family_fallback != AF_UNSPEC) {
b3353e
+       asock = BIO_socket(sock_family_fallback, sock_type, sock_protocol, 0);
b3353e
+       sock_address = sock_address_fallback;
b3353e
+	}
b3353e
     if (asock == INVALID_SOCKET
b3353e
         || !BIO_listen(asock, sock_address, sock_options)) {
b3353e
         BIO_ADDRINFO_free(res);