Re: openrsync(1): add support for IPv6-only hosts

2020-08-19 Thread Florian Obser
On Wed, Aug 19, 2020 at 12:20:19AM +0200, Klemens Nanni wrote:
> On Tue, Aug 18, 2020 at 09:58:56AM +0200, Sasha Romijn wrote:
> > 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.
> For openrsync(1) this won't happen with `family inet6 inet4' in
> resolv.conf(5).
> 
> > 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().
> Your diff reads correct to me, thanks; regular rsync(1) connects fine
> regardless of `family'.
> 
> > 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.
> Yes, I don't think a warning is warrented here - afterall it can connect
> without problems.
> 
> OK to commit anyone?
> 

Sorry for being late to the party.
Should we maybe inline inet_connect into rsync_connect and ignore all
connect(3) errors and try the host?
That's what ssh is doing in ssh_connect_direct()

-- 
I'm not entirely sure you are real.



Re: openrsync(1): add support for IPv6-only hosts

2020-08-18 Thread Klemens Nanni
On Tue, Aug 18, 2020 at 09:58:56AM +0200, Sasha Romijn wrote:
> 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.
For openrsync(1) this won't happen with `family inet6 inet4' in
resolv.conf(5).

> 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().
Your diff reads correct to me, thanks; regular rsync(1) connects fine
regardless of `family'.

> 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.
Yes, I don't think a warning is warrented here - afterall it can connect
without problems.

OK to commit anyone?



openrsync(1): add support for IPv6-only hosts

2020-08-18 Thread Sasha Romijn
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 -   1.27
+++ usr.bin/rsync/socket.c  18 Aug 2020 07:55:03 -
@@ -101,6 +101,8 @@ inet_connect(int *sd, const struct sourc

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