SoftEtherVPN: DNS resolution failure after #1329 in IPv4 single stack

Prerequisites

  • Can you reproduce?
  • Are you running the latest version of SoftEtherVPN?

SoftEther version: 26a27553b27403ac357b7126b29ad51a966d3028 Operating system: FreeBSD 13.0-RELEASE

IPv4 single stack. This issue does not reproduce in dual-stack environment.

@davidebeatrici Can you have a look?

$  build/vpncmd /tools /cmd:"trafficclient speed.softether.co.jp"
InitHamcore(): Loaded from "/usr/home/meta/SoftEtherVPN/build/hamcore.se2".
vpncmd command - SoftEther VPN Command Line Management Utility Developer Edition
SoftEther VPN Command Line Management Utility (vpncmd command)
Developer Edition
Version 5.02 Build 5180   (English)
Compiled 2021/07/13 08:16:49 by meta at softether.vmeta.jp
Copyright (c) all contributors on SoftEther VPN project in GitHub.
Copyright (c) Daiyuu Nobori, SoftEther Project at University of Tsukuba, and SoftEther Corporation.
All rights reserved.

VPN Tools has been launched. By inputting HELP, you can view a list of the commands that can be used.

VPN Tools>trafficclient speed.softether.com"
TrafficClient command - Run Network Traffic Speed Test Tool in Client Mode
Starting the client program...

-------------------------------------------------------
Network Traffic Speed Test Tool Client Setting Parameters

Destination Host Name               speed.softether.com
Destination TCP Port Number         9821
Number of TCP Connections to Establish 32
Data Transfer Direction             Full (Server < -- > Client)
Data Transmission Time              15.0 seconds
Data Correction for Ethernet Frames Yes
Measurement of Total Speed of Relay Device Input Output No
-------------------------------------------------------

The connection to server speed.softether.com (port 9821) will start. 32 TCP connections will be connected.
DnsResolver(): getaddrinfo() failed with error 4!
DnsResolve(): Could not resolve "speed.softether.co.jp". Searching for it in the cache...
The connection of TCP connection number 1 failed.
The TCP connection initialization with the server failed. Measurement will stop.
The client program has beens terminated.
Error occurred. (Error code: 1)
Connection to the server failed. Check network connection and make sure that address and port number of destination server are correct.

     --------- Mayaqua Kernel Status ---------
        Malloc Count ............... 55282
        ReAlloc Count .............. 18
        Free Count ................. 55282
        Total Memory Size .......... 38474331 bytes
      * Current Memory Blocks ...... 0 Blocks (Peek: 26936)
        Total Memory Blocks ........ 55282 Blocks
      * Current MemPool Blocks ..... 0 Blocks (Peek: 0)
        Total MemPool Mallocs ...... 0 Mallocs
        Total MemPool ReAllocs ..... 0 ReAllocs
        NewLock Count .............. 240
        DeleteLock Count ........... 240
      * Current Lock Objects ....... 0 Objects
      * Current Locked Objects ..... 0 Objects
        NewRef Count ............... 119
        FreeRef Count .............. 119
      * Current Ref Objects ........ 0 Objects
      * Current Ref Count .......... 0 Refs
        GetTime Count .............. 3
        GetTick Count .............. 13
        NewThread Count ............ 3
        FreeThread Count ........... 3
      * Current Threads ............ 0 Threads
        Wait For Event Count ....... 22

        @@@ NO MEMORY LEAKS @@@

It appears DnsResolver tries to resolve names via IPv6 address despite the server does not have IPv6 address.

diff --git a/src/Mayaqua/DNS.c b/src/Mayaqua/DNS.c
index f3a68410..59d95423 100644
--- a/src/Mayaqua/DNS.c
+++ b/src/Mayaqua/DNS.c
@@ -405,7 +405,7 @@ void DnsResolver(THREAD *t, void *param)
        struct addrinfo hints;
        Zero(&hints, sizeof(hints));

-       hints.ai_family = AF_INET6;
+       hints.ai_family = AF_UNSPEC;
        hints.ai_flags = AI_ALL | AI_ADDRCONFIG | AI_V4MAPPED;

        struct addrinfo *results;
@@ -430,6 +430,7 @@ void DnsResolver(THREAD *t, void *param)
                                Copy(&resolver->IPv4, &ip, sizeof(resolver->IPv4));
                                ipv4_ok = true;
                        }
+                       Debug("DnsResolver(): ipv6_ok=%d, ipv4_ok=%d\n", ipv6_ok, ipv4_ok);
                }

                resolver->OK = true;

After I change the code like above, DNS resolution looks going well but something’s still wrong. It appears strange. speed.softether.co.jp has only A record. Why ipv6_ok=1? The refactor of DnsResolver might have some regressions.

The connection to server speed.softether.co.jp (port 9821) will start. 32 TCP connections will be connected.
DnsResolver(): ipv6_ok=1, ipv4_ok=0
DnsResolver(): ipv6_ok=1, ipv4_ok=0
DnsResolver(): ipv6_ok=1, ipv4_ok=0
The connection of TCP connection number 1 failed.
The TCP connection initialization with the server failed. Measurement will stop.
The client program has beens terminated.
Error occurred. (Error code: 1)
Connection to the server failed. Check network connection and make sure that address and port number of destination server are correct.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (23 by maintainers)

Most upvoted comments

@davidebeatrici FYI, the glibc way of checking whether IPv6 is available is by looping through ifaddrs. https://elixir.bootlin.com/glibc/latest/source/inet/check_pf.c#L47

Okay but it is not important now.

The point that separate the current DNS resolution code works or not is whether any interface have IPv6 address. This cannot be checked by IsIPv6Supported(). We need to find out to do that.