Follow-up Comment #26, bug #15559 (project freeciv):

I switched from my v5 patch and applied the v6 patch by Jtn. (I also use my
own patch from bug #16458, because that bug blocks configure enabling IPv6.)
I confirm that p22-plural-listen-v6.diff and ptrunk-plural-listen-v6.diff
work with my OpenBSD system.

We think that the patch works with OpenBSD and with Linux, but the other
platforms are a mystery.

----

I also tried building S2_2 with --disable-ipv6. I confirm that
p22-plural-listen-v6.diff does not break a --disable-ipv6 build.

----

The original bug, as I understand it, is that the client fails to connect to
its own server if _both_ of the following are true:

0 Socket option IPV6_V6ONLY defaults to on (like *BSD with
net.inet6.ip6.v6only=1 or Linux with net.ipv6.bindv6only=1).
0 "localhost" resolves to 127.0.0.1 but not ::1.

To reproduce the original bug, you want to "sysctl -w net.ipv6.bindv6only=1"
(or equivalent) _and_ you want to kill the /etc/hosts line "::1 localhost"
(or equivalent). Then the server socket will accept only IPv6 connections,
and the client will fail to make an IPv4 connection to "localhost".

----

To use a link-local address from fe80::/64, you _must_ set a a scope (the
'sin6_scope_id' field of 'struct sockaddr_in6'). BSD getaddrinfo() understand
the syntax 'fe80::numbers%interface', where the network interface is the
scope.

For example, here is my Ethernet interface (with an edited address):


$ ifconfig gem0
gem0: ...
        lladdr 00:12:34:89:ab:cd
        inet6 fe80::212:34ff:fe89:abcd%gem0 prefixlen 64 scopeid 

If I say 'ping6 fe80::212:34ff:fe89:abcd%gem0' then it works, but if I say
'ping6 fe80::212:34ff:fe89:abcd' (without the '%gem0') then it fails.


$ ./ser -b fe80::20d:93ff:fe2d:f3fa%gem0         
This is the server for Freeciv version 2.2.2+
You can learn a lot about Freeciv at http://www.freeciv.org/
0: Server: bad address: <fe80::20d:93ff:fe2d:f3fa%gem0:5556>.


This is probably because Freeciv uses gethostbyname2() instead of
getaddrinfo(); see bug #16623.

----

The older versions of the patch, v1 through v4, added this extra code to
server_open_socket(), where opt = 1:


#if defined(IPV6_SUPPORT) && defined(IPV6_V6ONLY)
    if (names[i].saddr.sa_family == AF_INET6) {
      setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
                 (char *)&opt, sizeof(opt));
    }
#endif


I deleted this code from v5, because I was uncertain about whether to include
or exclude this code. I guess that this code is not necessary to fix this
bug.

If freeciv-server says "IPv4 bind failed: Address already in use", then its
IPv6 socket might accept IPv4 connections. This is not ideal, because
messages will refer to addresses like "::ffff:192.168.0.56" instead of
"192.168.0.56".

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?15559>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to