Hello,

The current openrsync client is not able to connect to dual-stack remote hosts, 
when the local host does not have any IPv4 connectivity. This is because 
connect() fails with EADDRNOTAVAIL when trying to connect to the remote IPv4 
address on an IPv6-only local host - and IPv4 seems to be attempted first. The 
current client does not try other remote host addresses after EADDRNOTAVAIL, 
and therefore never tries the remote IPv6 address.

The included patch allows the client to continue after EADDRNOTAVAIL, making it 
to try other addresses, until it reaches a working IPv6 address. If the local 
host is IPv6-only and the remote host IPv4-only, the connection still fails 
with an error produced from rsync_connect().

Perhaps a warning should be issued for the EADDRNOTAVAIL case, like it does for 
EHOSTUNREACH - but I thought it would be a bit much, as an IPv6-only host would 
then emit warnings on pretty much every single use of the openrsync client.

Sasha Romijn


Index: usr.bin/rsync/socket.c
===================================================================
RCS file: /cvs/src/usr.bin/rsync/socket.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 socket.c
--- usr.bin/rsync/socket.c      9 Aug 2019 13:11:26 -0000       1.27
+++ usr.bin/rsync/socket.c      18 Aug 2020 07:55:03 -0000
@@ -101,6 +101,8 @@ inet_connect(int *sd, const struct sourc

        c = connect(*sd, (const struct sockaddr *)&src->sa, src->salen);
        if (c == -1) {
+               if (errno == EADDRNOTAVAIL)
+                       return 0;
                if (errno == ECONNREFUSED || errno == EHOSTUNREACH) {
                        WARNX("connect refused: %s, %s",
                            src->ip, host);

Reply via email to