Summary: Server address binding fails
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Fri 04 Nov 2011 11:24:47 PM EET
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: None
         Planned Release: 2.4.0, 2.5.0



Rafał Mużyło reported folling in patch #2715:

0: bind failed: Cannot assign requested address

Some more information is also in patch #2997, most notably that this is
broken by patch #2933.

I've been reading code related (even one that is not part of it) to patch
#2933. Even if the patch works as designed (no implementation bugs) freeciv
has higher probability to fail with it than without. For security reasons
binding is iomplemented so that bind() of all addresses returned by
net_lookup_service() must success or operation as whole is considered fatal
failure. Before patch #2933 net_lookup_service() returned just one or two (one
IPv4 and one IPv6) addresses, now it returns all addresses that getaddrinfo()
One thing to test would be limit interfaces to bind by giving server
commandline parameter "-b", e.g., "-b localhost"

Antoher note is about error reporting. We report just the latest error, one
from attempt to listen last address in the list. Errors with earlier addresses
in the list are ignored, even though some of them may be more relevant one
(failing to listen the address that *should* success)

It might help to debug this if we get to know full list of addresses
net_lookup_service() is returning. There's call to sockaddr_debug() for each
address when bind has failed, but that function outputs only in loglevel
LOG_DEBUG. Maybe if one changes sockaddr_debug() calls to log_debug() to
log_normal() and then collects output, we get valuable information about what
kind of addresses we are trying to bind().

Yet another suspicios thing is what happens when there's both IPv4 and IPv6
address and system does not support IPV6_V6ONLY. Maybe binding of IPv6 address
causes binding of IPv4 address also, causing later explicit attempt to bind
IPv4 to fail - or vice versa.


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to