[issue35302] create_connection with local_addr misses valid socket bindings

twisteroid ambassador report at bugs.python.org
Thu Dec 20 08:02:23 EST 2018


twisteroid ambassador <twisteroid.ambassador at gmail.com> added the comment:

I don't have a Mac, so I have not tested Ronald's workaround. Assuming it works, we will have to either i) implement platform-specific behavior and only apply IPV6_V6ONLY on macOS for each AF_INET6 socket created, or ii) apply it to all AF_INET6 sockets on all platforms, ideally after testing the option on all these platforms to make sure it doesn't have any undesirable side effect.

Linux's man page of ipv6 (http://man7.org/linux/man-pages/man7/ipv6.7.html ) has this to say about IPV6_V6ONLY:


If this flag is set to true (nonzero), then the socket is re‐
stricted to sending and receiving IPv6 packets only.  In this
case, an IPv4 and an IPv6 application can bind to a single
port at the same time.

If this flag is set to false (zero), then the socket can be
used to send and receive packets to and from an IPv6 address
or an IPv4-mapped IPv6 address.


So setting IPV6_V6ONLY might break some use cases? I have no idea how prevalent that may be.

The upside of this solution, as well as the second suggestion in Neil's OP (filter out local addrinfos with mismatching family), is that they should not increase connect time for normal cases. My solution (for which I have already submitted a PR) probably has a negligible increase in connection time and resource usage, because a fresh socket object is created for each pair of remote and local addrinfo.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35302>
_______________________________________


More information about the Python-bugs-list mailing list