[issue35545] asyncio.base_events.create_connection doesn't handle scoped IPv6 addresses

Erwan Le Pape report at bugs.python.org
Thu May 30 04:27:25 EDT 2019


Erwan Le Pape <lepaperwan3 at gmail.com> added the comment:

Assuming similar configuration to the one in msg343430, a simple native getaddrinfo test to check whether any scope ID is returned.

```
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>


void test(char *addrstr) {
    int status;
    struct addrinfo *res;
    struct addrinfo *iter;
    struct sockaddr_in6 *addr;

    status = getaddrinfo(addrstr, "80", NULL, &res);
    if (status != 0) {
        fprintf(stderr, "getaddrinfo(%s) returned %i\n", addrstr, status);

        return;
    }

    for (iter = res; iter; iter = iter->ai_next) {
        if (iter->ai_addr->sa_family != AF_INET6)
            continue;

        addr = (struct sockaddr_in6 *) iter->ai_addr;
        if (addr->sin6_scope_id != 0) {
            fprintf(stdout, "getaddrinfo(%s) return scope %u\n", addrstr, addr->sin6_scope_id);

            return;
        }
    }
}

int main() {
    test("fe80::f8d1:81ff:fe81:ac05%2");
    test("fe80::f8d1:81ff:fe81:ac05%en1");

    return 0;
}
```

I've explicitly tested against numeric and named interfaces to ensure that this isn't linked to AIX only handling named interfaces for scopes instead of numeric ones (although given your `netstat` output, that's be surprising).

Since I've had to look for AIX programming documentation just to be sure, I also stumbled upon this AIX bug https://www-01.ibm.com/support/docview.wss?uid=isg1IV53671 (which is referenced by the one I mentioned previously but I missed that). It seem to apply up to 7100-03 so you should be immune nonetheless.

I also noticed that it mentions SSH not working so I went and checked the OpenSSH sources to see how they handle AIX.
While they have an explicit BROKEN_GETADDRINFO define, it doesn't check for the specific scoped IPv6 address issue so I'm not sure they decided to special case it.
https://github.com/openssh/openssh-portable/blob/85ceb0e64bff672558fc87958cd548f135c83cdd/configure.ac#L2341

If this is truly an "idiosyncrasy" in AIX, I'm not sure there is a better way to handle it than skipping it since it's not really a Python bug if the underlying `libc` doesn't work as intended.

----------

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


More information about the Python-bugs-list mailing list