K 10
svn:author
V 6
iulius
K 8
svn:date
V 27
2014-09-17T16:31:35.776610Z
K 7
svn:log
V 3806
update network functions to their latest upstream version

Use DEFAULT_TIMEOUT (300 seconds) for getlist and ident.

Entirely remove IP_OPTIONS and network_kill_options(), no longer
necessary nowadays.

Also remove a few parts of code related to IPV6_V6ONLY, that should no
longer be a problem (AF_UNSPEC can be used instead of specifically
AF_INET when IPv6 is not available).  CURRENT will enable IPv6
unconditionally.

Add a new network-innbind.c file, along with its headers, to deal
with network connections using innbind.  These functions are called by
INN; in case innbind is not necessary (port >= 1024 or we are root),
handle the connection to the generic functions provided by network.c
(from rra-c-util).

Split the network test suite into 4 specific tests (IPv4, IPv6, client
and server).


Changes mentioned in rra-c-util changelogs are:

- When binding IPv6 sockets, restrict them to only IPv6 connections
rather than also allowing IPv4 connections where possible.  The default
behavior, for maximum backward compatibility, is for IPv6-bound sockets
to accept IPv4 connections and expose those connections as IPv4 mapped
addresses.  This causes various problems, however, such as with reuse
of bound ports (which was causing test suite failures) and requirements
to handle IPv4 mapped addresses.  The network model (also used by BSD
systems) where IPv6 sockets only accept IPv6 connections is cleaner,
even if it requires juggling multiple sockets in some situations.

- network_addr_match now always fails (returns false) if either of the
strings are the empty string.  AIX 7.1's inet_aton treats the empty
string as equivalent to 0.0.0.0, but we want to treat it as a syntax
error since it's too easy to get an empty string by accident.

- The network_connect utility functions now take an optional timeout.
If non-zero, a non-blocking connect is done with that timeout, rather
than blocking on connect until the TCP stack gives up.  The network
utility code now depends on the fdflag code.

- network_connect, when given a timeout, now resumes waiting for the
nonblocking connect after being interrupted by a signal.  This can
mean that a connect can take longer than the timeout if interrupted;
hopefully both timeouts and catching signals are rare enough that this
won't pose a serious issue. 

- In network_read and network_write with a timeout, restart the I/O
attempt if a system call failed with EINTR instead of aborting the
operation. 

- When binding an IPv6-only socket with network_bind_ipv6 and not
binding to all local addresses, use IP_FREEBIND if it's available.
This allows binding to addresses that are not yet configured, which is
much more common with IPv6 given IPv6 autoconfiguration.

- Add new network_accept_any() function, which takes an array of file
descriptors (similar to what's returned by network_bind_all) and blocks
accepting incoming connections on any of those file descriptors. 

- Prefer reallocarray to realloc for multiplied sizes.

- The network_bind_* functions now more reliably set the socket errno
on failure and log somewhat more informative error messages with warn.

- Also improve the error handling and reporting from some of the other
network functions, and refactor the code to avoid more #ifdefs embedded
in the middle of other code.

- The network_bind_* functions now take a socket type as an additional
argument so that they can be used with UDP-based services.

- network_bind_all now returns a boolean, which will be false if no
sockets could be bound due to some error.  Callers may check this
instead of checking if the socket count is zero.

- Check the return status of snprintf when converting port numbers
to strings in network_bind_all and network_connect_host, and use the
correct format for the port number for the latter.

END
