PATCH: innd: separate sockets for IPv4 and IPV6

"Miquel van Smoorenburg" list-inn-workers at news.cistron.nl
Wed Apr 9 16:27:30 UTC 2008


In article <F053A078EE9B4C5C98DA0B1CEF880855 at Iulius>,
Julien ÉLIE  <julien at trigofacile.com> wrote:
>Hi Bill,
>
>>> Shouldn't it be a "syswarn" here instead of a "sysdie"?
>>
>> Unless I misunderstand the intent of "V6ONLY" here, if you can't set the
>> socket type you are not operating as requested, and sysdie is probably
>> the correct action. syswarn would leave the server in an unintended and
>> probably undesirable operating mode, if I read this right.
>
>I asked because syswarn is as often as not used in lib/network.c.
>There is:
>
>    /* Create the socket. */
>    fd = socket(PF_INET6, SOCK_STREAM, IPPROTO_IP);
>    if (fd < 0) {
>        if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
>            syswarn("cannot create IPv6 socket for %s,%hu", address, port);
>        return -1;
>    }
>    network_set_reuseaddr(fd);
>
>#ifdef IPV6_V6ONLY
>    flag = 1;
>    if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag)) < 0)
>        syswarn("cannot set IPv6 socket to v6only");
>#endif
>
>
>Do you think sysdie should be better here than a syswarn and a "return -1"?
>(which is currently not returned)

Well, that call should not fail, really. If you have a valid IPv6
socket and call setsockopt(IPV6_V6ONLY) on it it should work.
It's more a "better safe than sorry" option.

But let's check what happens if it does fail and falls through-

- network_bind_all() first binds IPv4, and then IPv6 addresses.
  So if network_bind_ipv6() fails because it tries to bind
  on the same port to both v4 and v6 , v6 won't work. Not
  a big deal.

- innd::RCsetup: network_bind_ipv6() is called before
  network_bind_ipv4(), so if bindaddress6: is to to "any" or "all",
  and IPV6_V6ONLY fails, the v6 socket will be bound to
  both ipv4 and ipv6. Then network_bind_ipv4() will fail if
  it's also set to 'any' or 'all'.

It's complicated. See also the comment above RCsetup().

Since this is a grey area, it might be best to syswarn() instead
of sysdie() - it doesn't really appear to break things horribly,
and the setsockopt() will never fail anyway on sane OSes.

Mike.
-- 
The From: and Reply-To: addresses are internal news2mail gateway addresses.
Reply to the list or to "Miquel van Smoorenburg" <miquels at cistron.nl>


More information about the inn-workers mailing list